Create base tax line for manual taxes
issue10429 review340811002
This commit is contained in:
1 parent
f3659b2874
commit
5b6a13bb4c
4 files changed
+105
-1
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Create base tax line for manual taxes
|
||||
|
||||
Version 6.0.0 - 2021-05-03
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
* Allow using debt accounts on supplier invoices
|
||||
|
||||
+12
-1
@@ -2648,10 +2648,13 @@ class InvoiceTax(sequence_ordered(), ModelSQL, ModelView):
|
||||
with Transaction().set_context(date=self.invoice.currency_date):
|
||||
amount = Currency.compute(self.invoice.currency, self.amount,
|
||||
self.invoice.company.currency)
|
||||
base = Currency.compute(self.invoice.currency, self.base,
|
||||
self.invoice.company.currency)
|
||||
line.amount_second_currency = self.amount
|
||||
line.second_currency = self.invoice.currency
|
||||
else:
|
||||
amount = self.amount
|
||||
base = self.base
|
||||
line.amount_second_currency = None
|
||||
line.second_currency = None
|
||||
if amount >= 0:
|
||||
@@ -2673,11 +2676,19 @@ class InvoiceTax(sequence_ordered(), ModelSQL, ModelView):
|
||||
line.party = self.invoice.party
|
||||
line.origin = self
|
||||
if self.tax:
|
||||
tax_lines = []
|
||||
tax_line = TaxLine()
|
||||
tax_line.amount = amount
|
||||
tax_line.type = 'tax'
|
||||
tax_line.tax = self.tax
|
||||
line.tax_lines = [tax_line]
|
||||
tax_lines.append(tax_line)
|
||||
if self.manual:
|
||||
tax_line = TaxLine()
|
||||
tax_line.amount = base
|
||||
tax_line.type = 'base'
|
||||
tax_line.tax = self.tax
|
||||
tax_lines.append(tax_line)
|
||||
line.tax_lines = tax_lines
|
||||
return [line]
|
||||
|
||||
def _credit(self):
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
==================
|
||||
Invoice Manual Tax
|
||||
==================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> from decimal import Decimal
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
>>> from trytond.modules.company.tests.tools import (
|
||||
... create_company, get_company)
|
||||
>>> from trytond.modules.account.tests.tools import (
|
||||
... create_fiscalyear, create_chart, get_accounts, create_tax,
|
||||
... create_tax_code)
|
||||
>>> from trytond.modules.account_invoice.tests.tools import (
|
||||
... set_fiscalyear_invoice_sequences)
|
||||
>>> today = dt.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('account_invoice')
|
||||
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> TaxCode = Model.get('account.tax.code')
|
||||
|
||||
Create company::
|
||||
|
||||
>>> _ = create_company()
|
||||
>>> company = get_company()
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear(company))
|
||||
>>> fiscalyear.click('create_period')
|
||||
>>> period_ids = [p.id for p in fiscalyear.periods]
|
||||
|
||||
Create chart of accounts::
|
||||
|
||||
>>> _ = create_chart(company)
|
||||
>>> accounts = get_accounts(company)
|
||||
|
||||
Create tax::
|
||||
|
||||
>>> tax = create_tax(Decimal('.10'))
|
||||
>>> tax.save()
|
||||
>>> invoice_base_code = create_tax_code(tax, 'base', 'invoice')
|
||||
>>> invoice_base_code.save()
|
||||
>>> invoice_tax_code = create_tax_code(tax, 'tax', 'invoice')
|
||||
>>> invoice_tax_code.save()
|
||||
|
||||
Create party::
|
||||
|
||||
>>> party = Party(name="Party")
|
||||
>>> party.save()
|
||||
|
||||
Post a supplier invoice with manual taxes::
|
||||
|
||||
>>> invoice = Invoice(type='in')
|
||||
>>> invoice.party = party
|
||||
>>> invoice.invoice_date = today
|
||||
>>> tax_line = invoice.taxes.new()
|
||||
>>> bool(tax_line.manual)
|
||||
True
|
||||
>>> tax_line.tax = tax
|
||||
>>> tax_line.base = Decimal('100')
|
||||
>>> tax_line.amount
|
||||
Decimal('10.00')
|
||||
>>> invoice.untaxed_amount, invoice.tax_amount, invoice.total_amount
|
||||
(Decimal('0.00'), Decimal('10.00'), Decimal('10.00'))
|
||||
|
||||
Post invoice and check tax codes::
|
||||
|
||||
>>> invoice.click('post')
|
||||
>>> invoice.untaxed_amount, invoice.tax_amount, invoice.total_amount
|
||||
(Decimal('0.00'), Decimal('10.00'), Decimal('10.00'))
|
||||
|
||||
>>> with config.set_context(periods=period_ids):
|
||||
... invoice_base_code = TaxCode(invoice_base_code.id)
|
||||
... invoice_base_code.amount
|
||||
Decimal('100.00')
|
||||
>>> with config.set_context(periods=period_ids):
|
||||
... invoice_tax_code = TaxCode(invoice_tax_code.id)
|
||||
... invoice_tax_code.amount
|
||||
Decimal('10.00')
|
||||
@@ -315,4 +315,8 @@ def suite():
|
||||
tearDown=doctest_teardown, encoding='utf-8',
|
||||
checker=doctest_checker,
|
||||
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
|
||||
suite.addTests(doctest.DocFileSuite('scenario_invoice_manual_tax.rst',
|
||||
tearDown=doctest_teardown, encoding='utf-8',
|
||||
checker=doctest_checker,
|
||||
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
|
||||
return suite
|
||||
Reference in new issue
Block a user