...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
- Класс: \CCrmProductRowRestProxy
- Вызов: CCrmProductRowRestProxy::innerGetList
protected function innerGetList($order, $filter, $select, $navigation, &$errors) { $ownerID = $filter['OWNER_ID'] ?? 0; $ownerType = $filter['OWNER_TYPE'] ?? ''; $ownerTypeName = CCrmProductRow::ResolveOwnerTypeName($ownerType); $ownerTypeID = CCrmOwnerType::ResolveID($ownerTypeName); if($ownerID <= 0 || $ownerType === '') { if ($ownerID <= 0) { $errors[] = 'The field OWNER_ID is required in filer.'; } if ($ownerType === '') { $errors[] = 'The field OWNER_TYPE is required in filer.'; } return false; } if($ownerType === 'I') { //Crutch for Invoices if(!CCrmInvoice::CheckReadPermission($ownerID)) { $errors[] = 'Access denied.'; return false; } $result = array(); $productRows = CCrmInvoice::GetProductRows($ownerID); foreach($productRows as $productRow) { $price = isset($productRow['PRICE']) ? round((double)$productRow['PRICE'], 2) : 0.0; $discountSum = isset($productRow['DISCOUNT_PRICE']) ? round((double)$productRow['DISCOUNT_PRICE'], 2) : 0.0; $vatRate = isset($productRow['VAT_RATE']) ? (double)$productRow['VAT_RATE'] * 100 : 0.0; $taxRate = isset($productRow['VAT_RATE']) ? round((double)$productRow['VAT_RATE'] * 100, 2) : 0.0; if(isset($productRow['VAT_INCLUDED']) && $productRow['VAT_INCLUDED'] === 'N') { $exclusivePrice = $price; $price = round(CCrmProductRow::CalculateInclusivePrice($exclusivePrice, $vatRate), 2); } else { $exclusivePrice = round(CCrmProductRow::CalculateExclusivePrice($price, $vatRate), 2); } unset($vatRate); $discountRate = \Bitrix\Crm\Discount::calculateDiscountRate(($exclusivePrice + $discountSum), $exclusivePrice); $result[] = array( 'ID' => $productRow['ID'], 'OWNER_ID' => $productRow['ORDER_ID'], 'OWNER_TYPE' => 'I', 'PRODUCT_ID' => $productRow['PRODUCT_ID'] ?? 0, 'PRODUCT_NAME' => $productRow['PRODUCT_NAME'] ?? '', 'PRICE' => $price, 'QUANTITY' => $productRow['QUANTITY'] ?? 0, 'DISCOUNT_TYPE_ID' => \Bitrix\Crm\Discount::MONETARY, 'DISCOUNT_RATE' => $discountRate, 'DISCOUNT_SUM' => $discountSum, 'TAX_RATE' => $taxRate, 'TAX_INCLUDED' => $productRow['VAT_INCLUDED'] ?? 'N', 'MEASURE_CODE' => $productRow['MEASURE_CODE'] ?? '', 'MEASURE_NAME' => $productRow['MEASURE_NAME'] ?? '', 'CUSTOMIZED' => $productRow['CUSTOM_PRICE'] ?? 'N', ); } return $result; } if(!EntityAuthorization::checkReadPermission($ownerTypeID, $ownerID)) { $errors[] = 'Access denied.'; return false; } return CCrmProductRow::GetList( $order, $filter, false, $navigation, $select, array('IS_EXTERNAL_CONTEXT' => true, 'EXTENDED_FIELDS' => true) ); }