Sergi Almacellas Abellana pushed to branch branch/default at Tryton / Tryton
Commits:
5e030b91 by Sergi Almacellas Abellana at 2023-01-02T16:01:13+01:00
Skip blocked payments when creating direct debits
Closes #11983
- - - - -
3 changed files:
- modules/account_payment/CHANGELOG
- modules/account_payment/account.py
- +
modules/account_payment/tests/scenario_account_payment_blocked_direct_debit.rst
Changes:
=====================================
modules/account_payment/CHANGELOG
=====================================
@@ -1,3 +1,5 @@
+* Skip blocked payments when creating direct debits
+
Version 6.6.0 - 2022-10-31
--------------------------
* Bug fixes (see mercurial logs for details)
=====================================
modules/account_payment/account.py
=====================================
@@ -200,6 +200,7 @@
('credit', '<', 0),
],
('maturity_date', '<=', date),
+ ('payment_blocked', '!=', True),
]
@classmethod
=====================================
modules/account_payment/tests/scenario_account_payment_blocked_direct_debit.rst
=====================================
@@ -0,0 +1,88 @@
+=====================================
+Payment Blocked Direct Debit Scenario
+=====================================
+
+Imports::
+
+ >>> import datetime as dt
+ >>> 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 = dt.date.today()
+
+Activate modules::
+
+ >>> config = activate_modules('account_payment')
+
+ >>> Journal = Model.get('account.journal')
+ >>> Line = Model.get('account.move.line')
+ >>> Move = Model.get('account.move')
+ >>> Party = Model.get('party.party')
+ >>> Payment = Model.get('account.payment')
+ >>> PaymentJournal = Model.get('account.payment.journal')
+
+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)
+
+ >>> revnue_journal, = Journal.find([('code', '=', 'REV')])
+
+Create payment journal::
+
+ >>> payment_journal = PaymentJournal(
+ ... name="Manual", process_method='manual')
+ >>> payment_journal.save()
+
+Create parties::
+
+ >>> customer = Party(name="Customer")
+ >>> _ = customer.reception_direct_debits.new(journal=payment_journal)
+ >>> customer.save()
+
+Create receivable moves::
+
+ >>> move = Move()
+ >>> move.journal = revnue_journal
+ >>> line = move.lines.new(
+ ... account=accounts['receivable'], party=customer,
+ ... debit=Decimal('100.00'), maturity_date=today)
+ >>> line = move.lines.new(
+ ... account=accounts['revenue'],
+ ... credit=Decimal('100.00'))
+ >>> move.click('post')
+
+Direct debit is not created when payment blocked::
+
+ >>> line, = Line.find([('party', '=', customer.id)])
+ >>> line.click('payment_block')
+ >>> create_direct_debit = Wizard('account.move.line.create_direct_debit')
+ >>> create_direct_debit.form.date = today
+ >>> create_direct_debit.execute('create_')
+ >>> len(Payment.find([]))
+ 0
+
+Direct debit is created when payment is unblocked::
+
+ >>> line.click('payment_unblock')
+ >>> create_direct_debit = Wizard('account.move.line.create_direct_debit')
+ >>> create_direct_debit.form.date = today
+ >>> create_direct_debit.execute('create_')
+ >>> len(Payment.find([]))
+ 1
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/5e030b91f97ff38783aabf3820313f5a1730f0f2
--
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/5e030b91f97ff38783aabf3820313f5a1730f0f2
You're receiving this email because of your account on foss.heptapod.net.