|
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\Sunat\InputValidator; |
|
14
|
|
|
use F72X\Sunat\Operations; |
|
15
|
|
|
|
|
16
|
|
|
class ResumenDiario extends AbstractSummary { |
|
17
|
|
|
|
|
18
|
|
|
protected $idPrefix = 'RC'; |
|
19
|
|
|
protected $xmlTplName = 'SummaryDocuments.xml'; |
|
20
|
|
|
protected $lineDefaults = [ |
|
21
|
|
|
'currencyCode' => 'PEN', |
|
22
|
|
|
'taxableOperations' => 0, |
|
23
|
|
|
'exemptedOperations' => 0, |
|
24
|
|
|
'unaffectedOperations' => 0, |
|
25
|
|
|
'freeOperations' => 0, |
|
26
|
|
|
'totalCharges' => 0, |
|
27
|
|
|
'totalIsc' => 0, |
|
28
|
|
|
'totalIgv' => 0, |
|
29
|
|
|
'totalOtherTaxes' => 0, |
|
30
|
|
|
'affectedDocType' => null, |
|
31
|
|
|
'affectedDocId' => null, |
|
32
|
|
|
'perceptionRegimeType' => null, |
|
33
|
|
|
'perceptionPercentage' => null, |
|
34
|
|
|
'perceptionBaseAmount' => null, |
|
35
|
|
|
'perceptionAmount' => null, |
|
36
|
|
|
'perceptionIncludedAmount' => null |
|
37
|
|
|
]; |
|
38
|
|
|
|
|
39
|
|
|
protected $validations = [ |
|
40
|
|
|
'legalValidity' => ['required' => true] |
|
41
|
|
|
]; |
|
42
|
|
|
|
|
43
|
|
|
public function parseInputLine(array $rawInputLine) { |
|
44
|
|
|
$parsedFields = [ |
|
45
|
|
|
'payableAmount' => Operations::formatAmount($rawInputLine['payableAmount']), |
|
46
|
|
|
'taxableOperations' => Operations::formatAmount($rawInputLine['taxableOperations']), |
|
47
|
|
|
'exemptedOperations' => Operations::formatAmount($rawInputLine['exemptedOperations']), |
|
48
|
|
|
'unaffectedOperations' => Operations::formatAmount($rawInputLine['unaffectedOperations']), |
|
49
|
|
|
'freeOperations' => Operations::formatAmount($rawInputLine['freeOperations']), |
|
50
|
|
|
'totalCharges' => Operations::formatAmount($rawInputLine['totalCharges']), |
|
51
|
|
|
'totalIsc' => Operations::formatAmount($rawInputLine['totalIsc']), |
|
52
|
|
|
'totalIgv' => Operations::formatAmount($rawInputLine['totalIgv']), |
|
53
|
|
|
'totalOtherTaxes' => Operations::formatAmount($rawInputLine['totalOtherTaxes']), |
|
54
|
|
|
'perceptionPercentage' => Operations::formatAmount($rawInputLine['perceptionPercentage']), |
|
55
|
|
|
'perceptionBaseAmount' => Operations::formatAmount($rawInputLine['perceptionBaseAmount']), |
|
56
|
|
|
'perceptionAmount' => Operations::formatAmount($rawInputLine['perceptionAmount']), |
|
57
|
|
|
'perceptionIncludedAmount' => Operations::formatAmount($rawInputLine['perceptionIncludedAmount']), |
|
58
|
|
|
]; |
|
59
|
|
|
return array_merge($rawInputLine, $parsedFields); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function validateInput(array $inputData) { |
|
63
|
|
|
$validator = new InputValidator($inputData, $this->validations); |
|
64
|
|
|
if (!$validator->isValid()) { |
|
65
|
|
|
$msg = $validator->getErrosString(); |
|
66
|
|
|
throw new \Exception("Invalid Document Input: [$msg]"); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|