Repository navigation
fix: correct one-day-early date in report Criteria sheet exports - #178
Conversation
Several inventory report exports (daily stock detail, daily stock summary, short expiry, transit, inward stock, expiry, beneficiary drug issue, consumption) push a raw JS Date object (from the Material datepicker, set at local midnight) directly into the ExcelJS "Criteria" worksheet row. ExcelJS's dateToExcel() serializes Date cells using the absolute UTC epoch with no timezone correction, so a Date built at local midnight in IST (UTC+5:30) lands on the previous UTC day once written to the sheet - the Criteria tab shows a date one day earlier than what was selected. Monthly and Yearly reports were unaffected because they never carry a Date object in their criteria (only a month name / year number). Fix: format the date into a plain dd-mm-yyyy string using local getters (not toISOString(), which reintroduces the same UTC shift) before pushing it into the criteria row. This matches a fix already present, but never committed, in daily-stock-details-report.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|


Summary
Dateobject)Root cause
These reports push a raw JS
Dateobject (from the Material datepicker, constructed at local midnight) straight into the ExcelJSCriteriaworksheet row. ExcelJS'sdateToExcel()serializesDatecells using the absolute UTC epoch with no timezone correction, so aDatebuilt at local midnight in IST (UTC+5:30) lands on the previous UTC day once written — the Criteria tab shows a date one day earlier than selected.Fix
Format the date into a plain
dd-mm-yyyystring using local getters (getDate/getMonth/getFullYear), nottoISOString()(which would reintroduce the same UTC shift), before pushing it into the criteria row. This matches a fix that was already present — but never committed — indaily-stock-details-report.component.ts; ported the same pattern to the other 7 affected reports.Note on base branch
release-3.9.0is a new branch cut frommainfor this PR. While preparing it, found thatrelease-3.6.3'samm-2380fix (store/sub-store lists of other projects/providers were visible) was not yet merged intomain— cherry-picked it directly ontorelease-3.9.0first so this release branch carries all 3.6.x content.Test plan
🤖 Generated with Claude Code