NoteMixin::addBillingReference()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 17
rs 9.9332
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * MÓDULO DE EMISIÓN ELECTRÓNICA F72X
5
 * UBL 2.1
6
 * Version 1.0
7
 * 
8
 * Copyright 2019, Jaime Cruz
9
 */
10
11
namespace F72X\Sunat\Document;
12
13
use F72X\UblComponent\DiscrepancyResponse;
14
use F72X\UblComponent\BillingReference;
15
use F72X\UblComponent\InvoiceDocumentReference;
16
use F72X\UblComponent\RequestedMonetaryTotal;
17
18
trait NoteMixin {
19
20
    public function addDiscrepancyResponse() {
21
22
        // Data
23
        $dataMap = $this->dataMap;
24
        $affectedDocId = $dataMap->getNoteAffectedDocId();
25
        $type = $dataMap->getNoteType();
26
        $description = $dataMap->getNoteDescription();
27
28
        // XML Nodes
29
        $DiscrepancyResponse = new DiscrepancyResponse();
30
        $DiscrepancyResponse
31
                ->setReferenceID($affectedDocId)
32
                ->setResponseCode($type)
33
                ->setDescription($description);
34
35
        // Add Node
36
        parent::setDiscrepancyResponse($DiscrepancyResponse);
37
    }
38
39
    public function addBillingReference() {
40
41
        // Data
42
        $dataMap = $this->dataMap;
43
        $affDocId = $dataMap->getNoteAffectedDocId();
44
        $affDocType = $dataMap->getNoteAffectedDocType();
45
46
        // XML Nodes
47
        $BillingReference = new BillingReference();
48
        $InvoiceDocumentReference = new InvoiceDocumentReference();
49
        $BillingReference
50
                ->setInvoiceDocumentReference($InvoiceDocumentReference
51
                        ->setID($affDocId)
52
                        ->setDocumentTypeCode($affDocType));
53
54
        // Add Node
55
        parent::setBillingReference($BillingReference);
56
    }
57
58
    private function addRequestedMonetaryTotal() {
59
        $dataMap         = $this->dataMap;
60
        $currencyID      = $this->getDocumentCurrencyCode(); // Tipo de moneda
0 ignored issues
show
Bug introduced by
It seems like getDocumentCurrencyCode() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

60
        /** @scrutinizer ignore-call */ 
61
        $currencyID      = $this->getDocumentCurrencyCode(); // Tipo de moneda
Loading history...
61
        $totalAllowances = $dataMap->getTotalAllowances();   // Total descuentos
62
        $payableAmount   = $dataMap->getPayableAmount();     // Total a pagar
63
        $billableAmount  = $dataMap->getBillableValue();
64
        // RequestedMonetaryTotal
65
        $RequestedMonetaryTotal = new RequestedMonetaryTotal();
66
        $RequestedMonetaryTotal
67
                ->setCurrencyID($currencyID)
68
                ->setLineExtensionAmount($billableAmount)
69
                ->setTaxInclusiveAmount($payableAmount)
70
                ->setAllowanceTotalAmount($totalAllowances)
71
                ->setPayableAmount($payableAmount);
72
73
        parent::setRequestedMonetaryTotal($RequestedMonetaryTotal);
74
    }
75
76
}
77