Skip to content

Conversation

ivannovosad
Copy link
Contributor

Context

DailyUsages::FillFromInvoiceService was not taking into account customer timezone when saving usage_date.
For that reason the last day of the period was skipped in some cases.

Description

Fix usage_date in DailyUsages::FillFromInvoiceService.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures DailyUsages::FillFromInvoiceService computes usage_date in the customer’s timezone and updates related tests accordingly.

  • Extracts timezone-aware usage_date calculation into a helper method in the service
  • Updates specs to include a customer timezone, refactors raw datetime strings, and adds a #usage_date unit test
  • Replaces direct to_date calls with the new helper throughout the service
Comments suppressed due to low confidence (1)

spec/services/daily_usages/fill_from_invoice_service_spec.rb:37

  • [nitpick] The top-level let(:usage_date) collides with the subject(:usage_date) in the #usage_date tests. Consider renaming the first helper to something like expected_usage_date for clarity.
  let(:usage_date) do

@ivannovosad ivannovosad merged commit 8536eac into main Jul 3, 2025
14 checks passed
@ivannovosad ivannovosad deleted the fix-usage-date branch July 3, 2025 13:59
diegocharles pushed a commit that referenced this pull request Jul 11, 2025
## Context

`DailyUsages::FillFromInvoiceService` was not taking into account
customer timezone when saving `usage_date`.
For that reason the last day of the period was skipped in some cases.

## Description

Fix usage_date in `DailyUsages::FillFromInvoiceService`.
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