Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ddccef1
#HOTFIX - fix problem Element type when running any command using the…
secret-anonymous-dev Jul 4, 2018
fa09bd3
Merge branch 'hotfix/v1.0.1'
secret-anonymous-dev Jul 4, 2018
26ccaf5
#HOTFIX - fix problem Element type when running any command using the…
secret-anonymous-dev Jul 4, 2018
52d4660
Merge branch 'hotfix/v1.0.2'
secret-anonymous-dev Jul 4, 2018
242e45a
Merge tag 'v1.0.2' into develop
secret-anonymous-dev Jul 4, 2018
39d5a80
#HOTFIX - up version with composer for v1.0.3
secret-anonymous-dev Jul 4, 2018
5a8de67
Merge branch 'hotfix/v1.0.3'
secret-anonymous-dev Jul 4, 2018
0c7bebd
Merge tag 'v1.0.3' into develop
secret-anonymous-dev Jul 4, 2018
86859d2
#HOTFIX - changing source_model to retrieve customer attributes inste…
secret-anonymous-dev Jul 4, 2018
36c72bf
Merge branch 'hotfix/v1.0.4'
secret-anonymous-dev Jul 4, 2018
9791b81
Merge tag 'v1.0.4' into develop
secret-anonymous-dev Jul 4, 2018
9a34a3d
#HOTFIX - changing source_model to retrieve customer attributes inste…
secret-anonymous-dev Jul 4, 2018
8f8a7a3
Merge branch 'hotfix/v1.0.5'
secret-anonymous-dev Jul 4, 2018
b6516b5
Merge tag 'v1.0.5' into develop
secret-anonymous-dev Jul 4, 2018
c61cf5b
#HOTFIX - changing source_model to retrieve customer attributes inste…
secret-anonymous-dev Jul 4, 2018
67fd5a9
Merge branch 'hotfix/v1.0.6'
secret-anonymous-dev Jul 4, 2018
5fce61a
Merge tag 'v1.0.6' into develop
secret-anonymous-dev Jul 4, 2018
bd01db3
#v1.0.7
secret-anonymous-dev Apr 20, 2019
0d1db85
Merge branch 'release/v1.0.7'
secret-anonymous-dev Apr 20, 2019
2e0cea3
Merge tag 'v1.0.7' into develop
secret-anonymous-dev Apr 20, 2019
28f28d7
Merge branch 'release/v1.0.8'
secret-anonymous-dev Apr 20, 2019
6b38672
Merge tag 'v1.0.8' into develop
secret-anonymous-dev Apr 20, 2019
882fb94
#HOTFIX envio de pedido para intelipost
secret-anonymous-dev May 27, 2019
84a704d
Merge branch 'hotfix/v1.0.9'
secret-anonymous-dev May 27, 2019
ad64960
Merge tag 'v1.0.9' into develop
secret-anonymous-dev May 27, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/*
.idea
60 changes: 60 additions & 0 deletions Model/Config/Source/Customer/Attributes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace Intelipost\Push\Model\Config\Source\Customer;

use Magento\Framework\Data\OptionSourceInterface;
use Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory as AttributeCollectionFactory;

class Attributes implements OptionSourceInterface
{
const CUSTOMER_ATTRIBUTE_SET = 1;

/** @var AttributeCollectionFactory $attributeCollectionFactory */
protected $attributeCollectionFactory;

/**
* Attributes constructor.
* @param AttributeCollectionFactory $attributeCollectionFactory
*/
public function __construct(
AttributeCollectionFactory $attributeCollectionFactory
)
{
$this->setAttributeCollectionFactory($attributeCollectionFactory);
}

/**
* @return array
*/
public function toOptionArray()
{
$attributeCollection = $this->getAttributeCollectionFactory()->create();
$attributeCollection->setAttributeSetFilter(self::CUSTOMER_ATTRIBUTE_SET);
$attributeCollection->getSelect()->order('frontend_label');

$options = [];
foreach ($attributeCollection as $attribute) {
$options[] = ['value' => $attribute->getAttributeCode(), 'label' => $attribute->getFrontendLabel()];
}

return $options;
}

/**
* @return AttributeCollectionFactory
*/
protected function getAttributeCollectionFactory()
{
return $this->attributeCollectionFactory;
}

