import GoodsListState from '../../GoodsListState'; import IGood from '../IGood'; import LineAttributeType from '../LineAttributeType'; export default class EndowCode { /** 准备赋码的货物索引列表 */ endowcodeGoodIndex: string[] = []; /** * 获取 税收分类编码列表 (弃用) * @deprecated 请使用 getTaxCategoryCodeTree 替换 * */ getTaxCategoryCodeList: (value: string) => Promise<{ value: string, label: string }[]> = async () => []; /** * 获取 税收分类编码树 * @param taxCategoryCode 税收分类编码 * @param val val * @returns 税收分类编码树 */ getTaxCategoryCodeTree?: (taxCategoryCode?: string, val?: string) => Promise<{ id: string, pid: string }[]>; /** * 动态加载 * */ onLoadTaxClassificationCode: (value?: any) => Promise = async () => []; /** 税率 优惠政策 */ getReadOnlyTaxRate?: (value?: GoodsListState) => boolean; /** 优惠政策 优惠政策 */ getReadOnlyFavouredPolicy?: (value?: GoodsListState) => boolean; /** * 获取赋码时候的默认值 * @param value 商品信息 * @param length 商品数量 * */ getDefaultValue?: (value: IGood, length: number) => Promise; /** 税率 是否可以编辑 校验函数 */ readonly readOnlyTaxRateMap: { [key: string]: (value?: GoodsListState) => boolean } = { /** 草稿发票 */ DRAFT: draft, }; /** 优惠政策类型列表 */ favouredPolicyNameList: string[] = [ '100%先征后退', '即征即退30%', '即征即退50%', '即征即退70%', '按3%简易征收', '按5%简易征收', '按3%简易征收减按1.5%计征', '稀土产品', '简易征收', '50%先征后退', '不征税', '先征后退', '免税', '即征即退100%', '超税负3%即征即退', '超税负8%即征即退', '超税负12%即征即退', ]; /** 免税类型 是否需要 */ isTaxFreeTypeNeeded: boolean = true; /** 免税类型 列表 */ taxFreeTypeList: any[] = [ { label: '出口免税和其他免税优惠政策(免税)', value: 1 }, { label: '不征增值税(不征税)', value: 2 }, { label: '普通零税率(0%)', value: 3 }, ]; /** * 小规模纳税人 自动赋码缓存 、 * */ cache: { [key: string]: any } = {}; /** * 打开侧边栏 * */ onSearchTaxClassificationCode: (value?: any) => Promise = async () => []; } /** 草稿发票 税率 是否可以编辑 校验函数 */ function draft(value?: GoodsListState) { if (!value) return true; // isDiscount const goods = value.endowCode.endowcodeGoodIndex.map(e => value.goodsMap.get(e)).filter(e => e?.lineAttribute !== LineAttributeType.折扣行); const isDiscount = goods.some(e => e?.lineAttribute === LineAttributeType.被折扣行); // 是否折扣 if (isDiscount) { return goods.length === 1 } else { return false; } }