def _round_products(self): """ Round the products ht and tva """ for value in self.products.values(): value['ht'] = floor(value['ht']) value['tva'] = floor(value['tva'])
def test_floor(self): # Ref #727 a = 292.65 * 100.0 self.assertEqual(floor(a), 29265) a = 29264.91 self.assertEqual(floor(a), 29265) a = 29264.5 self.assertEqual(floor(a), 29265)
def total_ht(self): """ compute the HT amount """ expenses_ht = self.expenses_ht or 0 return floor(self.lines_total_ht() - self.discount_total_ht() + expenses_ht)
def deposit_amounts(self): """ Return the lines of the deposit for the different amount of tvas """ ret_dict = {} for tva, total_ht in self.tva_parts().items(): ret_dict[tva] = floor(total_ht * int(self.deposit) / 100.0) return ret_dict
def _compute_value(self, val): result = 0 if self.type_object is not None: if self.type_object.type == 'expensetel': percentage = self.type_object.percentage val = val * percentage / 100.0 result = math_utils.floor(val) return result
def get_amount(self): """ Returns the reversed tva amount """ tva_amount = self.payment.tva.value ht_value = reverse_tva(self.payment.amount, tva_amount) tva_value = compute_tva(ht_value, tva_amount) return floor(tva_value)
def paymentline_amount_ttc(self): """ Return the ttc amount of payment (in equal repartition) """ total_ttc = 0 for tva, total_ht in self.paymentline_amounts().items(): line = LineCompute(cost=total_ht, tva=tva) total_ttc += floor(line.total()) return total_ttc
def _compute_value(self, val): result = 0 # In the first versions it was possible to delete expensetypes (now they # are disabled instead) if self.type_object is not None: if self.type_object.type == 'expensetel': percentage = self.type_object.percentage val = val * percentage / 100.0 result = math_utils.floor(val) return result
def deposit_amount(self): """ Compute the amount of the deposit """ import warnings warnings.warn("deprecated", DeprecationWarning) if self.deposit > 0: total = self.total_ht() return floor(total * int(self.deposit) / 100.0) return 0
def deposit_amount_ttc(self): """ Return the ttc amount of the deposit (for estimation display) """ if self.deposit > 0: total_ttc = 0 for tva, total_ht in self.deposit_amounts().items(): line = LineCompute(cost=total_ht, tva=tva) total_ttc += line.total() return floor(total_ttc) return 0
def test_manual_payment_line_amounts(self): def compute_payment_ttc(payment): total = 0 for tva, ht in payment.items(): line = DummyLine(tva=tva, cost=ht) total += line.total() return total task = self.getOne() task.manualDeliverables = 1 payments = task.manual_payment_line_amounts() assert payments[0].keys() == [1960] assert payments[1].keys() == [1960, 500] assert payments[2].keys() == [500] deposit = task.deposit_amount_ttc() amount1 = compute_payment_ttc(payments[0]) amount2 = compute_payment_ttc(payments[1]) assert math_utils.floor(amount1) == 4000000 assert math_utils.floor(amount2) == 6000000 total = task.sold() + deposit + amount1 + amount2 assert math_utils.floor_to_precision(total) == task.total()
def total(self): indemnity = self.type_object.amount return math_utils.floor(indemnity * self.km)
def floor(self, amount): return math_utils.floor(amount, self.round_floor)
def tva_amount(self): """ Compute the sum of the TVAs amount of TVA """ return floor(sum(tva for tva in self.get_tvas().values()))
# so it fits the limit case # # Line totals should be floats (here they are *100) from autonomie.tests.base import Dummy TASK_LINES_TOTAL_HT = (12531.25, 22500, -5200) TASK_LINES_TVAS = (2456.125, 4410, -1019.2) LINES_TOTAL_HT = sum(TASK_LINES_TOTAL_HT) LINES_TOTAL_TVAS = sum(TASK_LINES_TVAS) EXPENSE_TVA = 196 DISCOUNT_TOTAL_HT = sum([d['amount']for d in DISCOUNTS]) DISCOUNT_TVAS = (392,) DISCOUNT_TOTAL_TVAS = sum(DISCOUNT_TVAS) HT_TOTAL = math_utils.floor(LINES_TOTAL_HT - DISCOUNT_TOTAL_HT + TASK['expenses_ht']) TVA = math_utils.floor(LINES_TOTAL_TVAS - DISCOUNT_TOTAL_TVAS + EXPENSE_TVA) # TASK_TOTAL = lines + tva + expenses rounded TASK_TOTAL = HT_TOTAL + TVA + TASK['expenses'] class DummyLine(Dummy, LineCompute): """ Dummy line model """ pass class DummyTask(Dummy, TaskCompute): """