コード例 #1
0
ファイル: sage.py プロジェクト: Orelab/autonomie
 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'])
コード例 #2
0
ファイル: sage.py プロジェクト: w3bcr4ft/autonomie
 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'])
コード例 #3
0
ファイル: test_math_utils.py プロジェクト: yledoare/autonomie
 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)
コード例 #4
0
ファイル: test_math_utils.py プロジェクト: w3bcr4ft/autonomie
 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)
コード例 #5
0
ファイル: task.py プロジェクト: yledoare/autonomie
 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)
コード例 #6
0
ファイル: task.py プロジェクト: yledoare/autonomie
 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
コード例 #7
0
 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
コード例 #8
0
 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
コード例 #9
0
 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)
コード例 #10
0
ファイル: sage.py プロジェクト: Orelab/autonomie
 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)
コード例 #11
0
ファイル: task.py プロジェクト: yledoare/autonomie
 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
コード例 #12
0
 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
コード例 #13
0
ファイル: treasury.py プロジェクト: yledoare/autonomie
 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
コード例 #14
0
ファイル: task.py プロジェクト: yledoare/autonomie
 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
コード例 #15
0
ファイル: task.py プロジェクト: yledoare/autonomie
 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
コード例 #16
0
ファイル: test_task.py プロジェクト: tonthon/autonomie
    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()
コード例 #17
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()
コード例 #18
0
ファイル: treasury.py プロジェクト: yledoare/autonomie
 def total(self):
     indemnity = self.type_object.amount
     return math_utils.floor(indemnity * self.km)
コード例 #19
0
ファイル: task.py プロジェクト: w3bcr4ft/autonomie
 def floor(self, amount):
     return math_utils.floor(amount, self.round_floor)
コード例 #20
0
ファイル: task.py プロジェクト: yledoare/autonomie
 def tva_amount(self):
     """
         Compute the sum of the TVAs amount of TVA
     """
     return floor(sum(tva for tva in self.get_tvas().values()))
コード例 #21
0
 def total(self):
     indemnity = self.type_object.amount
     return math_utils.floor(indemnity * self.km)
コード例 #22
0
 def floor(self, amount):
     return math_utils.floor(amount, self.round_floor)
コード例 #23
0
ファイル: test_task.py プロジェクト: w3bcr4ft/autonomie
# 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):
    """