diff --git a/developer_docs/git/commit-conventions.md b/developer_docs/git/commit-conventions.md index a737f095872..2dbd244c44b 100644 --- a/developer_docs/git/commit-conventions.md +++ b/developer_docs/git/commit-conventions.md @@ -19,3 +19,23 @@ Co-Authored-By: Claude ## Auto-Close Behavior When Claude pushes commits that complete an issue, automatically include the appropriate closing keyword in the commit message. + +## Branch Naming Conventions + +### Hotfix Branches +When creating hotfix branches targeting production branches (e.g., `ruhunu-prod`), the branch name **must** end with `-hotfix`. This is required for the PR to be mergeable. + +**Format:** `--hotfix` + +**Examples:** +- `19635-configurable-bill-serial-digits-hotfix` +- `19500-fix-grn-return-hotfix` + +### Feature Branches +Feature branches should be based on `origin/development` (never `master`) and follow the pattern: + +**Format:** `-` + +**Examples:** +- `19635-configurable-bill-number-serial-digits` +- `19500-fix-grn-return-approval` diff --git a/src/main/java/com/divudi/bean/common/ConfigOptionApplicationController.java b/src/main/java/com/divudi/bean/common/ConfigOptionApplicationController.java index eaf3984dad6..5202167cf9d 100644 --- a/src/main/java/com/divudi/bean/common/ConfigOptionApplicationController.java +++ b/src/main/java/com/divudi/bean/common/ConfigOptionApplicationController.java @@ -215,6 +215,7 @@ private void loadPharmacyConfigurationDefaults() { // Future development: Apply these patterns to additional bill types as needed getShortTextValueByKey("Bill Number Delimiter", "/"); + getIntegerValueByKey("Bill Number Serial Digit Count", 6); // Generic bill numbering strategies (for backward compatibility) getBooleanValueByKey("Bill Number Generation Strategy for Department ID is Prefix Dept Ins Year Count", false); diff --git a/src/main/java/com/divudi/ejb/BillNumberGenerator.java b/src/main/java/com/divudi/ejb/BillNumberGenerator.java index f7c64d82e2b..7d3bd43a1bc 100644 --- a/src/main/java/com/divudi/ejb/BillNumberGenerator.java +++ b/src/main/java/com/divudi/ejb/BillNumberGenerator.java @@ -139,6 +139,17 @@ private String getLockKey(Institution institution) { return institution.getId() + "-" + "null" + "-" + "null"; } + private static final int MAX_SERIAL_DIGITS = 12; + + private String formatSerialNumber(Long serialNumber) { + Integer digits = configOptionApplicationController.getIntegerValueByKey("Bill Number Serial Digit Count", 6); + if (digits == null || digits < 1) { + digits = 6; + } + digits = Math.min(digits, MAX_SERIAL_DIGITS); + return String.format("%0" + digits + "d", serialNumber); + } + private String getBillNumberDelimiter() { String delimiter = configOptionApplicationController.getShortTextValueByKey("Bill Number Delimiter", "/"); if (delimiter == null) { @@ -2160,7 +2171,7 @@ public String departmentBillNumberGeneratorYearly(Department dep, BillTypeAtomic // Append formatted 6-digit bill number result.append(getBillNumberDelimiter()); - result.append(String.format("%06d", dd)); // Ensure bill number is always six digits + result.append(formatSerialNumber(dd)); // Ensure bill number is always six digits // Return the formatted bill number return result.toString(); @@ -2220,7 +2231,7 @@ public String departmentRequestNumberGeneratorYearly(Department dep, RequestType result.append(getBillNumberDelimiter()); // Append formatted 6-digit bill number - result.append(String.format("%06d", dd)); // Ensure bill number is always six digits + result.append(formatSerialNumber(dd)); // Ensure bill number is always six digits // Return the formatted bill number return result.toString(); @@ -2263,7 +2274,7 @@ public String departmentBillNumberGeneratorYearlyWithPrefixDeptInsYearCount(Depa result.append(String.format("%02d", year)); // Ensure year is always two digits result.append(getBillNumberDelimiter()); // Append formatted 6-digit bill number - result.append(String.format("%06d", dd)); // Ensure bill number is always six digits + result.append(formatSerialNumber(dd)); // Ensure bill number is always six digits // Return the formatted bill number return result.toString(); } @@ -2305,7 +2316,7 @@ public String departmentBillNumberGeneratorYearlyWithPrefixInsDeptYearCount(Depa result.append(String.format("%02d", year)); // Ensure year is always two digits result.append(getBillNumberDelimiter()); // Append formatted 6-digit bill number - result.append(String.format("%06d", dd)); // Ensure bill number is always six digits + result.append(formatSerialNumber(dd)); // Ensure bill number is always six digits // Return the formatted bill number return result.toString(); } @@ -2345,7 +2356,7 @@ public String departmentBillNumberGeneratorYearlyWithPrefixInsYearCount(Departme result.append(String.format("%02d", year)); // Ensure year is always two digits result.append(getBillNumberDelimiter()); // Append formatted 6-digit bill number - result.append(String.format("%06d", dd)); // Ensure bill number is always six digits + result.append(formatSerialNumber(dd)); // Ensure bill number is always six digits // Return the formatted bill number return result.toString(); } @@ -2382,7 +2393,7 @@ public String institutionBillNumberGeneratorYearlyWithPrefixInsYearCount(Departm int year = Calendar.getInstance().get(Calendar.YEAR) % 100; // Get last two digits of year result.append(String.format("%02d", year)); // Ensure year is always two digits // Append formatted 6-digit bill number - result.append(String.format("%06d", dd)); // Ensure bill number is always six digits + result.append(formatSerialNumber(dd)); // Ensure bill number is always six digits // Return the formatted bill number return result.toString(); } @@ -2496,7 +2507,7 @@ public String departmentBillNumberGeneratorYearlyWithPrefixInsYearCountInstituti result.append(String.format("%02d", year)); // Ensure year is always two digits result.append(getBillNumberDelimiter()); // Append formatted 6-digit bill number - result.append(String.format("%06d", dd)); // Ensure bill number is always six digits + result.append(formatSerialNumber(dd)); // Ensure bill number is always six digits // Return the formatted bill number return result.toString(); } @@ -2536,7 +2547,7 @@ public String institutionBillNumberGeneratorYearlyWithPrefixInsYearCountInstitut result.append(String.format("%02d", year)); // Ensure year is always two digits result.append(getBillNumberDelimiter()); // Append formatted 6-digit bill number - result.append(String.format("%06d", dd)); // Ensure bill number is always six digits + result.append(formatSerialNumber(dd)); // Ensure bill number is always six digits // Return the formatted bill number return result.toString(); } @@ -2626,7 +2637,7 @@ public String departmentBillNumberGeneratorYearly(Department dep, List