Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions billing/invoice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ func (s *Service) upsert(ctx context.Context, customerID string,
existingInvoice.HostedURL = stripeInvoice.HostedInvoiceURL
updateNeeded = true
}
if existingInvoice.Amount != stripeInvoice.Total {
existingInvoice.Amount = stripeInvoice.Total
updateNeeded = true
}

if updateNeeded {
if _, err := s.repository.UpdateByID(ctx, *existingInvoice); err != nil {
Expand Down
3 changes: 3 additions & 0 deletions internal/store/postgres/billing_invoice_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ func (r BillingInvoiceRepository) UpdateByID(ctx context.Context, toUpdate invoi
if toUpdate.HostedURL != "" {
updateRecord["hosted_url"] = toUpdate.HostedURL
}
// Do not guard this with `!= 0` like the fields above: an invoice can
// be credited down to zero, and that zero must be saved.
updateRecord["amount"] = toUpdate.Amount

query, params, err := dialect.Update(TABLE_BILLING_INVOICES).Set(updateRecord).Where(goqu.Ex{
"id": toUpdate.ID,
Expand Down
Loading