Skip to content

[usage] increment cycle on finalize invoice #15172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2022

Conversation

svenefftinge
Copy link
Member

Description

Increment the billing cycle on after finalize invoice webhook.

Related Issue(s)

Fixes #14992

How to test

Release Notes

NONE

Documentation

Werft options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh

@svenefftinge svenefftinge requested a review from a team December 6, 2022 07:34
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Dec 6, 2022
@svenefftinge svenefftinge force-pushed the sefftinge/ubp-when-receiving-a-14992 branch from 7274068 to 20828a7 Compare December 6, 2022 07:49

_, err = s.ccManager.IncrementBillingCycle(ctx, usage.AttributionID)
if err != nil {
return nil, err
Copy link
Member

Choose a reason for hiding this comment

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

This potentially leaks a DB error to the API. You should be catching the error and using status.Errorf(codes.NotFound, "Failed to get invoice with ID %s: %s", in.GetInvoiceId(), err.Error()) report an appropriate API facing error + code

}
err = c.conn.Save(&newCostCenter).Error
if err != nil {
return CostCenter{}, err
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return CostCenter{}, err
return CostCenter{}, fmt.Errorf("failed to store cost center ID: %s", err)

otherwise you don't actually know what failed

@svenefftinge svenefftinge force-pushed the sefftinge/ubp-when-receiving-a-14992 branch from 20828a7 to 524870c Compare December 6, 2022 08:13
@roboquat roboquat merged commit 57593bf into main Dec 6, 2022
@roboquat roboquat deleted the sefftinge/ubp-when-receiving-a-14992 branch December 6, 2022 08:24
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/M team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[UBP] When receiving a Stripe invoice finalization webhook, also update the Stripe CostCenter billing cycle dates
3 participants