Skip to content

Commit

Permalink
Send in history
Browse files Browse the repository at this point in the history
  • Loading branch information
uryvskiy-dima committed Jul 31, 2024
1 parent 31976ff commit ecf59a8
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 6,046 deletions.
21 changes: 21 additions & 0 deletions retailcrm/lib/RetailcrmHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -1525,10 +1525,13 @@ private static function updateAddressInvoice($addressInvoice, $customer, $order)

return;
}

if (RetailcrmTools::validateEntity($addressInvoice, null, true)) {
$addressInvoice->id_customer = $customer->id;
RetailcrmTools::assignAddressIdsByFields($customer, $addressInvoice);

self::setCompanyAndVatNumberForInvoiceAddress($order, $addressInvoice);

if (empty($addressInvoice->id)) {
self::loadInPrestashop($addressInvoice, 'save');

Expand Down Expand Up @@ -1954,6 +1957,24 @@ private static function createOrderDetail($item, $product, $parsedExtId, $presta
return $orderDetail;
}

private static function setCompanyAndVatNumberForInvoiceAddress($crmOrder, $addressInvoice)
{
if (!RetailcrmTools::isCorporateEnabled()
&& RetailcrmTools::isCampanyAndVatNumberSendEnabled()
) {
$company = $crmOrder['customFields']['ps_company'] ?? '';
$vatNumber = $crmOrder['customFields']['ps_vat_number'] ?? '';

if ('' !== $company) {
$addressInvoice->company = $company;
}

if ('' !== $vatNumber) {
$addressInvoice->vat_number = $vatNumber;
}
}
}

private static function handleError($order, $e)
{
RetailcrmLogger::writeCaller(
Expand Down
Loading

0 comments on commit ecf59a8

Please sign in to comment.