@@ -115,7 +115,7 @@ |
||
115 | 115 | for ($rowIndex = 0; $rowIndex < $ln; $rowIndex++) { |
116 | 116 | $detContent .= implode('|', $json['detalle'][$rowIndex]) . $ENTER; |
117 | 117 | } |
118 | - $invoiceId = $Invoice->getInvoiceId(); |
|
118 | + $invoiceId = $Invoice->getInvoiceId(); |
|
119 | 119 | $documentType = $Invoice->getDocumentType(); |
120 | 120 | self::writeFSFile("$companyRUC-$documentType-$invoiceId.CAB", $cabContent); |
121 | 121 | self::writeFSFile("$companyRUC-$documentType-$invoiceId.DET", $detContent); |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | 'issueDate' => $inv->getIssueDate()->format('d-m-Y'), |
58 | 58 | 'igvPercent' => SunatVars::IGV_PERCENT, |
59 | 59 | 'qr' => self::getQrString($inv), // QR Code |
60 | - 'taxableOperations' => $inv->getTotalTaxableOperations(), // Total operaciones gravadas |
|
61 | - 'freeOperations' => $inv->getTotalFreeOperations(), // Total operaciones gratuitas |
|
60 | + 'taxableOperations' => $inv->getTotalTaxableOperations(), // Total operaciones gravadas |
|
61 | + 'freeOperations' => $inv->getTotalFreeOperations(), // Total operaciones gratuitas |
|
62 | 62 | 'unaffectedOperations' => $inv->getTotalUnaffectedOperations(), // Total operaciones inafectas |
63 | - 'exemptedOperations' => $inv->getTotalExemptedOperations(), // Total operaciones exoneradas |
|
64 | - 'totalAllowances' => $inv->getTotalAllowances(), // Total operaciones exoneradas |
|
65 | - 'igvAmount' => $inv->getIGV(), // Total a pagar |
|
66 | - 'payableAmount' => $payableAmount, // Total a pagar |
|
67 | - 'payableInWords' => $payableInWords, // Monto en palabras |
|
63 | + 'exemptedOperations' => $inv->getTotalExemptedOperations(), // Total operaciones exoneradas |
|
64 | + 'totalAllowances' => $inv->getTotalAllowances(), // Total operaciones exoneradas |
|
65 | + 'igvAmount' => $inv->getIGV(), // Total a pagar |
|
66 | + 'payableAmount' => $payableAmount, // Total a pagar |
|
67 | + 'payableInWords' => $payableInWords, // Monto en palabras |
|
68 | 68 | 'items' => self::getInvoiceDataItems($inv) // Items |
69 | 69 | |
70 | 70 | ]; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $ln = $Items->getCount(); |
76 | 76 | $items2 = []; |
77 | 77 | for ($i = 0; $i < $ln; $i++) { |
78 | - $items2[]= [ |
|
78 | + $items2[] = [ |
|
79 | 79 | 'productCode' => $Items->getProductCode($i), |
80 | 80 | 'quantity' => $Items->getQunatity($i), |
81 | 81 | 'unitName' => Catalogo::getUnitName($Items->getUnitCode($i)), |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | private static function getQrContent(DataMap $inv) { |
102 | 102 | $ruc = Company::getRUC(); |
103 | 103 | $invoiveType = $inv->getDocumentType(); |
104 | - $documentSeries = $inv->getDocumentSeries(); |
|
104 | + $documentSeries = $inv->getDocumentSeries(); |
|
105 | 105 | $seriesNumber = $inv->getDocumentNumber(); |
106 | 106 | $igv = Operations::formatAmount($inv->getIGV()); |
107 | 107 | $payableAmount = Operations::formatAmount($inv->getPayableAmount()); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public static function getDocumentType($shortCode) { |
85 | 85 | switch ($shortCode) { |
86 | - case self::DOCTYPE_SC_FACTURA: return self::DOCTYPE_FACTURA ; |
|
86 | + case self::DOCTYPE_SC_FACTURA: return self::DOCTYPE_FACTURA; |
|
87 | 87 | case self::DOCTYPE_SC_BOLETA: return self::DOCTYPE_BOLETA; |
88 | 88 | case self::DOCTYPE_SC_NOTA_CREDITO: return self::DOCTYPE_NOTA_CREDITO; |
89 | 89 | case self::DOCTYPE_SC_NOTA_DEBITO: return self::DOCTYPE_NOTA_DEBITO; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | public static function getCurrencyPlural($currencyCode) { |
143 | 143 | $currencies = self::getCustomList('currencies'); |
144 | - if(isset($currencies[$currencyCode])){ |
|
144 | + if (isset($currencies[$currencyCode])) { |
|
145 | 145 | return $currencies[$currencyCode]; |
146 | 146 | } |
147 | 147 | throw new ConfigException("El código de moneda $currencyCode aún no ha sido configurado para su uso."); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | public static function getCustomListItem($listName, $itemId) { |
155 | 155 | $customList = self::getCustomList($listName); |
156 | - if(isset($customList[$itemId])){ |
|
156 | + if (isset($customList[$itemId])) { |
|
157 | 157 | return $customList[$itemId]; |
158 | 158 | } |
159 | 159 | throw new ConfigException("El codigó de item $itemId no existe en la lista $listName"); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | $path = Company::getListsPath(); |
167 | 167 | $fileName = "$path/$listName.php"; |
168 | - if(file_exists($fileName)){ |
|
168 | + if (file_exists($fileName)) { |
|
169 | 169 | $path = Company::getListsPath(); |
170 | 170 | $list = require $fileName; |
171 | 171 | // Cache |
@@ -86,7 +86,7 @@ |
||
86 | 86 | if (in_array($type, [Catalogo::DOCTYPE_FACTURA, Catalogo::DOCTYPE_BOLETA])) { |
87 | 87 | $this->operationType = $data['operationType']; |
88 | 88 | $this->purchaseOrder = $data['purchaseOrder']; |
89 | - }else{ |
|
89 | + } else { |
|
90 | 90 | |
91 | 91 | $this->noteType = $data['type']; |
92 | 92 | $this->noteDescription = $data['description']; |
@@ -86,7 +86,7 @@ |
||
86 | 86 | if (in_array($type, [Catalogo::DOCTYPE_FACTURA, Catalogo::DOCTYPE_BOLETA])) { |
87 | 87 | $this->operationType = $data['operationType']; |
88 | 88 | $this->purchaseOrder = $data['purchaseOrder']; |
89 | - }else{ |
|
89 | + } else{ |
|
90 | 90 | |
91 | 91 | $this->noteType = $data['type']; |
92 | 92 | $this->noteDescription = $data['description']; |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | |
83 | 83 | private function addDocumentTaxes() { |
84 | 84 | $Invoice = $this->dataMap; |
85 | - $currencyID = $Invoice->getCurrencyCode(); // Tipo de moneda |
|
86 | - $totalTaxableOperations = $Invoice->getTotalTaxableOperations(); // Total operaciones gravadas |
|
87 | - $totalTaxes = $Invoice->getTotalTaxes(); // Total operaciones gravadas |
|
88 | - $Igv = $Invoice->getIGV(); // Total IGV |
|
89 | - $totalExemptedOperations = $Invoice->getTotalExemptedOperations(); // Total operaciones exoneradas |
|
85 | + $currencyID = $Invoice->getCurrencyCode(); // Tipo de moneda |
|
86 | + $totalTaxableOperations = $Invoice->getTotalTaxableOperations(); // Total operaciones gravadas |
|
87 | + $totalTaxes = $Invoice->getTotalTaxes(); // Total operaciones gravadas |
|
88 | + $Igv = $Invoice->getIGV(); // Total IGV |
|
89 | + $totalExemptedOperations = $Invoice->getTotalExemptedOperations(); // Total operaciones exoneradas |
|
90 | 90 | $totalUnaffectedOperations = $Invoice->getTotalUnaffectedOperations(); // Total operaciones inafectas |
91 | - $totalFreeOpertions = $Invoice->getTotalFreeOperations(); // Total operaciones gratuitas |
|
91 | + $totalFreeOpertions = $Invoice->getTotalFreeOperations(); // Total operaciones gratuitas |
|
92 | 92 | |
93 | 93 | // XML nodes |
94 | 94 | $TaxTotal = new TaxTotal(); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | // Total operaciones exoneradas |
101 | 101 | if ($totalExemptedOperations) { |
102 | - UblHelper::addTaxSubtotal($TaxTotal, $currencyID, 0, $totalExemptedOperations, Catalogo::CAT5_EXO); |
|
102 | + UblHelper::addTaxSubtotal($TaxTotal, $currencyID, 0, $totalExemptedOperations, Catalogo::CAT5_EXO); |
|
103 | 103 | } |
104 | 104 | // Total operaciones inafectas |
105 | 105 | if ($totalUnaffectedOperations) { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | // Total operaciones gratuitas solo aplica a FACTURA |
109 | 109 | if ($totalFreeOpertions && $Invoice->getDocumentType() === Catalogo::DOCTYPE_FACTURA) { |
110 | - UblHelper::addTaxSubtotal($TaxTotal, $currencyID, 0, $totalFreeOpertions, Catalogo::CAT5_GRA); |
|
110 | + UblHelper::addTaxSubtotal($TaxTotal, $currencyID, 0, $totalFreeOpertions, Catalogo::CAT5_GRA); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | // Total impuestos |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | private function addInvoiceLegalMonetaryTotal() { |
269 | 269 | $Invoice = $this->dataMap; |
270 | 270 | $currencyID = $this->getDocumentCurrencyCode(); // Tipo de moneda |
271 | - $totalAllowances = $Invoice->getTotalAllowances(); // Total descuentos |
|
272 | - $payableAmount = $Invoice->getPayableAmount(); // Total a pagar |
|
271 | + $totalAllowances = $Invoice->getTotalAllowances(); // Total descuentos |
|
272 | + $payableAmount = $Invoice->getPayableAmount(); // Total a pagar |
|
273 | 273 | $billableAmount = $Invoice->getBillableValue(); |
274 | 274 | // LegalMonetaryTotal |
275 | 275 | $LegalMonetaryTotal = new LegalMonetaryTotal(); |
@@ -57,8 +57,8 @@ |
||
57 | 57 | private function addRequestedMonetaryTotal() { |
58 | 58 | $dataMap = $this->dataMap; |
59 | 59 | $currencyID = $this->getDocumentCurrencyCode(); // Tipo de moneda |
60 | - $totalAllowances = $dataMap->getTotalAllowances(); // Total descuentos |
|
61 | - $payableAmount = $dataMap->getPayableAmount(); // Total a pagar |
|
60 | + $totalAllowances = $dataMap->getTotalAllowances(); // Total descuentos |
|
61 | + $payableAmount = $dataMap->getPayableAmount(); // Total a pagar |
|
62 | 62 | $billableAmount = $dataMap->getBillableValue(); |
63 | 63 | // RequestedMonetaryTotal |
64 | 64 | $RequestedMonetaryTotal = new RequestedMonetaryTotal(); |
@@ -73,41 +73,41 @@ |
||
73 | 73 | $grossUnitValue = $item['unitPrice']; |
74 | 74 | $igvIncluded = $item['igvIncluded']; |
75 | 75 | |
76 | - $unitValue = $this->calcUnitValue($igvAffectCode, $grossUnitValue, $igvIncluded); // Valor unitario |
|
76 | + $unitValue = $this->calcUnitValue($igvAffectCode, $grossUnitValue, $igvIncluded); // Valor unitario |
|
77 | 77 | $unitTaxedValue = $this->calcUnitTaxedValue($igvAffectCode, $grossUnitValue, $igvIncluded); // Valor unitario incluyendo impuestos si son aplicables |
78 | - $unitBillableValue = $this->calcUnitBillableValue($unitValue, $priceType); // Valor unitario facturable |
|
78 | + $unitBillableValue = $this->calcUnitBillableValue($unitValue, $priceType); // Valor unitario facturable |
|
79 | 79 | $quantity = $item['quantity']; // Cantidad |
80 | 80 | |
81 | - $itemValue = $unitValue * $quantity; // Valor de item |
|
81 | + $itemValue = $unitValue * $quantity; // Valor de item |
|
82 | 82 | $itemBillableValue = $unitBillableValue * $quantity; // Valor de item |
83 | 83 | $itemAllowancesAmount = Operations::getTotalAllowances($itemBillableValue, $ac); // Descuentos de item |
84 | - $itemChargesAmount = Operations::getTotalCharges($itemValue, $ac); // Cargos de item |
|
85 | - $itemTaxableAmount = $this->calcItemTaxableAmount($itemValue, $priceType, $ac); // Valor de venta del ítem = (Valor del item - Descuentos + Cargos), 0 si el valor del item es referencial! |
|
84 | + $itemChargesAmount = Operations::getTotalCharges($itemValue, $ac); // Cargos de item |
|
85 | + $itemTaxableAmount = $this->calcItemTaxableAmount($itemValue, $priceType, $ac); // Valor de venta del ítem = (Valor del item - Descuentos + Cargos), 0 si el valor del item es referencial! |
|
86 | 86 | $igvAmount = $this->calcIgvAmount($igvAffectCode, $itemTaxableAmount); // Afectación al IGV por item |
87 | 87 | |
88 | 88 | $itemPayableAmount = $itemBillableValue + $igvAmount; |
89 | 89 | |
90 | - $this->set(self::COL_PRODUCT_CODE, $idx, $item['productCode']); |
|
91 | - $this->set(self::COL_UNPSC, $idx, $item['unspsc']); |
|
92 | - $this->set(self::COL_UNIT_CODE, $idx, $item['unitCode']); |
|
93 | - $this->set(self::COL_QUANTITY, $idx, $quantity); |
|
94 | - $this->set(self::COL_DESCRIPTION, $idx, $item['description']); |
|
95 | - $this->set(self::COL_CURRENCY_CODE, $idx, $currencyCode); |
|
90 | + $this->set(self::COL_PRODUCT_CODE, $idx, $item['productCode']); |
|
91 | + $this->set(self::COL_UNPSC, $idx, $item['unspsc']); |
|
92 | + $this->set(self::COL_UNIT_CODE, $idx, $item['unitCode']); |
|
93 | + $this->set(self::COL_QUANTITY, $idx, $quantity); |
|
94 | + $this->set(self::COL_DESCRIPTION, $idx, $item['description']); |
|
95 | + $this->set(self::COL_CURRENCY_CODE, $idx, $currencyCode); |
|
96 | 96 | // Códigos de catálogos predefinidos |
97 | - $this->set(self::COL_PRICE_TYPE, $idx, $priceType); |
|
98 | - $this->set(self::COL_TAX_TYPE, $idx, $item['taxType']); |
|
99 | - $this->set(self::COL_IGV_AFFECTATION, $idx, $item['igvAffectationType']); |
|
97 | + $this->set(self::COL_PRICE_TYPE, $idx, $priceType); |
|
98 | + $this->set(self::COL_TAX_TYPE, $idx, $item['taxType']); |
|
99 | + $this->set(self::COL_IGV_AFFECTATION, $idx, $item['igvAffectationType']); |
|
100 | 100 | |
101 | - $this->set(self::COL_UNIT_VALUE, $idx, $unitValue); |
|
101 | + $this->set(self::COL_UNIT_VALUE, $idx, $unitValue); |
|
102 | 102 | $this->set(self::COL_UNIT_BILLABLE_VALUE, $idx, $unitBillableValue); |
103 | - $this->set(self::COL_UNIT_TAXED_VALUE, $idx, $unitTaxedValue); |
|
104 | - $this->set(self::COL_ITEM_VALUE, $idx, $itemValue); |
|
103 | + $this->set(self::COL_UNIT_TAXED_VALUE, $idx, $unitTaxedValue); |
|
104 | + $this->set(self::COL_ITEM_VALUE, $idx, $itemValue); |
|
105 | 105 | $this->set(self::COL_ITEM_BILLABLE_VALUE, $idx, $itemBillableValue); |
106 | - $this->set(self::COL_ALLOWANCES_CHARGES, $idx, $ac); |
|
107 | - $this->set(self::COL_ALLOWANCES_AMOUNT, $idx, $itemAllowancesAmount); |
|
108 | - $this->set(self::COL_CHARGES_AMOUNT, $idx, $itemChargesAmount); |
|
106 | + $this->set(self::COL_ALLOWANCES_CHARGES, $idx, $ac); |
|
107 | + $this->set(self::COL_ALLOWANCES_AMOUNT, $idx, $itemAllowancesAmount); |
|
108 | + $this->set(self::COL_CHARGES_AMOUNT, $idx, $itemChargesAmount); |
|
109 | 109 | $this->set(self::COL_ITEM_TAXABLE_AMOUNT, $idx, $itemTaxableAmount); |
110 | - $this->set(self::COL_IGV, $idx, $igvAmount); |
|
110 | + $this->set(self::COL_IGV, $idx, $igvAmount); |
|
111 | 111 | $this->set(self::COL_ITEM_PAYABLE_AMOUNT, $idx, $itemPayableAmount); |
112 | 112 | } |
113 | 113 | } |
@@ -63,9 +63,9 @@ |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | public static function getModuleDir() { |
66 | - return __DIR__.'/..'; |
|
66 | + return __DIR__ . '/..'; |
|
67 | 67 | } |
68 | 68 | public static function getTempDir() { |
69 | - return self::getModuleDir().'/temp'; |
|
69 | + return self::getModuleDir() . '/temp'; |
|
70 | 70 | } |
71 | 71 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @return string |
115 | 115 | */ |
116 | 116 | public static function getListsPath() { |
117 | - return self::get('cconfigPath').'/lists'; |
|
117 | + return self::get('cconfigPath') . '/lists'; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @return string |
123 | 123 | */ |
124 | 124 | public static function getTplsPath() { |
125 | - return self::get('cconfigPath').'/tpls'; |
|
125 | + return self::get('cconfigPath') . '/tpls'; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | } |