Test Failed
Push — master ( d3c8d8...d4fc42 )
by JAIME ELMER
02:02
created

UblHelper::addTaxSubtotal()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 22
nc 1
nop 5
dl 0
loc 27
rs 9.568
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * MÓDULO DE EMISIÓN ELECTRÓNICA F72X
5
 * UBL 2.1
6
 * Version 1.1
7
 * 
8
 * Copyright 2018, Jaime Cruz
9
 */
10
11
namespace F72X\Tools;
12
13
use F72X\Sunat\Catalogo;
14
use F72X\UblComponent\OrderReference;
15
use F72X\UblComponent\Party;
16
use F72X\UblComponent\PartyIdentification;
17
use F72X\UblComponent\PartyName;
18
use F72X\UblComponent\AccountingSupplierParty;
19
use F72X\UblComponent\AccountingCustomerParty;
20
use F72X\UblComponent\PartyLegalEntity;
21
use F72X\UblComponent\TaxTotal;
22
use F72X\UblComponent\TaxSubTotal;
23
use F72X\UblComponent\TaxCategory;
24
use F72X\UblComponent\TaxScheme;
25
use F72X\UblComponent\LegalMonetaryTotal;
26
use F72X\UblComponent\InvoiceLine;
27
use F72X\UblComponent\AllowanceCharge;
28
use F72X\UblComponent\PricingReference;
29
use F72X\UblComponent\AlternativeConditionPrice;
30
use F72X\UblComponent\Item;
31
use F72X\UblComponent\SellersItemIdentification;
32
use F72X\UblComponent\CommodityClassification;
33
use F72X\UblComponent\Price;
34
35
class UblHelper {
36
37
    /**
38
     * 
39
     * @param SunatDocument|InvoiceLine $target
0 ignored issues
show
Bug introduced by
The type F72X\Tools\SunatDocument was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
40
     * @param string $currencyID
41
     * @param string $ChargeIndicator
42
     * @param string $AllowanceChargeReasonCode
43
     * @param float $Amount
44
     * @param float $BaseAmount
45
     */
46
    public static function addAllowanceCharge($target, $currencyID, $ChargeIndicator, $AllowanceChargeReasonCode, $MultiplierFactorNumeric, $Amount, $BaseAmount) {
47
        $AllowanceCharge = new AllowanceCharge();
48
        $AllowanceCharge
49
                ->setCurrencyID($currencyID)
50
                ->setChargeIndicator($ChargeIndicator)
51
                ->setAllowanceChargeReasonCode($AllowanceChargeReasonCode)
52
                ->setMultiplierFactorNumeric($MultiplierFactorNumeric)
53
                ->setAmount($Amount)
54
                ->setBaseAmount($BaseAmount);
55
        // Add AllowanceCharge
56
        $target
57
                ->addAllowanceCharge($AllowanceCharge);
58
    }
59
60
    public static function addTaxSubtotal(TaxTotal $TaxTotal, $currencyID, $taxAmount, $taxableAmount, $taxTypeCode) {
61
        // XML nodes
62
        $TaxSubTotal = new TaxSubTotal();
63
        $TaxCategory = new TaxCategory();
64
        $TaxCategory->setElementAttributes('ID', [
65
            'schemeID'         => 'UN/ECE 5305',
66
            'schemeName'       => 'Tax Category Identifier',
67
            'schemeAgencyName' => 'United Nations Economic Commission for Europe'
68
        ]);
69
        $TaxScheme = new TaxScheme();
70
        $TaxScheme->setElementAttributes('ID', [
71
            'schemeID'       => 'UN/ECE 5153',
72
            'schemeAgencyID' => '6']);
73
74
        $cat5Item = Catalogo::getCatItem(5, $taxTypeCode);
75
76
        $TaxSubTotal
77
                ->setCurrencyID($currencyID)
78
                ->setTaxAmount($taxAmount)
79
                ->setTaxableAmount($taxableAmount)
80
                ->setTaxCategory($TaxCategory
81
                        ->setID($cat5Item['categoria'])
82
                        ->setTaxScheme($TaxScheme
83
                                ->setID($taxTypeCode)
84
                                ->setName($cat5Item['name'])
85
                                ->setTaxTypeCode($cat5Item['UN_ECE_5153'])));
86
        $TaxTotal->addTaxSubTotal($TaxSubTotal);
87
    }
88
89
}
90