|  | @@ -65,7 +65,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 65 | 65 |          'COL_ITEM_PAYABLE_AMOUNT [base_imponible+IGV]' | 
                                                                                                            
                                                            | 66 | 66 |      ]; | 
                                                                                                            
                                                            | 67 | 67 |   | 
                                                                                                            
                                                            | 68 |  | -    public function populate($items,  $currencyCode) { | 
                                                                                                            
                                                            |  | 68 | +    public function populate($items, $currencyCode) { | 
                                                                                                            
                                                            | 69 | 69 |          foreach ($items as $idx => $item) { | 
                                                                                                            
                                                            | 70 | 70 |              $allowances     = isset($item['allowances']) ? $item['allowances'] : []; | 
                                                                                                            
                                                            | 71 | 71 |              $charges        = isset($item['charges']) ? $item['charges'] : []; | 
                                                                                                                                                        
                                                        |  | @@ -74,42 +74,42 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 74 | 74 |              $grossUnitValue = $item['unitValue']; | 
                                                                                                            
                                                            | 75 | 75 |              $igvIncluded    = $item['igvIncluded']; | 
                                                                                                            
                                                            | 76 | 76 |               | 
                                                                                                            
                                                            | 77 |  | -            $unitValue         = $this->calcUnitValue($igvAffectCode, $grossUnitValue, $igvIncluded);      // Valor unitario | 
                                                                                                            
                                                            |  | 77 | +            $unitValue         = $this->calcUnitValue($igvAffectCode, $grossUnitValue, $igvIncluded); // Valor unitario | 
                                                                                                            
                                                            | 78 | 78 |              $unitTaxedValue    = $this->calcUnitTaxedValue($igvAffectCode, $grossUnitValue, $igvIncluded); // Valor unitario incluyendo impuestos si son aplicables | 
                                                                                                            
                                                            | 79 |  | -            $unitBillableValue = $this->calcUnitBillableValue($unitValue, $priceType);                     // Valor unitario facturable | 
                                                                                                            
                                                            |  | 79 | +            $unitBillableValue = $this->calcUnitBillableValue($unitValue, $priceType); // Valor unitario facturable | 
                                                                                                            
                                                            | 80 | 80 |              $quantity          = $item['quantity']; // Cantidad | 
                                                                                                            
                                                            | 81 | 81 |   | 
                                                                                                            
                                                            | 82 |  | -            $itemValue            = $unitValue * $quantity;         // Valor de item | 
                                                                                                            
                                                            |  | 82 | +            $itemValue            = $unitValue * $quantity; // Valor de item | 
                                                                                                            
                                                            | 83 | 83 |              $itemBillableValue    = $unitBillableValue * $quantity; // Valor de item | 
                                                                                                            
                                                            | 84 | 84 |              $itemAllowancesAmount = Operations::getTotalAllowanceCharge($itemBillableValue, $allowances); // Descuentos de item | 
                                                                                                            
                                                            | 85 |  | -            $itemChargesAmount    = Operations::getTotalAllowanceCharge($itemValue, $charges);            // Cargos de item | 
                                                                                                            
                                                            | 86 |  | -            $itemTaxableAmount    = $this->calcItemTaxableAmount($itemValue, $priceType, $allowances, $charges);         // Valor de venta del ítem = (Valor del item - Descuentos + Cargos), 0 si el valor del item es referencial! | 
                                                                                                            
                                                            |  | 85 | +            $itemChargesAmount    = Operations::getTotalAllowanceCharge($itemValue, $charges); // Cargos de item | 
                                                                                                            
                                                            |  | 86 | +            $itemTaxableAmount    = $this->calcItemTaxableAmount($itemValue, $priceType, $allowances, $charges); // Valor de venta del ítem = (Valor del item - Descuentos + Cargos), 0 si el valor del item es referencial! | 
                                                                                                            
                                                            | 87 | 87 |              $igvAmount            = $this->calcIgvAmount($igvAffectCode, $itemTaxableAmount); // Afectación al IGV por item | 
                                                                                                            
                                                            | 88 | 88 |               | 
                                                                                                            
                                                            | 89 | 89 |              $itemIgvTaxed         = $itemBillableValue + $igvAmount; | 
                                                                                                            
                                                            | 90 | 90 |               | 
                                                                                                            
                                                            | 91 |  | -            $this->set(self::COL_PRODUCT_CODE,        $idx, $item['productCode']); | 
                                                                                                            
                                                            | 92 |  | -            $this->set(self::COL_UNPSC,               $idx, $item['sunatProductCode']); | 
                                                                                                            
                                                            | 93 |  | -            $this->set(self::COL_UNIT_CODE,           $idx, $item['unitCode']); | 
                                                                                                            
                                                            | 94 |  | -            $this->set(self::COL_QUANTITY,            $idx, $quantity); | 
                                                                                                            
                                                            | 95 |  | -            $this->set(self::COL_DESCRIPTION,         $idx, $item['description']); | 
                                                                                                            
                                                            | 96 |  | -            $this->set(self::COL_CURRENCY_CODE,       $idx, $currencyCode); | 
                                                                                                            
                                                            |  | 91 | +            $this->set(self::COL_PRODUCT_CODE, $idx, $item['productCode']); | 
                                                                                                            
                                                            |  | 92 | +            $this->set(self::COL_UNPSC, $idx, $item['sunatProductCode']); | 
                                                                                                            
                                                            |  | 93 | +            $this->set(self::COL_UNIT_CODE, $idx, $item['unitCode']); | 
                                                                                                            
                                                            |  | 94 | +            $this->set(self::COL_QUANTITY, $idx, $quantity); | 
                                                                                                            
                                                            |  | 95 | +            $this->set(self::COL_DESCRIPTION, $idx, $item['description']); | 
                                                                                                            
                                                            |  | 96 | +            $this->set(self::COL_CURRENCY_CODE, $idx, $currencyCode); | 
                                                                                                            
                                                            | 97 | 97 |              // Códigos de catálogos predefinidos | 
                                                                                                            
                                                            | 98 |  | -            $this->set(self::COL_PRICE_TYPE,          $idx, $priceType); | 
                                                                                                            
                                                            | 99 |  | -            $this->set(self::COL_TAX_TYPE,            $idx, $item['taxType']); | 
                                                                                                            
                                                            | 100 |  | -            $this->set(self::COL_IGV_AFFECTATION,     $idx, $item['igvAffectationCode']); | 
                                                                                                            
                                                            |  | 98 | +            $this->set(self::COL_PRICE_TYPE, $idx, $priceType); | 
                                                                                                            
                                                            |  | 99 | +            $this->set(self::COL_TAX_TYPE, $idx, $item['taxType']); | 
                                                                                                            
                                                            |  | 100 | +            $this->set(self::COL_IGV_AFFECTATION, $idx, $item['igvAffectationCode']); | 
                                                                                                            
                                                            | 101 | 101 |   | 
                                                                                                            
                                                            | 102 |  | -            $this->set(self::COL_UNIT_VALUE,          $idx, $unitValue); | 
                                                                                                            
                                                            |  | 102 | +            $this->set(self::COL_UNIT_VALUE, $idx, $unitValue); | 
                                                                                                            
                                                            | 103 | 103 |              $this->set(self::COL_UNIT_BILLABLE_VALUE, $idx, $unitBillableValue); | 
                                                                                                            
                                                            | 104 |  | -            $this->set(self::COL_UNIT_TAXED_VALUE,    $idx, $unitTaxedValue); | 
                                                                                                            
                                                            | 105 |  | -            $this->set(self::COL_ITEM_VALUE,          $idx, $itemValue); | 
                                                                                                            
                                                            |  | 104 | +            $this->set(self::COL_UNIT_TAXED_VALUE, $idx, $unitTaxedValue); | 
                                                                                                            
                                                            |  | 105 | +            $this->set(self::COL_ITEM_VALUE, $idx, $itemValue); | 
                                                                                                            
                                                            | 106 | 106 |              $this->set(self::COL_ITEM_BILLABLE_VALUE, $idx, $itemBillableValue); | 
                                                                                                            
                                                            | 107 |  | -            $this->set(self::COL_ALLOWANCES,          $idx, $allowances); | 
                                                                                                            
                                                            | 108 |  | -            $this->set(self::COL_ALLOWANCES_AMOUNT,   $idx, $itemAllowancesAmount); | 
                                                                                                            
                                                            | 109 |  | -            $this->set(self::COL_CHARGES,             $idx, $charges); | 
                                                                                                            
                                                            | 110 |  | -            $this->set(self::COL_CHARGES_AMOUNT,      $idx, $itemChargesAmount); | 
                                                                                                            
                                                            |  | 107 | +            $this->set(self::COL_ALLOWANCES, $idx, $allowances); | 
                                                                                                            
                                                            |  | 108 | +            $this->set(self::COL_ALLOWANCES_AMOUNT, $idx, $itemAllowancesAmount); | 
                                                                                                            
                                                            |  | 109 | +            $this->set(self::COL_CHARGES, $idx, $charges); | 
                                                                                                            
                                                            |  | 110 | +            $this->set(self::COL_CHARGES_AMOUNT, $idx, $itemChargesAmount); | 
                                                                                                            
                                                            | 111 | 111 |              $this->set(self::COL_ITEM_TAXABLE_AMOUNT, $idx, $itemTaxableAmount); | 
                                                                                                            
                                                            | 112 |  | -            $this->set(self::COL_IGV,                 $idx, $igvAmount); | 
                                                                                                            
                                                            |  | 112 | +            $this->set(self::COL_IGV, $idx, $igvAmount); | 
                                                                                                            
                                                            | 113 | 113 |              $this->set(self::COL_ITEM_PAYABLE_AMOUNT, $idx, $itemIgvTaxed); | 
                                                                                                            
                                                            | 114 | 114 |          } | 
                                                                                                            
                                                            | 115 | 115 |      } |