Skip to content

NUM · Document numbers

Contracts (PKS), BASTK, debt letters (surat hutang) and insurance claim codes take their number from one locking function, app.next_document_number(org, entity, kind, period), which counts in document_sequences. Code NUM.

These questions are open in #73. Each gets a rule with a new ID once it is answered.

  • Insurance claim codes' format (OQ6, #32): D53 gives them D40's format, with the placeholder type Claim. R-NUM-10 covers claims; R-NUM-03 and R-NUM-07 are retired, and a claim's entity is R-NUM-15. R-NUM-03 retired together with its test, after BE pack G2 (#212) added R-NUM-10's per-entity check (#210).

R-NUM-01 · Two saves at the same moment never get the same document number

Section titled “R-NUM-01 · Two saves at the same moment never get the same document number”
  • Status: planned
  • Example: given two checkers saving a BASTK for legal entity TOP in the same second, when both ask for the next number, then one gets 0041 and the other 0042.
  • Refusal: none: the second call waits for the first.
  • Who: every caller of app.next_document_number().
  • Source: D9 (P12).
Section titled “R-NUM-02 · Contracts, BASTK and debt letters (surat hutang) are numbered per legal entity”
  • Status: built
  • Example: given TOP's last contract of 2026 is 0120 and MOP's is 0045, when MOP signs a contract, then it gets 0046 and TOP's counter stays at 0120.
  • Refusal: none.
  • Who: every caller of app.next_document_number().
  • Source: D9 (Q6); the M0 acceptance checks.
Section titled “R-NUM-03 · Insurance claim codes are numbered per organization, not per legal entity”
  • Status: retired (replaced by R-NUM-10 and R-NUM-15 under D53: a claim is numbered per legal entity)
  • Example: given claims filed for a TOP car and then a MOP car, when each takes a code, then they come from one counter with no legal entity, in sequence.
  • Refusal: none.
  • Who: every caller of app.next_document_number().
  • Source: D9 (Q6); the M0 acceptance checks. Superseded by D53: a claim's number takes D40's format, per entity (R-NUM-10, R-NUM-15). Retired in #210, in the same pull request that drops its test.
Section titled “R-NUM-04 · A BASTK takes its legal entity from its rental's contract”
  • Status: planned
  • Example: given a rental whose contract is signed by MOP, when its handover BASTK is numbered, then MOP's counter is used.
  • Refusal: none.
  • Who: the handover and return functions.
  • Source: D9 (Q6).

R-NUM-05 · Contract numbers restart each year

Section titled “R-NUM-05 · Contract numbers restart each year”
  • Status: retired (replaced by R-NUM-13 under D40)
  • Example: given TOP's last contract of 2026 is 0120, when TOP signs its first contract of 2027, then it is number 1 of period 2027.
  • Refusal: none.
  • Who: the booking and renewal functions.
  • Source: [Ref] Database rules and conventions, Document numbers (contract: per legal entity, per year).

R-NUM-06 · BASTK numbers restart each month

Section titled “R-NUM-06 · BASTK numbers restart each month”
  • Status: retired (replaced by R-NUM-13 under D40)
  • Example: given TOP's last BASTK of October 2026 is 0310, when the first BASTK of November is numbered, then it is number 1 of period 2026-11.
  • Refusal: none.
  • Who: the handover and return functions.
  • Source: [Ref] Database rules and conventions, Document numbers (BASTK: per month).

R-NUM-07 · Insurance claim codes restart each year

Section titled “R-NUM-07 · Insurance claim codes restart each year”
  • Status: retired (replaced by R-NUM-13 under D53)
  • Example: given the last claim code of 2026 is 0057, when the first claim of 2027 is filed, then it is number 1 of period 2027.
  • Refusal: none.
  • Who: the claim function.
  • Source: [Ref] Database rules and conventions, Document numbers (insurance claim code: per year).

R-NUM-08 · App users can't read or write the number counters

Section titled “R-NUM-08 · App users can't read or write the number counters”
  • Status: built
  • Example: given a super_admin, when they read document_sequences, then no row comes back, and an update to last_no changes nothing.
  • Refusal: none: hidden on read; no effect on update.
  • Who: every app user, super_admin included. Only app.next_document_number() writes them.
  • Source: D9 (P12); [Ref] Roles, policy matrix; the M0 acceptance checks.

R-NUM-09 · A user can't take a number from another organization's counter

Section titled “R-NUM-09 · A user can't take a number from another organization's counter”
  • Status: built
  • Example: given an admin of organization A, when they call app.next_document_number() for organization B, then it is refused and B's counter doesn't move.
  • Refusal: access.not_member
  • Who: every signed-in user.
  • Source: the M0 acceptance checks; D9 (P2, P3).

R-NUM-10 · Contracts, BASTK, surat hutang and insurance claims are numbered TYPE/DIVISION/ENTITY/YYYYMMDD-NNN

Section titled “R-NUM-10 · Contracts, BASTK, surat hutang and insurance claims are numbered TYPE/DIVISION/ENTITY/YYYYMMDD-NNN”
  • Status: planned
  • Example: given a BASTK made by the vehicle management division for TOP on 2026-10-01, when it is numbered, then it reads BAST/VM/TOP/20261001-001; a contract by driver management reads Contract/DM/TOP/20261001-001, a surat hutang issued by driver management for TOP on 2026-10-19 reads SH/DM/TOP/20261019-001, and an insurance claim filed by vehicle management for a TOP car that day reads Claim/VM/TOP/20261019-001. There is no trailing slash.
  • Refusal: none.
  • Who: TOP and MOP's organization (D40's convention; another organization may have its own, which isn't built). The type codes are BAST, Contract, SH (surat hutang) and Claim (insurance claims, a placeholder until the business names it; changing it is a data change in master data, D53).
  • Source: D40; #144; D53, whose placeholder Debt for surat hutang is now SH (zuki on #165, the CTO on #164). D53 makes such a change a data change, not a decision. Claims since D53 (OQ6: claim codes come from Opleet).

R-NUM-11 · The division in a number is the creator's, from the organization's divisions

Section titled “R-NUM-11 · The division in a number is the creator's, from the organization's divisions”
  • Status: planned
  • Example: given Rina belongs to driver management, when they create a contract, then its number reads DM; the divisions start as VM (vehicle management), DM (driver management) and BD (business development) and grow when the business needs one.
  • Refusal: none.
  • Who: TOP and MOP's organization (D40's convention; another organization may have its own, which isn't built).
  • Source: D40; #144 (zuki's answer 9).

R-NUM-12 · Creating a numbered document is refused when its creator belongs to no division

Section titled “R-NUM-12 · Creating a numbered document is refused when its creator belongs to no division”
  • Status: planned
  • Example: given Deka belongs to no division, when they create a BASTK, then it is refused and no number is taken.
  • Refusal: a key named by BE in M4.
  • Who: TOP and MOP's organization (D40's convention; another organization may have its own, which isn't built).
  • Source: D40.

R-NUM-13 · The date in a number is the pool's date, and the three-digit sequence restarts each day for each type, division and entity

Section titled “R-NUM-13 · The date in a number is the pool's date, and the three-digit sequence restarts each day for each type, division and entity”
  • Status: planned
  • Example: given TOP's vehicle management made BAST/VM/TOP/20261001-007 last on 2026-10-01, when it makes one on 2026-10-02, then it reads BAST/VM/TOP/20261002-001; a BASTK by DM the same day starts at 001 too.
  • Refusal: none.
  • Who: TOP and MOP's organization (D40's convention; another organization may have its own, which isn't built).
  • Source: D40 (replaces the yearly and monthly restarts, R-NUM-05 and R-NUM-06); D9 (P11).

R-NUM-14 · v1's stored document numbers migrate as they are; only new documents take the new format

Section titled “R-NUM-14 · v1's stored document numbers migrate as they are; only new documents take the new format”
  • Status: planned
  • Example: given a v1 BASTK numbered BA/2026/09/0012, when it is migrated, then it keeps that number; v1's stored insurance claim codes keep theirs too.
  • Refusal: none.
  • Who: the migration.
  • Source: D40; D53 (claim codes).
Section titled “R-NUM-15 · An insurance claim's number takes the legal entity of its car's latest contract, or one its creator picks when the car has none”
  • Status: planned
  • Example: given a car whose latest contract is TOP's, when vehicle management files a claim for it, then the number reads Claim/VM/TOP/…; for a new car with no contract yet, the creator picks TOP or MOP and the number follows. The division is the creator's (R-NUM-11).
  • Refusal: a key named by BE in M5, when a claim for a car with no contract names no entity.
  • Who: the claim function (M5).
  • Source: D53 (a placeholder until the insurance flow is understood).