/**
* @param AttributeCollectionFactory $attributeCollectionFactory
* @return Attributes
*/
protected function setAttributeCollectionFactory($attributeCollectionFactory)
{
$this->attributeCollectionFactory = $attributeCollectionFactory;
return $this;
}
}
4 changes: 2 additions & 2 deletions Model/Request/ShipmentOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function shipmentOrder($collectionData)
$this->scheduling_window_end = $collectionData['scheduling_window_end'];
$this->shipment_order_type = $collectionData['shipment_order_type'];
$this->shipment_order_sub_type = $collectionData['shipment_order_sub_type'];
$this->shipment_order_volume_invoice = $invoiceObj->getInformation($collectionData['order_number']);
$this->shipment_order_volume_invoice = $invoiceObj->getInformation($collectionData['entity_id']);
$this->shipment_order_volume_array = $volObj->getInformation($collectionData['volumes'], $this->shipment_order_volume_invoice);
$this->end_customer = $ecObj->getInformation($collectionData['entity_id'], $collectionData['customer_taxvat']);
if($this->_scopeConfig->getValue('intelipost_push/order_status/create_and_ship')){
Expand Down Expand Up @@ -209,4 +209,4 @@ public function getNowDateTime()
$now = str_replace(' ', 'T', $localizedDateTimeISO);
return $now;
}
}
}
100 changes: 51 additions & 49 deletions Model/Request/ShipmentOrder/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,64 @@
namespace Intelipost\Push\Model\Request\ShipmentOrder;

use Magento\Framework\Model\AbstractModel;
use Magento\Sales\Api\OrderRepositoryInterface;

class Invoice extends AbstractModel
{
private $invoice_number;
private $invoice_series;
private $invoice_key;
private $invoice_date;
private $invoice_total_value;
private $invoice_products_value;
private $invoice_cfop;
private $invoice_number;
private $invoice_series;
private $invoice_key;
private $invoice_date;
private $invoice_total_value;
private $invoice_products_value;
private $invoice_cfop;

protected $_collectionFactory;
protected $_helper;
protected $_collectionFactory;
protected $_helper;

public function __construct(
\Intelipost\Push\Model\Resource\Invoice\CollectionFactory $collectionFactory
)
{
$this->_collectionFactory = $collectionFactory;
}
/** @var OrderRepositoryInterface $orderRepository */
protected $orderRepository;

public function getInformation($order_number)
{
$invoiceCollection = $this->getInvoiceCollection($order_number);
foreach($invoiceCollection as $invoice)
{
$this->invoice_number = $invoice['invoice_number'];
$this->invoice_series = $invoice['invoice_series'];
$this->invoice_key = $invoice['invoice_key'];
$this->invoice_date = str_replace(' ', 'T', $invoice['invoice_date']);
$this->invoice_total_value = $invoice['invoice_total_value'];
$this->invoice_products_value = $invoice['invoice_products_value'];
$this->invoice_cfop = $invoice['invoice_cfop'];
}
$shipment_order_volume_invoice_obj = $this->preapreInvoiceObj();
return $shipment_order_volume_invoice_obj;
}
/**
* Invoice constructor.
* @param \Intelipost\Push\Model\Resource\Invoice\CollectionFactory $collectionFactory
* @param OrderRepositoryInterface $orderRepository
*/
public function __construct(
\Intelipost\Push\Model\Resource\Invoice\CollectionFactory $collectionFactory,
OrderRepositoryInterface $orderRepository
)
{
$this->_collectionFactory = $collectionFactory;
$this->orderRepository = $orderRepository;
}

public function getInvoiceCollection($order_number)
{
$iCollection = $this->_collectionFactory->create();
$iCollection->addFieldToFilter('order_number', array('eq' => $order_number));
return $iCollection->getData();
}
public function getInformation($orderId)
{
$order = $this->orderRepository->get((int) $orderId);

public function preapreInvoiceObj()
{
$shipment_order_volume_invoice = new \Stdclass();
$shipment_order_volume_invoice->invoice_number = $this->invoice_number;
$shipment_order_volume_invoice->invoice_series = $this->invoice_series;
$shipment_order_volume_invoice->invoice_key = $this->invoice_key;
$shipment_order_volume_invoice->invoice_date = $this->invoice_date;
$shipment_order_volume_invoice->invoice_total_value = $this->invoice_total_value;
$shipment_order_volume_invoice->invoice_products_value = $this->invoice_products_value;
$shipment_order_volume_invoice->invoice_cfop = $this->invoice_cfop;
$this->invoice_number = $order->getEntityId();
$this->invoice_series = $order->getIncrementId();
$this->invoice_key = '01234567890123456789012345678901234567891234';
$this->invoice_date = str_replace(' ', 'T', $order->getCreatedAt());
$this->invoice_total_value = number_format($order->getGrandTotal(), '2', '.', '');
$this->invoice_products_value = number_format($order->getSubtotalInclTax(), '2', '.', '');
$this->invoice_cfop = "1612";

return $shipment_order_volume_invoice;
}
$shipment_order_volume_invoice_obj = $this->preapreInvoiceObj();
return $shipment_order_volume_invoice_obj;
}

public function preapreInvoiceObj()
{
$shipment_order_volume_invoice = new \Stdclass();
$shipment_order_volume_invoice->invoice_number = $this->invoice_number;
$shipment_order_volume_invoice->invoice_series = $this->invoice_series;
$shipment_order_volume_invoice->invoice_date = $this->invoice_date;
$shipment_order_volume_invoice->invoice_total_value = $this->invoice_total_value;
$shipment_order_volume_invoice->invoice_products_value = $this->invoice_products_value;
$shipment_order_volume_invoice->invoice_cfop = $this->invoice_cfop;

return $shipment_order_volume_invoice;
}
}
10 changes: 5 additions & 5 deletions Observer/OrderSaveAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function execute(Observer $observer)
$order = $observer->getOrder();
$magentoStatus = $order->getStatus();
$entity_id = $order->getEntityId();

