Skip to content

fix: correct one-day-early date in report Criteria sheet exports - #178

Merged
vishwab1 merged 1 commit into
release-3.9.0from
fix/report-criteria-date-offset
Sep 23, 2026
Merged

vishwab1 merged 1 commit into
release-3.9.0from
fix/report-criteria-date-offset

Conversation

@snehar-nd

Copy link
Copy Markdown
Contributor

Summary

  • Fixes the Criteria-tab date showing one day earlier than the date the user selected, in exported stock reports
  • Affects: daily stock detail report, daily stock summary report, short expiry report, transit report, inward stock report, expiry report, beneficiary drug issue report, consumption report
  • Monthly and Yearly reports were never affected (they only carry a month name / year number in their criteria, never a Date object)

Root cause

These reports push a raw JS Date object (from the Material datepicker, constructed at local midnight) straight 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 — the Criteria tab shows a date one day earlier than selected.

Fix

Format the date into a plain dd-mm-yyyy string using local getters (getDate/getMonth/getFullYear), not toISOString() (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 — in daily-stock-details-report.component.ts; ported the same pattern to the other 7 affected reports.

Note on base branch

release-3.9.0 is a new branch cut from main for this PR. While preparing it, found that release-3.6.3's amm-2380 fix (store/sub-store lists of other projects/providers were visible) was not yet merged into main — cherry-picked it directly onto release-3.9.0 first so this release branch carries all 3.6.x content.

Test plan

  • For each affected report, select a start/end date, export to Excel, and confirm the Criteria tab shows the actual selected date (not one day earlier)
  • Confirm Monthly/Yearly report exports are unaffected (no regression)
  • Confirm facility selection no longer shows stores/sub-stores belonging to other projects/providers (amm-2380)

🤖 Generated with Claude Code

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.
@coderabbitai

coderabbitai Bot commented Sep 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: ed489762-a851-4a46-9ef9-eef53753e8d8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
100.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@vishwab1
vishwab1 merged commit 94d3221 into release-3.9.0 Sep 23, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants