Conditions | 4 |
Paths | 8 |
Total Lines | 101 |
Code Lines | 81 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
129 | private function addDocumentItem($itemIndex, $lineType) { |
||
130 | $docLineClassName = "\F72X\UblComponent\\$lineType"; |
||
131 | // XML Nodes |
||
132 | $DocumentLine = new $docLineClassName(); |
||
133 | $PricingReference = new PricingReference(); |
||
134 | $TaxTotal = new TaxTotal(); |
||
135 | $TaxSubTotal = new TaxSubTotal(); |
||
136 | $TaxCategory = new TaxCategory(); |
||
137 | $TaxCategory |
||
138 | ->setElementAttributes('ID', [ |
||
139 | 'schemeID' => 'UN/ECE 5305', |
||
140 | 'schemeName' => 'Tax Category Identifier', |
||
141 | 'schemeAgencyName' => 'United Nations Economic Commission for Europe']) |
||
142 | ->setElementAttributes('TaxExemptionReasonCode', [ |
||
143 | 'listAgencyName' => 'PE:SUNAT', |
||
144 | 'listName' => 'SUNAT:Codigo de Tipo de Afectación del IGV', |
||
145 | 'listURI' => 'urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo07']); |
||
146 | |||
147 | $TaxScheme = new TaxScheme(); |
||
148 | $TaxScheme |
||
149 | ->setElementAttributes('ID', [ |
||
150 | 'schemeID' => 'UN/ECE 5153', |
||
151 | 'schemeName' => 'Tax Scheme Identifier', |
||
152 | 'schemeAgencyName' => 'United Nations Economic Commission for Europe']); |
||
153 | |||
154 | $AlternativeConditionPrice = new AlternativeConditionPrice(); |
||
155 | $Item = new Item(); |
||
156 | $SellersItemIdentification = new SellersItemIdentification(); |
||
157 | $CommodityClassification = new CommodityClassification(); |
||
158 | $Price = new Price(); |
||
159 | // Detail Operation Matrix |
||
160 | $Items = $this->dataMap->getItems(); |
||
161 | // Vars |
||
162 | $productCode = $Items->getProductCode($itemIndex); |
||
163 | $sunatProductCode = $Items->getUNPSC($itemIndex); |
||
164 | $unitCode = $Items->getUnitCode($itemIndex); |
||
165 | $quantity = $Items->getQunatity($itemIndex); |
||
166 | $description = $Items->getDescription($itemIndex); |
||
167 | $currencyCode = $Items->getCurrencyCode($itemIndex); |
||
168 | $unitBillableValue = $Items->getUnitBillableValue($itemIndex); |
||
169 | $priceTypeCode = $Items->getPriceTypeCode($itemIndex); |
||
170 | $taxTypeCode = $Items->getTaxTypeCode($itemIndex); |
||
171 | $igvAffectationType = $Items->getIgvAffectationType($itemIndex); |
||
172 | $taxCategoryPercent = $igvAffectationType === '10' ? SunatVars::IGV_PERCENT : '0.00'; |
||
173 | |||
174 | $itemValue = $Items->getItemValue($itemIndex); |
||
175 | $ac = $Items->getAllowancesAndCharges($itemIndex); |
||
176 | $itemTaxableAmount = $Items->getTaxableAmount($itemIndex); |
||
177 | $itemTaxAmount = $Items->getIgv($itemIndex); |
||
178 | $unitPrice = $Items->getUnitTaxedValue($itemIndex); |
||
179 | |||
180 | // Catálogo 5 Ipuesto aplicable |
||
181 | $cat5Item = Catalogo::getCatItem(5, $taxTypeCode); |
||
182 | |||
183 | // Descuentos y cargos |
||
184 | UblHelper::addAllowancesCharges($DocumentLine, $ac, $itemValue, $currencyCode); |
||
185 | |||
186 | // Config Item |
||
187 | $Item->setDescription($description); // Descripción |
||
188 | // Código de producto |
||
189 | if ($productCode) { |
||
190 | $Item->setSellersItemIdentification($SellersItemIdentification->setID($productCode)); |
||
191 | } |
||
192 | // Código de producto SUNAT |
||
193 | if ($sunatProductCode) { |
||
194 | $Item->setCommodityClassification($CommodityClassification->setItemClassificationCode($sunatProductCode)); |
||
195 | } |
||
196 | $DocumentLine |
||
197 | ->setCurrencyID($currencyCode) // Tipo de moneda |
||
198 | ->setID($itemIndex + 1) // Número de orden |
||
199 | ->setUnitCode($unitCode) // Codigo de unidad de medida |
||
200 | ->setLineExtensionAmount($itemTaxableAmount) // Valor de venta del ítem, sin impuestos |
||
201 | ->setPricingReference($PricingReference |
||
202 | ->setAlternativeConditionPrice($AlternativeConditionPrice |
||
203 | ->setCurrencyID($currencyCode) // Tipo de moneda |
||
204 | ->setPriceAmount($unitPrice) // Precio de venta unitario |
||
205 | ->setPriceTypeCode($priceTypeCode))) // Price |
||
206 | ->setTaxTotal($TaxTotal |
||
207 | ->setCurrencyID($currencyCode) |
||
208 | ->setTaxAmount($itemTaxAmount) |
||
209 | ->addTaxSubTotal($TaxSubTotal |
||
210 | ->setCurrencyID($currencyCode) // Tipo de moneda |
||
211 | ->setTaxableAmount($itemTaxableAmount) // Valor de venta del item sin impuestos |
||
212 | ->setTaxAmount($itemTaxAmount) // IGV |
||
213 | ->setTaxCategory($TaxCategory |
||
214 | ->setID($cat5Item['categoria']) // Codigo de categoria de immpuestos @CAT5 |
||
215 | ->setPercent($taxCategoryPercent) // Porcentaje de IGV (18.00) |
||
216 | ->setTaxExemptionReasonCode($igvAffectationType) // Código de afectación del IGV |
||
217 | ->setTaxScheme($TaxScheme |
||
218 | ->setID($taxTypeCode) // Codigo de categoria de impuesto |
||
219 | ->setName($cat5Item['name']) |
||
220 | ->setTaxTypeCode($cat5Item['UN_ECE_5153']))))) |
||
221 | ->setItem($Item) |
||
222 | ->setPrice($Price |
||
223 | ->setCurrencyID($currencyCode) // Tipo de moneda |
||
224 | ->setPriceAmount($unitBillableValue) // Precio unitario del item |
||
225 | ); |
||
226 | // Set Quantity |
||
227 | $this->setDocumentLineQuantity($DocumentLine, $lineType, $quantity); |
||
228 | // Añade item |
||
229 | $this->addDocumentLine($DocumentLine, $lineType); |
||
230 | } |
||
365 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.