Skip to content

Commit 6343268

Browse files
committed
[IMP] l10n_ar_tax: POV multiple payment receipt
This change introduces a new payment receipt report that consolidates multiple payments by company, receiver, and secondary currency. The purpose of this report is to enable the generation of a single, consolidated document containing all relevant payment information, which can then be sent as an official payment receipt.
1 parent 8a6e3f1 commit 6343268

2 files changed

Lines changed: 84 additions & 42 deletions

File tree

l10n_ar_tax/models/account_payment.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# For copyright and license notices, see __manifest__.py file in module root
33
# directory
44
##############################################################################
5+
from collections import defaultdict
6+
57
from odoo import Command, _, api, fields, models
68
from odoo.exceptions import UserError
79

@@ -348,3 +350,10 @@ def _get_name_receipt_report(self, report_xml_id):
348350
if self.company_id.country_id.code == "AR" and not self.is_internal_transfer:
349351
return "l10n_ar_tax.report_payment_receipt_document"
350352
return super()._get_name_receipt_report(report_xml_id)
353+
354+
def _get_payment_bundles(self):
355+
bundles = defaultdict(lambda: self.env["account.payment"])
356+
for rec in self:
357+
key = f"{rec.company_id.id}-{rec.partner_id.id}-{rec.payment_type}-{rec.currency_id.id if rec.other_currency else rec.counterpart_currency_id.id}"
358+
bundles[key] += rec
359+
return bundles

l10n_ar_tax/views/report_payment_receipt_templates.xml

Lines changed: 75 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
<t t-call="account.report_payment_receipt_document" position="attributes">
55
<attribute name="t-call">#{ o._get_name_receipt_report('account.report_payment_receipt_document') }</attribute>
66
</t>
7+
<t t-set="lang" position="after">
8+
<t t-set="payment_bundle" t-value="o"/>
9+
</t>
10+
</template>
11+
12+
<template id="report_payment_receipt_bundle">
13+
<t t-call="web.html_container">
14+
<t t-foreach="docs._get_payment_bundles().values()" t-as="payment_bundle">
15+
<t t-set="o" t-value="payment_bundle[0]"/>
16+
<t t-set="lang" t-value="o.partner_id.lang or o.company_id.partner_id.lang"/>
17+
<t t-call="#{o._get_name_receipt_report('account.report_payment_receipt_document')}" t-lang="lang"/>
18+
</t>
19+
</t>
720
</template>
821

