1
0
Fork 0
mirror of synced 2023-12-13 21:20:09 +01:00

Add sale payment type and bank account scenario test

#035806
From changeset-6375d1230d21
This commit is contained in:
Raimon Esteve 2018-10-24 12:32:33 +02:00
parent 145c53d383
commit e8d5ec642c
2 changed files with 152 additions and 0 deletions

View file

@ -0,0 +1,148 @@
==========================
Sale Payment Type Scenario
==========================
Imports::
>>> import datetime
>>> from dateutil.relativedelta import relativedelta
>>> from decimal import Decimal
>>> from trytond.tests.tools import activate_modules
>>> from proteus import config, Model, Wizard, Report
>>> from trytond.modules.company.tests.tools import create_company, \
... get_company
>>> from trytond.modules.account.tests.tools import create_fiscalyear, \
... create_chart, get_accounts, create_tax
>>> from trytond.modules.account_invoice.tests.tools import \
... set_fiscalyear_invoice_sequences, create_payment_term
>>> today = datetime.date.today()
Install sale_payment_type and account_bank::
>>> config = activate_modules(['sale_payment_type', 'account_bank'])
Create company::
>>> _ = create_company()
>>> company = get_company()
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear(company))
>>> fiscalyear.click('create_period')
Create chart of accounts::
>>> _ = create_chart(company)
>>> accounts = get_accounts(company)
>>> revenue = accounts['revenue']
>>> expense = accounts['expense']
>>> cash = accounts['cash']
>>> Journal = Model.get('account.journal')
>>> cash_journal, = Journal.find([('type', '=', 'cash')])
>>> cash_journal.credit_account = cash
>>> cash_journal.debit_account = cash
>>> cash_journal.save()
Create tax::
>>> tax = create_tax(Decimal('.10'))
>>> tax.save()
Create product::
>>> ProductUom = Model.get('product.uom')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> ProductTemplate = Model.get('product.template')
>>> Product = Model.get('product.product')
>>> product = Product()
>>> template = ProductTemplate()
>>> template.name = 'product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.salable = True
>>> template.list_price = Decimal('10')
>>> template.cost_price_method = 'fixed'
>>> template.account_expense = expense
>>> template.account_revenue = revenue
>>> template.supplier_taxes.append(tax)
>>> product, = template.products
>>> product.cost_price = Decimal('5')
>>> template.save()
>>> product, = template.products
Create payment term::
>>> payment_term = create_payment_term()
>>> payment_term.save()
Create payment type::
>>> PaymentType = Model.get('account.payment.type')
>>> receivable = PaymentType(name='Receivable', kind='receivable')
>>> receivable.account_bank = 'party'
>>> receivable.save()
>>> payable = PaymentType(name='Payable', kind='payable')
>>> payable.save()
>>> both = PaymentType(name='Both', kind='both')
>>> both.save()
Create party::
>>> Party = Model.get('party.party')
>>> party = Party(name='Party')
>>> party.customer_payment_type = receivable
>>> party.supplier_payment_type = payable
>>> party.save()
Create bank account::
>>> Bank = Model.get('bank')
>>> BankAccount = Model.get('bank.account')
>>> BankNumber = Model.get('bank.account.number')
>>> bparty = Party()
>>> bparty.name = 'Bank'
>>> bparty.save()
>>> bank = Bank(party=bparty)
>>> bank.save()
>>> bank_account = BankAccount()
>>> bank_account.bank = bank
>>> bank_number = bank_account.numbers.new()
>>> bank_number.type = 'iban'
>>> bank_number.number = 'BE82068896274468'
>>> bank_number = bank_account.numbers.new()
>>> bank_number.type = 'other'
>>> bank_number.number = 'not IBAN'
>>> bank_account.save()
>>> party.bank_accounts.append(bank_account)
>>> party.save()
Sale with payment type payable::
>>> Sale = Model.get('sale.sale')
>>> SaleLine = Model.get('sale.line')
>>> sale = Sale()
>>> sale.party = party
>>> sale.payment_term = payment_term
>>> sale.payment_type = receivable
>>> sale.invoice_method = 'order'
>>> sale_line = SaleLine()
>>> sale.lines.append(sale_line)
>>> sale_line.product = product
>>> sale_line.quantity = 2.0
>>> sale_line = SaleLine()
>>> sale.lines.append(sale_line)
>>> sale_line.product = product
>>> sale_line.quantity = 3.0
>>> sale.click('quote')
>>> sale.click('confirm')
>>> sale.click('process')
>>> sale.state
u'processing'
>>> invoice, = sale.invoices
>>> invoice.payment_type == receivable
True
>>> invoice.bank_account == bank_account
True

View file

@ -26,4 +26,8 @@ def suite():
tearDown=doctest_teardown, encoding='UTF-8',
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE,
checker=doctest_checker))
suite.addTests(doctest.DocFileSuite('scenario_sale_payment_type_bank_account.rst',
tearDown=doctest_teardown, encoding='UTF-8',
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE,
checker=doctest_checker))
return suite