Our payroll cycle does not follow the standard calendar month.
Instead, it runs from:
26th of previous month → 25th of selected month
Example:
-
January payroll → 26 Dec to 25 Jan
-
March payroll → 26 Feb to 25 Mar
While creating a Query Report, I initially hard-coded day columns from 1 to 31 to display attendance/payroll data. This caused multiple issues:
Issues Faced
-
Invalid Dates Appearing
-
February payroll shows columns for 29–31, even in non-leap years.
-
These dates appear because the report is hard-coded to 31 days.
-
-
Wrong Date Range for Payroll Month
-
Selecting March still pulls incorrect dates from February (29–31).
-
Payroll logic breaks because ERPNext correctly stores dates, but the report does not respect real calendar boundaries.
-
-
Maintenance Nightmare
-
Hard-coding day columns means extra logic for:
-
28-day months
-
30-day months
-
Leap years
-
-
This doesn’t scale well.
-