| @@ -75,29 +75,29 @@ discard block | ||
| 75 | 75 | 'precio_item [base_imponible+IGV]' | 
| 76 | 76 | ]; | 
| 77 | 77 | |
| 78 | -    public function populate($items,  $currencyCode) { | |
| 78 | +    public function populate($items, $currencyCode) { | |
| 79 | 79 |          foreach ($items as $idx => $item) { | 
| 80 | 80 | |
| 81 | - $cat7Item = Catalogo::getCatItem(7, $item['igvAffectationCode']); // Catálogo 7 Tipo de afectación del IGV | |
| 82 | - $priceType = $item['priceTypeCode']; // Tipo de precio | |
| 81 | + $cat7Item = Catalogo::getCatItem(7, $item['igvAffectationCode']); // Catálogo 7 Tipo de afectación del IGV | |
| 82 | + $priceType = $item['priceTypeCode']; // Tipo de precio | |
| 83 | 83 | |
| 84 | - $unitValue = $item['unitValue']; // Valor unitario | |
| 84 | + $unitValue = $item['unitValue']; // Valor unitario | |
| 85 | 85 | $igvIncluded = $item['igvIncluded']; | 
| 86 | 86 | $unitPayableAmount = $unitValue; | 
| 87 | -            if(isset($cat7Item['igv'])){ | |
| 87 | +            if (isset($cat7Item['igv'])) { | |
| 88 | 88 | // Aplica IGV | 
| 89 | 89 |                  if ($igvIncluded) { | 
| 90 | 90 | $unitPayableAmount = $unitValue; | 
| 91 | 91 | $unitValue = $unitPayableAmount / (1 + SunatVars::IGV); | 
| 92 | -                } else{ | |
| 92 | +                } else { | |
| 93 | 93 | $unitPayableAmount = $unitValue * (1 + SunatVars::IGV); | 
| 94 | 94 | } | 
| 95 | 95 | } | 
| 96 | 96 | $unitBillableValue = ($priceType === SunatVars::CAT16_REF_VALUE) ? 0 : $unitValue; // Valor unitario pagable | 
| 97 | - $quantity = $item['quantity']; // Cantidad | |
| 97 | + $quantity = $item['quantity']; // Cantidad | |
| 98 | 98 | |
| 99 | - $itemValue = $unitValue * $quantity; // Valor de item | |
| 100 | - $itemBillableValue = $unitBillableValue * $quantity; // Valor de item | |
| 99 | + $itemValue = $unitValue * $quantity; // Valor de item | |
| 100 | + $itemBillableValue = $unitBillableValue * $quantity; // Valor de item | |
| 101 | 101 | // Descuentos de item | 
| 102 | 102 | $itemAllowancesAmount = 0; | 
| 103 | 103 | $allowancesArray = isset($item['allowances']) ? $item['allowances'] : []; | 
| @@ -132,29 +132,29 @@ discard block | ||
| 132 | 132 | |
| 133 | 133 | $itemIgvTaxed = $itemBillableValue + $igvAmount; | 
| 134 | 134 | |
| 135 | - $this->set(self::COL_PRODUCT_CODE, $idx, $item['productCode']); | |
| 136 | - $this->set(self::COL_UNPSC, $idx, $item['sunatProductCode']); | |
| 137 | - $this->set(self::COL_UNIT_CODE, $idx, $item['unitCode']); | |
| 138 | - $this->set(self::COL_QUANTITY, $idx, $quantity); | |
| 139 | - $this->set(self::COL_DESCRIPTION, $idx, $item['description']); | |
| 140 | - $this->set(self::COL_CURRENCY_CODE, $idx, $currencyCode); | |
| 135 | + $this->set(self::COL_PRODUCT_CODE, $idx, $item['productCode']); | |
| 136 | + $this->set(self::COL_UNPSC, $idx, $item['sunatProductCode']); | |
| 137 | + $this->set(self::COL_UNIT_CODE, $idx, $item['unitCode']); | |
| 138 | + $this->set(self::COL_QUANTITY, $idx, $quantity); | |
| 139 | + $this->set(self::COL_DESCRIPTION, $idx, $item['description']); | |
| 140 | + $this->set(self::COL_CURRENCY_CODE, $idx, $currencyCode); | |
| 141 | 141 | // Códigos de catálogos predefinidos | 
| 142 | - $this->set(self::COL_PRICE_TYPE, $idx, $priceType); | |
| 143 | - $this->set(self::COL_TAX_TYPE, $idx, $item['taxTypeCode']); | |
| 144 | - $this->set(self::COL_IGV_AFFECTATION, $idx, $item['igvAffectationCode']); | |
| 145 | - | |
| 146 | - $this->set(self::COL_UNIT_VALUE, $idx, $unitValue); | |
| 147 | - $this->set(self::COL_UNIT_BILLABLE_VALUE, $idx, $unitBillableValue); | |
| 148 | - $this->set(self::COL_UNIT_PAYABLE_AMOUNT, $idx, $unitPayableAmount); | |
| 149 | - $this->set(self::COL_ITEM_VALUE, $idx, $itemValue); | |
| 150 | - $this->set(self::COL_ITEM_BILLABLE_VALUE, $idx, $itemBillableValue); | |
| 151 | - $this->set(self::COL_ALLOWANCES, $idx, $allowancesArray); | |
| 152 | - $this->set(self::COL_ALLOWANCES_AMOUNT, $idx, $itemAllowancesAmount); | |
| 153 | - $this->set(self::COL_CHARGES, $idx, $chargesArray); | |
| 154 | - $this->set(self::COL_CHARGES_AMOUNT, $idx, $itemChargesAmount); | |
| 155 | - $this->set(self::COL_ITEM_TAXABLE_AMOUNT, $idx, $itemTaxableAmount); | |
| 156 | - $this->set(self::COL_IGV, $idx, $igvAmount); | |
| 157 | - $this->set(self::COL_ITEM_PAYABLE_AMOUNT, $idx, $itemIgvTaxed); | |
| 142 | + $this->set(self::COL_PRICE_TYPE, $idx, $priceType); | |
| 143 | + $this->set(self::COL_TAX_TYPE, $idx, $item['taxTypeCode']); | |
| 144 | + $this->set(self::COL_IGV_AFFECTATION, $idx, $item['igvAffectationCode']); | |
| 145 | + | |
| 146 | + $this->set(self::COL_UNIT_VALUE, $idx, $unitValue); | |
| 147 | + $this->set(self::COL_UNIT_BILLABLE_VALUE, $idx, $unitBillableValue); | |
| 148 | + $this->set(self::COL_UNIT_PAYABLE_AMOUNT, $idx, $unitPayableAmount); | |
| 149 | + $this->set(self::COL_ITEM_VALUE, $idx, $itemValue); | |
| 150 | + $this->set(self::COL_ITEM_BILLABLE_VALUE, $idx, $itemBillableValue); | |
| 151 | + $this->set(self::COL_ALLOWANCES, $idx, $allowancesArray); | |
| 152 | + $this->set(self::COL_ALLOWANCES_AMOUNT, $idx, $itemAllowancesAmount); | |
| 153 | + $this->set(self::COL_CHARGES, $idx, $chargesArray); | |
| 154 | + $this->set(self::COL_CHARGES_AMOUNT, $idx, $itemChargesAmount); | |
| 155 | + $this->set(self::COL_ITEM_TAXABLE_AMOUNT, $idx, $itemTaxableAmount); | |
| 156 | + $this->set(self::COL_IGV, $idx, $igvAmount); | |
| 157 | + $this->set(self::COL_ITEM_PAYABLE_AMOUNT, $idx, $itemIgvTaxed); | |
| 158 | 158 | } | 
| 159 | 159 | } | 
| 160 | 160 | |
| @@ -15,7 +15,7 @@ | ||
| 15 | 15 | const SUNAT_SERVICE_URL_BETA = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService'; | 
| 16 | 16 | const SUNAT_SOL_USER_BETA = 'MODDATOS'; | 
| 17 | 17 | const SUNAT_SOL_KEY_BETA = 'moddatos'; | 
| 18 | - const DIR_CATS = __DIR__.'/catalogo'; | |
| 18 | + const DIR_CATS = __DIR__ . '/catalogo'; | |
| 19 | 19 | const IGV = 0.18; | 
| 20 | 20 | const IGV_PERCENT = 18.00; | 
| 21 | 21 | const CAT16_UNITARY_PRICE = '01'; | 
| @@ -103,14 +103,14 @@ | ||
| 103 | 103 | ]); | 
| 104 | 104 | |
| 105 | 105 | // Order Reference | 
| 106 | -        if($this->OrderReference){ | |
| 106 | +        if ($this->OrderReference) { | |
| 107 | 107 | $writer->write([ | 
| 108 | 108 | SchemaNS::CAC . 'OrderReference' => $this->OrderReference | 
| 109 | 109 | ]); | 
| 110 | 110 | } | 
| 111 | 111 | |
| 112 | 112 | // Despatch Document Reference | 
| 113 | -        if($this->DespatchDocumentReference){ | |
| 113 | +        if ($this->DespatchDocumentReference) { | |
| 114 | 114 | $writer->write([ | 
| 115 | 115 | SchemaNS::CAC . 'DespatchDocumentReference' => $this->DespatchDocumentReference | 
| 116 | 116 | ]); | 
| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | |
| 13 | 13 | use Sabre\Xml\Writer; | 
| 14 | 14 | |
| 15 | -class TaxScheme extends BaseComponent{ | |
| 15 | +class TaxScheme extends BaseComponent { | |
| 16 | 16 | |
| 17 | 17 | protected $ID; | 
| 18 | 18 | protected $IDAttributes = []; | 
| @@ -114,21 +114,21 @@ discard block | ||
| 114 | 114 | // Compress Document | 
| 115 | 115 | self::zipInvoice($Document); | 
| 116 | 116 | } | 
| 117 | -    private static function singInvoice(SunatDocument $Document){ | |
| 117 | +    private static function singInvoice(SunatDocument $Document) { | |
| 118 | 118 | $xmlFile = $Document->getFileName(); | 
| 119 | 119 | XmlDSig::sign($xmlFile); | 
| 120 | 120 | } | 
| 121 | -    private static function zipInvoice(SunatDocument $Document){ | |
| 121 | +    private static function zipInvoice(SunatDocument $Document) { | |
| 122 | 122 | $xmlFile = $Document->getFileName(); | 
| 123 | 123 | FileService::doZip($xmlFile); | 
| 124 | 124 | } | 
| 125 | 125 |      private static function addLegalMonetaryTotal(SunatDocument $Invoice) { | 
| 126 | 126 | |
| 127 | 127 | $DOM = $Invoice->getDetailMatrix(); | 
| 128 | - $currencyID = $Invoice->getDocumentCurrencyCode(); // Tipo de moneda | |
| 129 | - $itemsAllowance = $DOM->getTotalAllowances(); // Total descuentos por item | |
| 130 | - $taxableOperations = $DOM->getTotalTaxableOperations(); // Total operaciones gravadas | |
| 131 | - $exemptedOperations = $DOM->getTotalExcemptedOperations(); // Total operaciones exoneradas | |
| 128 | + $currencyID = $Invoice->getDocumentCurrencyCode(); // Tipo de moneda | |
| 129 | + $itemsAllowance = $DOM->getTotalAllowances(); // Total descuentos por item | |
| 130 | + $taxableOperations = $DOM->getTotalTaxableOperations(); // Total operaciones gravadas | |
| 131 | + $exemptedOperations = $DOM->getTotalExcemptedOperations(); // Total operaciones exoneradas | |
| 132 | 132 | |
| 133 | 133 | // Total descuentos globales | 
| 134 | 134 | $gloabalAllowance = 0; | 
| @@ -177,8 +177,8 @@ discard block | ||
| 177 | 177 | } | 
| 178 | 178 | |
| 179 | 179 |      private static function addInvoiceLines(SunatDocument $Invoice, $items) { | 
| 180 | - $currencyID = $Invoice->getDocumentCurrencyCode(); // Tipo de moneda | |
| 181 | - $DetailMatrix = new DetailMatrix(); // Matriz de calculos | |
| 180 | + $currencyID = $Invoice->getDocumentCurrencyCode(); // Tipo de moneda | |
| 181 | + $DetailMatrix = new DetailMatrix(); // Matriz de calculos | |
| 182 | 182 | $DetailMatrix->populate($items, $currencyID); | 
| 183 | 183 | $Invoice->setDetailMatrix($DetailMatrix); | 
| 184 | 184 | $ln = count($items); | 
| @@ -326,9 +326,9 @@ discard block | ||
| 326 | 326 | |
| 327 | 327 |      private static function addTaxes(SunatDocument $Invoice) { | 
| 328 | 328 | $DOM = $Invoice->getDetailMatrix(); | 
| 329 | - $currencyID = $Invoice->getDocumentCurrencyCode(); // Tipo de moneda | |
| 330 | - $taxableOperations = $DOM->getTotalTaxableOperations(); // Total operaciones gravadas | |
| 331 | - $exemptedOperations = $DOM->getTotalExcemptedOperations(); // Total operaciones exoneradas | |
| 329 | + $currencyID = $Invoice->getDocumentCurrencyCode(); // Tipo de moneda | |
| 330 | + $taxableOperations = $DOM->getTotalTaxableOperations(); // Total operaciones gravadas | |
| 331 | + $exemptedOperations = $DOM->getTotalExcemptedOperations(); // Total operaciones exoneradas | |
| 332 | 332 | $unaffectedOperations = $DOM->getTotalUnaffectedOperations(); // Total operaciones inafectas | 
| 333 | 333 | |
| 334 | 334 | // XML nodes | 
| @@ -338,11 +338,11 @@ discard block | ||
| 338 | 338 | // Operaciones gravadas - aplicando cargos y descuetos | 
| 339 | 339 | $igvBaseAmount = self::applyAllowancesAndCharges($Invoice, $taxableOperations); | 
| 340 | 340 | $taxAmount = $igvBaseAmount * SunatVars::IGV; | 
| 341 | - self::addTaxSubtotal($TaxTotal, $currencyID, $taxAmount, $igvBaseAmount, DetailMatrix::TAX_IGV); | |
| 341 | + self::addTaxSubtotal($TaxTotal, $currencyID, $taxAmount, $igvBaseAmount, DetailMatrix::TAX_IGV); | |
| 342 | 342 | |
| 343 | 343 | // Total operaciones exoneradas - aplicando cargos y descuetos | 
| 344 | 344 | $exoBaseAmount = self::applyAllowancesAndCharges($Invoice, $exemptedOperations); | 
| 345 | - self::addTaxSubtotal($TaxTotal, $currencyID, 0, $exoBaseAmount, DetailMatrix::TAX_EXO); | |
| 345 | + self::addTaxSubtotal($TaxTotal, $currencyID, 0, $exoBaseAmount, DetailMatrix::TAX_EXO); | |
| 346 | 346 | |
| 347 | 347 | // Total operaciones inafectas | 
| 348 | 348 | self::addTaxSubtotal($TaxTotal, $currencyID, 0, $unaffectedOperations, DetailMatrix::TAX_INA); | 
| @@ -11,8 +11,7 @@ | ||
| 11 | 11 |      public static function sendBill($zipName) {
 | 
| 12 | 12 | // $invoiceName = substr($zipName, 0, -3) . 'xml'; | 
| 13 | 13 | $service_url = F72X::isProductionMode() ? | 
| 14 | - SunatVars::SUNAT_SERVICE_URL_PROD : | |
| 15 | - SunatVars::SUNAT_SERVICE_URL_BETA; | |
| 14 | + SunatVars::SUNAT_SERVICE_URL_PROD : SunatVars::SUNAT_SERVICE_URL_BETA; | |
| 16 | 15 | |
| 17 | 16 | $fileDir = Company::getRepositoryPath(); | 
| 18 | 17 |          $contentFile = file_get_contents("$fileDir/zip/$zipName");
 |