允许手动移除附加成本并保留草稿模板删除状态
This commit is contained in:
1 parent
5777036743
commit
a3262a455d
8 files changed
+109
-11
No files matched your search
@@ -15,10 +15,11 @@
|
||||
for(const item of raw){
|
||||
if(!item||typeof item!=='object')throw new Error('附加项目格式无效');
|
||||
const id=item.id==null?'':String(item.id);if(id&&!/^[a-f0-9-]{36}$/.test(id))throw new Error('附加项目标识无效');
|
||||
if(item.costRemoved!==undefined&&typeof item.costRemoved!=='boolean')throw new Error('内部成本移除标记无效');
|
||||
const blank=item.amount==null||item.amount==='';const name=String(item.name??'').trim();
|
||||
if(blank&&(!id||!name))continue;
|
||||
if(!name||name.length>40)throw new Error('附加项目名称须为1~40字');
|
||||
const amount=blank?null:cents(item.amount,'附加项目金额');items.push({...(id?{id}:{}),name,amount});total+=amount||0;
|
||||
const amount=blank?null:cents(item.amount,'附加项目金额');items.push({...(id?{id}:{}),name,amount,...(item.costRemoved===true?{costRemoved:true}:{})});total+=amount||0;
|
||||
}
|
||||
if(total>100000000000)throw new Error('附加项目合计超出支持范围');
|
||||
return {items,total};
|
||||
|
||||
Reference in new issue
Block a user