922
<!-- we force priority greater than 16 so that it dont break inheritance of report_saleorder_document_inherit_sale_stock. with this we are loosing the incoterm field added but that sale_stock view -->
@@ -72,29 +85,33 @@
7285
</tr>
7386
</thead>
7487
<tbody>
75-
<t t-foreach="o._get_latam_checks()" t-as="check">
76-
<tr>
77-
<td>
78-
<span t-out="'Cheque nro %s' % (check.name)">Check nro 123456</span>
79-
<span t-if="check.bank_id" t-out="' - %s' % (check.bank_id.name)"> - Santander Rio</span>
80-
<span t-if="o.payment_method_code == 'own_checks'" t-out="' (%s)' % (check.payment_method_line_id.name)"> (Chequera electrónica)</span>
81-
<span t-if="check.payment_date"> - Venc. <span t-field="check.payment_date"/></span>
82-
</td>
83-
<td class="text-right" t-if="secondary_currency">
84-
<span class="text-nowrap" t-out="check.amount if o.other_currency else secondary_currency.round(check.amount / secondary_currency_rate)" t-options='{"widget": "monetary", "display_currency": secondary_currency}'/>
85-
</td>
86-
<td class="text-right o_price_total">
87-
<span class="text-nowrap" t-out="o.company_currency_id.round(check.amount * secondary_currency_rate) if o.other_currency else check.amount" t-options='{"widget": "monetary", "display_currency": o.company_currency_id}'/>
88-
</td>
89-
</tr>
88+
<t t-foreach="payment_bundle" t-as="doc">
89+
<t t-foreach="doc._get_latam_checks()" t-as="check">
90+
<tr>
91+
<td>
92+
<span t-out="'Cheque nro %s' % (check.name)">Check nro 123456</span>
93+
<span t-if="check.bank_id" t-out="' - %s' % (check.bank_id.name)"> - Santander Rio</span>
94+
<span t-if="doc.payment_method_code == 'own_checks'" t-out="' (%s)' % (check.payment_method_line_id.name)"> (Chequera electrónica)</span>
95+
<span t-if="check.payment_date"> - Venc. <span t-field="check.payment_date"/></span>
96+
</td>
97+
<td class="text-right" t-if="secondary_currency">
98+
<span class="text-nowrap" t-out="check.amount if o.other_currency else secondary_currency.round(check.amount / secondary_currency_rate)" t-options='{"widget": "monetary", "display_currency": secondary_currency}'/>
99+
</td>
100+
<td class="text-right o_price_total">
101+
<span class="text-nowrap" t-out="doc.company_currency_id.round(check.amount * secondary_currency_rate) if doc.other_currency else check.amount" t-options='{"widget": "monetary", "display_currency": o.company_currency_id}'/>
102+
</td>
103+
</tr>
104+
</t>
90105
</t>
91-
<t t-foreach="o.l10n_ar_withholding_line_ids" t-as="line">
106+
<t t-foreach="payment_bundle.l10n_ar_withholding_line_ids" t-as="line">
92107
<tr>
93108
<td>
94109
<span t-if="line.tax_id.l10n_ar_tax_type in ['earnings', 'earnings_scale']" t-out="line.tax_id.invoice_label or 'Retención Ganancias'"/>
95110
<span t-else="" t-out="line.tax_id.invoice_label or line.tax_id.name"/>
96111
</td>
97112
<td class="text-right" t-if="secondary_currency">
113+
<!-- TODO t t-set="line_secondary_currency_rate" t-value="o.exchange_rate if o.other_currency else o.counterpart_exchange_rate"/-->
114+
98115
<span class="text-nowrap" t-out="secondary_currency.round(line.amount / secondary_currency_rate)" t-options='{"widget": "monetary", "display_currency": secondary_currency}'/> </td>
99116
<td class="text-right o_price_total">
100117
<span class="text-nowrap" t-field="line.amount"/>
@@ -116,35 +133,40 @@
116133
</td>
117134
</tr>
118135
</t> -->
119-
<tr t-if="o.write_off_amount">
120-
<td>
121-
<span t-out="o.write_off_type_id.label or o.write_off_type_id.name"/>
122-
</td>
123-
<td class="text-right" t-if="secondary_currency">
124-
<span class="text-nowrap" t-out="secondary_currency.round(o.write_off_amount / secondary_currency_rate)" t-options='{"widget": "monetary", "display_currency": secondary_currency}'/> </td>
125-
<td class="text-right o_price_total">
126-
<span class="text-nowrap" t-field="o.write_off_amount"/>
127-
</td>
128-
</tr>
129-
<tr t-if="not o._is_latam_check_payment()">
130-
<td>
131-
<span t-field="o.journal_id.name"/>
132-
</td>
133-
<td class="text-right" t-if="secondary_currency">
134-
<span class="text-nowrap" t-out="o.amount_signed if o.other_currency else secondary_currency.round(o.amount / secondary_currency_rate)" t-options='{"widget": "monetary", "display_currency": secondary_currency}'/> </td>
135-
<td class="text-right o_price_total">
136-
<span class="text-nowrap" t-out="o.company_currency_id.round(o.amount * secondary_currency_rate) if o.other_currency else o.amount" t-options='{"widget": "monetary", "display_currency": o.company_currency_id}'/>
137-
</td>
138-
</tr>
136+
<t t-foreach="payment_bundle.filtered('write_off_amount')" t-as="doc">
137+
<tr >
138+
<td>
139+
<span t-out="doc.write_off_type_id.label or doc.write_off_type_id.name"/>
140+
</td>
141+
<td class="text-right" t-if="secondary_currency">
142+
<!-- TODO t t-set="line_secondary_currency_rate" t-value="o.exchange_rate if o.other_currency else o.counterpart_exchange_rate"/-->
143+
<span class="text-nowrap" t-out="secondary_currency.round(doc.write_off_amount / secondary_currency_rate)" t-options='{"widget": "monetary", "display_currency": secondary_currency}'/> </td>
144+
<td class="text-right o_price_total">
145+
<span class="text-nowrap" t-field="doc.write_off_amount"/>
146+
</td>
147+
</tr>
148+
</t>
149+
<t t-foreach="payment_bundle.filtered(lambda x: not x._is_latam_check_payment())" t-as="doc">
150+
<tr>
151+
<td>
152+
<span t-field="doc.journal_id.name"/>
153+
</td>
154+
<td class="text-right" t-if="secondary_currency">
155+
<span class="text-nowrap" t-out="doc.amount_signed if doc.other_currency else secondary_currency.round(doc.amount / secondary_currency_rate)" t-options='{"widget": "monetary", "display_currency": secondary_currency}'/> </td>
156+
<td class="text-right o_price_total">
157+
<span class="text-nowrap" t-out="doc.company_currency_id.round(doc.amount * secondary_currency_rate) if doc.other_currency else doc.amount" t-options='{"widget": "monetary", "display_currency": doc.company_currency_id}'/>
158+
</td>
159+
</tr>
160+
</t>
139161
</tbody>
140162
<tfoot>
141163
<tr>
142164
<td><strong><span>Total Pagado</span></strong></td>
143165
<td class="text-right" t-if="secondary_currency">
144-
<strong><span class="text-nowrap" t-out="secondary_currency.round(o.payment_total / secondary_currency_rate)" t-options="{'widget': 'monetary', 'display_currency': secondary_currency}"/></strong>
166+
<strong><span class="text-nowrap" t-out="secondary_currency.round(sum(payment_bundle.mapped('payment_total')) / secondary_currency_rate)" t-options="{'widget': 'monetary', 'display_currency': secondary_currency}"/></strong>
145167
</td>
146168
<td class="text-right">
147-
<strong><span class="text-nowrap" t-field="o.payment_total"/></strong>
169+
<strong><span class="text-nowrap" t-out="sum(payment_bundle.mapped('payment_total'))" t-options="{'widget': 'monetary', 'display_currency': o.company_currency_id}"/></strong>
148170
</td>
149171
</tr>
150172
</tfoot>
@@ -160,7 +182,7 @@
160182
</tr>
161183
</thead>
162184
<tbody>
163-
<t t-foreach="o.with_context(matched_payment_ids=o.ids).matched_move_line_ids" t-as="line">
185+
<t t-foreach="payment_bundle.with_context(matched_payment_ids=payment_bundle.ids).mapped('matched_move_line_ids')" t-as="line">
164186
<tr>
165187
<td><span t-field='line.move_id.display_name'/></td>
166188
<td class="text-center">
@@ -174,20 +196,20 @@
174196
</td>
175197
</tr>
176198
</t>
177-
<tr t-if="o.unmatched_amount">
199+
<tr t-if="sum(payment_bundle.mapped('unmatched_amount'))">
178200
<td>A cuenta</td>
179201
<td class="text-center"/>
180202
<td class="text-right o_price_total"/>
181203
<td class="text-right o_price_total">
182-
<span class="text-nowrap" t-field="o.unmatched_amount"/>
204+
<span class="text-nowrap" t-out="sum(payment_bundle.mapped('unmatched_amount'))" t-options="{'widget': 'monetary', 'display_currency': o.company_currency_id}" />
183205
</td>
184206
</tr>
185207
</tbody>
186208
<tfoot>
187209
<tr>
188210
<td colspan="3"><strong><span>Total Imputado</span></strong></td>
189211
<td class="text-right">
190-
<strong><span class="text-nowrap" t-out="o.unmatched_amount + o.matched_amount" t-options='{"widget": "monetary", "display_currency": o.company_currency_id}'/></strong>
212+
<strong><span class="text-nowrap" t-out="sum(payment_bundle.mapped('matched_amount')) + sum(payment_bundle.mapped('unmatched_amount'))" t-options='{"widget": "monetary", "display_currency": o.company_currency_id}'/></strong>
191213
<!-- <strong><span class="text-nowrap" t-out="o.matched_amount" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/></strong> -->
192214
</td>
193215
</tr>
@@ -242,4 +264,15 @@
242264
</div>
243265
</template>
244266

267+
<record id="action_report_receipt_bundle" model="ir.actions.report">
268+
<field name="name">Payment Receipt bundled</field>
269+
<field name="model">account.payment</field>
270+
<field name="report_type">qweb-pdf</field>
271+
<field name="report_name">l10n_ar_tax.report_payment_receipt_bundle</field>
272+
<field name="report_file">l10n_ar_tax.report_payment_receipt_bundle</field>
273+
<field name="binding_model_id" ref="model_account_payment"/>
274+
<field name="binding_type">report</field>
275+
<field name="binding_view_types">list</field>
276+
</record>
277+
245278
</odoo>

0 commit comments

Comments
 (0)