Add payment term date in invoice
issue9956 review292961002
This commit is contained in:
1 parent
cb0e0d04e5
commit
de0b29b7bf
5 files changed
+35
-4
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Add payment term date in invoice
|
||||
* Raise warning on invoice with maturity dates on the past
|
||||
* Remove foreign key for sequence of Invoice
|
||||
* Add summary to invoice line list
|
||||
* Add default customer payment term configuration
|
||||
|
||||
+5
-1
@@ -1,7 +1,7 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.exceptions import UserError, UserWarning
|
||||
from trytond.model.exceptions import ValidationError
|
||||
|
||||
|
||||
@@ -31,3 +31,7 @@ class InvoiceLineValidationError(ValidationError):
|
||||
|
||||
class PayInvoiceError(UserError):
|
||||
pass
|
||||
|
||||
|
||||
class InvoicePaymentTermDateWarning(UserWarning):
|
||||
pass
|
||||
+22
-3
@@ -29,7 +29,7 @@ from trytond.modules.product import price_digits
|
||||
|
||||
from .exceptions import (
|
||||
InvoiceTaxValidationError, InvoiceNumberError, InvoiceValidationError,
|
||||
InvoiceLineValidationError, PayInvoiceError)
|
||||
InvoiceLineValidationError, PayInvoiceError, InvoicePaymentTermDateWarning)
|
||||
|
||||
if config.getboolean('account_invoice', 'filestore', default=False):
|
||||
file_id = 'invoice_report_cache_id'
|
||||
@@ -94,6 +94,10 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
depends=['state'])
|
||||
accounting_date = fields.Date('Accounting Date', states=_states,
|
||||
depends=_depends)
|
||||
payment_term_date = fields.Date(
|
||||
"Payment Term Date", states=_states, depends=_depends,
|
||||
help="The date from which the payment term is calculated.\n"
|
||||
"Leave empty to use the invoice date.")
|
||||
sequence = fields.Integer("Sequence", readonly=True)
|
||||
party = fields.Many2One('party.party', 'Party',
|
||||
required=True, states=_states, depends=_depends)
|
||||
@@ -939,6 +943,10 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
Move = pool.get('account.move')
|
||||
Period = pool.get('account.period')
|
||||
Date = pool.get('ir.date')
|
||||
Warning = pool.get('res.user.warning')
|
||||
Lang = pool.get('ir.lang')
|
||||
|
||||
today = Date.today()
|
||||
|
||||
if self.move:
|
||||
return self.move
|
||||
@@ -956,12 +964,23 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
if line.amount_second_currency:
|
||||
total_currency += line.amount_second_currency
|
||||
|
||||
term_lines = [(Date.today(), total)]
|
||||
term_lines = [(self.payment_term_date or today, total)]
|
||||
if self.payment_term:
|
||||
payment_date = self.payment_term_date or self.invoice_date
|
||||
term_lines = self.payment_term.compute(
|
||||
total, self.company.currency, self.invoice_date)
|
||||
total, self.company.currency, payment_date)
|
||||
remainder_total_currency = total_currency
|
||||
for date, amount in term_lines:
|
||||
if date < today:
|
||||
lang = Lang.get()
|
||||
warning_key = 'invoice_payment_term_%d' % self.id
|
||||
if Warning.check(warning_key):
|
||||
raise InvoicePaymentTermDateWarning(warning_key,
|
||||
gettext('account_invoice'
|
||||
'.msg_invoice_payment_term_date_past',
|
||||
invoice=self.rec_name,
|
||||
date=lang.strftime(date)))
|
||||
|
||||
line = self._get_move_line(date, amount)
|
||||
if line.amount_second_currency:
|
||||
remainder_total_currency += line.amount_second_currency
|
||||
|
||||
@@ -66,6 +66,9 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.message" id="msg_invoice_payment_line_unique">
|
||||
<field name="text">A payment line can be linked to only one invoice.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_invoice_payment_term_date_past">
|
||||
<field name="text">The invoice "%(invoice)s" generates a payment date "%(date)s" in the past.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
||||
@@ -66,6 +66,9 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="comment" colspan="4"/>
|
||||
</page>
|
||||
<page string="Payment" id="payment">
|
||||
<label name="payment_term_date"/>
|
||||
<field name="payment_term_date"/>
|
||||
<newline/>
|
||||
<label name="amount_to_pay_today"/>
|
||||
<field name="amount_to_pay_today" symbol="currency"/>
|
||||
<label name="amount_to_pay"/>
|
||||
|
||||
Reference in new issue
Block a user