Prepare account credit note for Tryton 8.0
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
|
||||
from decimal import Decimal
|
||||
import unittest
|
||||
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.modules.account_credit_note.invoice import Invoice
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class MockInvoice:
|
||||
untaxed_amount = Decimal('100.00')
|
||||
total_amount = Decimal('118.00')
|
||||
|
||||
|
||||
class AccountCreditNoteTestCase(ModuleTestCase):
|
||||
"Test Account Credit Note module"
|
||||
module = 'account_credit_note'
|
||||
|
||||
|
||||
class AccountCreditNoteLogicTestCase(unittest.TestCase):
|
||||
|
||||
def test_full_factor(self):
|
||||
self.assertEqual(
|
||||
Invoice._credit_partial_compute_factor(
|
||||
MockInvoice(), 'full', None, None, 'total'),
|
||||
Decimal('1'))
|
||||
|
||||
def test_percent_factor_supports_user_and_internal_values(self):
|
||||
self.assertEqual(
|
||||
Invoice._credit_partial_compute_factor(
|
||||
MockInvoice(), 'percent', Decimal('20'), None, 'total'),
|
||||
Decimal('0.2'))
|
||||
self.assertEqual(
|
||||
Invoice._credit_partial_compute_factor(
|
||||
MockInvoice(), 'percent', Decimal('0.20'), None, 'total'),
|
||||
Decimal('0.20'))
|
||||
|
||||
def test_amount_factor_uses_selected_basis(self):
|
||||
self.assertEqual(
|
||||
Invoice._credit_partial_compute_factor(
|
||||
MockInvoice(), 'amount', None, Decimal('59'), 'total'),
|
||||
Decimal('0.5'))
|
||||
self.assertEqual(
|
||||
Invoice._credit_partial_compute_factor(
|
||||
MockInvoice(), 'amount', None, Decimal('25'), 'untaxed'),
|
||||
Decimal('0.25'))
|
||||
|
||||
def test_amount_can_not_exceed_basis(self):
|
||||
with self.assertRaises(UserError):
|
||||
Invoice._credit_partial_compute_factor(
|
||||
MockInvoice(), 'amount', None, Decimal('119'), 'total')
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
Reference in New Issue
Block a user