隔离美国报价口径,完善条件更正和订单分页
This commit is contained in:
@@ -116,6 +116,17 @@ def number(value, places=2):
|
||||
return format(Decimal(value).quantize(Decimal(10)**-places, rounding=ROUND_HALF_UP), 'f').rstrip('0').rstrip('.') if places else str(value)
|
||||
|
||||
|
||||
def exact_number(value):
|
||||
text=format(Decimal(value),'f')
|
||||
return text.rstrip('0').rstrip('.') if '.' in text else text
|
||||
|
||||
|
||||
def quantity_number(value,intent):
|
||||
if Decimal(value)==Decimal(intent.get('weight') or '0') or Decimal(value).as_tuple().exponent>=-6:
|
||||
return exact_number(value)
|
||||
return '约'+number(value,6)
|
||||
|
||||
|
||||
def render_rates(intent, book, destinations, remote_fees):
|
||||
from .quote_fees import charge_details
|
||||
from .quote_language import translate_quote
|
||||
@@ -124,12 +135,14 @@ def render_rates(intent, book, destinations, remote_fees):
|
||||
if intent.get('mode')=='time':
|
||||
lines.append('美国线路参考时效:')
|
||||
elif intent['weight']:
|
||||
lines.append(f"美国 {number(intent['weight'])}KG 基础运费:")
|
||||
lines.append(f"美国 {exact_number(intent['weight'])}KG 基础运费:")
|
||||
else:
|
||||
lines.append('美国线路报价:')
|
||||
if intent.get('quantity_note'):lines.append(intent['quantity_note'])
|
||||
if intent.get('allocations'):
|
||||
lines.append('按各目的仓分票计算,箱规需逐票核对:')
|
||||
if intent.get('metal_chargeable_weight') is not None:
|
||||
lines.append('请分别提供各目的仓的铁铝货物计费重,整票铁铝基数不能重复套用到每个仓。')
|
||||
elif len(intent.get('warehouses') or [])>1:
|
||||
lines.append('以下按各目的仓分别比较;实际分票请提供每个仓的重量。')
|
||||
if intent.get('air_requested') and not intent.get('air_only'):
|
||||
@@ -138,6 +151,8 @@ def render_rates(intent, book, destinations, remote_fees):
|
||||
part=destination.get('allocation')
|
||||
billing=({**intent,'weight':part['weight'],'packages':part.get('packages'),'dims':None,'cbm':None,'boxes':part.get('boxes')}
|
||||
if part else intent)
|
||||
if part and intent.get('metal_chargeable_weight') is not None:
|
||||
billing.update(metal_chargeable_weight=None,metal_scope='partial')
|
||||
rates = match_rates(billing, book, destination)
|
||||
if intent.get('mode') in ('cheapest','fastest') and rates:
|
||||
if intent['mode']=='cheapest':
|
||||
@@ -181,7 +196,7 @@ def render_rates(intent, book, destinations, remote_fees):
|
||||
total = amount*price
|
||||
details=charge_details(billing,rate,fees,book)
|
||||
total+=details['cny']
|
||||
rate_text += f",{number(amount,3)}{'KG' if unit == 'kg' else 'CBM'} = {number(total)}元"
|
||||
rate_text += f",{quantity_number(amount,billing)}{'KG' if unit == 'kg' else 'CBM'} = {number(total)}元"
|
||||
if details['items']:rate_text+='('+ ';'.join(details['items'])+')'
|
||||
for note in details['notes']:
|
||||
if note not in lines:lines.append(note)
|
||||
|
||||
Reference in New Issue
Block a user