@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | 'igvPercent' => SunatVars::IGV_PERCENT, |
| 105 | 105 | 'logo' => LogoMgr::getLogoString(), |
| 106 | 106 | 'qr' => QrGenerator::getQrString($inv), // QR Code |
| 107 | - 'taxableOperations' => $inv->getTotalTaxableOperations(), // Total operaciones gravadas |
|
| 108 | - 'freeOperations' => $inv->getTotalFreeOperations(), // Total operaciones gratuitas |
|
| 107 | + 'taxableOperations' => $inv->getTotalTaxableOperations(), // Total operaciones gravadas |
|
| 108 | + 'freeOperations' => $inv->getTotalFreeOperations(), // Total operaciones gratuitas |
|
| 109 | 109 | 'unaffectedOperations' => $inv->getTotalUnaffectedOperations(), // Total operaciones inafectas |
| 110 | - 'exemptedOperations' => $inv->getTotalExemptedOperations(), // Total operaciones exoneradas |
|
| 111 | - 'totalAllowances' => $inv->getTotalAllowances(), // Total operaciones exoneradas |
|
| 112 | - 'igvAmount' => $inv->getIGV(), // Total a pagar |
|
| 113 | - 'payableAmount' => $payableAmount, // Total a pagar |
|
| 114 | - 'payableInWords' => $payableInWords, // Monto en palabras |
|
| 110 | + 'exemptedOperations' => $inv->getTotalExemptedOperations(), // Total operaciones exoneradas |
|
| 111 | + 'totalAllowances' => $inv->getTotalAllowances(), // Total operaciones exoneradas |
|
| 112 | + 'igvAmount' => $inv->getIGV(), // Total a pagar |
|
| 113 | + 'payableAmount' => $payableAmount, // Total a pagar |
|
| 114 | + 'payableInWords' => $payableInWords, // Monto en palabras |
|
| 115 | 115 | 'items' => self::getDocumentDataItems($inv) // Items |
| 116 | 116 | ]; |
| 117 | 117 | // For credit and debit notes |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $ln = $Items->getCount(); |
| 135 | 135 | $items2 = []; |
| 136 | 136 | for ($i = 0; $i < $ln; $i++) { |
| 137 | - $items2[]= [ |
|
| 137 | + $items2[] = [ |
|
| 138 | 138 | 'productCode' => $Items->getProductCode($i), |
| 139 | 139 | 'quantity' => $Items->getQunatity($i), |
| 140 | 140 | 'unitName' => Catalogo::getUnitName($Items->getUnitCode($i)), |
@@ -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(); |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | private function addDocumentTaxes() |
| 117 | 117 | { |
| 118 | 118 | $Invoice = $this->dataMap; |
| 119 | - $currencyID = $Invoice->getCurrencyCode(); // Tipo de moneda |
|
| 120 | - $totalTaxableOperations = $Invoice->getTotalTaxableOperations(); // Total operaciones gravadas |
|
| 121 | - $totalTaxes = $Invoice->getTotalTaxes(); // Total operaciones gravadas |
|
| 122 | - $Igv = $Invoice->getIGV(); // Total IGV |
|
| 123 | - $totalExemptedOperations = $Invoice->getTotalExemptedOperations(); // Total operaciones exoneradas |
|
| 119 | + $currencyID = $Invoice->getCurrencyCode(); // Tipo de moneda |
|
| 120 | + $totalTaxableOperations = $Invoice->getTotalTaxableOperations(); // Total operaciones gravadas |
|
| 121 | + $totalTaxes = $Invoice->getTotalTaxes(); // Total operaciones gravadas |
|
| 122 | + $Igv = $Invoice->getIGV(); // Total IGV |
|
| 123 | + $totalExemptedOperations = $Invoice->getTotalExemptedOperations(); // Total operaciones exoneradas |
|
| 124 | 124 | $totalUnaffectedOperations = $Invoice->getTotalUnaffectedOperations(); // Total operaciones inafectas |
| 125 | - $totalFreeOpertions = $Invoice->getTotalFreeOperations(); // Total operaciones gratuitas |
|
| 125 | + $totalFreeOpertions = $Invoice->getTotalFreeOperations(); // Total operaciones gratuitas |
|
| 126 | 126 | |
| 127 | 127 | // XML nodes |
| 128 | 128 | $TaxTotal = new TaxTotal(); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | // Total operaciones exoneradas |
| 135 | 135 | if ($totalExemptedOperations) { |
| 136 | - UblHelper::addTaxSubtotal($TaxTotal, $currencyID, 0, $totalExemptedOperations, Catalogo::CAT5_EXO); |
|
| 136 | + UblHelper::addTaxSubtotal($TaxTotal, $currencyID, 0, $totalExemptedOperations, Catalogo::CAT5_EXO); |
|
| 137 | 137 | } |
| 138 | 138 | // Total operaciones inafectas |
| 139 | 139 | if ($totalUnaffectedOperations) { |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | // Total operaciones gratuitas |
| 143 | 143 | if ($totalFreeOpertions) { |
| 144 | - UblHelper::addTaxSubtotal($TaxTotal, $currencyID, 0, $totalFreeOpertions, Catalogo::CAT5_GRA); |
|
| 144 | + UblHelper::addTaxSubtotal($TaxTotal, $currencyID, 0, $totalFreeOpertions, Catalogo::CAT5_GRA); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // Total impuestos |
@@ -311,8 +311,8 @@ discard block |
||
| 311 | 311 | { |
| 312 | 312 | $Invoice = $this->dataMap; |
| 313 | 313 | $currencyID = $this->getDocumentCurrencyCode(); // Tipo de moneda |
| 314 | - $totalAllowances = $Invoice->getTotalAllowances(); // Total descuentos |
|
| 315 | - $payableAmount = $Invoice->getPayableAmount(); // Total a pagar |
|
| 314 | + $totalAllowances = $Invoice->getTotalAllowances(); // Total descuentos |
|
| 315 | + $payableAmount = $Invoice->getPayableAmount(); // Total a pagar |
|
| 316 | 316 | $billableAmount = $Invoice->getBillableValue(); |
| 317 | 317 | // LegalMonetaryTotal |
| 318 | 318 | $LegalMonetaryTotal = new LegalMonetaryTotal(); |
@@ -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; |