Passed
Branch develop (477450)
by JAIME ELMER
06:26
created

NoteMixin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 34
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addDiscrepancyResponse() 0 17 1
A addRequestedMonetaryTotal() 0 16 1
A addBillingReference() 0 17 1
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\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
        $this->setDiscrepancyResponse($DiscrepancyResponse);
0 ignored issues
show
Bug introduced by
It seems like setDiscrepancyResponse() 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

36
        $this->/** @scrutinizer ignore-call */ 
37
               setDiscrepancyResponse($DiscrepancyResponse);
Loading history...
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
        $this->setBillingReference($BillingReference);
0 ignored issues
show
Bug introduced by
It seems like setBillingReference() 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

55
        $this->/** @scrutinizer ignore-call */ 
56
               setBillingReference($BillingReference);
Loading history...
56
    }
57
    private function addRequestedMonetaryTotal() {
58
        $dataMap            = $this->dataMap;
59
        $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

59
        /** @scrutinizer ignore-call */ 
60
        $currencyID         = $this->getDocumentCurrencyCode(); // Tipo de moneda
Loading history...
60
        $totalAllowances    = $dataMap->getTotalAllowances();   // Total descuentos
61
        $payableAmount      = $dataMap->getPayableAmount();     // Total a pagar
62
        $billableAmount     = $dataMap->getBillableValue();
63
        // RequestedMonetaryTotal
64
        $RequestedMonetaryTotal = new RequestedMonetaryTotal();
65
        $RequestedMonetaryTotal
66
                ->setCurrencyID($currencyID)
67
                ->setLineExtensionAmount($billableAmount)
68
                ->setTaxInclusiveAmount($payableAmount)
69
                ->setAllowanceTotalAmount($totalAllowances)
70
                ->setPayableAmount($payableAmount);
71
72
        $this->setRequestedMonetaryTotal($RequestedMonetaryTotal);
0 ignored issues
show
Bug introduced by
It seems like setRequestedMonetaryTotal() 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

72
        $this->/** @scrutinizer ignore-call */ 
73
               setRequestedMonetaryTotal($RequestedMonetaryTotal);
Loading history...
73
    }
74
}
75