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
[FIX] point_of_sale: revert entry sign in tax report #161531
Conversation
7193171
to
4601a39
Compare
Hello @vin-odoo |
@agr-odoo Hi! I'd suggest checking with LAS or asking the accounting team for a review to be sure, and they can validate/ask him his opinion if needed/... (btw, it needs a test ^^) |
0f1cca9
to
f08442d
Compare
invoice_product_line = invoice.line_ids.filtered(lambda line: line.display_type == 'product') | ||
self.assertEqual(invoice_product_line.tax_tag_ids.name, 'invoice') | ||
misc_product_line = misc_reversal_entry.line_ids.filtered(lambda line: line.display_type == 'product') | ||
self.assertEqual(misc_product_line.tax_tag_ids.name, 'refund') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally speaking, do we really want to use the refund tag on the reversal ? We revert it to redo it on an invoice, right, so it's not really a refund 🤔 IMO it would make sense to have the same repartition, hence same tag, but in negative (so, inverting the sign of the chosen tag(s)). But maybe I'm wrong, and I'm not a POS expert ; did you discuss that with a PO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We revert it to redo it on an invoice, right, so it's not really a refund
Conceptually seems the same of adding a credit note selecting 'Full refund and new draft invoice', so current patch results make sense to me, but I'm not an accountant :D
I'll check with a PO to be sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really if I understand it right.
In the "full refund and new draft invoice" flow, the original invoice, its refund and the new invoice can have three different accounting dates (I mean, possibly in 3 different months/quarters). Therefore, the refund has to be considered as such (a refund). Since, assuming no other entry elsewhere, it could result in a negative grid 03 in the month/quarter of the out_refund. >> Belgian Tax Report would be rejected upon submission to Intervat.
While in the PoS flow, the entry that cancels the initial booking and the invoice addressed to a specific customer will necessarily happen the same day and share the same accounting date.
Or am I missing something?
@@ -659,7 +659,7 @@ def _prepare_aml_values_list_per_nature(self): | |||
if self.fiscal_position_id: | |||
account = self.fiscal_position_id.map_account(account) | |||
|
|||
is_refund = line.qty * line.price_unit < 0 | |||
is_refund = -line.qty * line.price_unit < 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are breaking everything with that. Let's start from the beginning:
The line of a pos order are already signed (+ for a sale, - for a refund (negative quantity)).
It's a refund if the line is negative so this line is completely correct, remove your diff!
Below (L671), you see quantity=-line.qty,
. This is because for a sale, the product and tax lines need accounting journal items in credit.
When asking for an invoice after the closing of the POS entry, you enter _create_misc_reversal_move
(L801).
In this method, we call _prepare_aml_values_list_per_nature
and then we reverse the accounting amounts.
Here is the error!
The refund is not considered as a refund since the pos order is always the same.
Instead, add an extra sign=1
parameter (named that way because there is one in the following versions because of Mexico).
Then:
is_refund = line.qty * line.price_unit * sign < 0
and
quantity=-line.qty * sign,
and you can remove the reverse of accounting amounts:
aml_values['balance'] = -aml_values['balance']
aml_values['amount_currency'] = -aml_values['amount_currency']
and call _prepare_aml_values_list_per_nature
with sign=-1
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agr-odoo Forget everything in the comment above. Instead, let's force the inverse_tax_tags
field as:
inverse_tax_tags = not is_refund
On the 2 loops below, force this value (L684 & L704):
# Create the tax lines
for tax_line_vals in tax_results['tax_lines_to_add']:
tax_rep = self.env['account.tax.repartition.line'].browse(tax_line_vals['tax_repartition_line_id'])
amount_currency = tax_line_vals['tax_amount']
balance = company_currency.round(amount_currency * rate)
aml_vals_list_per_nature['tax'].append({
'name': tax_rep.tax_id.name,
'account_id': tax_line_vals['account_id'],
'partner_id': tax_line_vals['partner_id'],
'currency_id': tax_line_vals['currency_id'],
'tax_repartition_line_id': tax_line_vals['tax_repartition_line_id'],
'tax_ids': tax_line_vals['tax_ids'],
'tax_tag_ids': tax_line_vals['tax_tag_ids'],
'group_tax_id': None if tax_rep.tax_id.id == tax_line_vals['tax_id'] else tax_line_vals['tax_id'],
'amount_currency': amount_currency,
'balance': balance,
'inverse_tax_tags': inverse_tax_tags, # <- HERE
})
total_amount_currency += amount_currency
total_balance += balance
# Create the aml values for order lines.
for base_line_vals, update_base_line_vals in tax_results['base_lines_to_update']:
order_line = base_line_vals['record']
amount_currency = update_base_line_vals['price_subtotal']
balance = company_currency.round(amount_currency * rate)
aml_vals_list_per_nature['product'].append({
'name': order_line.full_product_name,
'account_id': base_line_vals['account'].id,
'partner_id': base_line_vals['partner'].id,
'currency_id': base_line_vals['currency'].id,
'tax_ids': [(6, 0, base_line_vals['taxes'].ids)],
'tax_tag_ids': update_base_line_vals['tax_tag_ids'],
'amount_currency': amount_currency,
'balance': balance,
'inverse_tax_tags': inverse_tax_tags, # <- HERE
})
total_amount_currency += amount_currency
total_balance += balance
f08442d
to
c4df718
Compare
c4df718
to
7953116
Compare
7953116
to
c4d2bf5
Compare
With BE localization Enable 'Use QR code on ticket' in Settings Open POS Session Add a Product with 21% Tax Pay > Save QR link for later Close Pos session Access QR link, generate invoice Check Accounting>Reporting>Tax Report Issue: Line '03 - Operations subject to 21% VAT' will account twice the product amount instead of canceling it This occurs because when reverting the POS closing entry we create an entry having amounts with inverted signs but same tax tags as the original invoice. opw-3815770 opw-3821017 opw-3869363 Co-authored-by: Laurent Smet (las) <las@odoo.com>
c4d2bf5
to
2c5d066
Compare
@robodoo r+ |
With BE localization Enable 'Use QR code on ticket' in Settings Open POS Session Add a Product with 21% Tax Pay > Save QR link for later Close Pos session Access QR link, generate invoice Check Accounting>Reporting>Tax Report Issue: Line '03 - Operations subject to 21% VAT' will account twice the product amount instead of canceling it This occurs because when reverting the POS closing entry we create an entry having amounts with inverted signs but same tax tags as the original invoice. opw-3815770 opw-3821017 opw-3869363 closes #161531 Signed-off-by: Laurent Smet (las) <las@odoo.com> Co-authored-by: Laurent Smet (las) <las@odoo.com>
With BE localization Enable 'Use QR code on ticket' in Settings Open POS Session Add a Product with 21% Tax Pay > Save QR link for later Close Pos session Access QR link, generate invoice Check Accounting>Reporting>Tax Report Issue: Line '03 - Operations subject to 21% VAT' will account twice the product amount instead of canceling it This occurs because when reverting the POS closing entry we create an entry having amounts with inverted signs but same tax tags as the original invoice. opw-3815770 opw-3821017 opw-3869363 closes odoo#161531 Signed-off-by: Laurent Smet (las) <las@odoo.com> Co-authored-by: Laurent Smet (las) <las@odoo.com>
With BE localization
Enable 'Use QR code on ticket' in Settings
Open POS Session
Add a Product with 21% Tax
Pay > Save QR link for later
Close Pos session
Access QR link, generate invoice
Check Accounting>Reporting>Tax Report
Issue: Line '03 - Operations subject to 21% VAT' will account twice
the product amount instead of canceling it
This occurs because when reverting the POS closing entry we create an
entry having amounts with inverted signs and same tax tags. We also need
to set the flag
tax_tag_invert
to ensure the amount correctlyaccounted as reverse
opw-3815770
opw-3821017