[TELE-694] fix postage fees is sended by mail (2nd)

This commit is contained in:
Daniel Muyshond 2020-10-06 12:36:18 +02:00
parent 6d59e18def
commit 9d2d2594b7
1 changed files with 5 additions and 5 deletions

View File

@ -63,17 +63,17 @@ class ExtraFees(BaseResource):
for basket_item in data['data']:
try:
nb_documents += int(basket_item['request_data']['nb_documents'])
# Check if the item in send by mail and if so there is no postage_fee
destination = basket_item["request_data"]["form_var_destinations_raw"]
if destination and "mail" in destination:
postage_fee = 0
postage_fee = nb_letter * postage_fee
if Decimal(basket_item['request_data']['postage_fee']) > postage_fee:
postage_fee = Decimal(basket_item['request_data']['postage_fee'])
except KeyError:
# basket item not associated with any document, no fee
pass
nb_letter = int(nb_documents / int(self.max_doc_in_letter)) + (((nb_documents % int(self.max_doc_in_letter)) > 0) and 1 or 0)
# Check is the item in send by mail and if so there is no postage_fee
destination = basket_item["request_data"]["form_var_destinations_raw"]
if destination and "mail" in destination:
postage_fee = 0
postage_fee = nb_letter * postage_fee
return {'data': [{'subject': force_text(_('Postage')), 'amount': str(postage_fee)}]}
def namur_compute(self, request, **kwargs):