diff --git a/CHANGELOG.md b/CHANGELOG.md index bb794544..da34ec13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2023-06-30 v.6.3.16 +- Добавлена передача НДС товаров + ## 2023-06-22 v.6.3.15 - Исправлено зависание агента выгрузки заказов diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php index 7f39167d..f779679a 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php @@ -1035,8 +1035,17 @@ public static function orderHistory(): bool if ($item instanceof \Bitrix\Sale\BasketItem) { $elem = self::getInfoElement($product['offer']['externalId']); + $vatRate = null; - $item->setFields(array( + if (RetailcrmConfigProvider::getOrderVat() === 'Y') { + if ($product['vatRate'] === 0) { + $vatRate = 0; + } elseif($product['vatRate'] !== null) { + $vatRate = $product['vatRate'] / 100; + } + } + + $item->setFields([ 'CURRENCY' => $newOrder->getCurrency(), 'LID' => $site, 'BASE_PRICE' => $collectItems[$product['offer']['externalId']]['initialPrice_max'], @@ -1047,8 +1056,10 @@ public static function orderHistory(): bool 'WEIGHT' => $elem['WEIGHT'], 'NOTES' => GetMessage('PRICE_TYPE'), 'PRODUCT_XML_ID' => $elem["XML_ID"], - 'CATALOG_XML_ID' => $elem["IBLOCK_XML_ID"] - )); + 'CATALOG_XML_ID' => $elem["IBLOCK_XML_ID"], + 'VAT_INCLUDED' => $vatRate !== null ? 'Y' : 'N', + 'VAT_RATE' => $vatRate, + ]); } else { RCrmActions::eventLog( 'RetailCrmHistory::orderHistory', diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php index 21d0e7c4..fb372078 100644 --- a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php +++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php @@ -301,6 +301,14 @@ public static function orderSend( $item['initialPrice'] = $product['PRICE']; } + if ( + !empty($product['VAT_INCLUDED']) + && $product['VAT_INCLUDED'] === 'Y' + && RetailcrmConfigProvider::getOrderVat() === 'Y' + ) { + $item['vatRate'] = $product['VAT_RATE'] * 100; + } + $order['items'][] = $item; if ($send && $dimensionsSetting === 'Y') { diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index c90f6ab4..af0a8dcb 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Исправлено зависание агента выгрузки заказов \ No newline at end of file +- Добавлена передача НДС товаров \ No newline at end of file diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index a5868d5e..23800f9b 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.3.15', - 'VERSION_DATE' => '2023-06-22 15:30:00' + 'VERSION' => '6.3.16', + 'VERSION_DATE' => '2023-06-30 18:00:00' ]; diff --git a/intaro.retailcrm/lang/en/options.php b/intaro.retailcrm/lang/en/options.php index c6dd9beb..9adef6f2 100644 --- a/intaro.retailcrm/lang/en/options.php +++ b/intaro.retailcrm/lang/en/options.php @@ -62,7 +62,8 @@ $MESS ['UPLOAD_ORDERS_OPTIONS'] = 'Manual uploading'; $MESS ['OTHER_OPTIONS'] = 'Other settings'; $MESS ['ORDERS_OPTIONS'] = 'Order settings'; -$MESS ['ORDER_NUMBERS'] = 'Send order numbers to the store for orders created in CRM'; +$MESS ['ORDER_NUMBERS'] = 'Transferring order numbers to the store for orders created in CRM'; +$MESS ['ORDER_VAT'] = 'Transfer VAT of goods'; $MESS ['CRM_API_VERSION'] = 'API version'; $MESS ['CURRENCY'] = 'Currency set in the order when uploading from CRM'; $MESS ['ORDER_DIMENSIONS'] = 'Send dimensions and weight of the products in the order'; diff --git a/intaro.retailcrm/lang/ru/options.php b/intaro.retailcrm/lang/ru/options.php index 432a62f3..952bed90 100644 --- a/intaro.retailcrm/lang/ru/options.php +++ b/intaro.retailcrm/lang/ru/options.php @@ -76,7 +76,8 @@ $MESS ['LOYALTY_PROGRAM_TOGGLE_MSG'] = 'Включить программу лояльности'; $MESS ['OTHER_OPTIONS'] = 'Прочие настройки'; $MESS ['ORDERS_OPTIONS'] = 'Настройки заказов'; -$MESS ['ORDER_NUMBERS'] = 'Транслировать номера заказов созданных в црм в магазин'; +$MESS ['ORDER_NUMBERS'] = 'Транслировать номера заказов созданных в CRM в магазин'; +$MESS ['ORDER_VAT'] = 'Передавать НДС товаров'; $MESS ['CRM_API_VERSION'] = 'Версия API клиента'; $MESS ['CURRENCY'] = 'Валюта, устанавливаемая в заказе при выгрузке из CRM'; diff --git a/intaro.retailcrm/lib/component/configprovider.php b/intaro.retailcrm/lib/component/configprovider.php index d08ef0b7..40986755 100644 --- a/intaro.retailcrm/lib/component/configprovider.php +++ b/intaro.retailcrm/lib/component/configprovider.php @@ -66,6 +66,9 @@ class ConfigProvider /** @var bool|null|string $orderNumbers */ protected static $orderNumbers; + /** @var bool|null|string $orderVat */ + protected static $orderVat; + /** @var array $orderTypes */ protected static $orderTypes; @@ -614,6 +617,20 @@ public static function getOrderNumbers() return self::$orderNumbers; } + /** + * getOrderVat + * + * @return bool|string|null + */ + public static function getOrderVat() + { + if (self::isEmptyNotZero(self::$orderVat)) { + self::$orderVat = static::getOption(Constants::CRM_ORDER_VAT); + } + + return self::$orderVat; + } + /** * getOrderHistoryDate * diff --git a/intaro.retailcrm/lib/component/constants.php b/intaro.retailcrm/lib/component/constants.php index 03c573a1..54d9332a 100644 --- a/intaro.retailcrm/lib/component/constants.php +++ b/intaro.retailcrm/lib/component/constants.php @@ -43,6 +43,7 @@ class Constants public const CRM_CONTRAGENT_TYPE = 'contragent_type'; public const CRM_SITES_LIST_CORPORATE = 'shops-corporate'; public const CRM_ORDER_NUMBERS = 'order_numbers'; + public const CRM_ORDER_VAT = 'order_vat'; public const CRM_CANCEL_ORDER = 'cansel_order'; public const CRM_INVENTORIES_UPLOAD = 'inventories_upload'; public const CRM_STORES = 'stores'; diff --git a/intaro.retailcrm/options.php b/intaro.retailcrm/options.php index 4d8b3ce1..1f21878e 100644 --- a/intaro.retailcrm/options.php +++ b/intaro.retailcrm/options.php @@ -38,6 +38,7 @@ $CRM_CONTRAGENT_TYPE = 'contragent_type'; $CRM_SITES_LIST = 'sites_list'; $CRM_ORDER_NUMBERS = 'order_numbers'; +$CRM_ORDER_VAT = 'order_vat'; $CRM_CANSEL_ORDER = 'cansel_order'; $CRM_INVENTORIES_UPLOAD = 'inventories_upload'; $CRM_STORES = 'stores'; @@ -400,9 +401,10 @@ } //order numbers - $orderNumbers = htmlspecialchars(trim($_POST['order-numbers'])) ? htmlspecialchars(trim($_POST['order-numbers'])) : 'N'; - $orderDimensions = htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) ? htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) : 'N'; - $sendPaymentAmount = htmlspecialchars(trim($_POST[RetailcrmConstants::SEND_PAYMENT_AMOUNT])) ? htmlspecialchars(trim($_POST[RetailcrmConstants::SEND_PAYMENT_AMOUNT])) : 'N'; + $orderVat = htmlspecialchars(trim($_POST['order-vat'])) ?: 'N'; + $orderNumbers = htmlspecialchars(trim($_POST['order-numbers'])) ?: 'N'; + $orderDimensions = htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) ?: 'N'; + $sendPaymentAmount = htmlspecialchars(trim($_POST[RetailcrmConstants::SEND_PAYMENT_AMOUNT])) ?: 'N'; //stores $bitrixStoresArr = []; @@ -805,6 +807,11 @@ function maskCorp($var) { $CRM_ORDER_NUMBERS, $orderNumbers ); + COption::SetOptionString( + $mid, + $CRM_ORDER_VAT, + $orderVat + ); COption::SetOptionString( $mid, $CRM_CANSEL_ORDER, @@ -1007,6 +1014,7 @@ function maskCorp($var) { $optionsLegalDetails = unserialize(COption::GetOptionString($mid, $CRM_LEGAL_DETAILS, 0)); $optionsCustomFields = unserialize(COption::GetOptionString($mid, $CRM_CUSTOM_FIELDS, 0)); $optionsOrderNumbers = COption::GetOptionString($mid, $CRM_ORDER_NUMBERS, 0); + $optionsOrderVat= COption::GetOptionString($mid, $CRM_ORDER_VAT, 0); $canselOrderArr = unserialize(COption::GetOptionString($mid, $CRM_CANSEL_ORDER, 0)); $optionInventotiesUpload = COption::GetOptionString($mid, $CRM_INVENTORIES_UPLOAD, 0); @@ -2138,9 +2146,18 @@ function orderUpload() {