|
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 |
|
|
|
|
|
|
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
|
|
|
|