Skip to content

Commit c8409ef

Browse files
committed
Fix credit & debit template + Fix Tests
1 parent c585e56 commit c8409ef

File tree

8 files changed

+43
-60
lines changed

8 files changed

+43
-60
lines changed

src/Greenter/FeFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public function setParameters($params)
173173
private function getBillResult($xml, $filename)
174174
{
175175
$xmlS = $this->getXmmlSigned($xml);
176-
file_put_contents('notecrss.xml', $xmlS);
176+
177177
$zip = $this->zipper->compress("$filename.xml", $xmlS);
178178
return $this->sender->send("$filename.zip", $zip);
179179
}

src/Greenter/Ws/Reader/DomCdrReader.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ class DomCdrReader implements CdrReader
2828
*/
2929
public function getCdrResponse($xml)
3030
{
31-
$xp = $this->getXpath($xml);
31+
$xpt = $this->getXpath($xml);
3232

33-
$cdr = $this->getResponseByXpath($xp);
33+
$cdr = $this->getResponseByXpath($xpt);
3434
if (!$cdr) {
3535
throw new \Exception('Not found cdr response in xml');
3636
}
37-
$cdr->setNotes($this->getNotes($xp));
37+
$cdr->setNotes($this->getNotes($xpt));
3838

3939
return $cdr;
4040
}
@@ -49,10 +49,10 @@ private function getXpath($xmlContent)
4949
{
5050
$doc = new \DOMDocument();
5151
$doc->loadXML($xmlContent);
52-
$xp = new \DOMXPath($doc);
53-
$xp->registerNamespace('x', $this->appResponseNamespace);
54-
$xp->registerNamespace('cac', $this->cacNamespace);
55-
return $xp;
52+
$xpt = new \DOMXPath($doc);
53+
$xpt->registerNamespace('x', $this->appResponseNamespace);
54+
$xpt->registerNamespace('cac', $this->cacNamespace);
55+
return $xpt;
5656
}
5757

5858
/**

src/Greenter/Xml/Templates/invoice.html.twig

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,6 @@
100100
<cac:PartyName>
101101
<cbc:Name>{{ emp.nombreComercial }}</cbc:Name>
102102
</cac:PartyName>
103-
<cac:AgentParty>
104-
<cac:PartyIdentification>
105-
<cbc:ID>{{ emp.ruc }}</cbc:ID>
106-
</cac:PartyIdentification>
107-
<cac:PartyName>
108-
<cbc:Name>{{ emp.razonSocial }}</cbc:Name>
109-
</cac:PartyName>
110-
<cac:PartyLegalEntity>
111-
<cbc:RegistrationName>{{ emp.razonSocial }}</cbc:RegistrationName>
112-
</cac:PartyLegalEntity>
113-
</cac:AgentParty>
114103
</cac:SignatoryParty>
115104
<cac:DigitalSignatureAttachment>
116105
<cac:ExternalReference>

src/Greenter/Xml/Templates/notacr.html.twig

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,6 @@
101101
<cac:PartyName>
102102
<cbc:Name>{{ emp.nombreComercial }}</cbc:Name>
103103
</cac:PartyName>
104-
<cac:AgentParty>
105-
<cac:PartyIdentification>
106-
<cbc:ID>{{ emp.ruc }}</cbc:ID>
107-
</cac:PartyIdentification>
108-
<cac:PartyName>
109-
<cbc:Name>{{ emp.razonSocial }}</cbc:Name>
110-
</cac:PartyName>
111-
<cac:PartyLegalEntity>
112-
<cbc:RegistrationName>{{ emp.razonSocial }}</cbc:RegistrationName>
113-
</cac:PartyLegalEntity>
114-
</cac:AgentParty>
115104
</cac:SignatoryParty>
116105
<cac:DigitalSignatureAttachment>
117106
<cac:ExternalReference>
@@ -202,7 +191,7 @@
202191
{% for detail in doc.details %}
203192
<cac:CreditNoteLine>
204193
<cbc:ID>{{ loop.index }}</cbc:ID>
205-
<cbc:InvoicedQuantity unitCode="{{ detail.codUnidadMedida }}">{{ detail.ctdUnidadItem }}</cbc:InvoicedQuantity>
194+
<cbc:CreditedQuantity unitCode="{{ detail.codUnidadMedida }}">{{ detail.ctdUnidadItem }}</cbc:CreditedQuantity>
206195
<cbc:LineExtensionAmount currencyID="{{ doc.tipoMoneda }}">{{ detail.mtoValorVenta }}</cbc:LineExtensionAmount>
207196
{% if detail.mtoPrecioUnitario > 0 %}
208197
<cac:PricingReference>
@@ -219,10 +208,6 @@
219208
</cac:AlternativeConditionPrice>
220209
</cac:PricingReference>
221210
{% endif %}
222-
<cac:AllowanceCharge>
223-
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
224-
<cbc:Amount currencyID="{{ doc.tipoMoneda }}">0</cbc:Amount>
225-
</cac:AllowanceCharge>
226211
{% if detail.mtoIscItem %}
227212
{% set isc = detail.mtoIscItem|number_format(2) %}
228213
<cac:TaxTotal>

src/Greenter/Xml/Templates/notadb.html.twig

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,6 @@
101101
<cac:PartyName>
102102
<cbc:Name>{{ emp.nombreComercial }}</cbc:Name>
103103
</cac:PartyName>
104-
<cac:AgentParty>
105-
<cac:PartyIdentification>
106-
<cbc:ID>{{ emp.ruc }}</cbc:ID>
107-
</cac:PartyIdentification>
108-
<cac:PartyName>
109-
<cbc:Name>{{ emp.razonSocial }}</cbc:Name>
110-
</cac:PartyName>
111-
<cac:PartyLegalEntity>
112-
<cbc:RegistrationName>{{ emp.razonSocial }}</cbc:RegistrationName>
113-
</cac:PartyLegalEntity>
114-
</cac:AgentParty>
115104
</cac:SignatoryParty>
116105
<cac:DigitalSignatureAttachment>
117106
<cac:ExternalReference>
@@ -202,7 +191,7 @@
202191
{% for detail in doc.details %}
203192
<cac:DebitNoteLine>
204193
<cbc:ID>{{ loop.index }}</cbc:ID>
205-
<cbc:InvoicedQuantity unitCode="{{ detail.codUnidadMedida }}">{{ detail.ctdUnidadItem }}</cbc:InvoicedQuantity>
194+
<cbc:DebitedQuantity unitCode="{{ detail.codUnidadMedida }}">{{ detail.ctdUnidadItem }}</cbc:DebitedQuantity>
206195
<cbc:LineExtensionAmount currencyID="{{ doc.tipoMoneda }}">{{ detail.mtoValorVenta|number_format(2) }}</cbc:LineExtensionAmount>
207196
{% if detail.mtoPrecioUnitario > 0 %}
208197
<cac:PricingReference>
@@ -219,10 +208,6 @@
219208
</cac:AlternativeConditionPrice>
220209
</cac:PricingReference>
221210
{% endif %}
222-
<cac:AllowanceCharge>
223-
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
224-
<cbc:Amount currencyID="{{ doc.tipoMoneda }}">0</cbc:Amount>
225-
</cac:AllowanceCharge>
226211
{% if detail.mtoIscItem %}
227212
{% set isc = detail.mtoIscItem|number_format(2) %}
228213
<cac:TaxTotal>

tests/Greenter/FeFactoryTest.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,33 @@ public function testInvoice()
5858
);
5959
}
6060

61-
public function testNota()
61+
public function testNotaCredito()
6262
{
6363
$creditNote = $this->getCreditNote();
6464
$result = $this->factory->sendNote($creditNote);
6565

66-
$this->assertFalse($result->isSuccess());
67-
// $this->assertNotNull($result->getCdrResponse());
68-
// $this->assertEquals(
69-
// 'La Factura numero F001-123, ha sido aceptada',
70-
// $result->getCdrResponse()->getDescription()
71-
// );
66+
$this->assertTrue($result->isSuccess());
67+
$this->assertNotNull($result->getCdrResponse());
68+
$this->assertEquals(
69+
'La Nota de Credito numero FF01-123, ha sido aceptada',
70+
$result->getCdrResponse()->getDescription()
71+
);
72+
}
73+
74+
public function testNotaDebito()
75+
{
76+
$debitNote = $this->getDebitNote();
77+
$result = $this->factory->sendNote($debitNote);
78+
79+
$this->assertTrue($result->isSuccess());
80+
$this->assertNotNull($result->getCdrResponse());
81+
$this->assertEquals(
82+
'La Nota de Debito numero FF01-123, ha sido aceptada',
83+
$result->getCdrResponse()->getDescription()
84+
);
7285
}
7386

87+
7488
public function testResumen()
7589
{
7690
$resumen = $this->getSummary();

tests/Greenter/FeFactoryTrait.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private function getCreditNote()
7979
$note
8080
->setTipDocAfectado('01')
8181
->setNumDocfectado('F001-111')
82-
->setCodMotivo('01')
82+
->setCodMotivo('07')
8383
->setDesMotivo('ANULACION DE LA OPERACION')
8484
->setTipoDoc('07')
8585
->setSerie('FF01')
@@ -126,6 +126,16 @@ private function getCreditNote()
126126
return $note;
127127
}
128128

129+
private function getDebitNote()
130+
{
131+
$debit = $this->getCreditNote();
132+
$debit->setCodMotivo('01')
133+
->setDesMotivo(' XXXXXXX ')
134+
->setTipoDoc('08');
135+
136+
return $debit;
137+
}
138+
129139
private function getSummary()
130140
{
131141
$detiail1 = new SummaryDetail();

tests/Greenter/Xml/Builder/FeNoteBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testCreateXmlCreditNote()
4848
$xml = $generator->buildNote($note);
4949

5050
$this->assertNotEmpty($xml);
51-
file_put_contents('notecr.xml', $xml);
51+
// file_put_contents('notecr.xml', $xml);
5252
}
5353

5454
/**

0 commit comments

Comments
 (0)