feat(cost-center): 统一接单模板成本并自动同步商品
This commit is contained in:
@@ -18,7 +18,12 @@ import {
|
||||
backfillAdminNormalizedQuantities,
|
||||
backfillAdminProductMappings,
|
||||
} from './product-catalog-service.js'
|
||||
import { syncAdminWorkOrderTemplateCostVersions } from './work-order-product-service.js'
|
||||
import {
|
||||
buildTemplateProductSku,
|
||||
inferTemplateUnitName,
|
||||
} from './work-order-template-product-service.js'
|
||||
|
||||
export { buildTemplateProductSku, inferTemplateUnitName }
|
||||
|
||||
export async function previewAdminTemplateProductBootstrap(payload: JsonObject = {}) {
|
||||
const range = resolveBootstrapDateRange(payload)
|
||||
@@ -241,8 +246,6 @@ export async function applyAdminTemplateProductBootstrap(
|
||||
dateTo: range.toDate,
|
||||
})
|
||||
mappedOrderItemCount = mappingBackfill.updatedCount
|
||||
const templateCosts = await syncAdminWorkOrderTemplateCostVersions()
|
||||
|
||||
return {
|
||||
dateFrom: range.fromDate,
|
||||
dateTo: range.toDate,
|
||||
@@ -260,9 +263,6 @@ export async function applyAdminTemplateProductBootstrap(
|
||||
resetOrderItemCount: resetResult.resetOrderItemCount,
|
||||
mappingConflictCount: plan.conflicts.length,
|
||||
mappingConflictItemCount: plan.unresolvedItemCount,
|
||||
templateCostVersionCount: templateCosts.activeVersionCount,
|
||||
templateCostCreatedCount: templateCosts.createdCount,
|
||||
templateCostRetiredCount: templateCosts.retiredCount,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -806,19 +806,6 @@ async function loadTemplateProductBootstrapData(range: { fromDate: string; toDat
|
||||
}
|
||||
}
|
||||
|
||||
export function buildTemplateProductSku(ruleKey: string) {
|
||||
return `tpl:${String(ruleKey || '').trim()}`.slice(0, 64)
|
||||
}
|
||||
|
||||
export function inferTemplateUnitName(productName: string) {
|
||||
const name = String(productName || '').trim()
|
||||
if (/钻石|颗/.test(name)) return '颗'
|
||||
if (/枪|把/.test(name)) return '把'
|
||||
if (/套/.test(name)) return '套'
|
||||
if (/密钥|秘钥/.test(name)) return '个'
|
||||
return '件'
|
||||
}
|
||||
|
||||
function resolveBootstrapDateRange(payload: JsonObject) {
|
||||
const range = resolveFinanceDateRange(
|
||||
{ dateFrom: payload.dateFrom, dateTo: payload.dateTo },
|
||||
|
||||
Reference in New Issue
Block a user