def test_total_ttc(self): task = TaskCompute() task.line_groups = [DummyGroup(lines=[DummyLine(cost=1030000, quantity=1.25, tva=1960)])] # cf ticket #501 # line total : 12.875 # tva : 2.5235 -> 2.52 # => total : 15.40 (au lieu de 15.395) assert task.total_ttc() == 1540000
def test_total_ttc(self): task = TaskCompute() task.lines = [DummyLine(cost=1030, quantity=1.25, tva=1960)] # cf ticket #501 # line total : 12.875 # tva : 2.5235 -> 2.52 # A confirmer :l'arrondi ici bas # => total : 15.39 (au lieu de 15.395) self.assertEqual(task.total_ttc(), 1539)
def test_total_ttc(self): task = TaskCompute() task.lines = [DummyLine(cost=1030, quantity=1.25, tva=1960)] # cf ticket #501 # line total : 12.875 # tva : 2.5235 -> 2.52 # A confirmer :l'arrondi ici HALF UP # => total : 15.40 (au lieu de 15.395) assert task.total_ttc() == 1540
def test_get_tvas(self): task = TaskCompute() task.lines = [DummyLine(cost=35000, quantity=1, tva=1960), DummyLine(cost=40000, quantity=1, tva=550)] task.discounts = [DummyLine(amount=1200, tva=550), DummyLine(amount=15000, tva=1960)] tvas = task.get_tvas() self.assertEqual(tvas.keys(), [1960, 550]) self.assertEqual(tvas[1960], 3920) self.assertEqual(tvas[550], 2134)
def test_get_tvas(self): task = TaskCompute() task.lines = [DummyLine(cost=35000, quantity=1, tva=1960), DummyLine(cost=40000, quantity=1, tva=550)] task.discounts = [DummyLine(amount=1200, tva=550), DummyLine(amount=15000, tva=1960)] tvas = task.get_tvas() assert tvas.keys() == [1960, 550] assert tvas[1960] == 3920 assert tvas[550] == 2134
def test_total_ttc(self): task = TaskCompute() task.line_groups = [ DummyGroup( lines=[DummyLine(cost=1030000, quantity=1.25, tva=1960)]) ] # cf ticket #501 # line total : 12.875 # tva : 2.5235 -> 2.52 # => total : 15.40 (au lieu de 15.395) assert task.total_ttc() == 1540000
def test_get_tvas_multiple_rounding(self): task = TaskCompute() task.line_groups = [ DummyGroup( lines=[DummyLine(cost=10004000, quantity=1, tva=1000), DummyLine(cost=5002000, quantity=1, tva=2000)] ) ] # Ref https://github.com/CroissanceCommune/autonomie/issues/305 tvas = task.get_tvas() assert tvas[1000] == 1000000 assert task.tva_amount() == 2000000
def test_get_tva_ht_parts(self): task = TaskCompute() task.expenses_tva = 2000 task.line_groups = [DummyGroup( lines=[ DummyLine(cost=-120000000, quantity=1, tva=2000), DummyLine(cost=-120000000, quantity=0.5, tva=2000), ] )] task.expenses_ht = -36000000 assert task.tva_ht_parts()[2000] == -216000000.0
def test_get_tvas_multiple_rounding(self): task = TaskCompute() task.line_groups = [ DummyGroup(lines=[ DummyLine(cost=10004000, quantity=1, tva=1000), DummyLine(cost=5002000, quantity=1, tva=2000), ]) ] # Ref https://github.com/CroissanceCommune/autonomie/issues/305 tvas = task.get_tvas() assert tvas[1000] == 1000000 assert task.tva_amount() == 2000000
def test_get_tvas_multiple(self): task = TaskCompute() task.line_groups = [ DummyGroup(lines=[ DummyLine(cost=35000000, quantity=1, tva=1960), DummyLine(cost=40000000, quantity=1, tva=550) ]) ] task.discounts = [ DummyDiscountLine(amount=1200000, tva=550), DummyDiscountLine(amount=15000000, tva=1960) ] tvas = task.get_tvas() assert tvas.keys() == [1960, 550] assert tvas[1960] == 3920000 assert tvas[550] == 2134000
def invoice(def_tva, tva): p1 = MagicMock(name="product 1", compte_cg="P0001", tva=def_tva) p2 = MagicMock(name="product 2", compte_cg="P0002", tva=tva) line1 = DummyLine( cost=10000, quantity=1, tva=def_tva.value, product=p1, tva_object=def_tva ) line2 = DummyLine( cost=10000, quantity=1, tva=def_tva.value, product=p1, tva_object=def_tva, ) line3 = DummyLine( cost=10000, quantity=1, tva=tva.value, product=p2, tva_object=tva, ) company = Dummy(name="company", code_compta='COMP_CG', contribution=None) customer = Dummy(name="customer", compte_tiers="CUSTOMER", compte_cg='CG_CUSTOMER') invoice = TaskCompute() invoice.default_tva = def_tva.value invoice.expenses_tva = def_tva.value invoice.taskDate = datetime.date(2013, 02, 02) invoice.customer = customer invoice.company = company invoice.official_number = "INV_001" invoice.lines = [line1, line2, line3] invoice.expenses_ht = 10000 invoice.expenses = 10000 return invoice
def test_get_tva_ht_parts(self): task = TaskCompute() task.expenses_tva = 2000 task.line_groups = [ DummyGroup(lines=[ DummyLine(cost=-120000000, quantity=1, tva=2000), DummyLine(cost=-120000000, quantity=0.5, tva=2000), ]) ] task.expenses_ht = -36000000 assert task.tva_ht_parts()[2000] == -216000000.0
def prepare(discount=False): tva1 = MagicMock(name="tva1", value=1960, default=0, compte_cg="TVA0001", code='CTVA0001') tva2 = MagicMock(name="tva2", value=700, default=0, compte_cg="TVA0002", code='CTVA0002') p1 = MagicMock(name="product 1", compte_cg="P0001", tva=tva1) p2 = MagicMock(name="product 2", compte_cg="P0002", tva=tva2) line1 = DummyLine(cost=10000, quantity=1, tva=tva1.value, product=p1, tva_object=tva1) line2 = DummyLine(cost=10000, quantity=1, tva=tva1.value, product=p1, tva_object=tva1) line3 = DummyLine(cost=10000, quantity=1, tva=tva2.value, product=p2, tva_object=tva2) company = Dummy(name="company", code_compta='COMP_CG', contribution=None) customer = Dummy(name="customer", compte_tiers="CUSTOMER", compte_cg='CG_CUSTOMER') invoice = TaskCompute() invoice.taskDate = datetime.date(2013, 02, 02) invoice.customer = customer invoice.company = company invoice.officialNumber = "INV_001" invoice.lines = [line1, line2, line3] if discount: discount1 = DummyLine(cost=10000, quantity=1, tva=tva1.value, tva_object=tva1) discount2 = DummyLine(cost=10000, quantity=1, tva=tva2.value, tva_object=tva2) invoice.discounts = [discount1, discount2] invoice.expenses_ht = 10000 invoice.expenses = 10000 return ((tva1, tva2), (p1, p2), invoice)
def invoice_bug400(def_tva, tva20): prod = MagicMock(name="product 2", compte_cg="P0002", tva=tva20) lines = [] for cost, qtity in ( (22112500, 1), ): lines.append( DummyLine( cost=cost, quantity=qtity, tva=tva20.value, product=prod, tva_object=tva20 ) ) group = DummyGroup(lines=lines) company = Dummy(name="company", code_compta='COMP_CG', contribution=None) customer = Dummy(name="customer", compte_tiers="CUSTOMER", compte_cg='CG_CUSTOMER') invoice = TaskCompute() invoice.default_tva = def_tva.value invoice.expenses_tva = def_tva.value invoice.date = datetime.date(2013, 02, 02) invoice.customer = customer invoice.company = company invoice.official_number = "INV_001" invoice.line_groups = [group] invoice.all_lines = group.lines invoice.expenses_ht = 0 invoice.expenses = 0 return invoice
def prepare(discount=False): tva1 = MagicMock(name="tva1", value=1960, default=0, compte_cg="TVA0001", code='CTVA0001') tva2 = MagicMock(name="tva2", value=700, default=0, compte_cg="TVA0002", code='CTVA0002') p1 = MagicMock(name="product 1", compte_cg="P0001", tva=tva1) p2 = MagicMock(name="product 2", compte_cg="P0002", tva=tva2) line1 = DummyLine(cost=10000, quantity=1, tva=tva1.value, product=p1, tva_object=tva1) line2 = DummyLine(cost=10000, quantity=1, tva=tva1.value, product=p1, tva_object=tva1) line3 = DummyLine(cost=10000, quantity=1, tva=tva2.value, product=p2, tva_object=tva2) company = Dummy(name="company", code_compta='COMP_CG', contribution=None) customer = Dummy(name="customer", compte_tiers="CUSTOMER", compte_cg='CG_CUSTOMER') invoice = TaskCompute() invoice.default_tva = 1960 invoice.expenses_tva = 1960 invoice.taskDate = datetime.date(2013, 02, 02) invoice.customer = customer invoice.company = company invoice.official_number = "INV_001" invoice.lines = [line1, line2, line3] if discount: discount1 = DummyLine(cost=10000, quantity=1, tva=tva1.value, tva_object=tva1) discount2 = DummyLine(cost=10000, quantity=1, tva=tva2.value, tva_object=tva2) invoice.discounts = [discount1, discount2] invoice.expenses_ht = 10000 invoice.expenses = 10000 return ((tva1, tva2), (p1, p2), invoice)
def invoice(def_tva, tva): p1 = MagicMock(name="product 1", compte_cg="P0001", tva=def_tva) p2 = MagicMock(name="product 2", compte_cg="P0002", tva=tva) line1 = DummyLine(cost=10000000, quantity=1, tva=def_tva.value, product=p1, tva_object=def_tva) line2 = DummyLine( cost=10000000, quantity=1, tva=def_tva.value, product=p1, tva_object=def_tva, ) line3 = DummyLine( cost=10000000, quantity=1, tva=tva.value, product=p2, tva_object=tva, ) group = DummyGroup(lines=( line1, line2, line3, )) company = Dummy(name="company", code_compta='COMP_CG', contribution=None) customer = Dummy(name="customer", compte_tiers="CUSTOMER", compte_cg='CG_CUSTOMER') invoice = TaskCompute() invoice.default_tva = def_tva.value invoice.expenses_tva = def_tva.value invoice.date = datetime.date(2013, 02, 02) invoice.customer = customer invoice.company = company invoice.official_number = "INV_001" invoice.line_groups = [group] invoice.all_lines = group.lines invoice.expenses_ht = 10000000 invoice.expenses = 10000000 return invoice
def invoice_bug400(def_tva, tva20): prod = MagicMock(name="product 2", compte_cg="P0002", tva=tva20) lines = [] for cost, qtity in ((22112500, 1), ): lines.append( DummyLine(cost=cost, quantity=qtity, tva=tva20.value, product=prod, tva_object=tva20)) group = DummyGroup(lines=lines) company = Dummy(name="company", code_compta='COMP_CG', contribution=None) customer = Dummy(name="customer", compte_tiers="CUSTOMER", compte_cg='CG_CUSTOMER') invoice = TaskCompute() invoice.default_tva = def_tva.value invoice.expenses_tva = def_tva.value invoice.date = datetime.date(2013, 02, 02) invoice.customer = customer invoice.company = company invoice.official_number = "INV_001" invoice.line_groups = [group] invoice.all_lines = group.lines invoice.expenses_ht = 0 invoice.expenses = 0 return invoice
def invoice_bug363(def_tva, tva10): prod = MagicMock(name="product 2", compte_cg="P0002", tva=tva10) lines = [] for cost, qtity in ( (15000000, 1), (2000000, 86), (-173010000, 1), (10000000, 1), (-201845000, 1), (4500000, 33), (1800000, 74), (3500000, 28), ): lines.append(DummyLine(cost=cost, quantity=qtity, tva=tva10.value, product=prod, tva_object=tva10)) group = DummyGroup(lines=lines) company = Dummy(name="company", code_compta="COMP_CG", contribution=None) customer = Dummy(name="customer", compte_tiers="CUSTOMER", compte_cg="CG_CUSTOMER") invoice = TaskCompute() invoice.default_tva = def_tva.value invoice.expenses_tva = def_tva.value invoice.date = datetime.date(2016, 05, 04) invoice.customer = customer invoice.company = company invoice.official_number = "INV_002" invoice.line_groups = [group] invoice.all_lines = group.lines invoice.expenses_ht = 0 invoice.expenses = 0 return invoice