Allow scheduling payments on their line maturity dates

issue9073
review271051002
This commit is contained in:
Sergi Almacellas Abellana committed 2020-03-17 10:08:41 +01:00
1 parent 20d584075b
commit 18fdb0b4b2
4 files changed
+113 -11

No files matched your search

+2
View File
@@ -1,3 +1,5 @@
* Allow scheduling payments on their line maturity dates
Version 5.4.0 - 2019-11-04
* Bug fixes (see mercurial logs for details)
+9 -11
View File
@@ -184,14 +184,9 @@ class PayLineStart(ModelView):
"Pay Line"
__name__ = 'account.move.line.pay.start'
date = fields.Date(
"Date", required=True,
help="When the payments are scheduled to happen.")
@classmethod
def default_date(cls):
pool = Pool()
Date = pool.get('ir.date')
return Date.today()
"Date",
help="When the payments are scheduled to happen.\n"
"Leave empty to use the lines' maturity dates.")
class PayLineAskJournal(ModelView):
@@ -339,16 +334,19 @@ class PayLine(Wizard):
else:
kind = 'payable'
journal = journals[self._get_journal_key(line)]
return Payment(
payment = Payment(
company=line.move.company,
journal=journal,
party=line.party,
kind=kind,
amount=line.payment_amount,
line=line,
date=self.start.date,
)
date = self.start.date or line.maturity_date
# Use default value when empty
if date:
payment.date = date
return payment
def do_pay(self, action):
pool = Pool()
@@ -0,0 +1,97 @@
=========================
Payment Planning Scenario
=========================
Imports::
>>> import datetime
>>> from decimal import Decimal
>>> from proteus import Model, Wizard
>>> 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
>>> today = datetime.date.today()
>>> tomorrow = today + datetime.timedelta(days=1)
>>> next_week = today + datetime.timedelta(weeks=1)
Install account_payment::
>>> config = activate_modules('account_payment')
Create company::
>>> _ = create_company()
>>> company = get_company()
Create fiscal year::
>>> fiscalyear = create_fiscalyear(company)
>>> fiscalyear.click('create_period')
Create chart of accounts::
>>> _ = create_chart(company)
>>> accounts = get_accounts(company)
>>> payable = accounts['payable']
>>> Journal = Model.get('account.journal')
>>> expense, = Journal.find([('code', '=', 'EXP')])
Create payment journal::
>>> PaymentJournal = Model.get('account.payment.journal')
>>> payment_journal = PaymentJournal(name='Manual',
... process_method='manual')
>>> payment_journal.save()
Create parties::
>>> Party = Model.get('party.party')
>>> supplier = Party(name='Supplier')
>>> supplier.save()
Create payable move::
>>> Move = Model.get('account.move')
>>> move = Move()
>>> move.journal = expense
>>> line = move.lines.new(account=payable, party=supplier,
... credit=Decimal('50.00'), maturity_date=next_week)
>>> line = move.lines.new(account=expense, debit=Decimal('50.00'))
>>> move.click('post')
Paying the line without date uses the maturity date::
>>> Payment = Model.get('account.payment')
>>> line, = [l for l in move.lines if l.account == payable]
>>> pay_line = Wizard('account.move.line.pay', [line])
>>> pay_line.execute('next_')
>>> pay_line.execute('next_')
>>> payment, = Payment.find()
>>> payment.date == next_week
True
The date on the payment wizard is used for payment date::
>>> payment.delete()
>>> pay_line = Wizard('account.move.line.pay', [line])
>>> pay_line.form.date = tomorrow
>>> pay_line.execute('next_')
>>> pay_line.execute('next_')
>>> payment, = Payment.find()
>>> payment.date == tomorrow
True
If the line does not have any maturity date it is scheduled for today::
>>> payment.delete()
>>> line.maturity_date = None
>>> line.save()
>>> pay_line = Wizard('account.move.line.pay', [line])
>>> pay_line.execute('next_')
>>> pay_line.execute('next_')
>>> payment, = line.payments
>>> payment.date == today
True
+5
View File
@@ -26,4 +26,9 @@ def suite():
tearDown=doctest_teardown, encoding='utf-8',
checker=doctest_checker,
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
suite.addTests(doctest.DocFileSuite(
'scenario_account_payment_planning.rst',
tearDown=doctest_teardown, encoding='utf-8',
checker=doctest_checker,
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
return suite