Ejemplo n.º 1
0
$personTypeId = 0;
$arResult['CLIENT_TYPE_NAME'] = "CONTACT";
if (isset($arParams['PERSON_TYPE_ID']) && isset($arPersonTypes['COMPANY']) && isset($arPersonTypes['CONTACT'])) {
    $personTypeId = intval($arParams['PERSON_TYPE_ID']);
}
if ($personTypeId > 0) {
    if ($personTypeId === intval($arPersonTypes['COMPANY'])) {
        $arResult['CLIENT_TYPE_NAME'] = "COMPANY";
    } elseif ($personTypeId !== intval($arPersonTypes['CONTACT'])) {
        $personTypeId = 0;
    }
}
// Prepare tax list
if ($arResult['ALLOW_LD_TAX']) {
    if ($arResult['INVOICE_MODE']) {
        $arResult['TAX_LIST'] = CCrmInvoice::getTaxList($ownerID);
        if (!is_array($arResult['TAX_LIST'])) {
            $arResult['TAX_LIST'] = array();
        }
        foreach ($arResult['TAX_LIST'] as &$taxInfo) {
            $taxInfo['NAME'] = '';
            if (isset($taxInfo['TAX_NAME'])) {
                $taxInfo['NAME'] = $taxInfo['TAX_NAME'];
                unset($taxInfo['TAX_NAME']);
            }
        }
        unset($taxInfo);
    } else {
        $totalInfo = CCrmProductRow::LoadTotalInfo($ownerType, $ownerID);
        $arResult['TAX_LIST'] = is_array($totalInfo['TAX_LIST']) ? $totalInfo['TAX_LIST'] : array();
    }
Ejemplo n.º 2
0
    $rows = CCrmInvoice::GetProductRows($entityID);
    foreach ($rows as &$row) {
        $item = array('PRODUCT_NAME' => isset($row['PRODUCT_NAME']) ? $row['PRODUCT_NAME'] : '', 'PRICE' => isset($row['PRICE']) ? round(doubleval($row['PRICE']), 2) : 0.0, 'VAT_RATE' => isset($row['VAT_RATE']) ? round(doubleval($row['VAT_RATE']) * 100, 2) : 0.0, 'QUANTITY' => isset($row['QUANTITY']) ? intval($row['QUANTITY']) : 0);
        $item['FORMATTED_PRICE'] = CCrmCurrency::MoneyToString($item['PRICE'], $arResult['CURRENCY_ID']);
        $arResult['ITEMS'][] =& $item;
        unset($item);
    }
    unset($row);
    // VAT - VAT ONLY
    // EXT - EXTENDED MODE WITH CUSTOM TAXES
    $arResult['TAX_MODE'] = CCrmTax::isVatMode() ? 'VAT' : 'EXT';
    if ($arResult['TAX_MODE'] === 'VAT') {
        $arResult['VAT_SUM'] = isset($arResult['TAX_SUM']) ? $arResult['TAX_SUM'] : 0.0;
        $arResult['FORMATTED_VAT_SUM'] = CCrmCurrency::MoneyToString($arResult['VAT_SUM'], $arResult['CURRENCY_ID']);
        $arResult['FORMATTED_SUM_BRUTTO'] = CCrmCurrency::MoneyToString($arResult['SUM'], $arResult['CURRENCY_ID']);
    } else {
        $arResult['TAX_LIST'] = CCrmInvoice::getTaxList($entityID);
        foreach ($arResult['TAX_LIST'] as &$taxInfo) {
            $taxInfo['FORMATTED_SUM'] = CCrmCurrency::MoneyToString($taxInfo['VALUE_MONEY'], $arResult['CURRENCY_ID']);
        }
        unset($taxInfo);
        $arResult['TAX_LIST_PERCENT_PRECISION'] = SALE_VALUE_PRECISION;
    }
    $arResult['FORMATTED_SUM_BRUTTO'] = CCrmCurrency::MoneyToString($arResult['SUM'], $arResult['CURRENCY_ID']);
    $arResult['FORMATTED_SUM_NETTO'] = CCrmCurrency::MoneyToString($arResult['SUM'] - $arResult['TAX_SUM'], $arResult['CURRENCY_ID']);
} else {
    $arResult['TITLE'] = '';
    $arResult['CURRENCY_ID'] = CCrmCurrency::GetBaseCurrencyID();
    $arResult['SUM'] = 0.0;
}
$this->IncludeComponentTemplate();
Ejemplo n.º 3
0
$arResult['PRODUCT_ROWS'] = array();
if ($entityID > 0) {
    $rows = CCrmInvoice::GetProductRows($entityID);
    foreach ($rows as &$row) {
        $price = isset($row['PRICE']) ? round(doubleval($row['PRICE']), 2) : 0.0;
        $qty = isset($row['QUANTITY']) ? intval($row['QUANTITY']) : 0;
        $sum = $item['SUM'] = $price * $qty;
        $item = array('ID' => isset($row['ID']) ? intval($row['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, 'VAT_RATE' => isset($row['VAT_RATE']) ? round(doubleval($row['VAT_RATE']) * 100, 2) : 0.0);
        $item['FORMATTED_PRICE'] = CCrmCurrency::MoneyToString($price, $currencyID);
        $item['FORMATTED_SUM'] = CCrmCurrency::MoneyToString($sum, $currencyID);
        $item['CURRENCY_ID'] = $currencyID;
        $arResult['PRODUCT_ROWS'][] =& $item;
        unset($item);
    }
    unset($row);
    $taxList = CCrmInvoice::getTaxList($entityID);
    $taxInfo = CCrmMobileHelper::PrepareInvoiceTaxInfo($taxList, true);
    $arResult['TAX_INFOS'] = $taxInfo['ITEMS'];
    $sum = $arFields['~PRICE'];
    $arResult['SUM_BRUTTO'] = $sum;
    $arResult['SUM_NETTO'] = $sum - $taxInfo['SUM_EXCLUDED_FROM_PRICE'];
} elseif ($dealID > 0) {
    $recalculateData = array('ID' => 0, 'PAY_SYSTEM_ID' => $paySystemID, 'PERSON_TYPE_ID' => $personTypeID, 'INVOICE_PROPERTIES' => array(), 'PRODUCT_ROWS' => array());
    foreach ($properties as $propertyKey => &$propertyData) {
        $propertyFields = isset($propertyData['FIELDS']) ? $propertyData['FIELDS'] : null;
        $propertyID = is_array($propertyFields) && isset($propertyFields['ID']) ? $propertyFields['ID'] : '';
        if ($propertyID === '') {
            continue;
        }
        $recalculateData['INVOICE_PROPERTIES'][$propertyID] = isset($propertyData['VALUE']) ? $propertyData['VALUE'] : '';
    }