feat(est): exchange annual and draft progress
This commit is contained in:
@@ -263,3 +263,61 @@ def test_excel_exports_and_imports_contract_review_inputs():
|
||||
assert result["review"]["after"] == 80
|
||||
assert result["edit"]["Reason"] == "checked"
|
||||
assert result["rejected"] == 3
|
||||
|
||||
|
||||
def test_excel_exports_only_unlocked_progress_and_annual_stages():
|
||||
import openpyxl
|
||||
|
||||
data = export_workbook(
|
||||
{
|
||||
"name": "project",
|
||||
"tables": {},
|
||||
"annual": [{"name": "first", "formula": "[기준]*0.5"}],
|
||||
"progress": [
|
||||
{"id": "locked", "name": "old", "locked": True, "inputs": {"1": {"Gum": 2}}},
|
||||
{
|
||||
"id": "draft",
|
||||
"name": "new",
|
||||
"locked": False,
|
||||
"inputs": {"1": {"Gum": 3, "GumMode": "quantity"}},
|
||||
},
|
||||
],
|
||||
}
|
||||
)
|
||||
workbook = openpyxl.load_workbook(io.BytesIO(data))
|
||||
assert workbook["Annual"]["A2"].value == "first"
|
||||
assert workbook["ProgressDrafts"]["A2"].value == "draft"
|
||||
assert workbook["ProgressDrafts"].max_row == 2
|
||||
assert workbook["ProgressInputs"]["A2"].value == "draft"
|
||||
assert workbook["ProgressInputs"]["D2"].value == 3
|
||||
|
||||
|
||||
def test_excel_imports_progress_drafts_without_changing_locked_rounds():
|
||||
result = run(
|
||||
"math",
|
||||
"""(()=>{
|
||||
const p=EstNative.empty();p.options.SourceRefresh=false;
|
||||
p.tables.EstMainDat=[{PkID:1,Code:'A',GN:10,GU:100},{LinkIndex:54}];
|
||||
p.progress=[{id:'locked',name:'old',inputs:{'1':{Gum:2}}}];
|
||||
const q=EstProgress.lock(EstNative.calculate(p),'locked');
|
||||
q.progress.push({id:'draft',name:'new',locked:false,inputs:{'1':{Gum:1}}});
|
||||
const locked=JSON.stringify(q.progress[0]);
|
||||
const tables={ProgressDrafts:[{id:'draft',name:'new',approved:false,separateComponents:true}],
|
||||
ProgressInputs:[{RoundId:'draft',RowKey:'1',GumMode:'quantity',Gum:3}],
|
||||
Annual:[{name:'first',formula:'[기준]*0.5'}]};
|
||||
const next=EstExchange.apply(q,tables),progress=EstProgress.calculate(next,'draft');
|
||||
let rejected=0;for(const bad of [
|
||||
{ProgressDrafts:tables.ProgressDrafts},
|
||||
{...tables,ProgressInputs:[{RoundId:'locked',RowKey:'1',Gum:9}]},
|
||||
{...tables,ProgressDrafts:[{id:'locked'}]},
|
||||
{...tables,ProgressInputs:[{RoundId:'draft',RowKey:'1',GumMode:'invalid'}]},
|
||||
{...tables,ProgressInputs:[{RoundId:'draft',RowKey:'missing',Gum:1}]}])
|
||||
try{EstExchange.apply(q,bad)}catch{rejected++}
|
||||
return {same:JSON.stringify(next.progress[0])===locked,progress,annual:next.annual,rejected};
|
||||
})()""",
|
||||
)
|
||||
assert result["same"]
|
||||
assert result["progress"]["rows"][0]["JunTC"] == 200
|
||||
assert result["progress"]["rows"][0]["TotalTC"] == 500
|
||||
assert result["annual"] == [{"name": "first", "formula": "[기준]*0.5"}]
|
||||
assert result["rejected"] == 5
|
||||
|
||||
Reference in New Issue
Block a user