"""Generate fictional, synthetic inputs only."""
import json
import sys
from pathlib import Path
from openpyxl import Workbook


def create(root):
    root=Path(root); root.mkdir(parents=True,exist_ok=True)
    suppliers=['示例甲','示例乙','示例丙','示例丁']
    columns=dict(zip(['item','unit','spec','price','quantity','note'],['商品','单位','规格','报价','数量','备注']))
    sources=[]
    prices=[[1,2,3,None,2],[1,4,5,8,0],[9,9,9,10,None],[10,10,10,11,7]]
    for i,v in enumerate(suppliers):
        wb=Workbook(); ws=wb.active; ws.title='主报价'; ws.append(list(columns.values()))
        rows=[['测试品'+str(j+1),'公斤','标准',p,'2',None] for j,p in enumerate(prices[i])]
        if i==2: rows=rows[::-1]+[['测试品1','公斤','大规格','12','3',None],['新增品','公斤','标准','13','1',None]]
        for r in rows: ws.append(r)
        sources.append({'file':f'vendor-{i+1}.xlsx','sheet':ws.title,'supplier':v,'category':'蔬菜','columns':columns})
        if i==3:
            for name,item in [('猪肉','测试猪肉'),('猪肉补充','测试补充')]:
                ws=wb.create_sheet(name); ws.append(list(columns.values())); ws.append([item,'公斤','标准',15,2,None])
                sources.append({'file':f'vendor-{i+1}.xlsx','sheet':name,'supplier':v,'category':'猪肉','columns':columns})
        wb.save(root/f'vendor-{i+1}.xlsx')
    cfg={'suppliers':suppliers,'sources':sources,'tie_break':{},'ignored_sheets':[]}
    (root/'config.json').write_text(json.dumps(cfg,ensure_ascii=False,indent=2))
    return root/'config.json'

if __name__=='__main__': create(sys.argv[1])
