Skip to content
Permalink
Browse files

testeroo real

  • Loading branch information...
kebeclibre committed Mar 21, 2019
1 parent 2bd7cd1 commit 8c515a0ef3f5888cdc383ff81bc0ce9da3a9bd23
Showing with 86 additions and 23 deletions.
  1. +86 −23 addons/account/tests/test_reconciliation.py
@@ -1816,28 +1816,91 @@ def test_reconciliation_cash_basis_fx_02(self):
.filtered(lambda l: l.account_id == self.tax_final_account)
.debit, 17094.66)

def test_reconciliation_cash_basis_foreign_currency_low_values(self):
journal = self.env['account.journal'].create({
'name': 'Bank', 'type': 'bank', 'code': 'THE',
'currency_id': self.currency_usd_id,
# def test_reconciliation_cash_basis_foreign_currency_low_values(self):
# journal = self.env['account.journal'].create({
# 'name': 'Bank', 'type': 'bank', 'code': 'THE',
# 'currency_id': self.currency_usd_id,
# })
# usd = self.env['res.currency'].browse(self.currency_usd_id)
# usd.rate_ids.unlink()
# self.env['res.currency.rate'].create({
# 'name': time.strftime('%Y-01-01'),
# 'rate': 1/17.0,
# 'currency_id': self.currency_usd_id,
# 'company_id': self.env.ref('base.main_company').id,
# })
# invoice = self.create_invoice(
# type='out_invoice', invoice_amount=50,
# currency_id=self.currency_usd_id)
# invoice.journal_id.update_posted = True
# invoice.action_cancel()
# invoice.state = 'draft'
# invoice.invoice_line_ids.write({
# 'invoice_line_tax_ids': [(6, 0, [self.tax_cash_basis.id])]})
# invoice.compute_taxes()
# invoice.action_invoice_open()
# self.make_payment(invoice, journal, invoice.amount_total - 0.01)
# self.make_payment(invoice, journal, 0.01)

def test_reconciliation_cash_basis_revert(self):
company = self.env.ref('base.main_company')
company.tax_cash_basis_journal_id = self.cash_basis_journal
tax_cash_basis10percent = self.tax_cash_basis.copy({'amount': 10})
self.tax_waiting_account.reconcile = True
tax_waiting_account10 = self.tax_waiting_account.copy({
'name': 'TAX WAIT 10',
'code': 'TWAIT1',
})
usd = self.env['res.currency'].browse(self.currency_usd_id)
usd.rate_ids.unlink()
self.env['res.currency.rate'].create({
'name': time.strftime('%Y-01-01'),
'rate': 1/17.0,
'currency_id': self.currency_usd_id,
'company_id': self.env.ref('base.main_company').id,

AccountMoveLine = self.env['account.move.line'].with_context(check_move_validity=False)

# Purchase
purchase_move = self.env['account.move'].create({
'name': 'invoice',
'journal_id': self.purchase_journal.id,
})
invoice = self.create_invoice(
type='out_invoice', invoice_amount=50,
currency_id=self.currency_usd_id)
invoice.journal_id.update_posted = True
invoice.action_cancel()
invoice.state = 'draft'
invoice.invoice_line_ids.write({
'invoice_line_tax_ids': [(6, 0, [self.tax_cash_basis.id])]})
invoice.compute_taxes()
invoice.action_invoice_open()
self.make_payment(invoice, journal, invoice.amount_total - 0.01)
self.make_payment(invoice, journal, 0.01)

purchase_payable_line0 = AccountMoveLine.create({
'account_id': self.account_rsa.id,
'credit': 105,
'move_id': purchase_move.id,
})

AccountMoveLine.create({
'name': 'expenseTaxed 10%',
'account_id': self.expense_account.id,
'debit': 50,
'move_id': purchase_move.id,
'tax_ids': [(4, tax_cash_basis10percent.id, False)],
})
tax_line0 = AccountMoveLine.create({
'name': 'TaxLine0',
'account_id': tax_waiting_account10.id,
'debit': 5,
'move_id': purchase_move.id,
'tax_line_id': tax_cash_basis10percent.id,
})
AccountMoveLine.create({
'name': 'expenseTaxed 20%',
'account_id': self.expense_account.id,
'debit': 83.33,
'move_id': purchase_move.id,
'tax_ids': [(4, self.tax_cash_basis.id, False)],
})
tax_line1 = AccountMoveLine.create({
'name': 'TaxLine1',
'account_id': self.tax_waiting_account.id,
'debit': 16.67,
'move_id': purchase_move.id,
'tax_line_id': self.tax_cash_basis.id,
})
purchase_move.post()

reverted = self.env['account.move'].browse(purchase_move.reverse_moves())
self.assertTrue(reverted.exists())

for inv_line in [purchase_payable_line0, tax_line0, tax_line1]:
self.assertTrue(inv_line.full_reconcile_id.exists())
reverted_expected = reverted.line_ids.filtered(lambda l: l.account_id == inv_line.account_id)
self.assertEqual(len(reverted_expected), 1)
self.assertEqual(reverted_expected.full_reconcile_id == inv_line.full_reconcile_id)

0 comments on commit 8c515a0

Please sign in to comment.
You can’t perform that action at this time.