예제 #1
0
 for ($i = 0; $i < $rowQty; $i++) {
     $row = $rows[$i];
     $price = isset($row['PRICE']) ? round(doubleval($row['PRICE']), 2) : 0.0;
     if ($dealCurrencyID !== $currencyID) {
         $price = CCrmCurrency::ConvertMoney($price, $dealCurrencyID, $currencyID);
     }
     $qty = isset($row['QUANTITY']) ? intval($row['QUANTITY']) : 0;
     $sum = $item['SUM'] = $price * $qty;
     $item = array('ID' => 0, 'PRODUCT_ID' => isset($row['PRODUCT_ID']) ? intval($row['PRODUCT_ID']) : 0, 'PRODUCT_NAME' => isset($row['PRODUCT_NAME']) ? $row['PRODUCT_NAME'] : '', 'PRICE' => $price, 'QUANTITY' => $qty, 'SUM' => $sum, 'IDX' => $i);
     $item['FORMATTED_PRICE'] = CCrmCurrency::MoneyToString($price, $currencyID);
     $item['FORMATTED_SUM'] = CCrmCurrency::MoneyToString($sum, $currencyID);
     $item['CURRENCY_ID'] = $currencyID;
     $recalculateData['PRODUCT_ROWS'][] =& $item;
     unset($item);
 }
 $orderData = CCrmInvoice::QuickRecalculate($recalculateData);
 if (empty($orderData)) {
     $arResult['TAX_INFOS'] = array();
     $arResult['SUM_BRUTTO'] = $arResult['SUM_NETTO'] = 0.0;
 } else {
     $orderCurrencyID = isset($orderData['CURRENCY']) ? $orderData['CURRENCY'] : '';
     if ($orderCurrencyID !== '' && $orderCurrencyID !== $currencyID) {
         ShowError('ERROR: CURRENCIES ARE ARE MISMATCHED');
         return;
     }
     $sumBrutto = $arResult['SUM_BRUTTO'] = isset($orderData['PRICE']) ? $orderData['PRICE'] : 0.0;
     $taxSum = isset($orderData['TAX_VALUE']) ? $orderData['TAX_VALUE'] : 0.0;
     $sumNetto = $arResult['SUM_NETTO'] = $sumBrutto - $taxSum;
     if (isset($orderData['USE_VAT']) && $orderData['USE_VAT'] && $taxMode !== 'VAT') {
         ShowError('ERROR: TAX MODES ARE ARE MISMATCHED');
         return;
예제 #2
0
     CCrmInvoice::__RewritePayerInfo($companyID, $contactID, $properties);
     $payerInfo = CCrmInvoice::__MakePayerInfoString($properties);
     if ($resolvedPersonTypeID > 0) {
         $payerRequisites = CCrmMobileHelper::PrepareInvoiceClientRequisites($resolvedPersonTypeID, $properties);
     }
 }
 if (!$enableProductRows || empty($productRows)) {
     $resultData = array('PERSON_TYPE_ID' => $resolvedPersonTypeID, 'PAY_SYSTEM_ID' => $resolvedPaySystemID, 'PAY_SYSTEM_NAME' => $resolvedPaySystemID > 0 && isset($paySystems[$resolvedPaySystemID]) ? $paySystems[$resolvedPaySystemID] : '');
     if ($enablePayerInfo) {
         $resultData['PAYER_INFO'] = $payerInfo;
         $resultData['PAYER_INFO_FORMAT'] = $resolvedPersonTypeID > 0 ? CCrmMobileHelper::PrepareInvoiceClientInfoFormat($resolvedPersonTypeID) : '';
         $resultData['PAYER_REQUISITES'] = $payerRequisites;
     }
     __CrmMobileInvoiceEditEndResonse(array('RESULT_DATA' => $resultData));
 }
 $orderData = CCrmInvoice::QuickRecalculate($arFields);
 if (empty($orderData)) {
     __CrmMobileInvoiceEditEndResonse(array('ERROR' => GetMessage('CRM_INVOICE_COULD_NOT_RECALCULATE')));
 }
 $currencyID = isset($orderData['CURRENCY']) ? $orderData['CURRENCY'] : CCrmCurrency::GetBaseCurrencyID();
 $sumBrutto = isset($orderData['PRICE']) ? $orderData['PRICE'] : 0.0;
 $taxSum = isset($orderData['TAX_VALUE']) ? $orderData['TAX_VALUE'] : 0.0;
 $sumNetto = $sumBrutto - $taxSum;
 $taxList = isset($orderData['TAX_LIST']) && is_array($orderData['TAX_LIST']) ? $orderData['TAX_LIST'] : array();
 $taxMode = isset($orderData['USE_VAT']) && $orderData['USE_VAT'] ? 'VAT' : (!empty($taxList) ? 'EXT' : '');
 $resultData = array('PERSON_TYPE_ID' => $resolvedPersonTypeID, 'PAY_SYSTEM_ID' => $resolvedPaySystemID, 'PAY_SYSTEM_NAME' => $resolvedPaySystemID > 0 && isset($paySystems[$resolvedPaySystemID]) ? $paySystems[$resolvedPaySystemID] : '', 'CURRENCY_ID' => $currencyID, 'SUM_NETTO' => $sumNetto, 'SUM_BRUTTO' => $sumBrutto, 'TAX_SUM' => $taxSum, 'FORMATTED_SUM_NETTO' => CCrmCurrency::MoneyToString($sumNetto, $currencyID), 'FORMATTED_SUM_BRUTTO' => CCrmCurrency::MoneyToString($sumBrutto, $currencyID), 'FORMATTED_TAX_SUM' => CCrmCurrency::MoneyToString($taxSum, $currencyID), 'TAX_MODE' => $taxMode, 'PRODUCT_ROWS' => array());
 if ($enablePayerInfo) {
     $resultData['PAYER_INFO'] = $payerInfo;
     $resultData['PAYER_INFO_FORMAT'] = $resolvedPersonTypeID > 0 ? CCrmMobileHelper::PrepareInvoiceClientInfoFormat($resolvedPersonTypeID) : '';
     $resultData['PAYER_REQUISITES'] = $payerRequisites;
 }