@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | 'igvPercent' => SunatVars::IGV_PERCENT, |
84 | 84 | 'logo' => LogoMgr::getLogoString(), |
85 | 85 | 'qr' => QrGenerator::getQrString($dataMap), // QR Code |
86 | - 'taxableOperations' => Operations::formatAmount($dataMap->getTotalTaxableOperations()), // Total operaciones gravadas |
|
87 | - 'freeOperations' => Operations::formatAmount($dataMap->getTotalFreeOperations()), // Total operaciones gratuitas |
|
86 | + 'taxableOperations' => Operations::formatAmount($dataMap->getTotalTaxableOperations()), // Total operaciones gravadas |
|
87 | + 'freeOperations' => Operations::formatAmount($dataMap->getTotalFreeOperations()), // Total operaciones gratuitas |
|
88 | 88 | 'unaffectedOperations' => Operations::formatAmount($dataMap->getTotalUnaffectedOperations()), // Total operaciones inafectas |
89 | - 'exemptedOperations' => Operations::formatAmount($dataMap->getTotalExemptedOperations()), // Total operaciones exoneradas |
|
90 | - 'totalAllowances' => Operations::formatAmount($dataMap->getTotalAllowances()), // Total operaciones exoneradas |
|
91 | - 'igvAmount' => Operations::formatAmount($dataMap->getIGV()), // Total a pagar |
|
92 | - 'payableAmount' => Operations::formatAmount($payableAmount), // Total a pagar |
|
93 | - 'payableInWords' => $payableInWords, // Monto en palabras |
|
89 | + 'exemptedOperations' => Operations::formatAmount($dataMap->getTotalExemptedOperations()), // Total operaciones exoneradas |
|
90 | + 'totalAllowances' => Operations::formatAmount($dataMap->getTotalAllowances()), // Total operaciones exoneradas |
|
91 | + 'igvAmount' => Operations::formatAmount($dataMap->getIGV()), // Total a pagar |
|
92 | + 'payableAmount' => Operations::formatAmount($payableAmount), // Total a pagar |
|
93 | + 'payableInWords' => $payableInWords, // Monto en palabras |
|
94 | 94 | 'items' => self::getReadyToPrintDataItems($dataMap) // Items |
95 | 95 | ]; |
96 | 96 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $ln = $Items->getCount(); |
101 | 101 | $items2 = []; |
102 | 102 | for ($i = 0; $i < $ln; $i++) { |
103 | - $items2[]= [ |
|
103 | + $items2[] = [ |
|
104 | 104 | 'productCode' => $Items->getProductCode($i), |
105 | 105 | 'quantity' => $Items->getQunatity($i), |
106 | 106 | 'unitName' => Catalogo::getUnitName($Items->getUnitCode($i)), |
@@ -58,8 +58,8 @@ |
||
58 | 58 | private function addRequestedMonetaryTotal() { |
59 | 59 | $dataMap = $this->dataMap; |
60 | 60 | $currencyID = $this->getDocumentCurrencyCode(); // Tipo de moneda |
61 | - $totalAllowances = $dataMap->getTotalAllowances(); // Total descuentos |
|
62 | - $payableAmount = $dataMap->getPayableAmount(); // Total a pagar |
|
61 | + $totalAllowances = $dataMap->getTotalAllowances(); // Total descuentos |
|
62 | + $payableAmount = $dataMap->getPayableAmount(); // Total a pagar |
|
63 | 63 | $billableAmount = $dataMap->getBillableValue(); |
64 | 64 | // RequestedMonetaryTotal |
65 | 65 | $RequestedMonetaryTotal = new RequestedMonetaryTotal(); |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | 'igvPercent' => SunatVars::IGV_PERCENT, |
121 | 121 | 'logo' => LogoMgr::getLogoString(), |
122 | 122 | 'qr' => QrGenerator::getQrString($dataMap), // QR Code |
123 | - 'taxableOperations' => Operations::formatAmount($dataMap->getTotalTaxableOperations()), // Total operaciones gravadas |
|
124 | - 'freeOperations' => Operations::formatAmount($dataMap->getTotalFreeOperations()), // Total operaciones gratuitas |
|
123 | + 'taxableOperations' => Operations::formatAmount($dataMap->getTotalTaxableOperations()), // Total operaciones gravadas |
|
124 | + 'freeOperations' => Operations::formatAmount($dataMap->getTotalFreeOperations()), // Total operaciones gratuitas |
|
125 | 125 | 'unaffectedOperations' => Operations::formatAmount($dataMap->getTotalUnaffectedOperations()), // Total operaciones inafectas |
126 | - 'exemptedOperations' => Operations::formatAmount($dataMap->getTotalExemptedOperations()), // Total operaciones exoneradas |
|
127 | - 'totalAllowances' => Operations::formatAmount($dataMap->getTotalAllowances()), // Total operaciones exoneradas |
|
128 | - 'igvAmount' => Operations::formatAmount($dataMap->getIGV()), // Total a pagar |
|
129 | - 'payableAmount' => Operations::formatAmount($payableAmount), // Total a pagar |
|
130 | - 'payableInWords' => $payableInWords, // Monto en palabras |
|
131 | - 'items' => self::getReadyToPrintDataItems($dataMap), // Items |
|
126 | + 'exemptedOperations' => Operations::formatAmount($dataMap->getTotalExemptedOperations()), // Total operaciones exoneradas |
|
127 | + 'totalAllowances' => Operations::formatAmount($dataMap->getTotalAllowances()), // Total operaciones exoneradas |
|
128 | + 'igvAmount' => Operations::formatAmount($dataMap->getIGV()), // Total a pagar |
|
129 | + 'payableAmount' => Operations::formatAmount($payableAmount), // Total a pagar |
|
130 | + 'payableInWords' => $payableInWords, // Monto en palabras |
|
131 | + 'items' => self::getReadyToPrintDataItems($dataMap), // Items |
|
132 | 132 | 'noteType' => $dataMap->getNoteType(), |
133 | 133 | 'affectedDocumentId' => $dataMap->getNoteAffectedDocId(), |
134 | 134 | 'affectedDocumentOficialName' => Catalogo::getOfficialDocumentName($dataMap->getNoteAffectedDocType()), |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $ln = $Items->getCount(); |
142 | 142 | $items2 = []; |
143 | 143 | for ($i = 0; $i < $ln; $i++) { |
144 | - $items2[]= [ |
|
144 | + $items2[] = [ |
|
145 | 145 | 'productCode' => $Items->getProductCode($i), |
146 | 146 | 'quantity' => $Items->getQunatity($i), |
147 | 147 | 'unitName' => Catalogo::getUnitName($Items->getUnitCode($i)), |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | protected function parseInput(array $in) { |
38 | 38 | $out = $in; |
39 | - $lines = $this->parseInputLines($in['lines']); |
|
39 | + $lines = $this->parseInputLines($in['lines']); |
|
40 | 40 | $out['percent'] = Catalogo::getCatItemFieldValue($this->regimeCatNumber, $in['systemCode'], 'tasa'); |
41 | 41 | $out['lines'] = $lines; |
42 | 42 | // Calculate totals |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | // Set amount and netTotalCashed |
58 | 58 | $exchangeCalculationRate = ($out['currencyCode'] == self::LOCAL_CURRENCY_CODE) ? 1 : $out['exchangeRate']; |
59 | 59 | $paymentBase = $out['payment']['paidAmount'] * $exchangeCalculationRate; |
60 | - $opAmount = ($paymentBase * $percent)/100; |
|
60 | + $opAmount = ($paymentBase * $percent) / 100; |
|
61 | 61 | // Percepcion base + amount |
62 | 62 | // Retencion base - amount |
63 | 63 | $operator = $this->isPercepcion ? 1 : -1; |
@@ -76,43 +76,43 @@ |
||
76 | 76 | $grossUnitValue = $item['unitPrice']; |
77 | 77 | $igvIncluded = $item['igvIncluded']; |
78 | 78 | |
79 | - $unitValue = $this->calcUnitValue($igvAffectCode, $grossUnitValue, $igvIncluded); // Valor unitario |
|
79 | + $unitValue = $this->calcUnitValue($igvAffectCode, $grossUnitValue, $igvIncluded); // Valor unitario |
|
80 | 80 | $unitTaxedValue = $this->calcUnitTaxedValue($igvAffectCode, $grossUnitValue, $igvIncluded); // Valor unitario incluyendo impuestos si son aplicables |
81 | - $unitBillableValue = $this->calcUnitBillableValue($unitValue, $priceType); // Valor unitario facturable |
|
81 | + $unitBillableValue = $this->calcUnitBillableValue($unitValue, $priceType); // Valor unitario facturable |
|
82 | 82 | $quantity = $item['quantity']; // Cantidad |
83 | 83 | |
84 | - $itemValue = $unitValue * $quantity; // Valor de item |
|
84 | + $itemValue = $unitValue * $quantity; // Valor de item |
|
85 | 85 | $itemBillableValue = $unitBillableValue * $quantity; // Valor de item |
86 | 86 | $itemAllowancesAmount = Operations::getTotalAllowances($itemBillableValue, $ac); // Descuentos de item |
87 | - $itemChargesAmount = Operations::getTotalCharges($itemValue, $ac); // Cargos de item |
|
88 | - $itemBillableAmount = $this->calcItemBillableAmount($itemValue, $priceType, $ac); // Valor de venta del ítem = (Valor del item - Descuentos + Cargos), 0 si el valor del item es referencial! |
|
89 | - $itemTaxableAmount = $this->calcItemTaxableAmount($itemValue, $priceType, $ac); // Valor de venta del ítem = (Valor del item - Descuentos + Cargos), 0 si el valor del item es referencial! |
|
87 | + $itemChargesAmount = Operations::getTotalCharges($itemValue, $ac); // Cargos de item |
|
88 | + $itemBillableAmount = $this->calcItemBillableAmount($itemValue, $priceType, $ac); // Valor de venta del ítem = (Valor del item - Descuentos + Cargos), 0 si el valor del item es referencial! |
|
89 | + $itemTaxableAmount = $this->calcItemTaxableAmount($itemValue, $priceType, $ac); // Valor de venta del ítem = (Valor del item - Descuentos + Cargos), 0 si el valor del item es referencial! |
|
90 | 90 | $igvAmount = $this->calcIgvAmount($igvAffectCode, $itemTaxableAmount); // Afectación al IGV por item |
91 | 91 | |
92 | 92 | $itemPayableAmount = $itemBillableValue + $igvAmount; |
93 | 93 | |
94 | - $this->set(self::COL_PRODUCT_CODE, $idx, $item['productCode']); |
|
95 | - $this->set(self::COL_UNPSC, $idx, $item['unspsc']); |
|
96 | - $this->set(self::COL_UNIT_CODE, $idx, $item['unitCode']); |
|
97 | - $this->set(self::COL_QUANTITY, $idx, $quantity); |
|
98 | - $this->set(self::COL_DESCRIPTION, $idx, trim($item['description'])); |
|
99 | - $this->set(self::COL_CURRENCY_CODE, $idx, $currencyCode); |
|
94 | + $this->set(self::COL_PRODUCT_CODE, $idx, $item['productCode']); |
|
95 | + $this->set(self::COL_UNPSC, $idx, $item['unspsc']); |
|
96 | + $this->set(self::COL_UNIT_CODE, $idx, $item['unitCode']); |
|
97 | + $this->set(self::COL_QUANTITY, $idx, $quantity); |
|
98 | + $this->set(self::COL_DESCRIPTION, $idx, trim($item['description'])); |
|
99 | + $this->set(self::COL_CURRENCY_CODE, $idx, $currencyCode); |
|
100 | 100 | // Códigos de catálogos predefinidos |
101 | - $this->set(self::COL_PRICE_TYPE, $idx, $priceType); |
|
102 | - $this->set(self::COL_TAX_TYPE, $idx, $item['taxType']); |
|
103 | - $this->set(self::COL_IGV_AFFECTATION, $idx, $item['igvAffectationType']); |
|
101 | + $this->set(self::COL_PRICE_TYPE, $idx, $priceType); |
|
102 | + $this->set(self::COL_TAX_TYPE, $idx, $item['taxType']); |
|
103 | + $this->set(self::COL_IGV_AFFECTATION, $idx, $item['igvAffectationType']); |
|
104 | 104 | |
105 | - $this->set(self::COL_UNIT_VALUE, $idx, $unitValue); |
|
105 | + $this->set(self::COL_UNIT_VALUE, $idx, $unitValue); |
|
106 | 106 | $this->set(self::COL_UNIT_BILLABLE_VALUE, $idx, $unitBillableValue); |
107 | - $this->set(self::COL_UNIT_TAXED_VALUE, $idx, $unitTaxedValue); |
|
108 | - $this->set(self::COL_ITEM_VALUE, $idx, $itemValue); |
|
107 | + $this->set(self::COL_UNIT_TAXED_VALUE, $idx, $unitTaxedValue); |
|
108 | + $this->set(self::COL_ITEM_VALUE, $idx, $itemValue); |
|
109 | 109 | $this->set(self::COL_ITEM_BILLABLE_VALUE, $idx, $itemBillableValue); |
110 | - $this->set(self::COL_ALLOWANCES_CHARGES, $idx, $ac); |
|
111 | - $this->set(self::COL_ALLOWANCES_AMOUNT, $idx, $itemAllowancesAmount); |
|
112 | - $this->set(self::COL_CHARGES_AMOUNT, $idx, $itemChargesAmount); |
|
113 | - $this->set(self::COL_ITEM_BILLABLE_AMOUNT,$idx, $itemBillableAmount); |
|
110 | + $this->set(self::COL_ALLOWANCES_CHARGES, $idx, $ac); |
|
111 | + $this->set(self::COL_ALLOWANCES_AMOUNT, $idx, $itemAllowancesAmount); |
|
112 | + $this->set(self::COL_CHARGES_AMOUNT, $idx, $itemChargesAmount); |
|
113 | + $this->set(self::COL_ITEM_BILLABLE_AMOUNT, $idx, $itemBillableAmount); |
|
114 | 114 | $this->set(self::COL_ITEM_TAXABLE_AMOUNT, $idx, $itemTaxableAmount); |
115 | - $this->set(self::COL_IGV, $idx, $igvAmount); |
|
115 | + $this->set(self::COL_IGV, $idx, $igvAmount); |
|
116 | 116 | $this->set(self::COL_ITEM_PAYABLE_AMOUNT, $idx, $itemPayableAmount); |
117 | 117 | } |
118 | 118 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | public function __construct(array $data, $type) { |
25 | 25 | $this->data = $data; |
26 | 26 | $this->type = $type; |
27 | - if(is_array($type)){ |
|
27 | + if (is_array($type)) { |
|
28 | 28 | $this->validations = $type; |
29 | 29 | } |
30 | 30 | $this->validate(); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | private function validate() { |
42 | - if(!$this->validations){ |
|
42 | + if (!$this->validations) { |
|
43 | 43 | $this->validations = $this->getValidations(); |
44 | 44 | } |
45 | 45 | foreach ($this->validations as $field => $item) { |
@@ -37,7 +37,7 @@ |
||
37 | 37 | $this->documentNumber = str_pad($rawData['documentNumber'], 5, '0', STR_PAD_LEFT); |
38 | 38 | $this->issueDate = new DateTime($parsedData['issueDate']); |
39 | 39 | $this->referenceDate = new DateTime($parsedData['referenceDate']); |
40 | - $this->documentId = $this->documentType.'-' . $this->issueDate->format('Ymd') . '-' . $this->documentNumber; |
|
40 | + $this->documentId = $this->documentType . '-' . $this->issueDate->format('Ymd') . '-' . $this->documentNumber; |
|
41 | 41 | $this->documentFileName = Company::getRUC() . '-' . $this->documentId; |
42 | 42 | $this->rawData = $rawData; |
43 | 43 | $this->parsedData = $parsedData; |
@@ -88,7 +88,7 @@ |
||
88 | 88 | $this->documentId = $this->documentSeries . '-' . $this->documentNumber; |
89 | 89 | $this->issueDate = new DateTime($data['issueDate']); |
90 | 90 | if (isset($data['dueDate'])) { |
91 | - $this->dueDate = new DateTime($data['dueDate']); |
|
91 | + $this->dueDate = new DateTime($data['dueDate']); |
|
92 | 92 | } |
93 | 93 | $this->customerDocType = $data['customerDocType']; |
94 | 94 | $this->customerDocNumber = $data['customerDocNumber']; |
@@ -116,21 +116,21 @@ discard block |
||
116 | 116 | $name = str_replace('\\', '/', $name); |
117 | 117 | $hexdtime = pack('V', $this->unix2DosTime($time)); |
118 | 118 | $fr = "\x50\x4b\x03\x04"; |
119 | - $fr .= "\x14\x00"; // ver needed to extract |
|
120 | - $fr .= "\x00\x00"; // gen purpose bit flag |
|
121 | - $fr .= "\x08\x00"; // compression method |
|
122 | - $fr .= $hexdtime; // last mod time and date |
|
119 | + $fr .= "\x14\x00"; // ver needed to extract |
|
120 | + $fr .= "\x00\x00"; // gen purpose bit flag |
|
121 | + $fr .= "\x08\x00"; // compression method |
|
122 | + $fr .= $hexdtime; // last mod time and date |
|
123 | 123 | // "local file header" segment |
124 | 124 | $unc_len = strlen($data); |
125 | 125 | $crc = crc32($data); |
126 | 126 | $zdata = gzcompress($data); |
127 | 127 | $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug |
128 | 128 | $c_len = strlen($zdata); |
129 | - $fr .= pack('V', $crc); // crc32 |
|
130 | - $fr .= pack('V', $c_len); // compressed filesize |
|
131 | - $fr .= pack('V', $unc_len); // uncompressed filesize |
|
132 | - $fr .= pack('v', strlen($name)); // length of filename |
|
133 | - $fr .= pack('v', 0); // extra field length |
|
129 | + $fr .= pack('V', $crc); // crc32 |
|
130 | + $fr .= pack('V', $c_len); // compressed filesize |
|
131 | + $fr .= pack('V', $unc_len); // uncompressed filesize |
|
132 | + $fr .= pack('v', strlen($name)); // length of filename |
|
133 | + $fr .= pack('v', 0); // extra field length |
|
134 | 134 | $fr .= $name; |
135 | 135 | // "file data" segment |
136 | 136 | $fr .= $zdata; |
@@ -142,20 +142,20 @@ discard block |
||
142 | 142 | } |
143 | 143 | // now add to central directory record |
144 | 144 | $cdrec = "\x50\x4b\x01\x02"; |
145 | - $cdrec .= "\x00\x00"; // version made by |
|
146 | - $cdrec .= "\x14\x00"; // version needed to extract |
|
147 | - $cdrec .= "\x00\x00"; // gen purpose bit flag |
|
148 | - $cdrec .= "\x08\x00"; // compression method |
|
149 | - $cdrec .= $hexdtime; // last mod time & date |
|
150 | - $cdrec .= pack('V', $crc); // crc32 |
|
151 | - $cdrec .= pack('V', $c_len); // compressed filesize |
|
152 | - $cdrec .= pack('V', $unc_len); // uncompressed filesize |
|
145 | + $cdrec .= "\x00\x00"; // version made by |
|
146 | + $cdrec .= "\x14\x00"; // version needed to extract |
|
147 | + $cdrec .= "\x00\x00"; // gen purpose bit flag |
|
148 | + $cdrec .= "\x08\x00"; // compression method |
|
149 | + $cdrec .= $hexdtime; // last mod time & date |
|
150 | + $cdrec .= pack('V', $crc); // crc32 |
|
151 | + $cdrec .= pack('V', $c_len); // compressed filesize |
|
152 | + $cdrec .= pack('V', $unc_len); // uncompressed filesize |
|
153 | 153 | $cdrec .= pack('v', strlen($name)); // length of filename |
154 | - $cdrec .= pack('v', 0); // extra field length |
|
155 | - $cdrec .= pack('v', 0); // file comment length |
|
156 | - $cdrec .= pack('v', 0); // disk number start |
|
157 | - $cdrec .= pack('v', 0); // internal file attributes |
|
158 | - $cdrec .= pack('V', 32); // external file attributes |
|
154 | + $cdrec .= pack('v', 0); // extra field length |
|
155 | + $cdrec .= pack('v', 0); // file comment length |
|
156 | + $cdrec .= pack('v', 0); // disk number start |
|
157 | + $cdrec .= pack('v', 0); // internal file attributes |
|
158 | + $cdrec .= pack('V', 32); // external file attributes |
|
159 | 159 | // - 'archive' bit set |
160 | 160 | $cdrec .= pack('V', $this->old_offset); // relative offset of local header |
161 | 161 | $this->old_offset += strlen($fr); |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | pack('v', sizeof($this->ctrl_dir)) . //total #of entries overall |
183 | 183 | pack('V', strlen($ctrldir)) . //size of central dir |
184 | 184 | pack('V', $this->old_offset) . //offset to start of central dir |
185 | - "\x00\x00"; //.zip file comment length |
|
185 | + "\x00\x00"; //.zip file comment length |
|
186 | 186 | if ($this->doWrite) { // Send central directory & end ctrl dir to STDOUT |
187 | 187 | echo $header; |
188 | - return ""; // Return empty string |
|
188 | + return ""; // Return empty string |
|
189 | 189 | } else { // Return entire ZIP archive as string |
190 | 190 | $data = implode('', $this->datasec); |
191 | 191 | return $data . $header; |