$statusToCreate = $this->_scopeConfig->getValue('intelipost_push/order_status/status_to_create');
$magentoStatusAfterCreate = $this->_scopeConfig->getValue('intelipost_push/order_status/magento_status_after_create');
$createAndShip = $this->_scopeConfig->getValue('intelipost_push/order_status/create_and_ship');
Expand All @@ -57,18 +57,18 @@ public function execute(Observer $observer)

//Apenas uma entrega
if(sizeof($shipmentObj) == 1)
{
{
foreach($colData as $shipment)
{
//criação do pedido
if($magentoStatus == $statusToCreate && $shipment['intelipost_status'] == 'pending')
{
$col = $this->_shipmentOrder->create();
$col->shipmentOrder($shipment);
$col->shipmentOrder($shipment);
}

//despacho do pedido
if(!$createAndShip && $magentoStatus == $statusToShip && $shipment['intelipost_status'] == 'created')
if(!$createAndShip && $magentoStatus == $statusToShip)
{
$col = $this->_shipped->create();
$col->shippedRequestBody($shipment);
Expand All @@ -84,7 +84,7 @@ public function execute(Observer $observer)
$this->_helper->logIntelipost(json_encode('duas entregas'));
//criação do pedidos
foreach($colData as $shipment)
{
{
//fazer o match dos skus e criar as entregas relativas na Intelipost
}

Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "intelipost/magento2-push",
"description": "Intelipost Push",
"name": "luanet/magento2-push",
"description": "Fork Intelipost Push",
"type": "magento2-module",
"version": "1.0.0",
"version": "1.0.6",
"authors": [
{
"name": "Alex Restani",
"email": "integracoes@intelipost.com.br",
"homepage": "http://www.intelipost.com.br/"
"name": "Lucas Santos",
"email": "lsantos@lua.net",
"homepage": "http://lua.net/"
}
],
"license": [
Expand All @@ -26,4 +26,4 @@
"Intelipost\\Push\\": ""
}
}
}
}
2 changes: 1 addition & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<group id="attributes" translate="label" type="text" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Attributes</label>
<field id="federal_tax_payer_id" translate="label comment" type="select" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<source_model>Intelipost\Quote\Model\Config\Source\Attribute</source_model>
<source_model>Intelipost\Push\Model\Config\Source\Customer\Attributes</source_model>
<label>Federal tax payer id</label>
<comment>Select CPF attribute</comment>
</field>
Expand Down
24 changes: 12 additions & 12 deletions etc/di.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Intelipost\Push\Api\InvoiceInterface" type="Intelipost\Push\Model\Invoice" />
<type name="Intelipost\Quote\Model\Resource\Shipment\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="intelipost_grid_collection" xsi:type="string">Intelipost\Quote\Model\Resource\Shipment\Grid\Collection</item>
</argument>
</arguments>
</type>
<virtualType name="Intelipost\Quote\Model\Resource\Shipment\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">intelipost_shipment</argument>
<argument name="eventPrefix" xsi:type="string">intelipost_quote_grid_collection</argument>
<argument name="eventObject" xsi:type="string">intelipost_grid_collection</argument>
<argument name="eventObject" xsi:type="string">intelipost_grid_collection</argument>
<argument name="resourceModel" xsi:type="string">Intelipost\Quote\Model\Resource\Shipment</argument>
</arguments>
</type>
</virtualType>
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="intelipost_shipment_grid_data_source" xsi:type="string">Intelipost\Quote\Model\Resource\Shipment\Grid\Collection</item>
</argument>
</arguments>
</type>
</config>
</config>