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'
|
||||
exception(f)
|
||||
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 = []
|
||||
for p in pricings:
|
||||
np = {}
|
||||
@ -195,6 +201,7 @@ class PricingProgram:
|
||||
newpricings.append(np)
|
||||
d = {
|
||||
'fields': fields,
|
||||
'formula': formula,
|
||||
'pricings': newpricings
|
||||
}
|
||||
debug(f'{d=}')
|
||||
@ -328,6 +335,7 @@ where a.id = b.ppid
|
||||
if not d.pricing:
|
||||
exception(f'{d} has not "pricing"')
|
||||
raise Exception(f'定价定义中没有pricing数据')
|
||||
formula = d.formula
|
||||
ret_items = []
|
||||
for i, p in enumerate(d.pricings):
|
||||
p_ok = True
|
||||
@ -360,7 +368,17 @@ where a.id = b.ppid
|
||||
exception(e)
|
||||
raise Exception(e)
|
||||
np = p.copy()
|
||||
np.amount = p.price * float(times) / float(unit)
|
||||
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)
|
||||
ret_items.append(np)
|
||||
if len(ret_items) == 0:
|
||||
e = f'{config_data=}{yamlstr=}没有找到合适的定价'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user