1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315 |
- # -*- coding: utf-8 -*-
- from odoo.addons.account.tests.common import AccountTestInvoicingCommon
- from odoo.exceptions import UserError
- from odoo.tests import tagged, Form
- from odoo import Command
- @tagged('post_install', '-at_install')
- class TestAccountPaymentRegister(AccountTestInvoicingCommon):
- @classmethod
- def setUpClass(cls, chart_template_ref=None):
- super().setUpClass(chart_template_ref=chart_template_ref)
- cls.currency_data_3 = cls.setup_multi_currency_data({
- 'name': "Umbrella",
- 'symbol': '☂',
- 'currency_unit_label': "Umbrella",
- 'currency_subunit_label': "Broken Umbrella",
- }, rate2017=0.01)
- cls.payment_debit_account_id = cls.company_data['default_journal_bank'].company_id.account_journal_payment_debit_account_id.copy()
- cls.payment_credit_account_id = cls.company_data['default_journal_bank'].company_id.account_journal_payment_credit_account_id.copy()
- cls.bank_journal_1 = cls.company_data['default_journal_bank']
- cls.bank_journal_2 = cls.company_data['default_journal_bank'].copy()
- cls.partner_bank_account1 = cls.env['res.partner.bank'].create({
- 'acc_number': "0123456789",
- 'partner_id': cls.partner_a.id,
- 'acc_type': 'bank',
- })
- cls.partner_bank_account2 = cls.env['res.partner.bank'].create({
- 'acc_number': "9876543210",
- 'partner_id': cls.partner_a.id,
- 'acc_type': 'bank',
- })
- cls.comp_bank_account1 = cls.env['res.partner.bank'].create({
- 'acc_number': "985632147",
- 'partner_id': cls.env.company.partner_id.id,
- 'acc_type': 'bank',
- })
- cls.comp_bank_account2 = cls.env['res.partner.bank'].create({
- 'acc_number': "741258963",
- 'partner_id': cls.env.company.partner_id.id,
- 'acc_type': 'bank',
- })
- # Customer invoices sharing the same batch.
- cls.out_invoice_1 = cls.env['account.move'].create({
- 'move_type': 'out_invoice',
- 'date': '2017-01-01',
- 'invoice_date': '2017-01-01',
- 'partner_id': cls.partner_a.id,
- 'currency_id': cls.currency_data['currency'].id,
- 'invoice_line_ids': [(0, 0, {'product_id': cls.product_a.id, 'price_unit': 1000.0, 'tax_ids': []})],
- })
- cls.out_invoice_2 = cls.env['account.move'].create({
- 'move_type': 'out_invoice',
- 'date': '2017-01-01',
- 'invoice_date': '2017-01-01',
- 'partner_id': cls.partner_a.id,
- 'currency_id': cls.currency_data['currency'].id,
- 'invoice_line_ids': [(0, 0, {'product_id': cls.product_a.id, 'price_unit': 2000.0, 'tax_ids': []})],
- })
- cls.out_invoice_3 = cls.env['account.move'].create({
- 'move_type': 'out_invoice',
- 'date': '2017-01-01',
- 'invoice_date': '2017-01-01',
- 'partner_id': cls.partner_a.id,
- 'currency_id': cls.currency_data['currency'].id,
- 'invoice_line_ids': [(0, 0, {'product_id': cls.product_a.id, 'price_unit': 24.02, 'tax_ids': []})],
- })
- cls.out_invoice_4 = cls.env['account.move'].create({
- 'move_type': 'out_invoice',
- 'date': '2017-01-01',
- 'invoice_date': '2017-01-01',
- 'partner_id': cls.partner_a.id,
- 'currency_id': cls.currency_data['currency'].id,
- 'invoice_line_ids': [(0, 0, {'product_id': cls.product_a.id, 'price_unit': 23.98, 'tax_ids': []})],
- })
- (cls.out_invoice_1 + cls.out_invoice_2 + cls.out_invoice_3 + cls.out_invoice_4).action_post()
- # Vendor bills, in_invoice_1 + in_invoice_2 are sharing the same batch but not in_invoice_3.
- cls.in_invoice_1 = cls.env['account.move'].create({
- 'move_type': 'in_invoice',
- 'date': '2017-01-01',
- 'invoice_date': '2017-01-01',
- 'partner_id': cls.partner_a.id,
- 'invoice_line_ids': [(0, 0, {'product_id': cls.product_a.id, 'price_unit': 1000.0, 'tax_ids': []})],
- })
- cls.in_invoice_2 = cls.env['account.move'].create({
- 'move_type': 'in_invoice',
- 'date': '2017-01-01',
- 'invoice_date': '2017-01-01',
- 'partner_id': cls.partner_a.id,
- 'invoice_line_ids': [(0, 0, {'product_id': cls.product_a.id, 'price_unit': 2000.0, 'tax_ids': []})],
- })
- cls.in_invoice_3 = cls.env['account.move'].create({
- 'move_type': 'in_invoice',
- 'date': '2017-01-01',
- 'invoice_date': '2017-01-01',
- 'partner_id': cls.partner_b.id,
- 'invoice_payment_term_id': False,
- 'currency_id': cls.currency_data['currency'].id,
- 'invoice_line_ids': [(0, 0, {'product_id': cls.product_a.id, 'price_unit': 3000.0, 'tax_ids': []})],
- })
- (cls.in_invoice_1 + cls.in_invoice_2 + cls.in_invoice_3).action_post()
- # Credit note
- cls.in_refund_1 = cls.env['account.move'].create({
- 'move_type': 'in_refund',
- 'date': '2017-01-01',
- 'invoice_date': '2017-01-01',
- 'partner_id': cls.partner_a.id,
- 'invoice_line_ids': [(0, 0, {'product_id': cls.product_a.id, 'price_unit': 1600.0, 'tax_ids': []})],
- })
- cls.in_refund_1.action_post()
- def test_register_payment_single_batch_grouped_keep_open_lower_amount(self):
- ''' Pay 800.0 with 'open' as payment difference handling on two customer invoices (1000 + 2000). '''
- active_ids = (self.out_invoice_1 + self.out_invoice_2).ids
- payments = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=active_ids).create({
- 'amount': 800.0,
- 'group_payment': True,
- 'payment_difference_handling': 'open',
- 'currency_id': self.currency_data['currency'].id,
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- })._create_payments()
- self.assertRecordValues(payments, [{
- 'ref': 'INV/2017/00001 INV/2017/00002',
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- }])
- self.assertRecordValues(payments.line_ids.sorted('balance'), [
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 400.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': -800.0,
- 'reconciled': True,
- },
- # Liquidity line:
- {
- 'debit': 400.0,
- 'credit': 0.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': 800.0,
- 'reconciled': False,
- },
- ])
- def test_register_payment_single_batch_grouped_keep_open_higher_amount(self):
- ''' Pay 3100.0 with 'open' as payment difference handling on two customer invoices (1000 + 2000). '''
- active_ids = (self.out_invoice_1 + self.out_invoice_2).ids
- payments = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=active_ids).create({
- 'amount': 3100.0,
- 'group_payment': True,
- 'payment_difference_handling': 'open',
- 'currency_id': self.currency_data['currency'].id,
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- })._create_payments()
- self.assertRecordValues(payments, [{
- 'ref': 'INV/2017/00001 INV/2017/00002',
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- }])
- self.assertRecordValues(payments.line_ids.sorted('balance'), [
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 1550.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': -3100.0,
- 'reconciled': False,
- },
- # Liquidity line:
- {
- 'debit': 1550.0,
- 'credit': 0.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': 3100.0,
- 'reconciled': False,
- },
- ])
- def test_register_payment_single_batch_grouped_writeoff_lower_amount_debit(self):
- ''' Pay 800.0 with 'reconcile' as payment difference handling on two customer invoices (1000 + 2000). '''
- active_ids = (self.out_invoice_1 + self.out_invoice_2).ids
- payments = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=active_ids).create({
- 'amount': 800.0,
- 'group_payment': True,
- 'payment_difference_handling': 'reconcile',
- 'writeoff_account_id': self.company_data['default_account_revenue'].id,
- 'writeoff_label': 'writeoff',
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- })._create_payments()
- self.assertRecordValues(payments, [{
- 'ref': 'INV/2017/00001 INV/2017/00002',
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- }])
- self.assertRecordValues(payments.line_ids.sorted('balance'), [
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 1500.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': -3000.0,
- 'reconciled': True,
- },
- # Liquidity line:
- {
- 'debit': 400.0,
- 'credit': 0.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': 800.0,
- 'reconciled': False,
- },
- # Writeoff line:
- {
- 'debit': 1100.0,
- 'credit': 0.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': 2200.0,
- 'reconciled': False,
- },
- ])
- def test_register_payment_single_batch_grouped_writeoff_higher_amount_debit(self):
- ''' Pay 3100.0 with 'reconcile' as payment difference handling on two customer invoices (1000 + 2000). '''
- active_ids = (self.out_invoice_1 + self.out_invoice_2).ids
- payments = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=active_ids).create({
- 'amount': 3100.0,
- 'group_payment': True,
- 'payment_difference_handling': 'reconcile',
- 'writeoff_account_id': self.company_data['default_account_revenue'].id,
- 'writeoff_label': 'writeoff',
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- })._create_payments()
- self.assertRecordValues(payments, [{
- 'ref': 'INV/2017/00001 INV/2017/00002',
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- }])
- self.assertRecordValues(payments.line_ids.sorted('balance'), [
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 1500.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': -3000.0,
- 'reconciled': True,
- },
- # Writeoff line:
- {
- 'debit': 0.0,
- 'credit': 50.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': -100.0,
- 'reconciled': False,
- },
- # Liquidity line:
- {
- 'debit': 1550.0,
- 'credit': 0.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': 3100.0,
- 'reconciled': False,
- },
- ])
- def test_register_payment_single_batch_grouped_writeoff_lower_amount_credit(self):
- ''' Pay 800.0 with 'reconcile' as payment difference handling on two vendor billes (1000 + 2000). '''
- active_ids = (self.in_invoice_1 + self.in_invoice_2).ids
- payments = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=active_ids).create({
- 'amount': 800.0,
- 'group_payment': True,
- 'payment_difference_handling': 'reconcile',
- 'writeoff_account_id': self.company_data['default_account_revenue'].id,
- 'writeoff_label': 'writeoff',
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- })._create_payments()
- self.assertRecordValues(payments, [{
- 'ref': 'BILL/2017/01/0001 BILL/2017/01/0002',
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- }])
- self.assertRecordValues(payments.line_ids.sorted('balance'), [
- # Writeoff line:
- {
- 'debit': 0.0,
- 'credit': 2200.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -2200.0,
- 'reconciled': False,
- },
- # Liquidity line:
- {
- 'debit': 0.0,
- 'credit': 800.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -800.0,
- 'reconciled': False,
- },
- # Payable line:
- {
- 'debit': 3000.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 3000.0,
- 'reconciled': True,
- },
- ])
- def test_register_payment_single_batch_grouped_writeoff_higher_amount_credit(self):
- ''' Pay 3100.0 with 'reconcile' as payment difference handling on two vendor billes (1000 + 2000). '''
- active_ids = (self.in_invoice_1 + self.in_invoice_2).ids
- payments = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=active_ids).create({
- 'amount': 3100.0,
- 'group_payment': True,
- 'payment_difference_handling': 'reconcile',
- 'writeoff_account_id': self.company_data['default_account_revenue'].id,
- 'writeoff_label': 'writeoff',
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- })._create_payments()
- self.assertRecordValues(payments, [{
- 'ref': 'BILL/2017/01/0001 BILL/2017/01/0002',
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- }])
- self.assertRecordValues(payments.line_ids.sorted('balance'), [
- # Liquidity line:
- {
- 'debit': 0.0,
- 'credit': 3100.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -3100.0,
- 'reconciled': False,
- },
- # Writeoff line:
- {
- 'debit': 100.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 100.0,
- 'reconciled': False,
- },
- # Payable line:
- {
- 'debit': 3000.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 3000.0,
- 'reconciled': True,
- },
- ])
- def test_register_payment_single_batch_not_grouped(self):
- ''' Choose to pay two customer invoices with separated payments (1000 + 2000). '''
- active_ids = (self.out_invoice_1 + self.out_invoice_2).ids
- payment_register = self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=active_ids)\
- .create({
- 'group_payment': False,
- 'amount': 1200.0
- })
- self.assertRecordValues(payment_register, [{'payment_difference': 1800.0}])
- payments = payment_register._create_payments()
- self.assertRecordValues(payments, [
- {
- 'ref': 'INV/2017/00001',
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- },
- {
- 'ref': 'INV/2017/00002',
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- },
- ])
- self.assertRecordValues(payments[0].line_ids.sorted('balance') + payments[1].line_ids.sorted('balance'), [
- # == Payment 1: to pay out_invoice_1 ==
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 500.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': -1000.0,
- 'reconciled': True,
- },
- # Liquidity line:
- {
- 'debit': 500.0,
- 'credit': 0.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': 1000.0,
- 'reconciled': False,
- },
- # == Payment 2: to pay out_invoice_2 ==
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 1000.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': -2000.0,
- 'reconciled': True,
- },
- # Liquidity line:
- {
- 'debit': 1000.0,
- 'credit': 0.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': 2000.0,
- 'reconciled': False,
- },
- ])
- def test_register_payment_different_type_single_batch_not_grouped(self):
- """ Choose to pay a bill and a refund with separated payments (1000 + -2000)."""
- active_ids = (self.in_invoice_1 + self.in_refund_1).ids
- payments = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=active_ids).create({
- 'group_payment': False,
- })._create_payments()
- self.assertRecordValues(payments[0], [
- {
- 'ref': 'BILL/2017/01/0001',
- 'payment_type': 'outbound',
- }
- ])
- self.assertRecordValues(payments[1], [
- {
- 'ref': 'RBILL/2017/01/0001',
- 'payment_type': 'inbound',
- },
- ])
- self.assertRecordValues(payments[0].line_ids.sorted('balance'), [
- # == Payment 1: to pay in_invoice_1 ==
- # Liquidity line:
- {
- 'debit': 0.0,
- 'credit': 1000.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -1000.0,
- 'reconciled': False,
- },
- # Payable line:
- {
- 'debit': 1000.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 1000.0,
- 'reconciled': True,
- },
- ])
- self.assertRecordValues(payments[1].line_ids.sorted('balance'), [
- # == Payment 2: to pay in_refund_1 ==
- # Payable line:
- {
- 'debit': 0.0,
- 'credit': 1600.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -1600.0,
- 'reconciled': True,
- },
- # Liquidity line:
- {
- 'debit': 1600.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 1600.0,
- 'reconciled': False,
- },
- ])
- def test_register_payment_single_batch_grouped_with_credit_note(self):
- ''' Pay 1400.0 on two vendor bills (1000.0 + 2000.0) and one credit note (1600.0). '''
- active_ids = (self.in_invoice_1 + self.in_invoice_2 + self.in_refund_1).ids
- payments = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=active_ids).create({
- 'group_payment': True,
- })._create_payments()
- self.assertRecordValues(payments, [
- {
- 'ref': 'BILL/2017/01/0001 BILL/2017/01/0002 RBILL/2017/01/0001',
- 'payment_method_line_id': self.outbound_payment_method_line.id,
- },
- ])
- self.assertRecordValues(payments[0].line_ids.sorted('balance'), [
- # Liquidity line:
- {
- 'debit': 0.0,
- 'credit': 1400.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -1400.0,
- 'reconciled': False,
- },
- # Payable line:
- {
- 'debit': 1400.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 1400.0,
- 'reconciled': True,
- },
- ])
- def test_register_payment_multiple_batch_grouped_with_credit_note(self):
- ''' Do not batch payments if multiple partner_bank_id '''
- bank1 = self.env['res.partner.bank'].create({
- 'acc_number': 'BE43798822936101',
- 'partner_id': self.partner_a.id,
- })
- bank2 = self.env['res.partner.bank'].create({
- 'acc_number': 'BE85812541345906',
- 'partner_id': self.partner_a.id,
- })
- self.in_invoice_1.partner_bank_id = bank1
- self.in_invoice_2.partner_bank_id = bank2
- active_ids = (self.in_invoice_1 + self.in_invoice_2 + self.in_refund_1).ids
- payments = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=active_ids).create({
- 'group_payment': True,
- })._create_payments()
- self.assertRecordValues(payments, [
- {
- 'ref': 'BILL/2017/01/0001',
- 'payment_method_line_id': self.outbound_payment_method_line.id,
- },
- {
- 'ref': 'BILL/2017/01/0002',
- 'payment_method_line_id': self.outbound_payment_method_line.id,
- },
- {
- 'ref': 'RBILL/2017/01/0001',
- 'payment_method_line_id': self.inbound_payment_method_line.id,
- },
- ])
- self.assertRecordValues(payments[0].line_ids.sorted('balance') + payments[1].line_ids.sorted('balance') + payments[2].line_ids.sorted('balance'), [
- # Liquidity line:
- {
- 'debit': 0.0,
- 'credit': 1000.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -1000.0,
- 'reconciled': False,
- },
- # Payable line:
- {
- 'debit': 1000.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 1000.0,
- 'reconciled': True,
- },
- # Liquidity line:
- {
- 'debit': 0.0,
- 'credit': 2000.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -2000.0,
- 'reconciled': False,
- },
- # Payable line:
- {
- 'debit': 2000.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 2000.0,
- 'reconciled': True,
- },
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 1600.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -1600.0,
- 'reconciled': True,
- },
- # Liquidity line:
- {
- 'debit': 1600.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 1600.0,
- 'reconciled': False,
- },
- ])
- def test_register_payment_multi_batches_grouped(self):
- ''' Choose to pay multiple batches, one with two customer invoices (1000 + 2000)
- and one with a vendor bill of 600, by grouping payments.
- '''
- active_ids = (self.in_invoice_1 + self.in_invoice_2 + self.in_invoice_3).ids
- payment_register = self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=active_ids)\
- .create({
- 'group_payment': True,
- 'amount': 1000.0
- # Test _compute_payment_difference. Since the partners_ids are not the same, this should be without effect.
- })
- payments = payment_register._create_payments()
- self.assertRecordValues(payment_register, [{
- 'payment_difference': 0.0
- }])
- self.assertRecordValues(payments, [
- {
- 'ref': 'BILL/2017/01/0001 BILL/2017/01/0002',
- 'payment_method_line_id': self.outbound_payment_method_line.id,
- },
- {
- 'ref': 'BILL/2017/01/0003',
- 'payment_method_line_id': self.outbound_payment_method_line.id,
- },
- ])
- self.assertRecordValues(payments[0].line_ids.sorted('balance') + payments[1].line_ids.sorted('balance'), [
- # == Payment 1: to pay in_invoice_1 & in_invoice_2 ==
- # Liquidity line:
- {
- 'debit': 0.0,
- 'credit': 3000.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -3000.0,
- 'reconciled': False,
- },
- # Payable line:
- {
- 'debit': 3000.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 3000.0,
- 'reconciled': True,
- },
- # == Payment 2: to pay in_invoice_3 ==
- # Liquidity line:
- {
- 'debit': 0.0,
- 'credit': 1500.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': -3000.0,
- 'reconciled': False,
- },
- # Payable line:
- {
- 'debit': 1500.0,
- 'credit': 0.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': 3000.0,
- 'reconciled': True,
- },
- ])
- def test_register_payment_multi_batches_not_grouped(self):
- ''' Choose to pay multiple batches, one with two customer invoices (1000 + 2000)
- and one with a vendor bill of 600, by splitting payments.
- '''
- self.in_invoice_1.partner_bank_id = self.partner_bank_account1
- self.in_invoice_2.partner_bank_id = self.partner_bank_account2
- active_ids = (self.in_invoice_1 + self.in_invoice_2 + self.in_invoice_3).ids
- payments = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=active_ids).create({
- 'group_payment': False,
- })._create_payments()
- self.assertRecordValues(payments, [
- {
- 'journal_id': self.bank_journal_1.id,
- 'ref': 'BILL/2017/01/0001',
- 'payment_method_line_id': self.outbound_payment_method_line.id,
- 'partner_bank_id': self.partner_bank_account1.id,
- },
- {
- 'journal_id': self.bank_journal_1.id,
- 'ref': 'BILL/2017/01/0002',
- 'payment_method_line_id': self.outbound_payment_method_line.id,
- 'partner_bank_id': self.partner_bank_account2.id,
- },
- {
- 'journal_id': self.bank_journal_1.id,
- 'ref': 'BILL/2017/01/0003',
- 'payment_method_line_id': self.outbound_payment_method_line.id,
- 'partner_bank_id': False,
- },
- ])
- self.assertRecordValues(payments[0].line_ids.sorted('balance') + payments[1].line_ids.sorted('balance') + payments[2].line_ids.sorted('balance'), [
- # == Payment 1: to pay in_invoice_1 ==
- # Liquidity line:
- {
- 'debit': 0.0,
- 'credit': 1000.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -1000.0,
- 'reconciled': False,
- },
- # Payable line:
- {
- 'debit': 1000.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 1000.0,
- 'reconciled': True,
- },
- # == Payment 2: to pay in_invoice_2 ==
- # Liquidity line:
- {
- 'debit': 0.0,
- 'credit': 2000.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -2000.0,
- 'reconciled': False,
- },
- # Payable line:
- {
- 'debit': 2000.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 2000.0,
- 'reconciled': True,
- },
- # == Payment 3: to pay in_invoice_3 ==
- # Liquidity line:
- {
- 'debit': 0.0,
- 'credit': 1500.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': -3000.0,
- 'reconciled': False,
- },
- # Payable line:
- {
- 'debit': 1500.0,
- 'credit': 0.0,
- 'currency_id': self.currency_data['currency'].id,
- 'amount_currency': 3000.0,
- 'reconciled': True,
- },
- ])
- def test_register_payment_constraints(self):
- # Test to register a payment for a draft journal entry.
- self.out_invoice_1.button_draft()
- with self.assertRaises(UserError), self.cr.savepoint():
- self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=self.out_invoice_1.ids)\
- .create({})
- # Test to register a payment for an already fully reconciled journal entry.
- self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=self.out_invoice_2.ids)\
- .create({})\
- ._create_payments()
- with self.assertRaises(UserError), self.cr.savepoint():
- self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=self.out_invoice_2.ids)\
- .create({})
- def test_register_payment_multi_currency_rounding_issue_positive_delta(self):
- ''' When registering a payment using a different currency than the invoice one, the invoice must be fully paid
- at the end whatever the currency rate.
- '''
- payment = self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=self.out_invoice_3.ids)\
- .create({
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount': 0.12,
- })\
- ._create_payments()
- self.assertRecordValues(payment.line_ids.sorted('balance'), [
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 12.01,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': -0.12,
- 'reconciled': True,
- },
- # Liquidity line:
- {
- 'debit': 12.01,
- 'credit': 0.0,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': 0.12,
- 'reconciled': False,
- },
- ])
- def test_register_payment_multi_currency_rounding_issue_negative_delta(self):
- ''' When registering a payment using a different currency than the invoice one, the invoice must be fully paid
- at the end whatever the currency rate.
- '''
- payment = self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=self.out_invoice_4.ids)\
- .create({
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount': 0.12,
- })\
- ._create_payments()
- self.assertRecordValues(payment.line_ids.sorted('balance'), [
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 11.99,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': -0.12,
- 'reconciled': True,
- },
- # Liquidity line:
- {
- 'debit': 11.99,
- 'credit': 0.0,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': 0.12,
- 'reconciled': False,
- },
- ])
- def test_register_payment_multi_currency_rounding_issue_writeoff_lower_amount_keep_open(self):
- payment = self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=self.out_invoice_3.ids)\
- .create({
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount': 0.08,
- 'payment_difference_handling': 'open',
- })\
- ._create_payments()
- self.assertRecordValues(payment.line_ids.sorted('balance'), [
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 8.0,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': -0.08,
- 'reconciled': True,
- },
- # Liquidity line:
- {
- 'debit': 8.0,
- 'credit': 0.0,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': 0.08,
- 'reconciled': False,
- },
- ])
- def test_register_payment_multi_currency_rounding_issue_writeoff_lower_amount_reconcile_positive_delta(self):
- payment = self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=self.out_invoice_3.ids)\
- .create({
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount': 0.08,
- 'payment_difference_handling': 'reconcile',
- 'writeoff_account_id': self.company_data['default_account_revenue'].id,
- 'writeoff_label': 'writeoff',
- })\
- ._create_payments()
- self.assertRecordValues(payment.line_ids.sorted('balance'), [
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 12.01,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': -0.12,
- 'reconciled': True,
- },
- # Write-off line:
- {
- 'debit': 4.0,
- 'credit': 0.0,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': 0.04,
- 'reconciled': False,
- },
- # Liquidity line:
- {
- 'debit': 8.01,
- 'credit': 0.0,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': 0.08,
- 'reconciled': False,
- },
- ])
- def test_register_payment_multi_currency_rounding_issue_writeoff_lower_amount_reconcile_negative_delta(self):
- payment = self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=self.out_invoice_4.ids)\
- .create({
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount': 0.08,
- 'payment_difference_handling': 'reconcile',
- 'writeoff_account_id': self.company_data['default_account_revenue'].id,
- 'writeoff_label': 'writeoff',
- })\
- ._create_payments()
- self.assertRecordValues(payment.line_ids.sorted('balance'), [
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 11.99,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': -0.12,
- 'reconciled': True,
- },
- # Write-off line:
- {
- 'debit': 4.0,
- 'credit': 0.0,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': 0.04,
- 'reconciled': False,
- },
- # Liquidity line:
- {
- 'debit': 7.99,
- 'credit': 0.0,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': 0.08,
- 'reconciled': False,
- },
- ])
- def test_register_payment_multi_currency_rounding_issue_writeoff_higher_amount_reconcile_positive_delta(self):
- payment = self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=self.out_invoice_3.ids)\
- .create({
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount': 0.16,
- 'payment_difference_handling': 'reconcile',
- 'writeoff_account_id': self.company_data['default_account_revenue'].id,
- 'writeoff_label': 'writeoff',
- })\
- ._create_payments()
- self.assertRecordValues(payment.line_ids.sorted('balance'), [
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 12.01,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': -0.12,
- 'reconciled': True,
- },
- # Write-off line:
- {
- 'debit': 0.0,
- 'credit': 4.0,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': -0.04,
- 'reconciled': False,
- },
- # Liquidity line:
- {
- 'debit': 16.01,
- 'credit': 0.0,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': 0.16,
- 'reconciled': False,
- },
- ])
- def test_register_payment_multi_currency_rounding_issue_writeoff_higher_amount_reconcile_negative_delta(self):
- payment = self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=self.out_invoice_4.ids)\
- .create({
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount': 0.16,
- 'payment_difference_handling': 'reconcile',
- 'writeoff_account_id': self.company_data['default_account_revenue'].id,
- 'writeoff_label': 'writeoff',
- })\
- ._create_payments()
- self.assertRecordValues(payment.line_ids.sorted('balance'), [
- # Receivable line:
- {
- 'debit': 0.0,
- 'credit': 11.99,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': -0.12,
- 'reconciled': True,
- },
- # Write-off line:
- {
- 'debit': 0.0,
- 'credit': 4.0,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': -0.04,
- 'reconciled': False,
- },
- # Liquidity line:
- {
- 'debit': 15.99,
- 'credit': 0.0,
- 'currency_id': self.currency_data_3['currency'].id,
- 'amount_currency': 0.16,
- 'reconciled': False,
- },
- ])
- def test_suggested_default_partner_bank_inbound_payment(self):
- """ Test the suggested bank account on the wizard for inbound payment. """
- self.out_invoice_1.partner_bank_id = False
- ctx = {'active_model': 'account.move', 'active_ids': self.out_invoice_1.ids}
- wizard = self.env['account.payment.register'].with_context(**ctx).create({})
- self.assertRecordValues(wizard, [{
- 'journal_id': self.bank_journal_1.id,
- 'available_partner_bank_ids': [],
- 'partner_bank_id': False,
- }])
- self.bank_journal_2.bank_account_id = self.out_invoice_1.partner_bank_id = self.comp_bank_account2
- wizard = self.env['account.payment.register'].with_context(**ctx).create({})
- self.assertRecordValues(wizard, [{
- 'journal_id': self.bank_journal_2.id,
- 'available_partner_bank_ids': self.comp_bank_account2.ids,
- 'partner_bank_id': self.comp_bank_account2.id,
- }])
- wizard.journal_id = self.bank_journal_1
- self.assertRecordValues(wizard, [{
- 'journal_id': self.bank_journal_1.id,
- 'available_partner_bank_ids': [],
- 'partner_bank_id': False,
- }])
- def test_suggested_default_partner_bank_outbound_payment(self):
- """ Test the suggested bank account on the wizard for outbound payment. """
- self.in_invoice_1.partner_bank_id = False
- ctx = {'active_model': 'account.move', 'active_ids': self.in_invoice_1.ids}
- wizard = self.env['account.payment.register'].with_context(**ctx).create({})
- self.assertRecordValues(wizard, [{
- 'journal_id': self.bank_journal_1.id,
- 'available_partner_bank_ids': self.partner_a.bank_ids.ids,
- 'partner_bank_id': self.partner_bank_account1.id,
- }])
- self.in_invoice_1.partner_bank_id = self.partner_bank_account2
- wizard = self.env['account.payment.register'].with_context(**ctx).create({})
- self.assertRecordValues(wizard, [{
- 'journal_id': self.bank_journal_1.id,
- 'available_partner_bank_ids': self.partner_a.bank_ids.ids,
- 'partner_bank_id': self.partner_bank_account2.id,
- }])
- wizard.journal_id = self.bank_journal_2
- self.assertRecordValues(wizard, [{
- 'journal_id': self.bank_journal_2.id,
- 'available_partner_bank_ids': self.partner_a.bank_ids.ids,
- 'partner_bank_id': self.partner_bank_account2.id,
- }])
- def test_register_payment_inbound_multiple_bank_account(self):
- """ Pay customer invoices with different bank accounts. """
- self.out_invoice_1.partner_bank_id = self.comp_bank_account1
- self.out_invoice_2.partner_bank_id = self.comp_bank_account2
- self.bank_journal_2.bank_account_id = self.comp_bank_account2
- ctx = {'active_model': 'account.move', 'active_ids': (self.out_invoice_1 + self.out_invoice_2).ids}
- wizard = self.env['account.payment.register'].with_context(**ctx).create({'journal_id': self.bank_journal_2.id})
- payments = wizard._create_payments()
- self.assertRecordValues(payments, [
- {
- 'journal_id': self.bank_journal_2.id,
- 'ref': 'INV/2017/00001',
- 'partner_bank_id': self.comp_bank_account2.id,
- },
- {
- 'journal_id': self.bank_journal_2.id,
- 'ref': 'INV/2017/00002',
- 'partner_bank_id': self.comp_bank_account2.id,
- },
- ])
- def test_register_payment_invoice_foreign_curr_payment_comp_curr(self):
- # Invoice 1200 Gol = 400 USD
- invoice = self.env['account.move'].create({
- 'move_type': 'out_invoice',
- 'date': '2016-01-01',
- 'invoice_date': '2016-01-01',
- 'partner_id': self.partner_a.id,
- 'currency_id': self.currency_data['currency'].id,
- 'invoice_line_ids': [Command.create(
- {'product_id': self.product_a.id,
- 'price_unit': 1200.0,
- 'tax_ids': [],
- })],
- })
- invoice.action_post()
- # Payment of 600 USD (equivalent to 1200 Gol in 2017).
- # 600.0 USD should be computed correctly to fully paid the invoices.
- wizard = self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=invoice.ids)\
- .create({
- 'currency_id': self.company_data['currency'].id,
- 'payment_date': '2017-01-01',
- })
- self.assertRecordValues(wizard, [{
- 'amount': 600.0,
- 'payment_difference': 0.0,
- 'currency_id': self.company_data['currency'].id,
- }])
- payment = wizard._create_payments()
- lines = (invoice + payment.move_id).line_ids.filtered(lambda x: x.account_type == 'asset_receivable')
- self.assertRecordValues(lines, [
- {'amount_residual': 0.0, 'amount_residual_currency': 0.0, 'currency_id': self.currency_data['currency'].id, 'reconciled': True},
- {'amount_residual': 0.0, 'amount_residual_currency': 0.0, 'currency_id': self.company_data['currency'].id, 'reconciled': True},
- ])
- def test_register_payment_invoice_comp_curr_payment_foreign_curr(self):
- # Invoice of 600 USD (equivalent to 1200 Gol in 2017).
- invoice = self.env['account.move'].create({
- 'move_type': 'out_invoice',
- 'date': '2016-01-01',
- 'invoice_date': '2016-01-01',
- 'partner_id': self.partner_a.id,
- 'currency_id': self.company_data['currency'].id,
- 'invoice_line_ids': [Command.create({
- 'product_id': self.product_a.id,
- 'price_unit': 600.0,
- 'tax_ids': [],
- })],
- })
- invoice.action_post()
- # Payment of 600 USD = 1200 Gol.
- # 1200.0 Gol should be computed correctly to fully paid the invoices.
- wizard = self.env['account.payment.register']\
- .with_context(active_model='account.move', active_ids=invoice.ids)\
- .create({
- 'currency_id': self.currency_data['currency'].id,
- 'payment_date': '2017-01-01',
- })
- self.assertRecordValues(wizard, [{
- 'amount': 1200.0,
- 'payment_difference': 0.0,
- 'currency_id': self.currency_data['currency'].id,
- }])
- payment = wizard._create_payments()
- lines = (invoice + payment.move_id).line_ids.filtered(lambda x: x.account_type == 'asset_receivable')
- self.assertRecordValues(lines, [
- {'amount_residual': 0.0, 'amount_residual_currency': 0.0, 'currency_id': self.company_data['currency'].id, 'reconciled': True},
- {'amount_residual': 0.0, 'amount_residual_currency': 0.0, 'currency_id': self.currency_data['currency'].id, 'reconciled': True},
- ])
- def test_payment_method_different_type_single_batch_not_grouped(self):
- """ Test payment methods when paying a bill and a refund with separated payments (1000 + -2000)."""
- invoice_1 = self.in_invoice_1
- invoice_2 = invoice_1.copy({'invoice_date': invoice_1.invoice_date, 'partner_id': self.partner_b.id})
- refund_1, refund_2 = self.env['account.move'].create([
- {
- 'move_type': 'in_refund',
- 'date': '2017-01-01',
- 'invoice_date': '2017-01-01',
- 'partner_id': self.partner_a.id,
- 'invoice_line_ids': [(0, 0, {'product_id': self.product_a.id, 'price_unit': 1600.0, 'tax_ids': False})],
- },
- {
- 'move_type': 'in_refund',
- 'date': '2017-01-01',
- 'invoice_date': '2017-01-01',
- 'partner_id': self.partner_b.copy({'property_account_position_id': False}).id,
- 'invoice_line_ids': [(0, 0, {'product_id': self.product_a.id, 'price_unit': 1600.0, 'tax_ids': False})],
- },
- ])
- (invoice_2 + refund_1 + refund_2).action_post()
- for moves in ((invoice_1 + invoice_2), (refund_1 + refund_2)):
- wizard = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=moves.ids).create({
- 'group_payment': False,
- })
- expected_available_payment_method_lines = wizard.journal_id.inbound_payment_method_line_ids if moves[0].move_type == 'in_refund' else wizard.journal_id.outbound_payment_method_line_ids
- self.assertRecordValues(wizard, [
- {
- 'available_payment_method_line_ids': expected_available_payment_method_lines.ids,
- 'payment_method_line_id': expected_available_payment_method_lines[:1].id,
- }
- ])
- active_ids = (invoice_1 + invoice_2 + refund_1 + refund_2).ids
- payments = self.env['account.payment.register'].with_context(active_model='account.move', active_ids=active_ids).create({
- 'group_payment': False,
- })._create_payments()
- self.assertRecordValues(payments[0], [
- {
- 'ref': 'BILL/2017/01/0001',
- 'payment_method_line_id': self.bank_journal_1.outbound_payment_method_line_ids[0].id,
- 'payment_type': 'outbound',
- }
- ])
- self.assertRecordValues(payments[1], [
- {
- 'ref': 'BILL/2017/01/0004',
- 'payment_method_line_id': self.bank_journal_1.outbound_payment_method_line_ids[0].id,
- 'payment_type': 'outbound',
- }
- ])
- self.assertRecordValues(payments[2], [
- {
- 'ref': 'RBILL/2017/01/0002',
- 'payment_method_line_id': self.bank_journal_1.inbound_payment_method_line_ids[0].id,
- 'payment_type': 'inbound',
- },
- ])
- self.assertRecordValues(payments[3], [
- {
- 'ref': 'RBILL/2017/01/0003',
- 'payment_method_line_id': self.bank_journal_1.inbound_payment_method_line_ids[0].id,
- 'payment_type': 'inbound',
- },
- ])
- self.assertRecordValues(payments[0].line_ids.sorted('balance'), [
- # == Payment 1: to pay invoice_1 ==
- # Liquidity line:
- {
- 'debit': 0.0,
- 'credit': 1000.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -1000.0,
- 'reconciled': False,
- },
- # Payable line:
- {
- 'debit': 1000.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 1000.0,
- 'reconciled': True,
- },
- ])
- self.assertRecordValues(payments[1].line_ids.sorted('balance'), [
- # == Payment 2: to pay invoice_2 ==
- # Payable line:
- {
- 'debit': 0.0,
- 'credit': 1000.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -1000.0,
- 'reconciled': False,
- },
- # Liquidity line:
- {
- 'debit': 1000.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 1000.0,
- 'reconciled': True,
- },
- ])
- self.assertRecordValues(payments[2].line_ids.sorted('balance'), [
- # == Payment 3: to pay refund_1 ==
- # Liquidity line:
- {
- 'debit': 0.0,
- 'credit': 1600.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -1600.0,
- 'reconciled': True,
- },
- # Payable line:
- {
- 'debit': 1600.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 1600.0,
- 'reconciled': False,
- },
- ])
- self.assertRecordValues(payments[3].line_ids.sorted('balance'), [
- # == Payment 4: to pay refund_2 ==
- # Payable line:
- {
- 'debit': 0.0,
- 'credit': 1600.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': -1600.0,
- 'reconciled': True,
- },
- # Liquidity line:
- {
- 'debit': 1600.0,
- 'credit': 0.0,
- 'currency_id': self.company_data['currency'].id,
- 'amount_currency': 1600.0,
- 'reconciled': False,
- },
- ])
|