FPSMS-frontend
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 

292 строки
11 KiB

  1. import { TFunction } from "i18next";
  2. import { createTraceLabelTranslator } from "./traceLabelUtils";
  3. import { formatQty } from "./traceQtyUtils";
  4. import type { JoPreludeGraphLabels } from "./buildJoPreludeGraphNodes";
  5. import type { ProductionGraphLabels } from "./buildProductionGraphNodes";
  6. import type { ExtendedTraceGraphLabels } from "./buildExtendedTraceGraphNodes";
  7. import type { TraceGraphDetailLabels } from "./buildTraceGraphNodes";
  8. export type TraceGraphCompileLabels = TraceGraphDetailLabels &
  9. JoPreludeGraphLabels &
  10. ProductionGraphLabels &
  11. ExtendedTraceGraphLabels & {
  12. flowDoGroupTitle?: (count: number) => string;
  13. flowPickGroupTitle?: (pickOrderCode: string, count: number) => string;
  14. };
  15. export const buildTraceGraphLabels = (
  16. t: TFunction,
  17. lotUom: string,
  18. ): TraceGraphCompileLabels => {
  19. const tr = createTraceLabelTranslator(t);
  20. return {
  21. tr,
  22. nodeQcPass: t("nodeQcPass"),
  23. nodeQcFail: t("nodeQcFail"),
  24. nodeReceipt: t("nodeReceipt"),
  25. nodePurchase: t("nodePurchase"),
  26. nodePutaway: t("nodePutaway"),
  27. nodePutawayTransfer: t("nodePutawayTransfer"),
  28. putawayTransferDetail: t("putawayTransferInboundDetail"),
  29. nodeStockTake: t("nodeStockTake"),
  30. nodeAdjustment: t("nodeAdjustment"),
  31. nodeTransfer: t("nodeTransfer"),
  32. nodeMaterialIn: t("nodeMaterialIn"),
  33. nodeJoCreated: t("nodeJoCreated"),
  34. nodeMaterialPick: t("nodeMaterialPick"),
  35. nodeProductionStep: t("nodeProductionStep"),
  36. nodeByproduct: t("nodeByproduct"),
  37. nodeScrap: t("nodeScrap"),
  38. nodeDefect: t("nodeDefect"),
  39. detailProcessOutputQty: t("processOutputQty"),
  40. detailProcessScrapQty: t("processScrapQty"),
  41. detailProcessDefectQty: t("processDefectQty"),
  42. nodeOpen: t("nodeOpen"),
  43. nodeFail: t("nodeFail"),
  44. nodeDoOut: t("nodeDoOut"),
  45. nodeReplenishmentCreated: t("nodeReplenishmentCreated"),
  46. nodeJoOut: t("nodeJoOut"),
  47. nodePoOut: t("nodePoOut"),
  48. doOutboundExtra: t("doOutboundExtra"),
  49. doOutboundReplenish: t("doOutboundReplenish"),
  50. detailDoOutboundKind: t("detailDoOutboundKind"),
  51. flowDoGroupTitle: (count: number) => t("flowDoGroupTitle", { count }),
  52. flowPickGroupTitle: (pickOrderCode: string, count: number) =>
  53. t("flowPickGroupTitle", { pickOrderCode, count }),
  54. nodeReturn: t("nodeReturn"),
  55. nodeRepack: t("nodeRepack"),
  56. traceRepackLot: t("traceRepackLot"),
  57. nodeExpired: t("nodeExpired"),
  58. nodeDepleted: t("nodeDepleted"),
  59. directionIn: t("directionIn"),
  60. directionOut: t("directionOut"),
  61. formatQcSubtitle: (failQty: number, acceptedQty: number) =>
  62. `${t("failQty")}: ${formatQty(failQty, lotUom)} / ${t("acceptedQty")}: ${formatQty(acceptedQty, lotUom)}`,
  63. detailQty: t("qty"),
  64. detailTime: t("timestamp"),
  65. detailHandler: t("handler"),
  66. detailStockTaker: t("stockTaker"),
  67. detailApprover: t("approver"),
  68. detailWarehouse: t("from"),
  69. detailRemarks: t("remarks"),
  70. detailFailCategory: t("detailFailCategory"),
  71. detailProcessDescription: t("detailProcessDescription"),
  72. detailType: t("type"),
  73. detailRef: t("ref"),
  74. detailStockTakeCode: t("stockTakeCode"),
  75. detailAdjustmentRef: t("detailAdjustmentRef"),
  76. detailReplenishmentCode: t("detailReplenishmentCode"),
  77. detailReason: t("detailReason"),
  78. detailReturnRef: t("detailReturnRef"),
  79. detailSourceDoc: t("detailSourceDoc"),
  80. detailPurchaseOrderNo: t("detailPurchaseOrderNo"),
  81. detailInboundRef: t("detailInboundRef"),
  82. detailInboundSiNo: t("detailInboundSiNo"),
  83. detailPutawayBin: t("detailPutawayBin"),
  84. detailDirection: t("detailDirection"),
  85. detailStatus: t("status"),
  86. detailSupplier: t("supplier"),
  87. detailMaterial: t("material"),
  88. detailItemCode: t("detailItemCode"),
  89. detailItemName: t("detailItemName"),
  90. detailLot: t("lotNo"),
  91. detailAcceptedQty: t("acceptedQty"),
  92. detailFailQty: t("failQty"),
  93. detailQcCriteria: t("detailQcCriteria"),
  94. detailQcType: t("detailQcType"),
  95. detailQcUnknownItem: t("detailQcUnknownItem"),
  96. detailFrom: t("from"),
  97. detailTo: t("to"),
  98. detailVariance: t("variance"),
  99. detailBefore: t("before"),
  100. detailAfter: t("after"),
  101. detailStockTakeFirstCount: t("stockTakeStageFirstCount"),
  102. detailStockTakeSecondCount: t("stockTakeStageSecondCount"),
  103. detailStockTakeApproverCount: t("stockTakeStageApproverCount"),
  104. detailScrapQty: t("scrapQty"),
  105. detailDefectQty: t("defectQty"),
  106. detailEquipment: t("equipment"),
  107. detailProcessStep: t("processStep"),
  108. detailStepMaterials: t("detailStepMaterials"),
  109. detailAssignedStep: t("detailAssignedStep"),
  110. detailPickTargetDate: t("detailPickTargetDate"),
  111. detailProductLotNo: t("productLotNo"),
  112. deliveryOrder: t("deliveryOrder"),
  113. deliveryNoteCode: t("deliveryNoteCode"),
  114. ticketNo: t("ticketNo"),
  115. pickOrder: t("pickOrder"),
  116. jobOrder: t("jobOrder"),
  117. expiryDate: t("expiryDate"),
  118. totalAvailable: t("totalAvailable"),
  119. itemCode: t("itemCode"),
  120. detailOrderQty: t("detailOrderQty"),
  121. detailPutAwayQty: t("detailPutAwayQty"),
  122. detailPurchaseUnit: t("detailPurchaseUnit"),
  123. detailSupplyTo: t("detailSupplyTo"),
  124. detailStockTakeRound: t("detailStockTakeRound"),
  125. detailStockTakeSection: t("detailStockTakeSection"),
  126. detailLocation: t("detailLocation"),
  127. categoryPurchase: t("categoryPurchase"),
  128. categoryProduction: t("categoryProduction"),
  129. categoryInbound: t("phaseInbound"),
  130. categoryReceipt: t("categoryReceipt"),
  131. categoryPutaway: t("phasePutaway"),
  132. categoryTransfer: t("phaseWarehouse"),
  133. categoryStockTake: t("phaseStockTake"),
  134. categoryOpen: t("categoryOpen"),
  135. categoryAdjustment: t("nodeAdjustment"),
  136. categoryPick: t("phaseMaterialPick"),
  137. categoryQc: t("phaseQc"),
  138. categoryOutbound: t("phaseOutbound"),
  139. categoryTerminal: t("categoryTerminal"),
  140. processingStatus: t("processingStatus"),
  141. matchStatus: t("matchStatus"),
  142. };
  143. };
  144. /** Minimal labels for unit tests (no i18n). */
  145. export const createTestTraceGraphLabels = (): TraceGraphCompileLabels => {
  146. const identity = (s: string | null | undefined) => s?.trim() || "—";
  147. const tr = {
  148. refType: identity,
  149. movementType: identity,
  150. direction: (c: string | null | undefined) =>
  151. c?.toUpperCase() === "OUT" ? "Out" : c?.toUpperCase() === "IN" ? "In" : identity(c),
  152. stockInStatus: identity,
  153. adjustmentType: identity,
  154. usageType: identity,
  155. failType: identity,
  156. productionStatus: identity,
  157. pickStatus: identity,
  158. joStatus: identity,
  159. qcType: () => "IQC",
  160. qcPassed: (p: boolean) => (p ? "Pass" : "Fail"),
  161. putawayShelfStatus: (phase: "pending" | "completed") =>
  162. phase === "completed" ? "Put away done" : "Pending put-away",
  163. processingStatus: identity,
  164. matchStatus: identity,
  165. lotLineStatus: identity,
  166. };
  167. return {
  168. tr,
  169. nodeQcPass: "QC Pass",
  170. nodeQcFail: "QC Fail",
  171. nodeReceipt: "Receipt",
  172. nodePurchase: "Purchase",
  173. nodePutaway: "Putaway",
  174. nodePutawayTransfer: "Transfer inbound",
  175. putawayTransferDetail: "Inbound at target warehouse after transfer (auto-completed, not PO put-away queue)",
  176. nodeStockTake: "Stock take",
  177. nodeAdjustment: "Adjustment",
  178. nodeTransfer: "Transfer",
  179. nodeMaterialIn: "Material in",
  180. nodeJoCreated: "JO created",
  181. nodeMaterialPick: "Material pick",
  182. nodeProductionStep: "Production step",
  183. nodeByproduct: "Byproduct",
  184. nodeScrap: "Scrap",
  185. nodeDefect: "Defect",
  186. detailProcessOutputQty: "Process output",
  187. detailProcessScrapQty: "Scrap quantity",
  188. detailProcessDefectQty: "Defect quantity",
  189. nodeOpen: "Opening",
  190. nodeFail: "Pick fail",
  191. nodeDoOut: "DO PO",
  192. nodeReplenishmentCreated: "Replenishment created",
  193. nodeJoOut: "JO PO",
  194. nodePoOut: "PO pick",
  195. doOutboundExtra: "Add-on",
  196. doOutboundReplenish: "Replenishment",
  197. detailDoOutboundKind: "Outbound type",
  198. flowDoGroupTitle: (count) => `DO × ${count}`,
  199. flowPickGroupTitle: (code, count) => `Pick · ${code} × ${count}`,
  200. nodeReturn: "Return",
  201. nodeRepack: "Repack",
  202. traceRepackLot: "Trace lot",
  203. nodeExpired: "Expired",
  204. nodeDepleted: "Depleted",
  205. directionIn: "In",
  206. directionOut: "Out",
  207. formatQcSubtitle: (f, a) => `Fail ${f} / Accepted ${a}`,
  208. detailQty: "Qty",
  209. detailTime: "Time",
  210. detailHandler: "Handler",
  211. detailStockTaker: "First counter",
  212. detailApprover: "Approver",
  213. detailWarehouse: "Warehouse",
  214. detailRemarks: "Remarks",
  215. detailFailCategory: "Fail category",
  216. detailProcessDescription: "Step description",
  217. detailType: "Type",
  218. detailRef: "Doc no.",
  219. detailStockTakeCode: "Stock Take #",
  220. detailAdjustmentRef: "Adjustment #",
  221. detailReplenishmentCode: "Replenishment #",
  222. detailReason: "Reason",
  223. detailReturnRef: "Return #",
  224. detailSourceDoc: "Source doc #",
  225. detailPurchaseOrderNo: "PO no.",
  226. detailInboundRef: "Inbound SI",
  227. detailInboundSiNo: "Inbound SI no.",
  228. detailPutawayBin: "Bin",
  229. detailDirection: "Direction",
  230. detailStatus: "Status",
  231. detailSupplier: "Supplier",
  232. detailMaterial: "Material",
  233. detailItemCode: "Item code",
  234. detailItemName: "Item name",
  235. detailLot: "Lot",
  236. detailAcceptedQty: "Accepted",
  237. detailFailQty: "Fail",
  238. detailQcCriteria: "Criteria",
  239. detailQcType: "QC type",
  240. detailQcUnknownItem: "Unknown",
  241. detailFrom: "From",
  242. detailTo: "To",
  243. detailVariance: "Variance",
  244. detailBefore: "Book qty",
  245. detailAfter: "Accepted qty",
  246. detailStockTakeFirstCount: "First count",
  247. detailStockTakeSecondCount: "Re-count",
  248. detailStockTakeApproverCount: "Approver count",
  249. detailScrapQty: "Scrap",
  250. detailDefectQty: "Defect",
  251. detailEquipment: "Equipment",
  252. detailProcessStep: "Step",
  253. detailStepMaterials: "Step materials",
  254. detailAssignedStep: "Assigned step",
  255. detailPickTargetDate: "Target date",
  256. detailProductLotNo: "Product lot",
  257. deliveryOrder: "DO",
  258. deliveryNoteCode: "DN",
  259. ticketNo: "Ticket",
  260. pickOrder: "Pick",
  261. jobOrder: "Job order",
  262. expiryDate: "Expiry",
  263. totalAvailable: "Available",
  264. itemCode: "Item code",
  265. detailOrderQty: "Order qty",
  266. detailPutAwayQty: "Putaway qty",
  267. detailPurchaseUnit: "Purchase unit",
  268. detailSupplyTo: "Supply to",
  269. detailStockTakeRound: "Stock take round",
  270. detailStockTakeSection: "Stock take section",
  271. detailLocation: "Location",
  272. categoryPurchase: "Purchase",
  273. categoryProduction: "Production",
  274. categoryInbound: "Inbound",
  275. categoryReceipt: "Receipt",
  276. categoryPutaway: "Putaway",
  277. categoryTransfer: "Warehouse",
  278. categoryStockTake: "Stock take",
  279. categoryOpen: "Opening",
  280. categoryAdjustment: "Adjustment",
  281. categoryPick: "Pick",
  282. categoryQc: "QC",
  283. categoryOutbound: "Outbound",
  284. categoryTerminal: "Terminal",
  285. processingStatus: "Processing status",
  286. matchStatus: "Match status",
  287. };
  288. };