Skip to content

Commit

Permalink
[IMP] l10n_ar_ux: add currency amounts on invoice report
Browse files Browse the repository at this point in the history
closes #764

Signed-off-by: Juan José Scarafía <jjs@adhoc.com.ar>
  • Loading branch information
jjscarafia committed Nov 29, 2023
1 parent 215da8b commit d15716c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion l10n_ar_ux/reports/account_invoice_report_view.xml
Expand Up @@ -18,9 +18,13 @@
<field name="product_categ_id" optional="hide"/>
<field name="quantity" sum="Total"/>
<field name="price_unit"/>
<field name="price_average" optional="hide"/>
<field name="discount" groups="product.group_discount_per_so_line"/>
<field name="discount_amount" sum="Total" optional="hide" groups="product.group_discount_per_so_line"/>
<field name="price_subtotal" sum="Total without taxe"/>
<field name="price_subtotal_ic" sum="Total" optional="hide"/>
<field name="price_total" sum="Total" optional="hide"/>
<field name="price_subtotal" sum="Total"/>
<field name="total_cc" sum="Total"/>
<field name="state"/>
<field name="payment_state" optional="hide"/>
<field name="invoice_currency_id" optional="hide"/>
Expand Down
18 changes: 15 additions & 3 deletions l10n_ar_ux/reports/invoice_report.py
Expand Up @@ -6,14 +6,24 @@ class AccountInvoiceReport(models.Model):

_inherit = 'account.invoice.report'

# TODO mover todo esto a account_ux
# agregamos widgets monetary, referencia a company currency en string y help
price_subtotal = fields.Monetary(
currency_field='company_currency_id', string="Untaxed Total (CC)", help="Untaxed Total in company currency")
price_total = fields.Monetary(string='Total', currency_field='invoice_currency_id')
price_average = fields.Monetary(
currency_field='company_currency_id', string='Average Price (CC)', help="Average Price in company currency")
# creamos nuevos campos para tener descuentos, vinculos e importes en moneda de compañía
total_cc = fields.Monetary(
string='Total (CC)', readonly=True, help="Untaxed Total in company currency",
currency_field='company_currency_id')
invoice_currency_id = fields.Many2one('res.currency', string='Invoice Currency', readonly=True)
line_id = fields.Many2one('account.move.line', string='Journal Item', readonly=True)
price_subtotal_ic = fields.Monetary('Untaxed Total', readonly=True, currency_field='invoice_currency_id',)
price_unit = fields.Monetary('Unit Price', readonly=True, currency_field='invoice_currency_id',)
discount = fields.Float('Discount (%)', readonly=True)
discount_amount = fields.Monetary(
'Discount Amount', readonly=True, group_operator="sum", currency_field='invoice_currency_id',)
price_subtotal = fields.Monetary(currency_field='company_currency_id')
price_average = fields.Monetary(currency_field='company_currency_id')

_depends = {'account.move.line': ['price_unit', 'discount']}

Expand All @@ -25,7 +35,9 @@ def _select(self):
line.discount,
line.price_unit * line.quantity * line.discount/100 *
(CASE WHEN move
.move_type IN ('in_refund','out_refund','in_receipt') THEN -1 ELSE 1 END) as discount_amount
.move_type IN ('in_refund','out_refund','in_receipt') THEN -1 ELSE 1 END) as discount_amount,
-line.balance * (line.price_total / NULLIF(line.price_subtotal, 0.0)) AS total_cc,
-line.price_subtotal as price_subtotal_ic
"""

def _group_by(self):
Expand Down

0 comments on commit d15716c

Please sign in to comment.