FPSMS-frontend
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

58 wiersze
2.0 KiB

  1. const parseTicketTypeLetter = (ticketNo?: string | null): string | undefined => {
  2. const parts = (ticketNo ?? "").trim().split("-");
  3. return parts[1]?.toUpperCase();
  4. };
  5. export const isTiETicketNo = (ticketNo?: string | null): boolean => {
  6. const tn = (ticketNo ?? "").trim().toUpperCase();
  7. return parseTicketTypeLetter(tn) === "E" || tn.startsWith("TI-E-");
  8. };
  9. export const isTiMTicketNo = (ticketNo?: string | null): boolean =>
  10. (ticketNo ?? "").trim().toUpperCase().startsWith("TI-M-");
  11. const isExtraReleaseType = (releaseType?: string | null): boolean => {
  12. const rt = (releaseType ?? "").trim().toLowerCase();
  13. return rt === "isextra" || rt === "isextrabatch" || rt === "isextrasingle";
  14. };
  15. export type TraceDoOutboundExtraSource = {
  16. isExtra?: boolean;
  17. ticketNo?: string | null;
  18. consoCode?: string | null;
  19. releaseType?: string | null;
  20. deliveryOrderIsExtra?: boolean;
  21. deliveryOrderPickOrderId?: number | null;
  22. relationshipId?: number | null;
  23. };
  24. /**
  25. * Trace 加單 chip rules (aligned with DeliveryOrderService.isExtraDeliveryTicket):
  26. * - TI-E / conso TI-E- → extra
  27. * - TI-M → per DO isExtra, conso TI-E-, or relationshipId lineage (≠ own dop id)
  28. * - Other → releaseType / API isExtra
  29. */
  30. export const resolveTraceDoOutboundIsExtra = (
  31. source: TraceDoOutboundExtraSource,
  32. ): boolean => {
  33. if (source.isExtra === true) return true;
  34. const ticket = source.ticketNo?.trim() || "";
  35. const conso = source.consoCode?.trim() || "";
  36. const consoIsTiE = isTiETicketNo(conso);
  37. const deliveryOrderIsExtra = source.deliveryOrderIsExtra === true;
  38. if (isTiMTicketNo(ticket)) {
  39. if (deliveryOrderIsExtra) return true;
  40. if (consoIsTiE) return true;
  41. const dopId = source.deliveryOrderPickOrderId ?? null;
  42. const relationshipId = source.relationshipId ?? null;
  43. if (dopId != null && relationshipId != null && relationshipId !== dopId) return true;
  44. return false;
  45. }
  46. if (isTiETicketNo(ticket) || consoIsTiE) return true;
  47. if (isExtraReleaseType(source.releaseType) && !isTiMTicketNo(ticket)) return true;
  48. return deliveryOrderIsExtra;
  49. };