mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-04-11 12:50:55 +00:00
Support transfer company and vat number in CRM custom fields
This commit is contained in:
parent
d0782028ee
commit
d3f5a8cebc
6 changed files with 6077 additions and 88 deletions
|
@ -329,7 +329,7 @@ class RetailcrmOrderBuilder
|
|||
->setAddress($this->invoiceAddress)
|
||||
->build()
|
||||
->getDataArray()
|
||||
;
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -354,7 +354,7 @@ class RetailcrmOrderBuilder
|
|||
->setWithExternalId(true)
|
||||
->build()
|
||||
->getDataArray()
|
||||
;
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -979,15 +979,26 @@ class RetailcrmOrderBuilder
|
|||
;
|
||||
$crmOrder = array_merge($crmOrder, $addressBuilder->getDataArray());
|
||||
|
||||
if ($addressInvoice instanceof Address && !empty($addressInvoice->company)) {
|
||||
$crmOrder['contragent']['legalName'] = $addressInvoice->company;
|
||||
$isCorporateEnabled = RetailcrmTools::isCorporateEnabled();
|
||||
|
||||
if (!empty($addressInvoice->vat_number)) {
|
||||
$crmOrder['contragent']['INN'] = $addressInvoice->vat_number;
|
||||
$crmOrder['contragent']['contragentType'] = $isCorporateEnabled && RetailcrmTools::isOrderCorporate($order)
|
||||
? 'legal-entity'
|
||||
: 'individual';
|
||||
|
||||
if (!$isCorporateEnabled && RetailcrmTools::isCampanyAndVatNumberSendEnabled()) {
|
||||
$company = $addressDelivery->company;
|
||||
$vatNumber = $addressDelivery->vat_number;
|
||||
|
||||
if ($addressInvoice instanceof Address) {
|
||||
$company = !empty($addressInvoice->company) ? $addressInvoice->company : $company;
|
||||
$vatNumber = !empty($addressInvoice->vat_number) ? $addressInvoice->vat_number : $vatNumber;
|
||||
}
|
||||
|
||||
$crmOrder['customFields']['ps_company'] = $company;
|
||||
$crmOrder['customFields']['ps_vat_number'] = $vatNumber;
|
||||
}
|
||||
|
||||
if (isset($payment[$paymentType]) && !empty($payment[$paymentType])) {
|
||||
if (!empty($payment[$paymentType])) {
|
||||
$order_payment = [
|
||||
'externalId' => $order->id . '#' . $order->reference,
|
||||
'type' => $payment[$paymentType],
|
||||
|
@ -1124,9 +1135,6 @@ class RetailcrmOrderBuilder
|
|||
'productName' => $product['product_name'],
|
||||
'quantity' => $product['product_quantity'],
|
||||
'initialPrice' => round($product['product_price'], 2),
|
||||
/*'initialPrice' => !empty($item['rate'])
|
||||
? $item['price'] + ($item['price'] * $item['rate'] / 100)
|
||||
: $item['price'],*/
|
||||
'purchasePrice' => round($product['purchase_supplier_price'], 2),
|
||||
];
|
||||
|
||||
|
@ -1161,12 +1169,6 @@ class RetailcrmOrderBuilder
|
|||
if (!empty($site)) {
|
||||
$crmOrder['customer']['site'] = $site;
|
||||
}
|
||||
|
||||
if (RetailcrmTools::isCorporateEnabled() && RetailcrmTools::isOrderCorporate($order)) {
|
||||
$crmOrder['contragent']['contragentType'] = 'legal-entity';
|
||||
} else {
|
||||
$crmOrder['contragent']['contragentType'] = 'individual';
|
||||
}
|
||||
}
|
||||
|
||||
return RetailcrmTools::filter(
|
||||
|
|
|
@ -78,6 +78,16 @@ class RetailcrmTools
|
|||
return (bool) Configuration::get(RetailCRM::ENABLE_ICML_SERVICES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the transfer of company and VAT number is enabled in the settings
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isCampanyAndVatNumberSendEnabled()
|
||||
{
|
||||
return (bool) Configuration::get(RetailCRM::ENABLE_COMPANY_AND_VAT_NUMBER_SEND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if customer is corporate
|
||||
*
|
||||
|
@ -969,22 +979,6 @@ class RetailcrmTools
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return DateTime|false
|
||||
*/
|
||||
public static function getConfigurationCreatedAtByName($name)
|
||||
{
|
||||
$config = self::getConfigurationByName($name);
|
||||
|
||||
if (empty($config)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $config['date_add']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
@ -62,6 +62,7 @@ class RetailcrmSettingsItems
|
|||
'enableCorporate' => new RetailcrmSettingsItemBool('enableCorporate', RetailCRM::ENABLE_CORPORATE_CLIENTS),
|
||||
'enableOrderNumberSending' => new RetailcrmSettingsItemBool('enableOrderNumberSending', RetailCRM::ENABLE_ORDER_NUMBER_SENDING),
|
||||
'enableOrderNumberReceiving' => new RetailcrmSettingsItemBool('enableOrderNumberReceiving', RetailCRM::ENABLE_ORDER_NUMBER_RECEIVING),
|
||||
'enableCompanyAndVatNumberSend' => new RetailcrmSettingsItemBool('enableCompanyAndVatNumberSend', RetailCRM::ENABLE_COMPANY_AND_VAT_NUMBER_SEND),
|
||||
'webJobs' => new RetailcrmSettingsItemBool('webJobs', RetailCRM::ENABLE_WEB_JOBS, '1'),
|
||||
'debugMode' => new RetailcrmSettingsItemBool('debugMode', RetailCRM::ENABLE_DEBUG_MODE),
|
||||
|
||||
|
|
|
@ -72,12 +72,11 @@ class RetailCRM extends Module
|
|||
const ENABLE_BALANCES_RECEIVING = 'RETAILCRM_ENABLE_BALANCES_RECEIVING';
|
||||
const ENABLE_ORDER_NUMBER_SENDING = 'RETAILCRM_ENABLE_ORDER_NUMBER_SENDING';
|
||||
const ENABLE_ORDER_NUMBER_RECEIVING = 'RETAILCRM_ENABLE_ORDER_NUMBER_RECEIVING';
|
||||
const ENABLE_COMPANY_AND_VAT_NUMBER_SEND = 'RETAILCRM_ENABLE_COMPANY_AND_VAT_NUMBER_SEND';
|
||||
const ENABLE_DEBUG_MODE = 'RETAILCRM_ENABLE_DEBUG_MODE';
|
||||
|
||||
const CONSULTANT_SCRIPT = 'RETAILCRM_CONSULTANT_SCRIPT';
|
||||
const CONSULTANT_RCCT = 'RETAILCRM_CONSULTANT_RCCT';
|
||||
const ENABLE_WEB_JOBS = 'RETAILCRM_ENABLE_WEB_JOBS';
|
||||
|
||||
const REQUIRED_CRM_SITE_ACCESS = 'access_selective';
|
||||
const REQUIRED_CRM_SITE_COUNT = 1;
|
||||
const REQUIRED_CRM_SCOPES = [
|
||||
|
@ -343,6 +342,7 @@ class RetailCRM extends Module
|
|||
&& Configuration::deleteByName(static::ENABLE_BALANCES_RECEIVING)
|
||||
&& Configuration::deleteByName(static::ENABLE_ORDER_NUMBER_SENDING)
|
||||
&& Configuration::deleteByName(static::ENABLE_ORDER_NUMBER_RECEIVING)
|
||||
&& Configuration::deleteByName(static::ENABLE_COMPANY_AND_VAT_NUMBER_SEND)
|
||||
&& Configuration::deleteByName(static::ENABLE_DEBUG_MODE)
|
||||
&& Configuration::deleteByName(static::ENABLE_WEB_JOBS)
|
||||
&& Configuration::deleteByName('RETAILCRM_LAST_SYNC')
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue