-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
290 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2023 Camptocamp SA (http://www.camptocamp.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
|
||
def migrate(cr, version): | ||
if not version: | ||
return | ||
|
||
cr.execute( | ||
""" | ||
UPDATE ebill_postfinance_invoice_message | ||
SET payment_type = 'iban' | ||
WHERE payment_type = 'qr'; | ||
UPDATE ebill_postfinance_invoice_message | ||
SET payment_type = 'esr' | ||
WHERE payment_type = 'isr'; | ||
""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" type="string"> | ||
<Header> | ||
<From>Camptocamp SA</From> | ||
<To>IPECeBILLServer</To> | ||
<UseCase>CreateybInvoice</UseCase> | ||
<SessionID>1</SessionID> | ||
<Version>2.0</Version> | ||
<Status>0</Status> | ||
<SoftwareName>Odoo</SoftwareName> | ||
<SoftwareVersion>14.0</SoftwareVersion> | ||
</Header> | ||
<Body> | ||
<DeliveryInfo> | ||
<BillerID>41101000001021209</BillerID> | ||
<eBillAccountID>41010198248040391</eBillAccountID> | ||
<DeliveryDate>2019-06-21</DeliveryDate> | ||
<TransactionID>$TRANSACTION_ID</TransactionID> | ||
<BillDetailsType>PDFAppendix</BillDetailsType> | ||
<URLBillDetails/> | ||
</DeliveryInfo> | ||
<Bill> | ||
<Header> | ||
<DocumentType>CREDITADVICE</DocumentType> | ||
<DocumentID>INV_TEST_01</DocumentID> | ||
<DocumentDate>2019-06-21</DocumentDate> | ||
<SenderParty> | ||
<TaxLiability>VAT</TaxLiability> | ||
<PartyType> | ||
<Address> | ||
<CompanyName>Camptocamp SA</CompanyName> | ||
<Address1>StreetOne</Address1> | ||
<ZIP>1015</ZIP> | ||
<City>Lausanne</City> | ||
<Country>CH</Country> | ||
<Email>[email protected]</Email> | ||
</Address> | ||
<TaxID>CHE012345678</TaxID> | ||
</PartyType> | ||
</SenderParty> | ||
<ReceiverParty> | ||
<PartyType> | ||
<CustomerID>$CUSTOMER_ID</CustomerID> | ||
<Address> | ||
<CompanyName>Test RAD Customer XML</CompanyName> | ||
<Address1>Teststrasse 100</Address1> | ||
<Address2>This is a very long street name that should be sna</Address2> | ||
<ZIP>1700</ZIP> | ||
<City>Fribourg</City> | ||
<Country>CH</Country> | ||
</Address> | ||
<!-- <TaxID>CHE333222111</TaxID> --> | ||
</PartyType> | ||
</ReceiverParty> | ||
<DeliveryPlace> | ||
<Address> | ||
<CompanyName>Test RAD Customer XML</CompanyName> | ||
<ZIP>1700</ZIP> | ||
<City>Fribourg</City> | ||
<Country>CH</Country> | ||
<!-- <Contact1>0000000001</Contact1> --> | ||
</Address> | ||
</DeliveryPlace> | ||
<AchievementDate> | ||
<StartDateAchievement>2019-06-21</StartDateAchievement> | ||
<EndDateAchievement>2019-06-21</EndDateAchievement> | ||
</AchievementDate> | ||
<Currency>CHF</Currency> | ||
<AccountAssignment> | ||
<OrderReference> | ||
<ReferencePosition>1</ReferencePosition> | ||
<ReferenceType>OrderReference</ReferenceType> | ||
<ReferenceValue>CustomerRef</ReferenceValue> | ||
</OrderReference> | ||
<OrderDate>2019-06-01</OrderDate> | ||
</AccountAssignment> | ||
<Language>en</Language> | ||
<PaymentInformation> | ||
<PaymentDueDate>2019-07-01</PaymentDueDate> | ||
<PaymentType>CREDIT</PaymentType> | ||
<fixAmount>Yes</fixAmount> | ||
</PaymentInformation> | ||
<!-- <FreeText>Dies ist eine Musterrechnung mit QR-IBAN Angaben</FreeText> --> | ||
</Header> | ||
<LineItems> | ||
<LineItem> | ||
<LineItemType>NORMAL</LineItemType> | ||
<LineItemID>1</LineItemID> | ||
<ProductDescription>Product Q & A</ProductDescription> | ||
<ProductID>370003021</ProductID> | ||
<Quantity>4.0</Quantity> | ||
<QuantityDescription>Units</QuantityDescription> | ||
<PriceUnit>1</PriceUnit> | ||
<Tax> | ||
<TaxDetail> | ||
<Rate>7.7</Rate> | ||
<Amount>37.88</Amount> | ||
<BaseAmountExclusiveTax>492.0</BaseAmountExclusiveTax> | ||
<BaseAmountInclusiveTax>529.88</BaseAmountInclusiveTax> | ||
</TaxDetail> | ||
<TotalTax>37.88</TotalTax> | ||
</Tax> | ||
<AmountInclusiveTax>529.88</AmountInclusiveTax> | ||
<AmountExclusiveTax>492.0</AmountExclusiveTax> | ||
<FixedReference> | ||
<ReferencePosition>2</ReferencePosition> | ||
<ReferenceType>OrderNumberBySupplier</ReferenceType> | ||
<ReferenceValue>Order123</ReferenceValue> | ||
</FixedReference> | ||
<FixedReference> | ||
<ReferencePosition>3</ReferencePosition> | ||
<ReferenceType>OrderNumberByBuyer</ReferenceType> | ||
<ReferenceValue>CustomerRef</ReferenceValue> | ||
</FixedReference> | ||
</LineItem> | ||
<LineItem> | ||
<LineItemType>NORMAL</LineItemType> | ||
<LineItemID>2</LineItemID> | ||
<ProductDescription>Product With a Very Long Name That Need To Be Truncated</ProductDescription> | ||
<ProductID>370003022</ProductID> | ||
<Quantity>1.0</Quantity> | ||
<QuantityDescription>Units</QuantityDescription> | ||
<PriceUnit>1</PriceUnit> | ||
<Tax> | ||
<TaxDetail> | ||
<Rate>7.7</Rate> | ||
<Amount>0.0</Amount> | ||
<BaseAmountExclusiveTax>0.0</BaseAmountExclusiveTax> | ||
<BaseAmountInclusiveTax>0.0</BaseAmountInclusiveTax> | ||
</TaxDetail> | ||
<TotalTax>0.0</TotalTax> | ||
</Tax> | ||
<AmountInclusiveTax>0.0</AmountInclusiveTax> | ||
<AmountExclusiveTax>0.0</AmountExclusiveTax> | ||
<FixedReference> | ||
<ReferencePosition>4</ReferencePosition> | ||
<ReferenceType>OrderNumberBySupplier</ReferenceType> | ||
<ReferenceValue>Order123</ReferenceValue> | ||
</FixedReference> | ||
<FixedReference> | ||
<ReferencePosition>5</ReferencePosition> | ||
<ReferenceType>OrderNumberByBuyer</ReferenceType> | ||
<ReferenceValue>CustomerRef</ReferenceValue> | ||
</FixedReference> | ||
</LineItem> | ||
<LineItem> | ||
<LineItemType>NORMAL</LineItemType> | ||
<LineItemID>3</LineItemID> | ||
<ProductDescription>Phone support</ProductDescription> | ||
<Quantity>4.0</Quantity> | ||
<QuantityDescription>PCE</QuantityDescription> | ||
<PriceUnit>1</PriceUnit> | ||
<AmountInclusiveTax>0.0</AmountInclusiveTax> | ||
<AmountExclusiveTax>0.0</AmountExclusiveTax> | ||
</LineItem> | ||
</LineItems> | ||
<Summary> | ||
<Tax> | ||
<TaxDetail> | ||
<Rate>7.7</Rate> | ||
<Amount>-37.88</Amount> | ||
<BaseAmountExclusiveTax>-492.0</BaseAmountExclusiveTax> | ||
<BaseAmountInclusiveTax>-529.88</BaseAmountInclusiveTax> | ||
</TaxDetail> | ||
<TotalTax>37.88</TotalTax> | ||
</Tax> | ||
<TotalAmountExclusiveTax>-492.0</TotalAmountExclusiveTax> | ||
<TotalAmountInclusiveTax>-529.88</TotalAmountInclusiveTax> | ||
<!-- <TotalAmountPaid>200.00</TotalAmountPaid> --> | ||
<TotalAmountDue>-529.88</TotalAmountDue> | ||
</Summary> | ||
</Bill> | ||
<Appendix> | ||
</Appendix> | ||
</Body> | ||
</Envelope> |
63 changes: 63 additions & 0 deletions
63
ebill_postfinance/tests/test_ebill_postfinance_message_yb_creditnote.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright 2022 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
import os | ||
from string import Template | ||
|
||
from freezegun import freeze_time | ||
from lxml import etree as ET | ||
|
||
from odoo.modules.module import get_module_root | ||
from odoo.tools import file_open | ||
|
||
from .common import CommonCase | ||
|
||
|
||
@freeze_time("2019-06-21 09:06:00") | ||
class TestEbillPostfinanceMessageYBCreditNote(CommonCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.schema_file = ( | ||
get_module_root(os.path.dirname(__file__)) | ||
+ "/messages/ybInvoice_V2.0.4.xsd" | ||
) | ||
|
||
def test_invoice_credit_note(self): | ||
"""Check XML payload genetated for a credit note.""" | ||
# If ebill_postfinance_stock is installed it will break the test | ||
try: | ||
self.invoice.invoice_line_ids.sale_line_ids.write({"move_ids": False}) | ||
except Exception: | ||
pass | ||
self.invoice.name = "INV_TEST_01" | ||
self.invoice.invoice_date_due = "2019-07-01" | ||
self.invoice.move_type = "out_refund" | ||
message = self.invoice.create_postfinance_ebill() | ||
message.set_transaction_id() | ||
message.payload = message._generate_payload_yb() | ||
# Validate the xml generated on top of the xsd schema | ||
node = ET.fromstring(message.payload.encode("utf-8")) | ||
self.assertXmlValidXSchema(node, xschema=None, filename=self.schema_file) | ||
# Remove the PDF file data from the XML to ease diff check | ||
lines = message.payload.splitlines() | ||
for pos, line in enumerate(lines): | ||
if line.find("MimeType") != -1: | ||
lines.pop(pos) | ||
break | ||
payload = "\n".join(lines).encode("utf8") | ||
# Prepare the XML file that is expected | ||
expected_tmpl = Template( | ||
file_open("ebill_postfinance/tests/examples/credit_note_yb.xml").read() | ||
) | ||
expected = expected_tmpl.substitute( | ||
TRANSACTION_ID=message.transaction_id, CUSTOMER_ID=self.customer.id | ||
).encode("utf8") | ||
# Remove the comments in the expected xml | ||
expected_nocomment = [ | ||
line | ||
for line in expected.split(b"\n") | ||
if not line.lstrip().startswith(b"<!--") | ||
] | ||
expected_nocomment = b"\n".join(expected_nocomment) | ||
self.assertFalse(self.compare_xml_line_by_line(payload, expected_nocomment)) |