Drop support of Python 2.6
review2691002
This commit is contained in:
@@ -4,7 +4,7 @@ Installing trytond_account_invoice
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
* Python 2.6 or later (http://www.python.org/)
|
||||
* Python 2.7 or later (http://www.python.org/)
|
||||
* python-dateutil (http://labix.org/python-dateutil)
|
||||
* python-sql (http://code.google.com/p/python-sql/)
|
||||
* trytond (http://www.tryton.org/)
|
||||
|
||||
+13
@@ -544,6 +544,7 @@ class Invoice(Workflow, ModelSQL, ModelView):
|
||||
type_name = cls.tax_amount._field.sql_type().base
|
||||
in_max = cursor.IN_MAX
|
||||
tax = InvoiceTax.__table__()
|
||||
to_round = False
|
||||
for i in range(0, len(invoices), in_max):
|
||||
sub_ids = [i.id for i in invoices[i:i + in_max]]
|
||||
red_sql = reduce_ids(tax.invoice, sub_ids)
|
||||
@@ -555,7 +556,13 @@ class Invoice(Workflow, ModelSQL, ModelView):
|
||||
# SQLite uses float for SUM
|
||||
if not isinstance(sum_, Decimal):
|
||||
sum_ = Decimal(str(sum_))
|
||||
to_round = True
|
||||
tax_amount[invoice_id] = sum_
|
||||
# Float amount must be rounded to get the right precision
|
||||
if to_round:
|
||||
for invoice in invoices:
|
||||
tax_amount[invoice.id] = invoice.currency.round(
|
||||
tax_amount[invoice.id])
|
||||
|
||||
invoices_move = []
|
||||
invoices_no_move = []
|
||||
@@ -571,6 +578,7 @@ class Invoice(Workflow, ModelSQL, ModelView):
|
||||
invoice = cls.__table__()
|
||||
move = Move.__table__()
|
||||
line = MoveLine.__table__()
|
||||
to_round = False
|
||||
for i in range(0, len(invoices_move), in_max):
|
||||
sub_ids = [i.id for i in invoices_move[i:i + in_max]]
|
||||
red_sql = reduce_ids(invoice.id, sub_ids)
|
||||
@@ -585,11 +593,16 @@ class Invoice(Workflow, ModelSQL, ModelView):
|
||||
# SQLite uses float for SUM
|
||||
if not isinstance(sum_, Decimal):
|
||||
sum_ = Decimal(str(sum_))
|
||||
to_round = True
|
||||
total_amount[invoice_id] = sum_
|
||||
|
||||
for invoice in invoices_move:
|
||||
if invoice.type in ('in_invoice', 'out_credit_note'):
|
||||
total_amount[invoice.id] *= -1
|
||||
# Float amount must be rounded to get the right precision
|
||||
if to_round:
|
||||
total_amount[invoice.id] = invoice.currency.round(
|
||||
total_amount[invoice.id])
|
||||
untaxed_amount[invoice.id] = (
|
||||
total_amount[invoice.id] - tax_amount[invoice.id])
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ setup(name='trytond_account_invoice',
|
||||
'Natural Language :: Slovenian',
|
||||
'Natural Language :: Spanish',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python :: 2.6',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Topic :: Office/Business',
|
||||
'Topic :: Office/Business :: Financial :: Accounting',
|
||||
|
||||
+52
-46
@@ -192,47 +192,50 @@ Create invoice::
|
||||
>>> line.description = 'Test'
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal(20)
|
||||
>>> invoice.untaxed_amount == Decimal(220)
|
||||
True
|
||||
>>> invoice.tax_amount == Decimal(20)
|
||||
True
|
||||
>>> invoice.total_amount == Decimal(240)
|
||||
True
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('220.00')
|
||||
>>> invoice.tax_amount
|
||||
Decimal('20.00')
|
||||
>>> invoice.total_amount
|
||||
Decimal('240.00')
|
||||
>>> invoice.save()
|
||||
>>> Invoice.post([invoice.id], config.context)
|
||||
>>> invoice.reload()
|
||||
>>> invoice.state
|
||||
u'posted'
|
||||
>>> invoice.untaxed_amount == Decimal(220)
|
||||
True
|
||||
>>> invoice.tax_amount == Decimal(20)
|
||||
True
|
||||
>>> invoice.total_amount == Decimal(240)
|
||||
True
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('220.00')
|
||||
>>> invoice.tax_amount
|
||||
Decimal('20.00')
|
||||
>>> invoice.total_amount
|
||||
Decimal('240.00')
|
||||
>>> receivable.reload()
|
||||
>>> (receivable.debit, receivable.credit) == \
|
||||
... (Decimal(240), Decimal(0))
|
||||
True
|
||||
>>> receivable.debit
|
||||
Decimal('240.00')
|
||||
>>> receivable.credit
|
||||
Decimal('0.00')
|
||||
>>> revenue.reload()
|
||||
>>> (revenue.debit, revenue.credit) == \
|
||||
... (Decimal(0), Decimal(220))
|
||||
True
|
||||
>>> revenue.debit
|
||||
Decimal('0.00')
|
||||
>>> revenue.credit
|
||||
Decimal('220.00')
|
||||
>>> account_tax.reload()
|
||||
>>> (account_tax.debit, account_tax.credit) == \
|
||||
... (Decimal(0), Decimal(20))
|
||||
True
|
||||
>>> account_tax.debit
|
||||
Decimal('0.00')
|
||||
>>> account_tax.credit
|
||||
Decimal('20.00')
|
||||
>>> invoice_base_code.reload()
|
||||
>>> invoice_base_code.sum == Decimal(200)
|
||||
True
|
||||
>>> invoice_base_code.sum
|
||||
Decimal('200.00')
|
||||
>>> invoice_tax_code.reload()
|
||||
>>> invoice_tax_code.sum == Decimal(20)
|
||||
True
|
||||
>>> invoice_tax_code.sum
|
||||
Decimal('20.00')
|
||||
>>> credit_note_base_code.reload()
|
||||
>>> credit_note_base_code.sum == Decimal(0)
|
||||
True
|
||||
>>> credit_note_base_code.sum
|
||||
Decimal('0.00')
|
||||
>>> credit_note_tax_code.reload()
|
||||
>>> credit_note_tax_code.sum == Decimal(0)
|
||||
True
|
||||
>>> credit_note_tax_code.sum
|
||||
Decimal('0.00')
|
||||
|
||||
Credit invoice with refund::
|
||||
|
||||
@@ -243,29 +246,32 @@ Credit invoice with refund::
|
||||
>>> invoice.state
|
||||
u'paid'
|
||||
>>> receivable.reload()
|
||||
>>> (receivable.debit, receivable.credit) == \
|
||||
... (Decimal(240), Decimal(240))
|
||||
True
|
||||
>>> receivable.debit
|
||||
Decimal('240.00')
|
||||
>>> receivable.credit
|
||||
Decimal('240.00')
|
||||
>>> revenue.reload()
|
||||
>>> (revenue.debit, revenue.credit) == \
|
||||
... (Decimal(220), Decimal(220))
|
||||
True
|
||||
>>> revenue.debit
|
||||
Decimal('220.00')
|
||||
>>> revenue.credit
|
||||
Decimal('220.00')
|
||||
>>> account_tax.reload()
|
||||
>>> (account_tax.debit, account_tax.credit) == \
|
||||
... (Decimal(20), Decimal(20))
|
||||
True
|
||||
>>> account_tax.debit
|
||||
Decimal('20.00')
|
||||
>>> account_tax.credit
|
||||
Decimal('20.00')
|
||||
>>> invoice_base_code.reload()
|
||||
>>> invoice_base_code.sum == Decimal(200)
|
||||
True
|
||||
>>> invoice_base_code.sum
|
||||
Decimal('200.00')
|
||||
>>> invoice_tax_code.reload()
|
||||
>>> invoice_tax_code.sum == Decimal(20)
|
||||
True
|
||||
>>> invoice_tax_code.sum
|
||||
Decimal('20.00')
|
||||
>>> credit_note_base_code.reload()
|
||||
>>> credit_note_base_code.sum == Decimal(200)
|
||||
True
|
||||
>>> credit_note_base_code.sum
|
||||
Decimal('200.00')
|
||||
>>> credit_note_tax_code.reload()
|
||||
>>> credit_note_tax_code.sum == Decimal(20)
|
||||
True
|
||||
>>> credit_note_tax_code.sum
|
||||
Decimal('20.00')
|
||||
|
||||
Create empty invoice::
|
||||
|
||||
|
||||
@@ -191,47 +191,50 @@ Create invoice::
|
||||
>>> line.description = 'Test'
|
||||
>>> line.quantity = 1
|
||||
>>> line.unit_price = Decimal(10)
|
||||
>>> invoice.untaxed_amount == Decimal(110)
|
||||
True
|
||||
>>> invoice.tax_amount == Decimal(10)
|
||||
True
|
||||
>>> invoice.total_amount == Decimal(120)
|
||||
True
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('110.00')
|
||||
>>> invoice.tax_amount
|
||||
Decimal('10.00')
|
||||
>>> invoice.total_amount
|
||||
Decimal('120.00')
|
||||
>>> invoice.save()
|
||||
>>> Invoice.post([invoice.id], config.context)
|
||||
>>> invoice.reload()
|
||||
>>> invoice.state
|
||||
u'posted'
|
||||
>>> invoice.untaxed_amount == Decimal(110)
|
||||
True
|
||||
>>> invoice.tax_amount == Decimal(10)
|
||||
True
|
||||
>>> invoice.total_amount == Decimal(120)
|
||||
True
|
||||
>>> invoice.untaxed_amount
|
||||
Decimal('110.00')
|
||||
>>> invoice.tax_amount
|
||||
Decimal('10.00')
|
||||
>>> invoice.total_amount
|
||||
Decimal('120.00')
|
||||
>>> payable.reload()
|
||||
>>> (payable.debit, payable.credit) == \
|
||||
... (Decimal(0), Decimal(120))
|
||||
True
|
||||
>>> payable.debit
|
||||
Decimal('0.00')
|
||||
>>> payable.credit
|
||||
Decimal('120.00')
|
||||
>>> expense.reload()
|
||||
>>> (expense.debit, expense.credit) == \
|
||||
... (Decimal(110), Decimal(0))
|
||||
True
|
||||
>>> expense.debit
|
||||
Decimal('110.00')
|
||||
>>> expense.credit
|
||||
Decimal('0.00')
|
||||
>>> account_tax.reload()
|
||||
>>> (account_tax.debit, account_tax.credit) == \
|
||||
... (Decimal(10), Decimal(0))
|
||||
True
|
||||
>>> account_tax.debit
|
||||
Decimal('10.00')
|
||||
>>> account_tax.credit
|
||||
Decimal('0.00')
|
||||
>>> invoice_base_code.reload()
|
||||
>>> invoice_base_code.sum == Decimal(100)
|
||||
True
|
||||
>>> invoice_base_code.sum
|
||||
Decimal('100.00')
|
||||
>>> invoice_tax_code.reload()
|
||||
>>> invoice_tax_code.sum == Decimal(10)
|
||||
True
|
||||
>>> invoice_tax_code.sum
|
||||
Decimal('10.00')
|
||||
>>> credit_note_base_code.reload()
|
||||
>>> credit_note_base_code.sum == Decimal(0)
|
||||
True
|
||||
>>> credit_note_base_code.sum
|
||||
Decimal('0.00')
|
||||
>>> credit_note_tax_code.reload()
|
||||
>>> credit_note_tax_code.sum == Decimal(0)
|
||||
True
|
||||
>>> credit_note_tax_code.sum
|
||||
Decimal('0.00')
|
||||
|
||||
Credit invoice::
|
||||
|
||||
|
||||
Reference in New Issue
Block a user