Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
82cf8f2 to
d5146d4
Compare
48376bb to
de35fd3
Compare
| // Let's find out the service period for the credit realization | ||
| servicePeriod := timeutil.ClosedPeriod{ | ||
| From: input.Charge.Intent.ServicePeriod.From, | ||
| To: input.AsOf, | ||
| } | ||
|
|
||
| lastRealizedPeriod := input.Charge.Realizations.Credit.LastRealizedPeriod() | ||
| if lastRealizedPeriod != nil { | ||
| servicePeriod.From = lastRealizedPeriod.To | ||
| } | ||
|
|
||
| h.customerAccountBalance -= amountToRealize.InexactFloat64() | ||
|
|
||
| // Note: we are also realizing the 0 value to make sure that we signify that in that period there was no usage | ||
| // in this setup the ledger transaction should not be created. | ||
|
|
||
| return []charges.CreditRealizationCreateInput{ | ||
| { | ||
| Amount: amountToRealize, | ||
| ServicePeriod: servicePeriod, | ||
| }, | ||
| }, nil | ||
| } |
There was a problem hiding this comment.
TODO: store the realization state inside the charge object and pass it to the handler as an already calculated value.
There was a problem hiding this comment.
This also allows us to not to create 0 amount credit realizations, which will be good for the db schema as we can mandate the transaction group id
de35fd3 to
784fba4
Compare
784fba4 to
69b0f76
Compare
Overview
Fixes #(issue)
Notes for reviewer