Commit c462a6e4 authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request: quantity precision is not related to the price currency

parent 07fd88e9
......@@ -53,26 +53,6 @@ if (0 < unused_day_count):
**sale_packing_list_edit_kw
)
"""
price = -subscription_request.getPrice() * (unused_day_count / (next_period_date - start_date))
precision = context.getQuantityPrecisionFromResource(subscription_request.getPriceCurrencyValue())
# Use currency precision to reduce the float length
price = float(('%%0.%sf' % precision) % price)
discount_service = portal.restrictedTraverse('service_module/slapos_discount')
sale_packing_list.newContent(
portal_type="Sale Packing List Line",
resource_value=discount_service,
# Use a quantity of 1 to be able to count how many discount were distributed
quantity=1,
price=price,
quantity_unit_value=discount_service.getQuantityUnitValue(),
base_contribution_list=discount_service.getBaseContributionList(),
use=discount_service.getUse(),
activate_kw=activate_kw
)
"""
variation_category_list = open_sale_order_cell.getVariationCategoryList()
sale_packing_list_line = sale_packing_list.newContent(
portal_type="Sale Packing List Line",
......@@ -104,19 +84,10 @@ if (0 < unused_day_count):
quantity = open_sale_order_cell.getQuantity() * (unused_day_count / (next_period_date - start_date))
# precision = context.getQuantityPrecisionFromResource(subscription_request.getResourceValue())
# XXX use currency precision, to ensure accounting is readable?
precision = context.getQuantityPrecisionFromResource(open_sale_order_cell.getPriceCurrencyValue())
# precision = 3
precision = context.getQuantityPrecisionFromResource(open_sale_order_cell.getResourceValue())
# Use currency precision to reduce the float length
quantity = float(('%%0.%sf' % precision) % quantity)
# raise NotImplementedError('%s %s -- %s' % (precision, quantity, subscription_request.getResourceValue().getBaseUnitQuantity()))
price = -open_sale_order_cell.getPrice() * (unused_day_count / (next_period_date - start_date))
precision = context.getQuantityPrecisionFromResource(open_sale_order_cell.getPriceCurrencyValue())
# Use currency precision to reduce the float length
price = float(('%%0.%sf' % precision) % price)
aggregate_value_list = [x for x in open_sale_order_cell.getAggregateValue() if (x.getPortalType() != 'Hosting Subscription')]
sale_packing_list_cell.edit(
# Quantity is negative, to reduce the stock of the consumed product
......@@ -126,7 +97,6 @@ if (0 < unused_day_count):
activate_kw=activate_kw
)
# """
sale_packing_list.Delivery_fixBaseContributionTaxableRate()
sale_packing_list.Base_checkConsistency()
sale_packing_list.confirm()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment