adapt to 5.1, not finished
This commit is contained in:
parent
8b33fedfa6
commit
fa277c1d45
12
payment.py
12
payment.py
|
@ -11,9 +11,8 @@ from trytond.transaction import Transaction
|
|||
__all__ = ['Journal', 'Payment']
|
||||
|
||||
|
||||
class Journal:
|
||||
class Journal(metaclass=PoolMeta):
|
||||
__name__ = 'account.payment.journal'
|
||||
__metaclass__ = PoolMeta
|
||||
processing_account = fields.Many2One('account.account',
|
||||
'Processing Account', states={
|
||||
'required': Bool(Eval('processing_journal')),
|
||||
|
@ -26,9 +25,8 @@ class Journal:
|
|||
depends=['processing_account'])
|
||||
|
||||
|
||||
class Payment:
|
||||
class Payment(metaclass=PoolMeta):
|
||||
__name__ = 'account.payment'
|
||||
__metaclass__ = PoolMeta
|
||||
processing_move = fields.Many2One('account.move', 'Processing Move',
|
||||
readonly=True)
|
||||
|
||||
|
@ -61,7 +59,7 @@ class Payment:
|
|||
if l.account == payment.line.account] + [payment.line]
|
||||
if not sum(l.debit - l.credit for l in lines):
|
||||
to_reconcile[payment.party].extend(lines)
|
||||
for lines in to_reconcile.itervalues():
|
||||
for lines in list(to_reconcile.values()):
|
||||
Line.reconcile(lines)
|
||||
|
||||
return group
|
||||
|
@ -159,7 +157,7 @@ class Payment:
|
|||
line.account.id,
|
||||
line.party.id if line.party else None)
|
||||
to_reconcile[key].append(line)
|
||||
for lines in to_reconcile.itervalues():
|
||||
for lines in list(to_reconcile.values()):
|
||||
if not sum((l.debit - l.credit) for l in lines):
|
||||
Line.reconcile(lines)
|
||||
|
||||
|
@ -212,7 +210,7 @@ class Payment:
|
|||
if to_post:
|
||||
Move.post(to_post)
|
||||
for party in to_reconcile:
|
||||
for lines in to_reconcile[party].itervalues():
|
||||
for lines in list(to_reconcile[party].values()):
|
||||
Line.reconcile(lines)
|
||||
|
||||
cls.write(payments, {'processing_move': None})
|
||||
|
|
4
setup.py
4
setup.py
|
@ -4,7 +4,7 @@
|
|||
from setuptools import setup
|
||||
import re
|
||||
import os
|
||||
import ConfigParser
|
||||
import configparser
|
||||
|
||||
MODULE = 'account_payment_processing'
|
||||
PREFIX = 'nantic'
|
||||
|
@ -24,7 +24,7 @@ def get_require_version(name):
|
|||
major_version, minor_version + 1)
|
||||
return require
|
||||
|
||||
config = ConfigParser.ConfigParser()
|
||||
config = configparser.ConfigParser()
|
||||
config.readfp(open('tryton.cfg'))
|
||||
info = dict(config.items('tryton'))
|
||||
for key in ('depends', 'extras_depend', 'xml'):
|
||||
|
|
|
@ -9,9 +9,8 @@ from trytond.pool import Pool, PoolMeta
|
|||
__all__ = ['StatementMoveLine']
|
||||
|
||||
|
||||
class StatementMoveLine:
|
||||
class StatementMoveLine(metaclass=PoolMeta):
|
||||
__name__ = 'account.bank.statement.move.line'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
@fields.depends('invoice', 'payment')
|
||||
def on_change_invoice(self):
|
||||
|
@ -66,6 +65,6 @@ class StatementMoveLine:
|
|||
line.account.id,
|
||||
line.party.id if line.party else None)
|
||||
to_reconcile[key].append(line)
|
||||
for lines in to_reconcile.itervalues():
|
||||
for lines in list(to_reconcile.values()):
|
||||
if not sum((l.debit - l.credit) for l in lines):
|
||||
MoveLine.reconcile(lines)
|
||||
|
|
|
@ -59,8 +59,7 @@ Create chart of accounts::
|
|||
... bank_reconcile=True,
|
||||
... reconcile=True,
|
||||
... party_required=True,
|
||||
... deferral=True,
|
||||
... kind='other')
|
||||
... deferral=True)
|
||||
>>> customer_processing_payments.save()
|
||||
>>> customer_bank_discounts = Account(
|
||||
... name='Customers Bank Discount',
|
||||
|
@ -68,8 +67,7 @@ Create chart of accounts::
|
|||
... bank_reconcile=True,
|
||||
... reconcile=True,
|
||||
... party_required=False,
|
||||
... deferral=True,
|
||||
... kind='other')
|
||||
... deferral=True)
|
||||
>>> customer_bank_discounts.save()
|
||||
|
||||
Create and get journals::
|
||||
|
@ -82,10 +80,15 @@ Create and get journals::
|
|||
>>> bank_journal = AccountJournal(
|
||||
... name='Bank Statement',
|
||||
... type='cash',
|
||||
... credit_account=account_cash,
|
||||
... debit_account=account_cash,
|
||||
... sequence=sequence)
|
||||
>>> bank_journal.save()
|
||||
>>> PaymentMethod = Model.get('account.invoice.payment.method')
|
||||
>>> payment_method = PaymentMethod()
|
||||
>>> payment_method.name = bank_journal.name
|
||||
>>> payment_method.company = company
|
||||
>>> payment_method.journal = bank_journal
|
||||
>>> payment_method.credit_account = account_cash
|
||||
>>> payment_method.debit_account = account_cash
|
||||
>>> revenue_journal, = AccountJournal.find([('code', '=', 'REV')])
|
||||
|
||||
Create payment journal::
|
||||
|
@ -116,7 +119,8 @@ Create statement journal::
|
|||
>>> StatementJournal = Model.get('account.bank.statement.journal')
|
||||
>>> statement_journal = StatementJournal(
|
||||
... name='Test',
|
||||
... journal=bank_journal)
|
||||
... journal=bank_journal,
|
||||
... account=account_cash)
|
||||
>>> statement_journal.save()
|
||||
|
||||
Create party::
|
||||
|
@ -150,7 +154,7 @@ Create customer invoice::
|
|||
>>> customer_invoice.save()
|
||||
>>> customer_invoice.click('post')
|
||||
>>> customer_invoice.state
|
||||
u'posted'
|
||||
'posted'
|
||||
|
||||
Create customer invoice payment::
|
||||
|
||||
|
@ -158,26 +162,27 @@ Create customer invoice payment::
|
|||
>>> line, = [l for l in customer_invoice.move.lines
|
||||
... if l.account == receivable]
|
||||
>>> pay_line = Wizard('account.move.line.pay', [line])
|
||||
>>> pay_line.execute('next_')
|
||||
>>> pay_line.form.journal = payment_receivable_100_journal
|
||||
>>> pay_line.form.approve = False
|
||||
>>> pay_line.execute('start')
|
||||
>>> pay_line.execute('next_')
|
||||
>>> payment, = Payment.find([('state', '=', 'draft')])
|
||||
>>> payment.amount
|
||||
Decimal('100.00')
|
||||
>>> payment.click('approve')
|
||||
>>> payment.state
|
||||
u'approved'
|
||||
'approved'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment])
|
||||
>>> process_payment.execute('process')
|
||||
>>> payment.reload()
|
||||
>>> payment.state
|
||||
u'processing'
|
||||
'processing'
|
||||
|
||||
Check invoice is still pending to pay so the amount is in customer's debit account::
|
||||
|
||||
>>> customer_invoice.reload()
|
||||
>>> customer_invoice.state
|
||||
u'paid'
|
||||
'paid'
|
||||
>>> payment.processing_move != None
|
||||
True
|
||||
>>> payment.clearing_move is None
|
||||
|
@ -194,7 +199,7 @@ Create and confirm bank statement::
|
|||
>>> statement.save()
|
||||
>>> statement.click('confirm')
|
||||
>>> statement.state
|
||||
u'confirmed'
|
||||
'confirmed'
|
||||
|
||||
Create transaction lines on statement line and post it::
|
||||
|
||||
|
@ -204,9 +209,9 @@ Create transaction lines on statement line and post it::
|
|||
>>> st_move_line.amount
|
||||
Decimal('100.00')
|
||||
>>> st_move_line.account.name
|
||||
u'Customers Bank Discount'
|
||||
'Customers Bank Discount'
|
||||
>>> st_move_line.party.name
|
||||
u'Customer'
|
||||
'Customer'
|
||||
>>> statement_line.save()
|
||||
>>> statement_line.click('post')
|
||||
|
||||
|
@ -228,7 +233,7 @@ bank::
|
|||
|
||||
>>> customer_invoice.reload()
|
||||
>>> customer_invoice.state
|
||||
u'paid'
|
||||
'paid'
|
||||
>>> receivable.reload()
|
||||
>>> receivable.balance
|
||||
Decimal('0.00')
|
||||
|
@ -247,7 +252,7 @@ statement::
|
|||
>>> statement2.save()
|
||||
>>> statement2.click('confirm')
|
||||
>>> statement2.state
|
||||
u'confirmed'
|
||||
'confirmed'
|
||||
|
||||
Create transaction lines on statement line and post it::
|
||||
|
||||
|
@ -257,9 +262,9 @@ Create transaction lines on statement line and post it::
|
|||
>>> st_move_line.amount
|
||||
Decimal('-100.00')
|
||||
>>> st_move_line.account.name
|
||||
u'Customers Bank Discount'
|
||||
'Customers Bank Discount'
|
||||
>>> st_move_line.party.name
|
||||
u'Customer'
|
||||
'Customer'
|
||||
>>> statement_line2.save()
|
||||
>>> statement_line2.click('post')
|
||||
|
||||
|
@ -268,12 +273,12 @@ we doesn't have cash::
|
|||
|
||||
>>> payment.reload()
|
||||
>>> payment.state
|
||||
u'failed'
|
||||
'failed'
|
||||
>>> payment.clearing_move == None
|
||||
True
|
||||
>>> customer_invoice.reload()
|
||||
>>> customer_invoice.state
|
||||
u'posted'
|
||||
'posted'
|
||||
>>> receivable.reload()
|
||||
>>> receivable.balance
|
||||
Decimal('100.00')
|
||||
|
@ -294,7 +299,7 @@ But finally, the customer pays the invoice directly::
|
|||
>>> statement3.save()
|
||||
>>> statement3.click('confirm')
|
||||
>>> statement3.state
|
||||
u'confirmed'
|
||||
'confirmed'
|
||||
|
||||
Create transaction lines on statement line and post it::
|
||||
|
||||
|
@ -304,9 +309,9 @@ Create transaction lines on statement line and post it::
|
|||
>>> st_move_line.amount
|
||||
Decimal('100.00')
|
||||
>>> st_move_line.account.name
|
||||
u'Main Receivable'
|
||||
'Main Receivable'
|
||||
>>> st_move_line.party.name
|
||||
u'Customer'
|
||||
'Customer'
|
||||
>>> statement_line3.save()
|
||||
>>> statement_line3.click('post')
|
||||
|
||||
|
@ -314,7 +319,7 @@ So the payment is succeeded, the invoice paid again and due amounts are 0::
|
|||
|
||||
>>> customer_invoice.reload()
|
||||
>>> customer_invoice.state
|
||||
u'paid'
|
||||
'paid'
|
||||
>>> receivable.reload()
|
||||
>>> receivable.balance
|
||||
Decimal('0.00')
|
||||
|
@ -335,7 +340,7 @@ Create two customer invoices::
|
|||
>>> customer_invoice2.save()
|
||||
>>> customer_invoice2.click('post')
|
||||
>>> customer_invoice2.state
|
||||
u'posted'
|
||||
'posted'
|
||||
|
||||
>>> customer_invoice3 = Invoice(type='out')
|
||||
>>> customer_invoice3.party = customer
|
||||
|
@ -348,7 +353,7 @@ Create two customer invoices::
|
|||
>>> customer_invoice3.save()
|
||||
>>> customer_invoice3.click('post')
|
||||
>>> customer_invoice3.state
|
||||
u'posted'
|
||||
'posted'
|
||||
|
||||
>>> receivable.reload()
|
||||
>>> receivable.balance
|
||||
|
@ -359,38 +364,40 @@ Create a payment with 80% bank discount for first of them::
|
|||
>>> line, = [l for l in customer_invoice2.move.lines
|
||||
... if l.account == receivable]
|
||||
>>> pay_line = Wizard('account.move.line.pay', [line])
|
||||
>>> pay_line.execute('next_')
|
||||
>>> pay_line.form.journal = payment_receivable_80_journal
|
||||
>>> pay_line.execute('start')
|
||||
>>> pay_line.execute('next_')
|
||||
>>> payment2, = Payment.find([('state', '=', 'draft')])
|
||||
>>> payment2.amount
|
||||
Decimal('200.00')
|
||||
>>> payment2.click('approve')
|
||||
>>> payment2.state
|
||||
u'approved'
|
||||
'approved'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment2])
|
||||
>>> process_payment.execute('process')
|
||||
>>> payment2.reload()
|
||||
>>> payment2.state
|
||||
u'processing'
|
||||
'processing'
|
||||
|
||||
And another payment with 100% bank discount for the second one::
|
||||
|
||||
>>> line, = [l for l in customer_invoice3.move.lines
|
||||
... if l.account == receivable]
|
||||
>>> pay_line = Wizard('account.move.line.pay', [line])
|
||||
>>> pay_line.execute('next_')
|
||||
>>> pay_line.form.journal = payment_receivable_100_journal
|
||||
>>> pay_line.execute('start')
|
||||
>>> pay_line.execute('next_')
|
||||
>>> payment3, = Payment.find([('state', '=', 'draft')])
|
||||
>>> payment3.amount
|
||||
Decimal('80.00')
|
||||
>>> payment3.click('approve')
|
||||
>>> payment3.state
|
||||
u'approved'
|
||||
'approved'
|
||||
>>> process_payment = Wizard('account.payment.process', [payment3])
|
||||
>>> process_payment.execute('process')
|
||||
>>> payment3.reload()
|
||||
>>> payment3.state
|
||||
u'processing'
|
||||
'processing'
|
||||
|
||||
Create and confirm bank statement::
|
||||
|
||||
|
@ -406,7 +413,7 @@ Create and confirm bank statement::
|
|||
>>> statement4.save()
|
||||
>>> statement4.click('confirm')
|
||||
>>> statement4.state
|
||||
u'confirmed'
|
||||
'confirmed'
|
||||
|
||||
Create transaction lines on statement lines and post them::
|
||||
|
||||
|
@ -416,9 +423,9 @@ Create transaction lines on statement lines and post them::
|
|||
>>> st_move_line.amount
|
||||
Decimal('160.00')
|
||||
>>> st_move_line.account.name
|
||||
u'Customers Bank Discount'
|
||||
'Customers Bank Discount'
|
||||
>>> st_move_line.party.name
|
||||
u'Customer'
|
||||
'Customer'
|
||||
>>> statement_line4.save()
|
||||
>>> statement_line4.click('post')
|
||||
>>> st_move_line = statement_line5.lines.new()
|
||||
|
@ -426,9 +433,9 @@ Create transaction lines on statement lines and post them::
|
|||
>>> st_move_line.amount
|
||||
Decimal('80.00')
|
||||
>>> st_move_line.account.name
|
||||
u'Customers Bank Discount'
|
||||
'Customers Bank Discount'
|
||||
>>> st_move_line.party.name
|
||||
u'Customer'
|
||||
'Customer'
|
||||
>>> statement_line5.save()
|
||||
>>> statement_line5.click('post')
|
||||
|
||||
|
@ -456,7 +463,7 @@ paid by customer but bank substract the third invoice amount::
|
|||
>>> statement5.save()
|
||||
>>> statement5.click('confirm')
|
||||
>>> statement5.state
|
||||
u'confirmed'
|
||||
'confirmed'
|
||||
|
||||
Create transaction line on statement line with pending amount of second
|
||||
invoice, selecting the invoice and the payment::
|
||||
|
@ -464,14 +471,15 @@ invoice, selecting the invoice and the payment::
|
|||
>>> statement_line6, statement_line7 = statement5.lines
|
||||
>>> st_move_line = statement_line6.lines.new()
|
||||
>>> st_move_line.invoice = customer_invoice2
|
||||
>>> import pdb;pdb.set_trace()
|
||||
>>> st_move_line.payment == payment2
|
||||
True
|
||||
>>> st_move_line.amount
|
||||
Decimal('40.00')
|
||||
>>> st_move_line.account.name
|
||||
u'Main Receivable'
|
||||
'Main Receivable'
|
||||
>>> st_move_line.party.name
|
||||
u'Customer'
|
||||
'Customer'
|
||||
>>> statement_line6.save()
|
||||
>>> statement_line6.click('post')
|
||||
|
||||
|
@ -479,10 +487,10 @@ The payment of second customer invoice is succeeded::
|
|||
|
||||
>>> payment2.reload()
|
||||
>>> payment2.state
|
||||
u'succeeded'
|
||||
'succeeded'
|
||||
>>> customer_invoice2.reload()
|
||||
>>> customer_invoice2.state
|
||||
u'posted'
|
||||
'posted'
|
||||
|
||||
Create transaction line on statement line with recovering of bank discount for
|
||||
third invoice selecting the payment::
|
||||
|
@ -492,9 +500,9 @@ third invoice selecting the payment::
|
|||
>>> st_move_line.amount
|
||||
Decimal('-80.00')
|
||||
>>> st_move_line.account.name
|
||||
u'Customers Bank Discount'
|
||||
'Customers Bank Discount'
|
||||
>>> st_move_line.party.name
|
||||
u'Customer'
|
||||
'Customer'
|
||||
>>> statement_line7.save()
|
||||
>>> statement_line7.click('post')
|
||||
|
||||
|
@ -502,10 +510,10 @@ And the payment of third customer invoice is failed::
|
|||
|
||||
>>> payment3.reload()
|
||||
>>> payment3.state
|
||||
u'failed'
|
||||
'failed'
|
||||
>>> customer_invoice3.reload()
|
||||
>>> customer_invoice3.state
|
||||
u'posted'
|
||||
'posted'
|
||||
|
||||
The third invoice amount is also owed, the due with bank is empty and the cash
|
||||
do not have the third invoice amount::
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=4.7.0
|
||||
version=5.1.0
|
||||
depends:
|
||||
account_payment
|
||||
account_payment_clearing
|
||||
|
|
Loading…
Reference in New Issue