feat(est): persist and refresh Excel quantity links

This commit is contained in:
2026-11-07 15:56:04 +09:00
parent aac94d6508
commit fd6e2e6933
7 changed files with 165 additions and 12 deletions
+22 -1
View File
@@ -16,10 +16,31 @@ def test_excel_quantity_cell_rejects_invalid_address_or_non_numeric_value():
for(const [name,address,t,v] of [['Other','B2','n','1'],['Data','XFE1','n','1'],['Data','B3','n','1'],['Data','B2','s','1'],['Data','B2','n',''],['Data','B2','n','1e100']]){
type=t;value=v;try{EstQuantity.excelCell(files,name,address)}catch{rejected++}
}
type='n';value='8';const p={tables:{EstMainDat:[{PkID:1,GN:2},{PkID:2,GN:3}]},excelQuantityLinks:[{target:1,file:'a.xlsx',sheet:'Data',cell:'B2'},{target:2,file:'a.xlsx',sheet:'Data',cell:'B2'}]};
const updates=EstQuantity.excelUpdates(p,'a.xlsx',files).map(x=>x.value),before=p.tables.EstMainDat.map(x=>x.GN);let bad=0;
p.excelQuantityLinks[1].cell='B3';try{EstQuantity.excelUpdates(p,'a.xlsx',files)}catch{bad++}
p.tables.EstMainDat.push({PkID:1});try{EstQuantity.excelUpdates(p,'a.xlsx',files)}catch{bad++}
try{EstQuantity.excelUpdates(p,'missing.xlsx',files)}catch{bad++}
return {valid,rejected,updates,before,bad};
})()""",
)
assert result == {"valid": 6.25, "rejected": 6, "updates": [8, 8], "before": [2, 3], "bad": 3}
def test_excel_quantity_links_validate_and_survive_project_validation():
result = run(
"math",
"""(()=>{
const p=EstNative.empty();p.excelQuantityLinks=[{target:1,file:'a.xlsx',sheet:'Data',cell:'B2'}];
const valid=EstModel.validate(p).excelQuantityLinks;let rejected=0;
for(const bad of [[valid[0],valid[0]],[{...valid[0],target:'1'}],[{...valid[0],cell:'wrong'}],[{...valid[0],cell:'XFE1'}],[{...valid[0],cell:'A1048577'}]]){
const q=EstNative.empty();q.excelQuantityLinks=bad;try{EstModel.validate(q)}catch{rejected++}
}
return {valid,rejected};
})()""",
)
assert result == {"valid": 6.25, "rejected": 6}
assert result["valid"] == [{"target": 1, "file": "a.xlsx", "sheet": "Data", "cell": "B2"}]
assert result["rejected"] == 5
def test_apply_all_quantities_sums_sheets_and_rejects_errors_atomically():