bugfix
This commit is contained in:
parent
5ce62b2129
commit
2e3755e262
@ -184,7 +184,13 @@ class PricingProgram:
|
|||||||
e = f'pricing_program({pptid}) can not find pricing_program'
|
e = f'pricing_program({pptid}) can not find pricing_program'
|
||||||
exception(f)
|
exception(f)
|
||||||
pp = pps[0]
|
pp = pps[0]
|
||||||
fields = yaml.safe_load(pp.pricing_spec)
|
pp_spec = yaml.safe_load(pp.pricing_spec)
|
||||||
|
formula = None
|
||||||
|
if pp_spec.get('fields'):
|
||||||
|
fields = pp_spec.get('fields')
|
||||||
|
pricing_formula = pp_spec.get('formula')
|
||||||
|
else:
|
||||||
|
fields = pp_spec
|
||||||
newpricings = []
|
newpricings = []
|
||||||
for p in pricings:
|
for p in pricings:
|
||||||
np = {}
|
np = {}
|
||||||
@ -195,6 +201,7 @@ class PricingProgram:
|
|||||||
newpricings.append(np)
|
newpricings.append(np)
|
||||||
d = {
|
d = {
|
||||||
'fields': fields,
|
'fields': fields,
|
||||||
|
'formula': formula,
|
||||||
'pricings': newpricings
|
'pricings': newpricings
|
||||||
}
|
}
|
||||||
debug(f'{d=}')
|
debug(f'{d=}')
|
||||||
@ -328,6 +335,7 @@ where a.id = b.ppid
|
|||||||
if not d.pricing:
|
if not d.pricing:
|
||||||
exception(f'{d} has not "pricing"')
|
exception(f'{d} has not "pricing"')
|
||||||
raise Exception(f'定价定义中没有pricing数据')
|
raise Exception(f'定价定义中没有pricing数据')
|
||||||
|
formula = d.formula
|
||||||
ret_items = []
|
ret_items = []
|
||||||
for i, p in enumerate(d.pricings):
|
for i, p in enumerate(d.pricings):
|
||||||
p_ok = True
|
p_ok = True
|
||||||
@ -360,6 +368,16 @@ where a.id = b.ppid
|
|||||||
exception(e)
|
exception(e)
|
||||||
raise Exception(e)
|
raise Exception(e)
|
||||||
np = p.copy()
|
np = p.copy()
|
||||||
|
times = float(times)
|
||||||
|
unit = float(unit)
|
||||||
|
if formula:
|
||||||
|
ns = {
|
||||||
|
'price': p.price,
|
||||||
|
'times': times,
|
||||||
|
'unit': unit
|
||||||
|
}
|
||||||
|
np.amount = eval(formula, ns)
|
||||||
|
else:
|
||||||
np.amount = p.price * float(times) / float(unit)
|
np.amount = p.price * float(times) / float(unit)
|
||||||
ret_items.append(np)
|
ret_items.append(np)
|
||||||
if len(ret_items) == 0:
|
if len(ret_items) == 0:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user