Skip to content

Commit

Permalink
ref #77474 Добавлена передача НДС товаров (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
uryvskiy-dima authored Jul 3, 2023
1 parent 17e3b00 commit c7cec20
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2023-06-30 v.6.3.16
- Добавлена передача НДС товаров

## 2023-06-22 v.6.3.15
- Исправлено зависание агента выгрузки заказов

Expand Down
17 changes: 14 additions & 3 deletions intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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',
Expand Down
8 changes: 8 additions & 0 deletions intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
2 changes: 1 addition & 1 deletion intaro.retailcrm/description.ru
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Исправлено зависание агента выгрузки заказов
- Добавлена передача НДС товаров
4 changes: 2 additions & 2 deletions intaro.retailcrm/install/version.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$arModuleVersion = [
'VERSION' => '6.3.15',
'VERSION_DATE' => '2023-06-22 15:30:00'
'VERSION' => '6.3.16',
'VERSION_DATE' => '2023-06-30 18:00:00'
];
3 changes: 2 additions & 1 deletion intaro.retailcrm/lang/en/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion intaro.retailcrm/lang/ru/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
17 changes: 17 additions & 0 deletions intaro.retailcrm/lib/component/configprovider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
*
Expand Down
1 change: 1 addition & 0 deletions intaro.retailcrm/lib/component/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
33 changes: 25 additions & 8 deletions intaro.retailcrm/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -805,6 +807,11 @@ function maskCorp($var) {
$CRM_ORDER_NUMBERS,
$orderNumbers
);
COption::SetOptionString(
$mid,
$CRM_ORDER_VAT,
$orderVat
);
COption::SetOptionString(
$mid,
$CRM_CANSEL_ORDER,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -2138,9 +2146,18 @@ function orderUpload() {
<tr>
<td colspan="2" class="option-head option-other-top option-other-bottom">
<b>
<label><input class="addr" type="checkbox" name="order-numbers" value="Y" <?php if ($optionsOrderNumbers === 'Y') {
<label><input class="addr" type="checkbox" name="order-vat" value="Y" <?php if ($optionsOrderVat === 'Y') {
echo "checked";
} ?>> <?php echo GetMessage('ORDER_NUMBERS'); ?></label>
} ?>> <?php echo GetMessage('ORDER_VAT'); ?></label>
</b>
</td>
</tr>
<tr>
<td colspan="2" class="option-head option-other-top option-other-bottom">
<b>
<label>
<input class="addr" type="checkbox" name="<?php echo RetailcrmConstants::SEND_PAYMENT_AMOUNT; ?>" value="Y" <?php if(RetailcrmConfigProvider::shouldSendPaymentAmount()) echo "checked"; ?>> <?php echo GetMessage('SEND_PAYMENT_AMOUNT'); ?>
</label>
</b>
</td>
</tr>
Expand All @@ -2158,9 +2175,9 @@ function orderUpload() {
<tr>
<td colspan="2" class="option-head option-other-top option-other-bottom">
<b>
<label>
<input class="addr" type="checkbox" name="<?php echo RetailcrmConstants::SEND_PAYMENT_AMOUNT; ?>" value="Y" <?php if(RetailcrmConfigProvider::shouldSendPaymentAmount()) echo "checked"; ?>> <?php echo GetMessage('SEND_PAYMENT_AMOUNT'); ?>
</label>
<label><input class="addr" type="checkbox" name="order-numbers" value="Y" <?php if ($optionsOrderNumbers === 'Y') {
echo "checked";
} ?>> <?php echo GetMessage('ORDER_NUMBERS'); ?></label>
</b>
</td>
</tr>
Expand Down

0 comments on commit c7cec20

Please sign in to comment.