fix(est): apply head cost classification safely

This commit is contained in:
2026-11-07 16:39:55 +09:00
parent 9eae77d8f2
commit 5e72aff136
7 changed files with 68 additions and 18 deletions
+27
View File
@@ -42,6 +42,33 @@ def test_estimate_classification_refreshes_only_selected_source_and_preserves_ma
assert result["other"] and not result["flag"]
def test_head_classification_preserves_other_groups_and_rejects_unsafe_restoration():
result = run(
"math",
"""(()=>{
const p=EstNative.empty();p.options.SourceRefresh=false;p.options.AutoCalc=false;
p.tables.StuffcDat=[{Code:'M',Name:'material',Cost1:100,ValueIndex:0},{Code:'N',Name:'other',Cost1:800,ValueIndex:0}];
p.tables.HeadMainDat=[{Index:1,Code:'H1',Name:'first'},{Index:0,Code:'M',LinkIndex:5,GN:2,GU:100,GC:200,JC:0},
{Index:2,Code:'H2',Name:'second'},{Index:0,Code:'N',LinkIndex:5,GN:1,GU:5,GC:5}];
const row=p.tables.HeadMainDat[1],other=JSON.stringify(p.tables.HeadMainDat[3]);
EstBusinessActions.setEstimateClassification(p,row,1,3,'HeadMainDat');
const otherPreserved=JSON.stringify(p.tables.HeadMainDat[3])===other;
const manual={JU:row.JU,GU:row.GU,GC:row.GC,JC:row.JC};
const auto=EstNative.calculate(p).tables.HeadMainDat[1];
EstBusinessActions.setEstimateClassification(p,row,1,0,'HeadMainDat');
const restored={GU:row.GU,JU:row.JU};
const mismatch=p.tables.HeadMainDat[3];EstBusinessActions.setEstimateClassification(p,mismatch,3,3,'HeadMainDat');
let rejected=false;try{EstBusinessActions.setEstimateClassification(p,mismatch,3,0,'HeadMainDat')}catch{rejected=true}
return {manual,auto:{GC:auto.GC,JC:auto.JC},restored,rejected,mismatch,otherPreserved,flag:p.options.SourceRefresh};
})()""",
)
assert result["manual"] == {"JU": 100, "GU": 0, "GC": 200, "JC": 0}
assert result["auto"] == {"GC": 0, "JC": 200}
assert result["restored"] == {"GU": 100, "JU": 0}
assert result["rejected"] and result["mismatch"]["JU"] == 5
assert result["otherPreserved"] and not result["flag"]
def test_annual_formulas_split_component_amounts_and_preserve_remainder():
result = run(
"math",