You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .agents/skills/charges/SKILL.md
+14-2Lines changed: 14 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ Primary packages:
35
35
36
36
`openmeter/billing/charges` is the root facade for charge operations.
37
37
38
-
For charge-owned detailed lines, the shared invoice-agnostic base belongs in `openmeter/billing/models/stddetailedline`. Keep charge wrappers thin by adding only `charge_id` / `run_id`-style ownership fields around `stddetailedline.Base`, and reuse shared detailed-line base mapping helpers instead of duplicating the common field assembly in charge adapters.
38
+
For charge-owned detailed lines, the shared invoice-agnostic base belongs in `openmeter/billing/models/stddetailedline`. Prefer using `type DetailedLine = stddetailedline.Base` in charge packages and keep ownership implicit through containment in the parent aggregate (`flatfee.Realizations` or `usagebased.RealizationRun`) rather than duplicating `charge_id` / `run_id`fields in the domain type. Reuse the shared detailed-line base mapping and create helpers instead of duplicating common field assembly in charge adapters.
39
39
40
40
Charge-backed invoicing no longer relies on a charges-side `InvoicePendingLines(...)` wrapper. Billing owns invoice creation and dispatches gathering lines by `billing.LineEngineType`, while charge packages provide charge-specific line engines where needed.
41
41
@@ -73,6 +73,7 @@ Important types:
73
73
-`CreditRealizations`
74
74
-`AccruedUsage`
75
75
-`Payment`
76
+
-`DetailedLines`
76
77
-`flatfee.Intent.CalculateAmountAfterProration()` computes the prorated amount from `AmountBeforeProration`, `ServicePeriod/FullServicePeriod` ratio, and `ProRating` config, with currency-precision rounding
77
78
- Charge-backed targets do not use invoice-style semantic proration or empty-period filtering; the charge stack materializes and prorates state itself, and the flat fee charge is responsible for omitting empty lines
78
79
-`usagebased.Intent` carries `FeatureKey`, `Price`, `SettlementMode`, `InvoiceAt`, and `ServicePeriod`
@@ -86,6 +87,15 @@ Important types:
86
87
-`CollectionEnd`
87
88
-`MeterValue`
88
89
-`Totals`
90
+
-`usagebased.RealizationRun` can expand:
91
+
-`DetailedLines`
92
+
93
+
Detailed-line expansion rules:
94
+
95
+
-`meta.ExpandDetailedLines` is not standalone for charge reads; it requires `meta.ExpandRealizations`
96
+
- usage-based detailed lines live under `RealizationRun.DetailedLines`
97
+
- flat-fee detailed lines also live under `Charge.Realizations.DetailedLines`, not on the root charge
98
+
-`mo.None()` means detailed lines were not expanded; present options mean expanded data, even when the underlying slice is nil/empty
89
99
90
100
## Billing Line Engines
91
101
@@ -99,7 +109,7 @@ Current engine values:
99
109
100
110
Current implementations:
101
111
102
-
- flat fee line engine: `openmeter/billing/charges/flatfee/lineengine`
112
+
- flat fee line engine: `openmeter/billing/charges/flatfee/service/lineengine.go`
103
113
- credit purchase line engine: `openmeter/billing/charges/creditpurchase/lineengine`
104
114
- usage-based line engine: `openmeter/billing/charges/usagebased/service/lineengine.go`
105
115
@@ -112,6 +122,8 @@ Important rules:
112
122
- charge test setups must also register those engines explicitly; keep this in `openmeter/billing/charges/testutils`
113
123
- if a charge create path stamps a new `LineEngineType`, app wiring and charge test wiring must register a matching implementation in the same change
114
124
- usage-based exposes its billing line engine from `usagebased.Service.GetLineEngine()`; register that returned engine instead of reusing the service type directly
125
+
- flat-fee now follows the same pattern: `flatfee.Service.GetLineEngine()` returns the engine owned by the service package
126
+
- because flat-fee owns its line engine, `flatfee/service.New(...)` requires a `rating.Service`; forgetting that dependency breaks app/test wiring with `rating service cannot be null`
0 commit comments