fix(intake): normalize barcode print data source
This commit is contained in:
parent
882e112a2a
commit
ac24f0546c
@ -124,6 +124,17 @@ function buildFactoryModel(model: string, supplierCode: string) {
|
||||
return `${normalizedModel}${normalizedSupplierCode}`;
|
||||
}
|
||||
|
||||
function normalizeDataSource(value: string) {
|
||||
const normalizedValue = value.trim();
|
||||
if (!normalizedValue) return "流程";
|
||||
|
||||
if (normalizedValue.toLowerCase() === "sku_workbook") {
|
||||
return "流程";
|
||||
}
|
||||
|
||||
return normalizedValue;
|
||||
}
|
||||
|
||||
export function buildBarcodePrintRows(
|
||||
products: NonIntegratedProductRecord[],
|
||||
): BarcodePrintRow[] {
|
||||
@ -215,7 +226,7 @@ export function buildBarcodePrintRows(
|
||||
product.installMethod,
|
||||
),
|
||||
createdAt: normalizeCreatedAt(pricingRow?.systemEnteredAt ?? ""),
|
||||
dataSource: firstText(sku?.sourceTable, sku?.source, "流程"),
|
||||
dataSource: normalizeDataSource(firstText(sku?.sourceTable, sku?.source, "流程")),
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@ -74,6 +74,8 @@ function buildProduct() {
|
||||
executeStandard: 'GB/T 3324',
|
||||
manufacturer: '临沂美诗家居',
|
||||
manufacturerCode: 'N1280',
|
||||
source: 'sku_workbook',
|
||||
sourceTable: 'sku_workbook',
|
||||
},
|
||||
],
|
||||
factoryRows: [
|
||||
@ -121,6 +123,7 @@ describe('barcodePrintService', () => {
|
||||
|
||||
expect(result.rows).toHaveLength(1)
|
||||
expect(result.rows[0]?.supplierCode).toBe('N1280')
|
||||
expect(result.rows[0]?.dataSource).toBe('流程')
|
||||
expect(mockFindMany).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
where: { supplierCode: 'N1280' },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user