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_ht_parts().items(): ret_dict[tva] = self.floor( math_utils.percentage(total_ht, self.deposit)) return ret_dict
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_ht_parts().items(): ret_dict[tva] = self.floor( math_utils.percentage(total_ht, self.deposit) ) return ret_dict
def post_percent_discount_view(self): """ View handling percent discount configuration Generates discounts for each tva used in this document current context : Invoice/Estimation/CancelInvoice """ percent = self.request.json_body.get('percentage') description = self.request.json_body.get('description') lines = [] if percent is not None and description is not None: tva_parts = self.context.tva_ht_parts() for tva, ht in tva_parts.items(): amount = percentage(ht, percent) line = DiscountLine(description=description, amount=amount, tva=tva) lines.append(line) self.context.discounts.append(line) self.request.dbsession.merge(self.context) return lines
def post_percent_discount_view(self): """ View handling percent discount configuration Generates discounts for each tva used in this document current context : Invoice/Estimation/CancelInvoice """ percent = self.request.json_body.get('percentage') description = self.request.json_body.get('description') lines = [] if percent is not None and description is not None: tva_parts = self.context.tva_ht_parts() for tva, ht in tva_parts.items(): amount = percentage(ht, percent) line = DiscountLine( description=description, amount=amount, tva=tva ) lines.append(line) self.context.discounts.append(line) self.request.dbsession.merge(self.context) return lines
def get_amount(self, product): """ Return the amount for the current module (the same for credit or debit) """ return percentage(product['ht'], self.get_contribution())
def _amount_method(a, b): return percentage(a, b)
def _get_contribution_amount(self, ht): """ Return the contribution on the HT total """ return percentage(ht, self.get_contribution())
def test_percentage(self): # Ref #32 a = 0.25 b = 10000 self.assertEqual(percentage(a, b), 25)