Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ebillpostfinance: hide password value #2

Open
wants to merge 6 commits into
base: ebillpostfinance
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ebill_postfinance/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
37 changes: 37 additions & 0 deletions ebill_postfinance/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "eBill Postfinance",
"summary": """Postfinance eBill integration""",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Camptocamp,Odoo Community Association (OCA)",
"maintainers": ["TDu"],
"website": "https://github.com/OCA/l10n-switzerland",
"depends": [
"account",
"account_invoice_export",
"base_ebill_payment_contract",
"l10n_ch_base_bank",
"l10n_ch_qriban",
"queue_job",
"sale",
],
"external_dependencies": {
"python": [
"zeep",
"ebilling_postfinance",
]
},
"data": [
"data/ir_cron.xml",
"data/transmit.method.xml",
"data/mail_activity_type.xml",
"security/ir.model.access.csv",
"views/ebill_payment_contract.xml",
"views/message_template.xml",
"views/ebill_postfinance_service.xml",
"views/ebill_postfinance_invoice_message.xml",
],
}
14 changes: 14 additions & 0 deletions ebill_postfinance/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record model="ir.cron" id="cron_search_invoices">
<field name="name">eBill Postfinance - Check invoices state on server</field>
<field name="interval_number">1</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field name="active" eval="True" />
<field name="doall" eval="False" />
<field name="model_id" ref="model_ebill_postfinance_service" />
<field name="state">code</field>
<field name="code">model.cron_update_invoices()</field>
</record>
</odoo>
12 changes: 12 additions & 0 deletions ebill_postfinance/data/mail_activity_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<record id="mail_activity_ebill_postfinance_error" model="mail.activity.type">
<field name="name">eBill Postfinance Error</field>
<field name="icon">fa-warning</field>
<field name="delay_count">0</field>
<field name="sequence">99</field>
<field name="decoration_type">warning</field>
</record>
</data>
</odoo>
10 changes: 10 additions & 0 deletions ebill_postfinance/data/transmit.method.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="postfinance_transmit_method" model="transmit.method">
<field name="name">Postfinance</field>
<field name="code">postfinance</field>
<field name="customer_ok" eval="True" />
<field name="supplier_ok" eval="False" />
<field name="send_through_http" eval="True" />
</record>
</odoo>
238 changes: 238 additions & 0 deletions ebill_postfinance/messages/invoice-2003A.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE XML-FSCM-INVOICE-2003A SYSTEM "XML-FSCM-INVOICE-2003A.DTD">
<XML-FSCM-INVOICE-2003A>
<INTERCHANGE>
<IC-SENDER>
<Pid>{{ client_pid }}</Pid>
</IC-SENDER>
<IC-RECEIVER>
<Pid>41010106799303734</Pid>
</IC-RECEIVER>
<IC-Ref>{{ transaction_id }}</IC-Ref>
</INTERCHANGE>
<INVOICE Type="{{ document_type }}">
<HEADER>
<FUNCTION-FLAGS>
<Confirmation-Flag />
</FUNCTION-FLAGS>
<MESSAGE-REFERENCE>
<REFERENCE-DATE>
<Reference-No>{{ invoice.name }}</Reference-No>
<Date Format="CCYYMMDD">{{ format_date() }}</Date>
</REFERENCE-DATE>
</MESSAGE-REFERENCE>
<PRINT-DATE>
<Date Format="CCYYMMDD">{{ format_date(invoice.date_invoice) }}</Date>
</PRINT-DATE>
<DELIVERY-DATE>
<Date Format="CCYYMMDD">{{ format_date(invoice.date_invoice) }}</Date>
</DELIVERY-DATE>
<REFERENCE>
<INVOICE-REFERENCE>
<REFERENCE-DATE>
<Reference-No>{{ invoice.name }}</Reference-No>
<Date Format="CCYYMMDD">{{ format_date(invoice.date_invoice) }}</Date>
</REFERENCE-DATE>
</INVOICE-REFERENCE>
{% for order in invoice_lines.sale_line_ids.mapped('order_id') if order.postfinance_ebill_client_order_ref %}
{%- if loop.index0 < 5 %}
<ORDER>
<REFERENCE-DATE>
<Reference-No>{{ order.postfinance_ebill_client_order_ref }}</Reference-No>
<Date Format="CCYYMMDD">{{ format_date(order.date_order) }}</Date>
</REFERENCE-DATE>
</ORDER>
{%- endif %}
{% endfor %}
{% for picking in invoice_lines.sale_line_ids.move_ids.mapped('picking_id')[:9] %}
{%- if picking.state != 'cancel' %}
<DELIVERY-NOTE>
<REFERENCE-DATE>
<Reference-No>{{ picking.name }}</Reference-No>
{%- if picking.date_done %}
<Date Format="CCYYMMDD">{{ format_date(picking.date_done) }}</Date>
{%- endif %}
</REFERENCE-DATE>
</DELIVERY-NOTE>
{%- endif %}
{% endfor %}
{% for ref in invoice.get_postfinance_other_reference() %}
<OTHER-REFERENCE Type="{{ ref.type }}">
<REFERENCE-DATE>
<Reference-No>{{ ref.no|truncate(35, True, "") }}</Reference-No>
</REFERENCE-DATE>
</OTHER-REFERENCE>
{% endfor %}
</REFERENCE>
<BILLER>
{#- Doc says vat number or business identitfiaction number #}
{%- if invoice.company_id.vat %}
<Tax-No>{{ invoice.company_id.vat }}</Tax-No>
{%- endif %}
{%- if invoice.payment_reference %}
<Doc-Reference Type="{{ 'QRR' if payment_type == 'qr' else 'ESR-NEU' }}">{{ invoice.payment_reference }}</Doc-Reference>
{%- endif %}
<PARTY-ID>
<Pid>{{ client_pid }}</Pid>
</PARTY-ID>
<NAME-ADDRESS Format="COM">
<NAME>
<Line-35>{{ biller.name }}</Line-35>
</NAME>
<STREET>
<Line-35>{{ (biller.street or '')|truncate(35, True, "") }}</Line-35>
{%- if biller.street2 %}
<Line-35>{{ biller.street2|truncate(5, True, "") }}</Line-35>
{% endif %}
</STREET>
<City>{{ biller.city or ''}}</City>
<Zip>{{ biller.zip or '' }}</Zip>
<Country>{{ biller.country_id.code or 'CH' }}</Country>
</NAME-ADDRESS>
<BANK-INFO>
{%- if payment_type in ['isr', 'esp'] %}
<Acct-No>{{ bank_account }}</Acct-No>
<BankId Type="BCNr-int" Country="CH">{{ bank.bank_id.clearing }}</BankId>
{%- elif payment_type == 'qr' %}
<Acct-No>{{ bank_account }}</Acct-No>
<BankId Type="IID" Country="CH">{{ bank_account[4:9] if bank_account else ''}}</BankId>
{%- endif %}
</BANK-INFO>
</BILLER>
<PAYER>
<PARTY-ID>
<Pid>{{ ebill_account_number }}</Pid>
</PARTY-ID>
<NAME-ADDRESS Format="COM">
<NAME>
{%- if customer.name != customer.commercial_company_name and customer.commercial_company_name %}
<Line-35>{{ customer.commercial_company_name|truncate(35, True, '') }}</Line-35>
{%- endif %}
<Line-35>{{ (customer.name or "")|truncate(35, True, "") }}</Line-35>
</NAME>
<STREET>
<Line-35>{{ (customer.street or "")|truncate(35, True, "") }}</Line-35>
{%- if customer.street2 %}
<Line-35>{{ customer.street2|truncate(35, True, "") }}</Line-35>
{%- endif %}
</STREET>
<City>{{ customer.city or ""}}</City>
<Zip>{{ customer.zip or ""}}</Zip>
<Country>{{ customer.country_id.code or 'CH' }}</Country>
</NAME-ADDRESS>
</PAYER>
{%- if delivery %}
<DELIVERY-PARTY>
<NAME-ADDRESS Format="COM">
<NAME>
{%- if delivery.name != delivery.commercial_company_name and delivery.commercial_company_name %}
<Line-35>{{ delivery.commercial_company_name|truncate(35, True, '') }}</Line-35>
{%- endif %}
<Line-35>{{ (delivery.name or "")|truncate(35, True, "") }}</Line-35>
</NAME>
<STREET>
<Line-35>{{ (delivery.street or "")|truncate(35, True, "") }}</Line-35>
{%- if delivery.street2 %}
<Line-35>{{ delivery.street2|truncate(35, True, "") }}</Line-35>
{%- endif %}
</STREET>
<City>{{ delivery.city or '' }}</City>
<Zip>{{ delivery.zip or '' }}</Zip>
<Country>{{ delivery.country_id.code or 'CH' }}</Country>
</NAME-ADDRESS>
</DELIVERY-PARTY>
{%- endif %}
</HEADER>
{% for line in invoice_lines %}
<LINE-ITEM Line-Number="{{ loop.index }}">
{%- if line.product_id %}
<ITEM-ID>
<Item-Id Type="VN">{{ line.product_id.default_code or ''}}</Item-Id>
<Item-Id Type="SA">{{ line.product_id.default_code or ''}}</Item-Id>
</ITEM-ID>
{%- endif %}
<ITEM-DESCRIPTION>
<Item-Type-Code>1011</Item-Type-Code>
<Line-35>{{ (line.product_id.name or line.name or "")[:35] }}</Line-35>
{%- if (line.product_id.name or line.name or "")|length > 35 %}
<Line-35>{{ (line.product_id.name or line.name)[35:]|truncate(34, True) }}</Line-35>
{%- endif %}
</ITEM-DESCRIPTION>
{% for order in invoice_lines.sale_line_ids.mapped('order_id') %}
{%- if order.postfinance_ebill_client_order_ref %}
<ITEM-REFERENCE Type="ON">
<REFERENCE-DATE>
<Reference-No>{{ order.postfinance_ebill_client_order_ref }}</Reference-No>
<Date Format="CCYYMMDD">{{ format_date(order.date_order) }}</Date>
</REFERENCE-DATE>
</ITEM-REFERENCE>
{%- endif %}
{% endfor %}
<Quantity Type="47" Units="PCE">{{ line.quantity }}</Quantity>
<Price Type="YYY">{{ line.price_subtotal|round(2) }}</Price>
<Price Type="AAA">{{ line.price_subtotal|round(2) }}</Price>
<Price Type="XXX">{{ line.price_total|round(2) }}</Price>
<ITEM-AMOUNT Type="66">
<Amount Currency="{{ invoice.currency_id.name }}">{{ line.price_subtotal|round(2) }}</Amount>
</ITEM-AMOUNT>
{% for tax in line.tax_ids %}
{%- if loop.index == 1 %}
<TAX>
<Rate>{{ tax.amount}}</Rate>
<Amount Currency="{{ invoice.currency_id.name }}">{{ tax._compute_amount(line.price_subtotal, line.price_unit)|round(2) }}</Amount>
</TAX>
{%- endif %}
{% else %}
<TAX>
<Rate>0</Rate>
</TAX>
{% endfor %}
</LINE-ITEM>
{% endfor %}
<SUMMARY>
<INVOICE-AMOUNT Print-Status="25">
<Amount Currency="{{ invoice.currency_id.name }}">{{ invoice.amount_total|round(2) }}</Amount>
</INVOICE-AMOUNT>
<VAT-AMOUNT Print-Status="25">
<Amount Currency="{{ invoice.currency_id.name }}">{{ invoice.amount_tax|round(2) }}</Amount>
</VAT-AMOUNT>
<EXTENDED-AMOUNT Type="79">
<Amount Currency="{{ invoice.currency_id.name }}">{{ invoice.amount_untaxed|round(2) }}</Amount>
</EXTENDED-AMOUNT>
{% if amount_by_group %}
{% for taxgroup in amount_by_group %}
<TAX>
<TAX-BASIS>
<Amount Currency="{{ invoice.currency_id.name }}">{{ taxgroup[2]|round(2) }}</Amount>
</TAX-BASIS>
{%- if taxgroup[0] %}
<Rate Category="S">{{ taxgroup[0] }}</Rate>
{%- else %}
<Rate Category="E">0</Rate>
{%- endif %}
<Amount Currency="{{ invoice.currency_id.name }}">{{ taxgroup[1]|round(2) }}</Amount>
</TAX>
{% endfor %}
{%- else %}
<TAX>
<TAX-BASIS>
<Amount Currency="{{ invoice.currency_id.name }}">{{ invoice.amount_untaxed|round(2) }}</Amount>
</TAX-BASIS>
<Rate Category="E">0</Rate>
<Amount Currency="{{ invoice.currency_id.name }}">0</Amount>
</TAX>
{% endif -%}
<PAYMENT-TERMS>
<BASIC Payment-Type="{{ 'ESR' if payment_type == 'isr' else payment_type|upper }}" Terms-Type="5">
<TERMS>
<Date>{{ date_due }}</Date>
</TERMS>
</BASIC>
{% include discount_template ignore missing %}
</PAYMENT-TERMS>
<Back-Pack-Container Encode="Base64">
{{- pdf_data | safe -}}
</Back-Pack-Container>
</SUMMARY>
</INVOICE>
</XML-FSCM-INVOICE-2003A>
Loading