Send in history

This commit is contained in:
Uryvskiy Dima 2024-07-31 17:02:53 +03:00
parent 31976ff84c
commit ecf59a8b83
3 changed files with 75 additions and 6046 deletions

View file

@ -1525,10 +1525,13 @@ class RetailcrmHistory
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');
@ -1954,6 +1957,24 @@ class RetailcrmHistory
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(

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long