batchAdjust.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /** 年调标差额补发批识别(统一口径,避免各页正则写坏) */
  2. export type AdjustBatchLike = {
  3. batchNo?: string | null
  4. month?: string | null
  5. payMonth?: string | null
  6. id?: string | null
  7. remarks?: string | null
  8. remark?: string | null
  9. yearlyAdjust?: boolean | string | null
  10. batchLevel?: string | null
  11. village?: string | null
  12. }
  13. function compact(raw?: string | null): string {
  14. return String(raw || '').replace(/[-_/]/g, '')
  15. }
  16. function hasAdjust99(raw?: string | null): boolean {
  17. return /20\d{2}99/.test(compact(raw))
  18. }
  19. function isCalendarMonthToken(raw?: string | null): boolean {
  20. const s = compact(raw)
  21. return /20\d{2}(0[1-9]|1[0-2])/.test(s) && !/20\d{2}99/.test(s)
  22. }
  23. /**
  24. * 是否年调标差额专批:业务号/发放月含 20xx99。
  25. * 全区月批、镇统计即使备注写了 YEARLY_ADJUST,也按日常发放批处理。
  26. */
  27. export function isYearlyAdjustBatchLike(b?: AdjustBatchLike | null): boolean {
  28. if (!b) return false
  29. const level = String(b.batchLevel || '').toUpperCase()
  30. if (level === 'DISTRICT' || level === 'TOWN' || b.village === '全区') return false
  31. if (
  32. isCalendarMonthToken(b.payMonth) ||
  33. isCalendarMonthToken(b.month) ||
  34. isCalendarMonthToken(b.batchNo)
  35. ) {
  36. return false
  37. }
  38. if (hasAdjust99(b.batchNo) || hasAdjust99(b.month) || hasAdjust99(b.payMonth)) return true
  39. return b.yearlyAdjust === true || b.yearlyAdjust === 'true'
  40. }