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 DateTime; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* AbstractSummary |
17
|
|
|
* |
18
|
|
|
* Base class for Resumen Diario y Comunicación de baja. |
19
|
|
|
*/ |
20
|
|
|
abstract class AbstractSummary extends AbstractDocument { |
21
|
|
|
|
22
|
|
|
protected $idPrefix; // RA|RC |
23
|
|
|
protected $usesSeries = false; |
24
|
|
|
protected $numberMaxLength = 5; |
25
|
|
|
/** |
26
|
|
|
* @var DateTime |
27
|
|
|
*/ |
28
|
|
|
protected $referenceDate; |
29
|
|
|
|
30
|
|
|
protected function parseInput(array $rawInput) { |
31
|
|
|
$parsedData = $rawInput; |
32
|
|
|
$parsedData['referenceDate'] = new DateTime($rawInput['referenceDate']); |
33
|
|
|
$parsedData['items'] = $this->parseInputLines($rawInput['items']); |
34
|
|
|
return $parsedData; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function setBodyFields() { |
38
|
|
|
$data = $this->getParsedData(); |
39
|
|
|
$this->referenceDate = $data['referenceDate']; |
40
|
|
|
// Lines |
41
|
|
|
$this->lines = $data['items']; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Sets: Document: Number, ID and filename |
46
|
|
|
*/ |
47
|
|
|
protected function setId() { |
48
|
|
|
$this->id = $this->idPrefix . '-' . $this->issueDate->format('Ymd') . '-' . $this->number; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getDataForXml() { |
52
|
|
|
// Get base fields |
53
|
|
|
$data = $this->getBaseFieldsForXml(); |
54
|
|
|
$data['referenceDate'] = $this->referenceDate->format('Y-m-d'); |
55
|
|
|
return $data; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Returns the prefix that is added at the beginning of the document ID |
60
|
|
|
* @return string RA|RC |
61
|
|
|
*/ |
62
|
|
|
public function getIdPrefix() { |
63
|
|
|
return $this->idPrefix; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getReferenceDate() { |
67
|
|
|
return $this->referenceDate; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function setReferenceDate(DateTime $referenceDate) { |
71
|
|
|
$this->referenceDate = $referenceDate; |
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
} |
76
|
|
|
|