From 19c721be8a1f2e074aa1f2813d1315d01386b0e8 Mon Sep 17 00:00:00 2001 From: Peter Turi Date: Wed, 23 Oct 2024 06:16:29 +0200 Subject: [PATCH] feat: billing profiles (#1703) This patch adds support for billing profiles as the first implemented API. For testing purposes, a new OpenMeter Sandbox is added. The sandbox app gets installed by default if apps are enabled for easier testing. The change also makes sure that the customeroverrides codebase works as expected, however we are going to implement the APIs at a later point. --- api/api.gen.go | 1516 +++++++------ api/openapi.yaml | 360 ++- api/spec/src/app/app.tsp | 2 + api/spec/src/app/main.tsp | 1 + api/spec/src/app/sandbox.tsp | 11 + api/spec/src/billing/invoices/tax.tsp | 3 - api/spec/src/billing/profile.tsp | 132 +- api/spec/src/types.tsp | 8 - app/config/apps.go | 15 + app/config/billing.go | 15 + app/config/config.go | 8 + cmd/server/main.go | 56 +- config.example.yaml | 6 + go.mod | 6 +- go.sum | 16 +- openmeter/app/entity/app.go | 6 +- openmeter/app/entity/base/app.go | 5 +- openmeter/app/httpdriver/app.go | 60 +- openmeter/app/sandbox/app.go | 90 + openmeter/app/sandbox/helpers.go | 67 + openmeter/app/sandbox/marketplace.go | 40 + openmeter/app/stripe/entity/app/app.go | 2 +- openmeter/app/stripe/entity/input.go | 4 - openmeter/billing/adapter.go | 116 +- openmeter/billing/adapter/adapter.go | 62 +- openmeter/billing/adapter/customeroverride.go | 125 +- openmeter/billing/adapter/invoiceitems.go | 20 +- openmeter/billing/adapter/profile.go | 234 +- openmeter/billing/customeroverride.go | 126 +- openmeter/billing/entity/customeroverride.go | 113 + openmeter/billing/{ => entity}/invoice.go | 2 +- openmeter/billing/entity/invoiceitem.go | 102 + openmeter/billing/entity/profile.go | 315 +++ openmeter/billing/{ => entity}/tax.go | 2 +- openmeter/billing/gobldriver/invoice.go | 20 +- openmeter/billing/gobldriver/invoice_test.go | 7 +- openmeter/billing/httpdriver/defaults.go | 7 + openmeter/billing/httpdriver/errors.go | 20 + openmeter/billing/httpdriver/handler.go | 51 + openmeter/billing/httpdriver/profile.go | 506 +++++ openmeter/billing/invoiceitem.go | 99 +- openmeter/billing/profile.go | 347 +-- openmeter/billing/provider/api/api.go | 28 - openmeter/billing/provider/config.go | 122 - .../provider/openmetersandbox/provider.go | 37 - openmeter/billing/provider/stripe/provider.go | 37 - openmeter/billing/service.go | 22 +- openmeter/billing/service/customeroverride.go | 110 +- openmeter/billing/service/invoice.go | 28 +- openmeter/billing/service/invoiceitem.go | 8 +- openmeter/billing/service/profile.go | 235 +- openmeter/billing/service/service.go | 8 + openmeter/ent/db/app.go | 50 +- openmeter/ent/db/app/app.go | 90 + openmeter/ent/db/app/where.go | 69 + openmeter/ent/db/app_create.go | 94 + openmeter/ent/db/app_query.go | 222 +- openmeter/ent/db/app_update.go | 487 ++++ openmeter/ent/db/billingcustomeroverride.go | 103 +- .../billingcustomeroverride.go | 68 +- .../ent/db/billingcustomeroverride/where.go | 417 ++-- .../ent/db/billingcustomeroverride_create.go | 466 +--- .../ent/db/billingcustomeroverride_update.go | 361 +-- openmeter/ent/db/billinginvoice.go | 51 +- .../ent/db/billinginvoice/billinginvoice.go | 59 +- openmeter/ent/db/billinginvoice/where.go | 131 +- openmeter/ent/db/billinginvoice_create.go | 260 +-- openmeter/ent/db/billinginvoice_update.go | 197 +- openmeter/ent/db/billinginvoiceitem.go | 8 +- .../billinginvoiceitem/billinginvoiceitem.go | 4 +- openmeter/ent/db/billinginvoiceitem/where.go | 10 +- openmeter/ent/db/billinginvoiceitem_create.go | 18 +- openmeter/ent/db/billinginvoiceitem_update.go | 18 +- openmeter/ent/db/billingprofile.go | 116 +- .../ent/db/billingprofile/billingprofile.go | 145 +- openmeter/ent/db/billingprofile/where.go | 402 +++- openmeter/ent/db/billingprofile_create.go | 350 +-- openmeter/ent/db/billingprofile_query.go | 225 +- openmeter/ent/db/billingprofile_update.go | 203 +- openmeter/ent/db/billingworkflowconfig.go | 102 +- .../billingworkflowconfig.go | 76 +- .../ent/db/billingworkflowconfig/where.go | 418 ++-- .../ent/db/billingworkflowconfig_create.go | 425 +--- .../ent/db/billingworkflowconfig_update.go | 318 +-- openmeter/ent/db/client.go | 96 + openmeter/ent/db/migrate/schema.go | 64 +- openmeter/ent/db/mutation.go | 1969 +++++++---------- openmeter/ent/db/setorclear.go | 142 +- openmeter/ent/schema/app.go | 3 + openmeter/ent/schema/billing.go | 97 +- openmeter/server/router/app.go | 12 + openmeter/server/router/appstripe.go | 9 + openmeter/server/router/billing.go | 35 +- openmeter/server/router/router.go | 34 +- pkg/datex/date.go | 64 + pkg/framework/entutils/transaction.go | 15 + test/billing/customeroverride_test.go | 92 +- test/billing/invoice_test.go | 23 +- test/billing/profile_test.go | 340 ++- test/billing/suite_test.go | 45 + test/customer/customer.go | 6 +- .../20241021124045_billing-profile.down.sql | 8 + .../20241021124045_billing-profile.up.sql | 15 + tools/migrate/migrations/atlas.sum | 4 +- 104 files changed, 7822 insertions(+), 6552 deletions(-) create mode 100644 api/spec/src/app/sandbox.tsp create mode 100644 app/config/apps.go create mode 100644 app/config/billing.go create mode 100644 openmeter/app/sandbox/app.go create mode 100644 openmeter/app/sandbox/helpers.go create mode 100644 openmeter/app/sandbox/marketplace.go create mode 100644 openmeter/billing/entity/customeroverride.go rename openmeter/billing/{ => entity}/invoice.go (99%) create mode 100644 openmeter/billing/entity/invoiceitem.go create mode 100644 openmeter/billing/entity/profile.go rename openmeter/billing/{ => entity}/tax.go (89%) create mode 100644 openmeter/billing/httpdriver/defaults.go create mode 100644 openmeter/billing/httpdriver/errors.go create mode 100644 openmeter/billing/httpdriver/handler.go create mode 100644 openmeter/billing/httpdriver/profile.go delete mode 100644 openmeter/billing/provider/api/api.go delete mode 100644 openmeter/billing/provider/config.go delete mode 100644 openmeter/billing/provider/openmetersandbox/provider.go delete mode 100644 openmeter/billing/provider/stripe/provider.go create mode 100644 pkg/datex/date.go create mode 100644 tools/migrate/migrations/20241021124045_billing-profile.down.sql create mode 100644 tools/migrate/migrations/20241021124045_billing-profile.up.sql diff --git a/api/api.gen.go b/api/api.gen.go index a04e88ccc..061186caf 100644 --- a/api/api.gen.go +++ b/api/api.gen.go @@ -17,7 +17,6 @@ import ( "strings" "time" - "github.com/alpacahq/alpacadecimal" "github.com/cloudevents/sdk-go/v2/event" "github.com/getkin/kin-openapi/openapi3" "github.com/go-chi/chi/v5" @@ -49,7 +48,8 @@ const ( // Defines values for AppType. const ( - AppTypeStripe AppType = "stripe" + AppTypeSandbox AppType = "sandbox" + AppTypeStripe AppType = "stripe" ) // Defines values for BillingCustomerOverrideOrderBy. @@ -110,6 +110,8 @@ const ( // Defines values for BillingProfileOrderBy. const ( BillingProfileOrderByCreatedAt BillingProfileOrderBy = "createdAt" + BillingProfileOrderByDefault BillingProfileOrderBy = "default" + BillingProfileOrderByName BillingProfileOrderBy = "name" BillingProfileOrderByUpdatedAt BillingProfileOrderBy = "updatedAt" ) @@ -137,12 +139,6 @@ const ( BillingWorkflowCollectionMethodSendInvoice BillingWorkflowCollectionMethod = "send_invoice" ) -// Defines values for BillingWorkflowItemResolution. -const ( - BillingWorkflowItemResolutionDay BillingWorkflowItemResolution = "day" - BillingWorkflowItemResolutionPeriod BillingWorkflowItemResolution = "period" -) - // Defines values for CheckoutSessionUIMode. const ( CheckoutSessionUIModeEmbedded CheckoutSessionUIMode = "embedded" @@ -368,6 +364,11 @@ const ( RecurringPeriodIntervalYEAR RecurringPeriodInterval = "YEAR" ) +// Defines values for SandboxAppType. +const ( + SandboxAppTypeSandbox SandboxAppType = "sandbox" +) + // Defines values for SortOrder. const ( SortOrderASC SortOrder = "ASC" @@ -443,8 +444,11 @@ type Address struct { // Annotations Set of key-value pairs managed by the system. Cannot be modified by user. type Annotations map[string]interface{} -// App A installed Stripe app object. -type App = StripeApp +// App App. +// One of: stripe +type App struct { + union json.RawMessage +} // AppBase Abstract base model for installed apps. // @@ -571,8 +575,7 @@ type BillingCustomerOverrideOrderBy string // BillingCustomerWorkflowOverride defines model for BillingCustomerWorkflowOverride. type BillingCustomerWorkflowOverride struct { - // CollectionAlignment When to collect the pending line items into an invoice. - CollectionAlignment *BillingWorkflowCollectionAlignment `json:"collectionAlignment,omitempty"` + Collection *BillingWorkflowCollectionSettings `json:"collection,omitempty"` // CreatedAt Timestamp of when the resource was created. CreatedAt time.Time `json:"createdAt"` @@ -581,16 +584,12 @@ type BillingCustomerWorkflowOverride struct { DeletedAt *time.Time `json:"deletedAt,omitempty"` // Id A unique identifier for the resource. - Id string `json:"id"` - - // Invoice WorkflowInvoice represents the invoice settings for a billing workflow - Invoice *BillingWorkflowInvoice `json:"invoice,omitempty"` - InvoicingApp App `json:"invoicingApp"` - - // ItemCollectionPeriod The period for collecting the pending line items into an invoice. - ItemCollectionPeriod *string `json:"itemCollectionPeriod,omitempty"` - PaymentApp App `json:"paymentApp"` - TaxApp App `json:"taxApp"` + Id string `json:"id"` + Invoicing *BillingWorkflowInvoicingSettings `json:"invoicing,omitempty"` + InvoicingApp App `json:"invoicingApp"` + Payment *BillingWorkflowPaymentSettings `json:"payment,omitempty"` + PaymentApp App `json:"paymentApp"` + TaxApp App `json:"taxApp"` // UpdatedAt Timestamp of when the resource was last updated. UpdatedAt time.Time `json:"updatedAt"` @@ -598,14 +597,9 @@ type BillingCustomerWorkflowOverride struct { // BillingCustomerWorkflowOverrideCreate defines model for BillingCustomerWorkflowOverrideCreate. type BillingCustomerWorkflowOverrideCreate struct { - // CollectionAlignment When to collect the pending line items into an invoice. - CollectionAlignment *BillingWorkflowCollectionAlignment `json:"collectionAlignment,omitempty"` - - // Invoice WorkflowInvoice represents the invoice settings for a billing workflow - Invoice *BillingWorkflowInvoice `json:"invoice,omitempty"` - - // ItemCollectionPeriod The period for collecting the pending line items into an invoice. - ItemCollectionPeriod *string `json:"itemCollectionPeriod,omitempty"` + Collection *BillingWorkflowCollectionSettings `json:"collection,omitempty"` + Invoicing *BillingWorkflowInvoicingSettings `json:"invoicing,omitempty"` + Payment *BillingWorkflowPaymentSettings `json:"payment,omitempty"` } // BillingDocumentRef defines model for BillingDocumentRef. @@ -883,6 +877,8 @@ type BillingPeriod struct { // BillingProfile Profile represents a billing profile type BillingProfile struct { + Apps BillingProfileApps `json:"apps"` + // CreatedAt Timestamp of when the resource was created. CreatedAt time.Time `json:"createdAt"` Default bool `json:"default"` @@ -903,14 +899,32 @@ type BillingProfile struct { Name string `json:"name"` Supplier BillingParty `json:"supplier"` - // UpdatedAt Timestamp of when the resource was last updated. + // UpdatedAt When the resource was last updated. + // + // For updates this field must be set to the last update time to detect conflicts. UpdatedAt time.Time `json:"updatedAt"` Workflow BillingWorkflow `json:"workflow"` } +// BillingProfileApps ProfileApps represents the applications used by a billing profile +type BillingProfileApps struct { + Invoicing App `json:"invoicing"` + Payment App `json:"payment"` + Tax App `json:"tax"` +} + +// BillingProfileCreateAppsInput ProfileCreateAppsInput represents the input for creating a billing profile's apps +type BillingProfileCreateAppsInput struct { + Invoicing BillingWorkflowAppIdOrType `json:"invoicing"` + Payment BillingWorkflowAppIdOrType `json:"payment"` + Tax BillingWorkflowAppIdOrType `json:"tax"` +} + // BillingProfileCreateInput ProfileCreateInput represents the input for creating a billing profile type BillingProfileCreateInput struct { - Default bool `json:"default"` + // Apps ProfileCreateAppsInput represents the input for creating a billing profile's apps + Apps BillingProfileCreateAppsInput `json:"apps"` + Default bool `json:"default"` // Description Optional description of the resource. Maximum 1024 characters. Description *string `json:"description,omitempty"` @@ -921,9 +935,28 @@ type BillingProfileCreateInput struct { // Name Human-readable name for the resource. Between 1 and 256 characters. Name string `json:"name"` Supplier BillingPartyCreate `json:"supplier"` + Workflow BillingWorkflow `json:"workflow"` +} + +// BillingProfileCreateOrUpdate Profile represents a billing profile +type BillingProfileCreateOrUpdate struct { + Default bool `json:"default"` + + // Description Optional description of the resource. Maximum 1024 characters. + Description *string `json:"description,omitempty"` + + // Metadata Additional metadata for the resource. + Metadata *Metadata `json:"metadata,omitempty"` - // Workflow WorkflowCreate represents the workflow settings for creation of a billing profile - Workflow BillingWorkflowCreateInput `json:"workflow"` + // Name Human-readable name for the resource. Between 1 and 256 characters. + Name string `json:"name"` + Supplier BillingParty `json:"supplier"` + + // UpdatedAt When the resource was last updated. + // + // For updates this field must be set to the last update time to detect conflicts. + UpdatedAt time.Time `json:"updatedAt"` + Workflow BillingWorkflow `json:"workflow"` } // BillingProfileOrderBy ProfileOrderBy specifies the ordering options for profiles @@ -937,8 +970,7 @@ type BillingTaxIdentificationCode = string // BillingTaxIdentity defines model for BillingTaxIdentity. type BillingTaxIdentity struct { - Code *BillingTaxIdentificationCode `json:"code,omitempty"` - Country CountryCode `json:"country"` + Code *BillingTaxIdentificationCode `json:"code,omitempty"` } // BillingTaxItem defines model for BillingTaxItem. @@ -997,8 +1029,7 @@ type BillingVoidInvoiceItemOverride struct { // BillingWorkflow Workflow represents a billing workflow type BillingWorkflow struct { - // CollectionAlignment When to collect the pending line items into an invoice. - CollectionAlignment *BillingWorkflowCollectionAlignment `json:"collectionAlignment,omitempty"` + Collection *BillingWorkflowCollectionSettings `json:"collection,omitempty"` // CreatedAt Timestamp of when the resource was created. CreatedAt time.Time `json:"createdAt"` @@ -1007,27 +1038,18 @@ type BillingWorkflow struct { DeletedAt *time.Time `json:"deletedAt,omitempty"` // Id A unique identifier for the resource. - Id string `json:"id"` - - // Invoice WorkflowInvoice represents the invoice settings for a billing workflow - Invoice *BillingWorkflowInvoice `json:"invoice,omitempty"` - InvoicingApp App `json:"invoicingApp"` - - // ItemCollectionPeriod The period for collecting the pending line items into an invoice. - ItemCollectionPeriod *string `json:"itemCollectionPeriod,omitempty"` - PaymentApp App `json:"paymentApp"` - TaxApp App `json:"taxApp"` + Id string `json:"id"` + Invoicing *BillingWorkflowInvoicingSettings `json:"invoicing,omitempty"` + Payment *BillingWorkflowPaymentSettings `json:"payment,omitempty"` // UpdatedAt Timestamp of when the resource was last updated. UpdatedAt time.Time `json:"updatedAt"` } -// BillingWorkflowAppReference AppReference can be used to reference an app during creation only. -type BillingWorkflowAppReference struct { - // Id ULID (Universally Unique Lexicographically Sortable Identifier). - Id *string `json:"id,omitempty"` - Type *AppType `json:"type,omitempty"` -} +// BillingWorkflowAppIdOrType AppIdOrType can be used to reference an app during creation only. +// +// This can be either an AppType or the ULID of an app. +type BillingWorkflowAppIdOrType = string // BillingWorkflowCollectionAlignment CollectionAlignment specifies when the pending line items should be collected into // an invoice. @@ -1036,50 +1058,31 @@ type BillingWorkflowCollectionAlignment string // BillingWorkflowCollectionMethod CollectionMethod specifies how the invoice should be collected (automatic vs manual) type BillingWorkflowCollectionMethod string -// BillingWorkflowCreateInput WorkflowCreate represents the workflow settings for creation of a billing profile -type BillingWorkflowCreateInput struct { - // CollectionAlignment When to collect the pending line items into an invoice. - CollectionAlignment *BillingWorkflowCollectionAlignment `json:"collectionAlignment,omitempty"` - - // Invoice WorkflowInvoice represents the invoice settings for a billing workflow - Invoice *BillingWorkflowInvoice `json:"invoice,omitempty"` - - // InvoicingApp AppReference can be used to reference an app during creation only. - InvoicingApp *BillingWorkflowAppReference `json:"invoicingApp,omitempty"` - - // ItemCollectionPeriod The period for collecting the pending line items into an invoice. - ItemCollectionPeriod *string `json:"itemCollectionPeriod,omitempty"` +// BillingWorkflowCollectionSettings defines model for BillingWorkflowCollectionSettings. +type BillingWorkflowCollectionSettings struct { + // Alignment When to collect the pending line items into an invoice. + Alignment *BillingWorkflowCollectionAlignment `json:"alignment,omitempty"` - // PaymentApp AppReference can be used to reference an app during creation only. - PaymentApp *BillingWorkflowAppReference `json:"paymentApp,omitempty"` - - // TaxApp AppReference can be used to reference an app during creation only. - TaxApp *BillingWorkflowAppReference `json:"taxApp,omitempty"` + // Interval The interval for collecting the pending line items into an invoice. + Interval *string `json:"interval,omitempty"` } -// BillingWorkflowInvoice WorkflowInvoice represents the invoice settings for a billing workflow -type BillingWorkflowInvoice struct { +// BillingWorkflowInvoicingSettings WorkflowInvoice represents the invoice settings for a billing workflow +type BillingWorkflowInvoicingSettings struct { // AutoAdvance Whether to automatically issue the invoice after the draftPeriod has passed. AutoAdvance *bool `json:"autoAdvance,omitempty"` - // CollectionMethod The method to collect the invoice. - CollectionMethod *BillingWorkflowCollectionMethod `json:"collectionMethod,omitempty"` - // DraftPeriod The period for the invoice to be kept in draft status for manual reviews. DraftPeriod *string `json:"draftPeriod,omitempty"` // DueAfter The period after which the invoice is due. DueAfter *string `json:"dueAfter,omitempty"` - - // ItemPerSubject Whether to create one line item per subject in the invoice. - ItemPerSubject *bool `json:"itemPerSubject,omitempty"` - - // ItemResolution The resolution of the line items in the invoice. - ItemResolution *BillingWorkflowItemResolution `json:"itemResolution,omitempty"` } -// BillingWorkflowItemResolution ItemResolution specifies how the line items should be resolved in the invoice -type BillingWorkflowItemResolution string +// BillingWorkflowPaymentSettings WorkflowPaymentSettings represents the payment settings for a billing workflow +type BillingWorkflowPaymentSettings struct { + CollectionMethod *BillingWorkflowCollectionMethod `json:"collectionMethod,omitempty"` +} // CheckoutSessionCustomTextAfterSubmitParams Stripe CheckoutSession.custom_text type CheckoutSessionCustomTextAfterSubmitParams struct { @@ -2278,13 +2281,13 @@ type NotificationRulePaginatedResponse struct { } // Numeric Numeric represents an arbitrary precision number. -type Numeric = alpacadecimal.Decimal +type Numeric = string // OAuth2AuthorizationCodeGrantErrorType OAuth2 authorization code grant error types. type OAuth2AuthorizationCodeGrantErrorType string // Percentage Numeric representation of a percentage -type Percentage = alpacadecimal.Decimal +type Percentage = string // Period A period with a start and end time. type Period struct { @@ -2809,6 +2812,42 @@ type ResetEntitlementUsageInput struct { RetainAnchor *bool `json:"retainAnchor,omitempty"` } +// SandboxApp defines model for SandboxApp. +type SandboxApp struct { + // CreatedAt Timestamp of when the resource was created. + CreatedAt time.Time `json:"createdAt"` + + // DeletedAt Timestamp of when the resource was permanently deleted. + DeletedAt *time.Time `json:"deletedAt,omitempty"` + + // Description Optional description of the resource. Maximum 1024 characters. + Description *string `json:"description,omitempty"` + + // Id A unique identifier for the resource. + Id string `json:"id"` + + // Listing The marketplace listing that this installed app is based on. + Listing MarketplaceListing `json:"listing"` + + // Metadata Additional metadata for the resource. + Metadata *Metadata `json:"metadata,omitempty"` + + // Name Human-readable name for the resource. Between 1 and 256 characters. + Name string `json:"name"` + + // Status Status of the app connection. + Status AppStatus `json:"status"` + + // Type The app's type is Sandbox. + Type SandboxAppType `json:"type"` + + // UpdatedAt Timestamp of when the resource was last updated. + UpdatedAt time.Time `json:"updatedAt"` +} + +// SandboxAppType The app's type is Sandbox. +type SandboxAppType string + // ServiceUnavailableProblemResponse A Problem Details object (RFC 7807). // Additional properties specific to the problem type may be present. type ServiceUnavailableProblemResponse = UnexpectedProblemResponse @@ -3855,7 +3894,7 @@ type BillingCreatePendingItemByCustomerJSONRequestBody = BillingInvoiceLineCreat type BillingCreateProfileJSONRequestBody = BillingProfileCreateInput // BillingUpdateProfileJSONRequestBody defines body for BillingUpdateProfile for application/json ContentType. -type BillingUpdateProfileJSONRequestBody = BillingProfile +type BillingUpdateProfileJSONRequestBody = BillingProfileCreateOrUpdate // CreateCustomerJSONRequestBody defines body for CreateCustomer for application/json ContentType. type CreateCustomerJSONRequestBody = Customer @@ -3929,6 +3968,95 @@ type OverrideEntitlementJSONRequestBody = EntitlementCreateInputs // ResetEntitlementUsageJSONRequestBody defines body for ResetEntitlementUsage for application/json ContentType. type ResetEntitlementUsageJSONRequestBody = ResetEntitlementUsageInput +// AsStripeApp returns the union data inside the App as a StripeApp +func (t App) AsStripeApp() (StripeApp, error) { + var body StripeApp + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromStripeApp overwrites any union data inside the App as the provided StripeApp +func (t *App) FromStripeApp(v StripeApp) error { + v.Type = "stripe" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeStripeApp performs a merge with any union data inside the App, using the provided StripeApp +func (t *App) MergeStripeApp(v StripeApp) error { + v.Type = "stripe" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsSandboxApp returns the union data inside the App as a SandboxApp +func (t App) AsSandboxApp() (SandboxApp, error) { + var body SandboxApp + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromSandboxApp overwrites any union data inside the App as the provided SandboxApp +func (t *App) FromSandboxApp(v SandboxApp) error { + v.Type = "sandbox" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeSandboxApp performs a merge with any union data inside the App, using the provided SandboxApp +func (t *App) MergeSandboxApp(v SandboxApp) error { + v.Type = "sandbox" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t App) Discriminator() (string, error) { + var discriminator struct { + Discriminator string `json:"type"` + } + err := json.Unmarshal(t.union, &discriminator) + return discriminator.Discriminator, err +} + +func (t App) ValueByDiscriminator() (interface{}, error) { + discriminator, err := t.Discriminator() + if err != nil { + return nil, err + } + switch discriminator { + case "sandbox": + return t.AsSandboxApp() + case "stripe": + return t.AsStripeApp() + default: + return nil, errors.New("unknown discriminator value: " + discriminator) + } +} + +func (t App) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *App) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + // AsBillingPaymentTermInstant returns the union data inside the BillingPaymentTerms as a BillingPaymentTermInstant func (t BillingPaymentTerms) AsBillingPaymentTermInstant() (BillingPaymentTermInstant, error) { var body BillingPaymentTermInstant @@ -10349,613 +10477,615 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+y9i3PbNro4+q9gdPc3Tc6RFdt5tPGdnR3Fdhpvk9jrR7PdKteFSUjCmgJYALSt9pf/", - "/Q4+PAiSoEQ5dl7VmZ1TRySBD8CH7/34s5fwWc4ZYUr2dv7s5VjgGVFEwL9e0CyjbHLArjhNyGsq1ZF+", - "LgfkJscs1a+QmzzjKentjHEmSb9HWW+n93tBxLzX7zE8I72dnn2735PJlMyw/owqMoMp/ibIuLfT+38e", - "lXA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MnZgsBSKM9XBNkXLVmZc74rLheFjg8p/jKkMy+", - "ZxkOV+oIvAh3rGhlxPIDlheqKZLYCPbAidYS7OAETV8NyIauO/+glYv6iFbN1whnWe1jV6nAjpBWwiaq", - "M5+9PthDD84YvSJC4iybI5Mfh16TG5rwicD5lCbw4IQLBaTowNsqHn4GO3ijMsiS09mjMnFS4d1Li0PL", - "jTlg7Bw98AE1kONoZQ2Xz/gQRLYLvErcQWzWF1oMFC7Q23i+TPg80EwsETaiItxlC4ODDC45ZVIRnDps", - "t8j1nUSymOkftbojB/ckLvndso4pABWi2QMoBnG2aAlhScAwXBbDDwlK7Wkbj68hIktV+Yjg5YYJNlnL", - "XlnGr03kgRnarUBvQ0ZUwPcoS4m+lRWBnrKUXtG0wJnb4KXou+/L5dYzY4LHvm6JdHpDSci8LzysaVsr", - "eBsazgGwntZuDN3s9XuygNUKEINIQlITsfk/i3S00Fm+KrM4Y1QdiZirvfKkcjilgl4m6fKsPCDHBVyo", - "dCg0PCgYVQ9RLqw2v+RI9NylKeb2K7NjfMHrOxTGInYX6/RjfXHrLROkolfM+vGhGFe7td6zZ59ObtWx", - "EatYqcEDrfm9GYoRqaUXTSmkWUXGQYAd40RxoXWuDbCsSqJA7n1gQciJgN+5QMEvblse6s98aS74PiEM", - "C8olehD+Lh28RtWHNciglgCeEc28xvTmYYXVH7z9eaM0vW6AhWtJDP5iQtHq8qs+r1E6bhMdK/5AR/Fs", - "bHlI3Nz+DGz0rY958fHnbaHqy0mdFXGbcoZySsVqcrI00o1jn1bM96YAr2AC/5vy62ql6IploMMlaIvo", - "rDz2qph0cXc2xaFmDbW7PcFaSTfMQpArSq79lpe28HNXrQEwiBU4O3ea/rln0v2erZ9AOTsfY5qRtMOJ", - "uPCwpsH8K3aH3qHV0T0wlpAsC2QFBSl9HwIxYHWNT6hqZN5rMsGZieOc2xodzso+4VzTPwFRs5oEDdZZ", - "ePedhedEZXnLovVesfrQlJvhLL20LFvF5YBo1GPzvxl3eWtY5WkYr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EIPP/Km2oGq17SF7DUR1lC5+qUNb2awvNol2NpbdgdqHbUuCLok", - "uUKUVUvA6VcN6Uam8Ym87V34Ysq2GSpyRMRJYS7CCqhnZFTEWVhwICcCSTNWuyUuwDT90TGRPCtuZfXy", - "l7E6TBXLbA2CftTM6r5p1E6QDfjDFERv8Knf914H0tJYc82LU3kekTSighMs5apRcSsQMlI8r1ZkcJq4", - "PrhyJ2JYsjslySUv1AmRknJmetmfkhsFaHxSXMyoOsICx7pRnkB9eVQbYmA8lOeK3KgmMSxHbcY7zYiU", - "1hHUof26nFIo1+eyfD92uDsBCnK8DscnptDMMElIrhzlv/24sZlqu3528IbHLNwtZ1TQ8xlPQxwiswuS", - "plBVYsqlaunYtJtRw+ohM+qYyJwzSWJ+LfOkjKZK4EtQTx4c5kSzDXBiJ5eEpQ812YG8KXj3cFio6TbS", - "V6qpbRaipdTn2fHr6DC4UFMuXPcEiBycCMyUH3+xxq7ni2ndu7bG+pHgFxnca78X3SjdGTN9b0laHyLu", - "nRPWV5iEZYdcb54UuqhrucEXfy/9+6aCuWF3ZftzzaFVNWK7ucYyFLOZsndwcogebz17trFVZu1dX18P", - "qOSQskcl34DnNghyA3p2D6Zqlj1EOMuneGO7EtE5GFkChNQ138iIVuwrLxjvLM4kh2hpLhRxwi67IowS", - "Vhdjz05qkeGVEN3tRoju+z+34yV9jAJlrlPtNlknbkS3NIzU3sHEfoWk+cwdaMRTlOcxj81BtZVwv6L3", - "20kC9R/RMcJs/hnKH1W6kHVKyt21XxykS7Nw3auxujlmZ/QdcFEyxmdUyGo78pIABeW/TMR5fQBzGQKx", - "CCNGroMGQR/6PRu0vkKI81JkOrRDNhdpn1gxXwNmjx7MMD7dxVTbrmKcCTQ1s5Yb3sYzgj0ceM+772Md", - "bCEsRtqNqX/MxYgV0kbgNvf9O1nH4HDa5ebUsk2DO4Qore6836veYTdrwyqiuX52dvw6wuD7PcMMvd56", - "sBd/K+gd2L1joLt+Wohb+mV36a+eReSjiY8ihQ+aD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ypIzyhTLOcdrewf8VbOW+NDM6nuRJSWD23", - "DnnMzNyOEwvB8ERma3Vs6ThwgMEroEe3wZ/GBq8nOIfo0cSe5QhzFpG6PlZkGozYIQsIV4KZKVQ+KzJF", - "84y44CXZH7GLQkF0k4tn0i9D3fILknEzLWcLpZnQ/BPbbTeZoe5grXPraHYeCrG3qV+Fleuj5cJPAmDq", - "eNxoblu+GjuhvZUbb7svFvYzGZZNRqBegStVcAjax05QmKdvCw71ERfmoKNxCZFZY1nFrtqPm715kPmC", - "AU6rJYOsmhSOFdLvgHxvNsoQmUtil2FIdJgbECHmQbx/OKOL1gngrpUU71p6vTZCfYf3GQzqo7k7efGD", - "j96Yy7rUmx98cqKwoskqX7xw4YZNA035ElJklmfGQy3KXBdTGAo2mJQvm47NKM8wG4zYS4JVIeyHfEZV", - "pXkNiczRh+Y6UzKHT8wcPnAPqislWKTLus+6MMruOwB2GNjw7kcDtbj1jq9wNPEmZlV8eYElObX7EfES", - "TbEm4qaWiEPx2FZGBMWv3yatgPcdrdgeLOgLFnEKWl5u2KIrUv4NmZfH5ha22QzsY1tC0wYoS4dSzh5Q", - "VwCHx/95/HZv/6fTk5+fHB+/fPmvZ89/fPpy+PMdOrMtYD+R+d0Bbv/asN9uXJL5/eiGcQP1McEpCEpW", - "TwStvKoj3u8mN5Dos5mj7QnY2n1OrGqRvUtz/iXxm2fFQPtxZeucaLixdV+nu1paYkDdfXriYqEloOgV", - "g7JtevnNGI9XJeXHRNPraq/H5k46wSGk6ZGd7ZxdHDZuDJC1QqNCQrtEInRSx23wpyIddBPcbB6imbSO", - "WWsJYS0hrCWEtYSwlhDuSUJwJgenlL7/ln3BXxY7txx7IVe/O3Ye1BFoj4OHxhrG4RthyA1+fDeUecT2", - "KSSnlutD3P/rINXfuH37esn47Vf5CWn+Z6GeK5GiO7jGlTYZ0RtduclYSp5QcGv5lLuKlNravXHBpazf", - "xttaYCvjrGyNve3XMZISCats0JQqLblTG2kFllvYS2vfr2g7rW1kFzvqj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ubo3MUtymi/oVqUwtWaqearmGGMEumXFQRvmd+XBzp", - "W6YN9vaGvwTOchc+bsdosqsyxti8A8oRtlZIUQe8Htd626SToZ2rRe4LsyA7CjXVM/AK+IKYRn1haMBv", - "3KSDmCLfqJRbavh2bztghik3ccDyQq2R5K+EJB1w46A18Xc5LGXc9W8pnv/WR79dE3Kp/zvjTE1/62sW", - "9NucYPFbyBY0EvR77/b3f+r1e28O356+6vV7v+wPj6OmNjAiBhI8mAJacRkso751b0PH9wltwxa/jEE2", - "ha6nNJk65kI087z0SYJ9x1LBosP49QCd+hcTzBhX6MJ34RsXpm2rEUqgL01a2qyUKFgCHgNrUJpRViiC", - "0gJaaE75NZpSqbigiZF+iUAg/2otR3ER4XEf11aoZsRt7tKehmEGlpXroItu1G7LQf+Y0CvC+vCGoKlz", - "DARK3nfSCykXZIqvKBeDEdtASw3D7q3AJBy85qYeRM29gihM2bCF9rSs0hicLb2xNAnMzzb6m4vSFF0p", - "lD+0PaAay1oyYmSFrV8smjeyBbFMtRMjAp+V3cGOBL/IyCyMAu+qnZCbnCRKKw/VIVraD0CzMr0SG9ic", - "zVHBQD3TFwGzNHN03zTrtlckbB+sDz/jGM5Bw5EWWkufYU2xGGYJ6duLDb6vjF6SbG5z0cgVNY47cLFI", - "PtOCc4bn0cq1J1woqOgZJyIcin2mVOgzqDbaHJ7s9vq9vf2T3SixO1GC5mSY5zFuSJlUGtIUmdcQzvOY", - "KblSgnGR1EvTZVlRGZXKBm4mOMcXNKOGlP5aB8+CBKoDzpLCRKVqnSPnIjSR2RxOUKDBlAHLz8m5/+xc", - "4RvXD2Cnt+t+1mOXh+Hf1r9qPTMKjpvMm2+kEW807pSViStg2E/O/RclKAc2/XQ3eOR9b/CofNIKks1k", - "kijhWUYSJREvlFSYAWUU5Iow137XfuEgCcikS4eaETXlaXMrzdDnbq5gN80TdFQ+cRtqnvgHzVvq91S5", - "8gU2d3jOC30T7QjlCoNFQFJHwtmZ0GLgIzrDEyIfGXAHOfT9s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RNroReNEsPKIuocayok1prcbCpKclX4ShddVbWcPHFIlJMoJ1FOopxE+VxRPpa3FbJ2aWm+SGGz", - "/cX/34JL4k9013qlSmWFWGfEZIxKiCMV1VUbpkbQzEhbuoQdPnR8XOctVA0Riw9witbNPbzxoa4be432", - "zusnjz/98Pjx/qvf9t/89HJn990f7YNfn736qTF5jENuQsQFxAVkPkLmIwRGBEa3CUaFe/G1wGium9Uc", - "wqnytrrfcNL+ZvQhpN8gjiGOIY4hjiGOufscA6hxTYRJ8wqE+ZDGvEZLM0svLvG9A5hv9WyJWIpYiliK", - "WIpYiliKWOrmWMozz5oOy3CKrWrb7F5abNn80mW+wK4ZLylj0MgtKweCScWOXx2wR48ePYO1YMBt60yh", - "1bCRF+hcX2XZi97l1Wi22959tNXe2WrvnLZ39vC/Vru986nRbLj8G3uNovhqL/fJGr9U8bXra/Vt1fYV", - "+pn7a/cHeWJlmgjWFdzmmWAyNvCJnYuRmbSz9gl+9H+3ds7ydnv3yfTj3b/rBsQlmGjl0q5YSzbC+8fV", - "N8In+NH/DY2YflzbiODZv85GZHmCwzBZc3j6Y3vn56c/7/7+x6fdd49/e/7Hm/azly8+vXp+8umta8c4", - "0ffH33/89NPO0/ab4ze/Pnn07vnux/3Hda2C16qbNLXd+uXwBXvwQckLkRmeJCP2Qcn/ywX7RVzKSPcy", - "nvZlhD+c6MziAn+IcNWVInvYQqP8W9wgXXUEiiP86UHwP4Qu/v2nH354+vvz9uMnP5+0nz59f/DHqRuH", - "yXQnO8c7r5+9/Pjuye7x691H+8/ePvm5bijG6/hGjMY36T+BYupGvCfqc7pN3wmsBXlO0BaattBkbkk7", - "SPKcmPGcEGFjdhObx+0v+NdbWS5reoDvLGl4gAJtKa29r8lcnf3XMgtwrSApTFKYpDApskmRTRiy4UYB", - "wov160FIlidiVQU2vrNYf32MWV8nLAcWdNdjcizZiK8SkGNFVff2Leu5b1aDd6b22bkYwXrEWe5edRhb", - "EFZuHFxJ99rIOdA6GIBmnx69ONpzHj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diK4UjE6u48xJJIc5IPG3k67jZzo/1XgH8yFnshuwP67COo018po3OCK4ErEJ8QnxCfk", - "tE/ieQPE84x4XXhP/pSOxknW2pA+JUmzJoPdsiy7ZWPd6aJJbJLYJLFJYpPE5saJzbpd6bZf27iLUVMt", - "Ww+LNKZavBrWGbHDF9jZeec/IrKzAnecydR+9qpSN82gACud4JTxvHozPlFfV91WVSRfX//5mSXJVPNh", - "IeTlts+cm4Qn2mW/FAqQwQnJeZLzJOdJzpOcX13Oe2m0QPEcUlWrnk9CHreh9vWFkcqXZBrJNJJpJNM2", - "W6YVsqde6fshNSKzprT1Yk6va6Dv8tRtWcNvZ+pMHeItj+ERXuOovrPOlqEJsw37tCNCDPDWzCvO7GEi", - "bcozWFNgqLHImA2l7eNbaaYvZCxi1pUiiU1VAA5oQhB9V98NryJhXZnVcvZm1dMk90nuk9wnuU9yn+T+", - "FeR+xW52+4v/v8P4KFsyyHoQ3YWS+lyM6gKnjyXxYjP8yZrMtcUn70ISkCQgSUCSgCQBeaMb49rw2MsJ", - "vdfCfjWJd3OWTsUOknaMJBBJIJLzEjkvERHQlrluy7wNK5tNxADqtvgG+3LqKUsn9kpnLOqL6BymWykh", - "4xFIriZsP3EQty94kouSr7wyVvB47rHzy3I114wnzeU8qaSKkjwWTlcQV7tU+dd9CR2tE8HVbflOlfqM", - "FOqER4RHpC8gOthsOiiL0eVvRz9KhcIoIrhO2H4mBANpYpjuTiDBnguQI+Im87KuibdrGyD1qMVgNOFF", - "5g22RyyG9AOphFu68cfJTN1b+MkmI5irXcFtnrk7ut36Df3HrYQJUZy2lwEEczWpiGQX1jWpJmaLX+55", - "qPvEq0qI2DBeFMqN0ZEcH+z7tx6iRcEWe+5aPclJsehKJXwnjHPyVASls7PGAXy8RrCTk6OpFfas0YKs", - "T9zrEzknwrKRzlnKjWE80arnvN66spc7joJZnQjWy7gC4TNd6gfjvn5pinphs35nfzAjLLxizhrsARQw", - "7jlXwkOs1tvZTjOszy8EG3A1wiZF3A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w", + "2SZHKRQfllylKryUggcNsjK9FOM1fMepY2HfHnmM7B5+p+d2DMddIUZulBVd/95rlh7s98BScqZM/E2k", + "6ETZEHLuCzfAN04gLpiimbk+ejkuk7ACDJUam/XRp4H33llfyCxX80+0mDTMfQXxPVHLhhhHP+71+tFo", + "FAjuM+hexvd5MuzjNksIj7b2QmAOTg5/egZ+oSXO9wA/FoS/O0dyFdSm29B2bAHSXCoFcVOMUddtdTsb", + "W5thKb09HIiQhkgaldGqh7YQIojIptRoBqe1KGisYFSdA7FczfndMWLMyTq3MHPt2gT0wC9gBqtabamE", + "7Yhpl7e2JOvpF5uRu4IQsxZ/e7FNZRmJ1bRmW1eiGm2j769vsOykFbOfIEqOoYGEKT4lSMInDOyGKBdF", + "zqXTozWXW/VYT01ZnfBE3+DcyjSkFuIHFwuuUjXQzTuhmof9CZJGm+3eCF82+MltWajSpyVKstRJHatq", + "9RrfNeuVcWXSZtE7UcFiwxKiuOt1qLuLbqs3HbsBQmdDovCqIW/1aDlTiNcWvnXyPwR6mX4n9xG0X11R", + "EItGx2gM67PL0rQ9iBurBq/dWUja4BYxaeVh16PSrKJtq5YE6KtR1ckU7rpdQCtwcxMXSYrVKKdviu2u", + "OWYHEL5CXnMXhNTS0I60sxHltsbztWS4lgw/220NxZ5uV/Z+wvnXAs9XKvC0BeIb2FOSFokKu03djdxj", + "kDWwjwXaew1AeLWei1Hm8gJ19wkVxpefYObpO2W12Mk2e5vxjEb8NdABYwX67npmVMufBpZ4MikyLFDO", + "JciUZnigCdeQXxg6r0t/uekZNgZPRdwH/W0SYh/b5atG6oMYLKo5XI13NB10RYkiOIzwq/RaiKY74ZuD", + "1em+1sBT4y5vuD3Nzz9IlAF8B3umEV5ZpQPfoLwQhtKj0ymZQz4sWLpN1q0JRJF9dFEodE1+EMSEulCm", + "iCBSOV2eS2KarzXHjXGCkEnpTa5KXjkR0sSqXBSSQty8WcmiywzjtFXI+Ibuzhq1VkStu0ekRjLvLUtr", + "ViP8G7U1fT2HlUKNyvziGWVNvFxed6HEtE8ou1AWn29NGnYM1edQd80D7liB0mzf+0beRHBwPlkY/E0w", + "V5DyXEslWlZFIRj+ALriqHvCi/oGUjvbne5ffN/swpbvG8T052GcbMetO23Djn5snfbD2vdV8FbaihhI", + "snv7qXZUWNaOakGlgPhRyMWHMAjX4jXGKiKRWDbp11kuZp+lzVrdsaYs4pupgHMSL0C++G6aFfbh6Jqa", + "fIW5AdwCs8niq9dWKdc+qI5ZK3TbKIaC83z1SEs701B/Wxcj4KYmNrgBhIcLW+2kDso3X+fS+uE/BLWq", + "beRAUGnYrrYlXGGdJLVuRbY0C2mdYtK9ydfdBq/DWsBnzJnCiarogG6Nbs4olQuo8ZJY8He3Cf+m0kZ9", + "zwqpjDqqvBux/NTmXXWICH9864jwcKba7b7TCPF3vgxj7bDczjdDw30JR896Pi0c3MPeN/yzZAbvl/Lt", + "oWW4Ud6tH9btkVGGupyx36Jm52ets/tJ5W3vt7ZtXbsKumeZfHi32OWnbcxX+lh9ianowdfeq+MAhR9r", + "TVdqGPAD2OvlXSBC7aYN8/wgPRTN2l+fsQ7zIhjuAW1WmP2zY1MXTLo1FrUqCN3VgjrO35ms/DXKmGvZ", + "7DPJZpGCS/cioX1Vcondyrjo4S6VFUK6ko/2iJlbGRDWV3t9tddq11rt+gTytlzL6q5etZYiqz7vUorM", + "Qi3DEmQtumFJimFJC1KvTvHNCzLFV9REAZYeoSQrJL0igBju78XjuFgKoxvu2hil4EI/3l7UkXm48R/f", + "lPm30WgwGm2MRo/Q+fu/h49aWjRH/MmRJhYpub2HurKuEOfe6iuR0T9JCqI3OKnllF8zV07DdSOwJj41", + "D1vxBe5lBzmSigvi2JVxlfpa54o7S+EcMrfNF3W/NYQClY5H8KyKhT5pl2bR2LWLADtW3TmPWZUMUetv", + "wjcmVtCjGuICeVxztAMiXU2Elsnyho7q3YE5xTe75pMKndB7ZWoeC9ukvRA2uOHuy9RW/Gx5GT2nibSp", + "UpfNTUNcRcSMsjAGTWBFRuySNCIF9YMyTBANEaOZDx+kMxt/acq9aNkHUHN2wUeMSvTf/01uyCxX//3f", + "diab5yoLcSdp9HxGLNJR4pEXYu1KscPPtXhlC8syV/PbVsVQXxG2Fkd2l3VEC0aVzWuuhHAznPEJL8Cf", + "POEX2Q8SwXQznpKsXxbNdBvm20LMcyOKQMeDUnSDpgrxhufd9+UYK7KLRTXGd6/SfODarvuCQGscnpnC", + "Nn8U2FPd2+PNP+0oYeWr+kz12IVaNGWXuA7bDtfD/L4jgt2yTm+tPO8a2dbI1hnZbl00uaVW8hr51sgX", + "R75fOU1tHYZhErd82Mf6TfNKUMIXagZzNMUszUxFlSsOHSUg9LB5XPh23eQCKLW4aiGt17tpB6TvDEA7", + "rs1FIO/hVeSeFpHPl9uptHHyfTguHDh/Rw/IYDJAW5ub/wcKbUpTisPlRAn34sNYa303c9/tY7eDbbHU", + "H5M/CiLBYKDnDJII7v/YmtUizBQ+ONQqUXVsqoT4LP3CNd93fQ5jHk8iAqLnG4R7846ZJOzk7VR228r7", + "d/PG741kEcVNPWQH+irBuLWNK9sg93usyDJTrsnGbNSCb8tUm+Yem2ewNr1NrvxdGGgZ7O/it5cn4yTW", + "omkhqh9FR9wt8SYM7qQyMaVm3HX2f50zcqPOk3lSrYgTHXIpIaMWk2p1BRbFf7YdXeNAWl5shSlQ7CMg", + "mdgse073QXcjNLf9ElJbukH/9+Bbztk5dUz6YE+v0dGHpchvF96FUL8LTKE1m7AzZUY9IYFdct1EfN1E", + "fN1E/C/YAfiv1f66AxENI2SaGF8+rCTQVopxYyjDh9ICHDGJoxCcZfNSwbVf2/LYmKFhnpvUGXN/gL+Z", + "niY4zxeJC02KO8zohDnMqi4g8lLgQfJH7Op6e7lWBomClm5DEpziIxZvuyKLi3LisN1HSfWxh3OV1b0h", + "asrTRUszbwTrau9LU67lAS4Un2FFE3QlrXX9YegxAwXr3L+lRYtevycJSyvdopvLnBmAV1njgkKG4dl+", + "Imcu8cQoVK4cX+Xo+lE3M3c714YuJj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2EwI9h3Ky3lIzsTa0IIyznJisndI3p5eWGD5DnYIe74BpiVSr2ACLq7dvrhfZlGmukvvzjfvtO1", + "Yy0u43CxOmJL12srqiz2XX55sWVNvtfke02+1+S7TvoCEreAuumb09zV1yZ1qPRIGPkdmns5jChJPxi0", + "KEuyIiXSOBC0dmvPo5R1JXpA074+sEh1mZjsfFYfoQLBZwgcsCdi9wpZeLyFUvS6itP6TB2iMkRns0LB", + "wRaxFYb3zqDvVPBiMuXGUYOGRwf9ERuXBboMP6ZMEYETZcoXqinCzvr3g2yGsfuNm+TqyblB/siSTbhP", + "BzOTXvYCPFst6N45lUP3OMzSPerezvsNRNw7k8g62v5zRNu/zLA6EjTmedCPbMPzBaVRu0kkb4sZETRp", + "MbHZfDp314N5I8Ez+nEExeMxKhbOhSt/R9XUFos8JWK2aCMMIcnNy0gRMfuiW5NXoe4Yx64/D9drJnYO", + "HcrOcXqFjVcoUqgxWHsEqhHbC9LVKEN2rPs9SS4uaJoSdiT4RUZmIW3rtidnjNzkJFEkrQ/RUrWPiCsi", + "UMFSIqTiPLXa3x8FkQoiCAQZFxLckggXasoF/VPf90FMnoMqly8Kwfb4NXtFpeJifkIms6ijfIikeVQp", + "GYguCsGgcB2amgEGIzZiQzShV4T5T6IhFSBE2FGIuibEehSlVdymmE1Iigj18SX1KctKl8C9rPCsRw8s", + "+NF4pqHaZy2ehjAcxYUJ2cYnhPng3piH4JaxQB6kE4VFZOcXAAR50fcAEmy0DaKSfq/adLAOVVib2+xW", + "ciEIvoTT5GOTG41NVWmbWNuy8zumRuvBnq83W9V+Nrd+fvb0Pz8+fTp8+W74y6v9re23/97c/efzl69g", + "Vz62bkJ5PWqb4E/nC25D5Lw/10ZA7lI0/kurHbaYJYQu4USZbPSyqmUt1Akz8GWDQm1T7LtKaT97WI5J", + "wkXaa1+AF9/aQ8OuiDAFIhYEd93JhcrvMumrmmZgaexgQSDXqY/L8pQ36OPE7pZ61Nho7krIGNjK02gQ", + "vpYb16/S7Chxqu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zw7evJxMfj15fjjmR3j89qfqyT8wHz38+29448/hxn82N57/z6O/vf/weLu/tblZKdPkNsVu", + "Wuda3gtFtxhLiUlv32sLu1josuWI6Oz4te2U07jt1JDzKuDO9uDqmmuNu3k1gtFvXd8xlF1taLJeSUcB", + "JKrxRUo/mjsGtwCq22nOhcFkYETsjqrfEmnh2+O4XxmnWtPyNS3/ZFr+ddPB1UldSzJ6q5bl+8DUwkEY", + "48biKFdINgk+iiQhRWOzbSs6qI8C1UdsX8xdgADay/HUdysppIkLaS2nH0LQsXi+Z9PNfQkVM61Ou9Yk", + "0fZBd9USoEtZfXpFxPxEYVW0mE7cO9DtrZCLj35lUwog2V4VjI8LdSADjH21aYDpGhe7cBmh+vGP7V/e", + "Hm39+/Rf/zz+16vTvX88+eXo+Mej/2zevfoBe7FE67ANsW5nn4QJjuwIEUfCHSHy4vX5+fs9UWS3tLQe", + "6y/jrhBWgVlPYevPTggjwjTZmVJZHnYbuIfXjAhkZvoUq/C+D8eIALyUmC7ezCVm4apZFra7celLnOrE", + "EGx1o9OpIHLKs/SoRMi6wRYeNC3JQQWT3ytFZ20xpYFyY//eIvCuVvq76xL24h1tT10fOFfbrGxJ13Y2", + "bul7tnD4qrH6ke0KZkYXJOOmQfSXo1UVKaoL4VKOuHxXDFStZoguGYyVMxfjv76RKxxAXDJdQBzKM+m3", + "x5msdH2aveaaN+c+KELYB757v6vyI9sJGK5/K8WtVrsYl32quk3nS1EsmCMoVxFEp3Qb/8R+sGh8/06/", + "V2LZrTlwHRNMQ+lF8/tXKzE2Kx/X8omCl5F9u15GKDjO8jTLfe/7MJPKfVx+P/buWqiuWXvuIKACwgK6", + "eqgr4GKlwa31Rx90ZRSB41QQLNuSTMwztylg5rQQ2B0j1uxZpfovTS0pE62SQ+qFDWUvIDY/F/yKpkSU", + "RdJarwnMcWxAjNbhstkht5RAqigCs0WOYy9EkgUMxZWCiVqlTs52d/dPThqLvY312SJr3fb82djxys19", + "zDl5ZKtagN1FusWlPlHR7K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1lPp5pdS1dLeW7tbS3V1LdzX2aA/LcMCA7y1hd3tUJs4g311G", + "dF8F1tnIJYDiufo1LRIayeGQaS61E5hnoS+C70a8EMZFtuDyWXPWZmkOE7l5yo+xIrsa8VrysUrEBFyB", + "lDA3ehD+OWJtRDjytr4HwcgLolc+Kfbkvjpw+DohdkGnPKJ35AtOCqhEcPzjykbVe7QGQuRmcC9C636j", + "Urlq7VmjAu9xOKOzIwdwB07hVUIYaiPE0Hl1i3fTA7rI4P0NODfBLr92aH4Oh2bJZL4gv/6u3Chrh8V9", + "qoLpJwkkbclpgUgQ05DLz/twA8UVjhQ1O7BPEB4rG09bQXhQ/oDFK4GZpC64E2bUV8wLCkWW9cuf3Yd0", + "NiMpxVo9WzxFFWGOtv69tVfBDtuar9fv6ZnAt143w7tFrtW1715dE52F3Jr9qBMrdyJ0KBse+yEjsuF3", + "l+TRySZJywtXnsdCfn1nhsg1nV/T+TWdX9P5z0rnF1mnVqeF34hK6415a7328+m1hlV34JPCyg1rjrnm", + "mLfjmGtm9M0yoyj9WFSprox0wR42Z4IF1zHExCt6pZfvokxabbL3QKTW8QXr+IJ1fMGaLK9d99+i677J", + "j7hQODvll4TFtPKEM1nMiEA5vIegMz8UGPjVND/hAqWcSPaDQvyCzJETsm2Kp7F1oZKFjNgJITvINdwI", + "Ov1KxfOMTqaK8kf6ziuBs0dUyoLIR1vbPz5putM1dpAUagmfZMVkQSWIPqJjUwMCAkUz27HCURZkq5DA", + "2V0QZEeuEBOtM1wSJs9BddAc159YW+vrLuXAvq4+0A3jZIPU3+RGhfrQ9m5QocO8LL+DZccSHr76Wi9L", + "VxWUvI60VdqKZ/ZFCQUEOehHmjPD/RJEFULfNqxsgrfNhvcT8dm5ISrnB0O29/gof/due7j9Tvw0e/6/", + "4z/Jq+znf/10M9v91/XPg/nTP56cbAzf/fGyePbH/47xyz83//znH0/2/9z+6Viy+a/X/xiP//X0j5s3", + "V3z5uus1a+0mRJV9TZ2P8HxGmDolokWEy80LSBExM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j7EPXej2fNARGdNdJlVPGKwizETDjFSRYAOpYoXXr388PSiCmZezPHAz", + "/JF5DM0SFt7PRizmI8YtG8jS61XqmJdQX59XYyFdWHFpt9OEy6nRmva9IIAggCCAILsEkp8b51mIEyEI", + "wJL9PQqaSckKX7ZNxAAqtzgCdDm1i1eYJDgyJu/8W0TWYKy9ruA2z4RpMbxtRKg41VLhyozDEftrOng8", + "kEoaC9LwQrA0z1IN36ZWyah1pk4164pwl8ZEyRiosQiU6MtmaSK4wchD+EZoYaja9lf/f2/F6Cg7fPnP", + "RNuLWrbO1GGXpbDcgyTJ9AXed42fmOXnAp6JCJbESGBr8R6/YMhfDAvDGEnAIyBfq1wUXpV7fkaRMjkA", + "r2Vi3W0hnREb5ImVaSLG/QxM8hEk1B77+3/805/8362ds7zd3n02/Xj370Z17G2fYCLmduFPMAUZM04D", + "zeVqHsZksub+6U9BYxSqPvO8tu4+5VrrXpo1DHKYakTp59NRKn7CMRWxa8n0jz5oeV1zppJXN2veKvNq", + "KoPKRm9isPRSx1w5YPqiPNYdNH16ETnG6KVE/kT+RP5E/kT+m0b+lZReov+yrJjrglt+f/tr6V+HLuBp", + "rQ1SGY06IybjSnVXqR4vRnin8uJDxIlKbMgtzKV+IqFOQp2EOp0H0nkgUc1GnQcuzywXizWY08d7Qwly", + "BrpdDgTLuOq5u4oP3a2+OOdQI8MQUMLnV+gEpWW+O3EBSrix7Idd1td5XViSVxfLaPtOLM8si7kVW1gz", + "qdjx6wP25MmT5/700lVTRUlu5IVoNepu0XPt3bevMz2Y0B65bBp7jaKUCriZUYi9UvGNVutU30ClDruT", + "o5LA+uc4GHs7DGmRAIadITaiphlfKE+JACewzuDcrM7BXT9YnYXO7WwuNd3R5waX0UZFIL2JSw1nFxqn", + "5z986e65joBgDMxVkO7wuG4A4sa8oH1zivL61crywm8rqGYXlnxTX0L3W5r/9iZm/fvCaMFPO6v9eUNd", + "sU43WnmT5k673WwM+KUc5IPwL6n8v4rKgOjp3YjXxlK660O/TO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BjRVX39i3ruW9Wg3em9tm5", + "GMF6xFnuXnUYWxBWbhxcSffayDnQOhiAZp8evTzacx42mMt4nTI6yd2arZnJ01RnlnW07TOsNVcxewtF", + "K1zvDB8IZlIRoZCLdCx6QsEHdbex4q6qAHbTnUeTDl312uD9489P3r989fb05NP3x8evX//67Pmbp6/3", + "P1Vog3f/ePr79+/fv/n15Mnuwesfd357/vTVkytpg++rehVW0RvRrtZmdJvKVagE6VZpV0e7OtKt0qaG", + "dKszutXMbxrWFZIG8l8mHs2xO+Rft8EwFPPNRKLBNlMYGpLdJLtJdpPsJtl9hTA03jjuBpSS21/hz1Wj", + "z6BZ4PzQM85y8CbiznhYWHzA6lpEEWcIAQgB6FCWDmWJgYiBHl7EmZUYaPlwMyWkWWTy9ZCApP1t6DpI", + "d0HgQuBC4ELgQuDyAK3JVmSWpePLVJ+3zAaXuefE8k2eEhE5ETkRORE5ETkRORE5rTWgzBqOvbatcKYt", + "1SYupzBQNRoiI1QMsxIG0FjvLDiUts8yrmI9YDG3fJbKIMuHqkXa+UacEslkhuCJ4IngieCJ4GnTLgu/", + "GhUNRaev9fm2uZCX9Th0wJOkw6NzJlScaqms8+XqjNjJhbyEAcFMR4x3dG5ZAT48qY3HdyxQUMH7R+Pk", + "IZrCOnQ+U0X95lq+ks6HzHcIRwhHyIKXpDFJ40WqDC/gnISclYhX0WekCVdLhBPAZNURBD5gDitGDcD8", + "vv1AAc59GqAEKtyCBdTaTHZyK2pcmmW8yZFGi546F6OFXXUuRsv01bViANyEi/5NdYdy074FYw6fZdE/", + "pr6DPrm0E/3EYycaePIhg8/RSlF2mIdVsYfe5uGJdkF9YSmxI5wysRDpUXj6DfnRw1pyZd/52pfX7S8P", + "BZOPPFE6UTpROlE6+cgDNKeeigOQg4y4ojs8QkONBzxkuybdFmTtCrltF3dsFJ3RkbglcUvilsQtidvl", + "3NpTJwvnS9xp1df2V/izgtM6JC8phMrO6vjTlf3TvShfbLzjKkw+6SS/SX6TjQ3Z2BDAEM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IoM1lFfKHRbORZ", + "0thr9K1Nzd72tk6FcurKCH+f1eH9oiOezLy3s/tDq91qt3b2fvzxxx8bULRv4ddAOR90ZnmCOfon+2lq", + "yv9+r63shmV8qi9KyeZ1WSnZgb/pZKKIF/7zqn/tQ8LnFo6HK+Un7xwslp68FJ28V35Q3DP4z5d//l8A", + "AAD//9R2vWn8IAYA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/api/openapi.yaml b/api/openapi.yaml index 276b88383..6b2b5eac5 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -1756,7 +1756,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/BillingProfile' + $ref: '#/components/schemas/BillingProfileCreateOrUpdate' /api/v1/customers: post: operationId: createCustomer @@ -7182,9 +7182,14 @@ components: externalId: 019142cc-a016-796a-8113-1a942fecd26d description: Set of key-value pairs managed by the system. Cannot be modified by user. App: - type: object - allOf: + anyOf: - $ref: '#/components/schemas/StripeApp' + - $ref: '#/components/schemas/SandboxApp' + discriminator: + propertyName: type + mapping: + stripe: '#/components/schemas/StripeApp' + sandbox: '#/components/schemas/SandboxApp' description: |- App. One of: stripe @@ -7335,6 +7340,7 @@ components: type: string enum: - stripe + - sandbox description: Type of the app. BadRequestProblemResponse: type: object @@ -7479,19 +7485,18 @@ components: description: Timestamp of when the resource was permanently deleted. title: Deletion Time readOnly: true - collectionAlignment: + collection: allOf: - - $ref: '#/components/schemas/BillingWorkflowCollectionAlignment' - description: When to collect the pending line items into an invoice. - default: subscription - itemCollectionPeriod: - type: string - format: ISO8601 - example: P1D - description: The period for collecting the pending line items into an invoice. - default: PT1H - invoice: - $ref: '#/components/schemas/BillingWorkflowInvoice' + - $ref: '#/components/schemas/BillingWorkflowCollectionSettings' + title: The collection settings for this workflow + invoicing: + allOf: + - $ref: '#/components/schemas/BillingWorkflowInvoicingSettings' + title: The invoicing settings for this workflow + payment: + allOf: + - $ref: '#/components/schemas/BillingWorkflowPaymentSettings' + title: The payment settings for this workflow id: type: string example: 01G65Z755AFWAKHE12NY0CQ9FH @@ -7514,19 +7519,18 @@ components: BillingCustomerWorkflowOverrideCreate: type: object properties: - collectionAlignment: + collection: allOf: - - $ref: '#/components/schemas/BillingWorkflowCollectionAlignment' - description: When to collect the pending line items into an invoice. - default: subscription - itemCollectionPeriod: - type: string - format: ISO8601 - example: P1D - description: The period for collecting the pending line items into an invoice. - default: PT1H - invoice: - $ref: '#/components/schemas/BillingWorkflowInvoice' + - $ref: '#/components/schemas/BillingWorkflowCollectionSettings' + title: The collection settings for this workflow + invoicing: + allOf: + - $ref: '#/components/schemas/BillingWorkflowInvoicingSettings' + title: The invoicing settings for this workflow + payment: + allOf: + - $ref: '#/components/schemas/BillingWorkflowPaymentSettings' + title: The payment settings for this workflow BillingDocumentRef: type: object allOf: @@ -8184,6 +8188,7 @@ components: - updatedAt - supplier - workflow + - apps - default properties: id: @@ -8216,13 +8221,6 @@ components: description: Timestamp of when the resource was created. title: Creation Time readOnly: true - updatedAt: - type: string - format: date-time - example: 2024-01-01T01:01:01.001Z - description: Timestamp of when the resource was last updated. - title: Last Update Time - readOnly: true deletedAt: type: string format: date-time @@ -8230,6 +8228,15 @@ components: description: Timestamp of when the resource was permanently deleted. title: Deletion Time readOnly: true + updatedAt: + type: string + format: date-time + example: 2023-01-01T01:01:01.001Z + description: |- + When the resource was last updated. + + For updates this field must be set to the last update time to detect conflicts. + title: Last update time of the resource supplier: allOf: - $ref: '#/components/schemas/BillingParty' @@ -8238,17 +8245,62 @@ components: allOf: - $ref: '#/components/schemas/BillingWorkflow' title: The billing workflow settings for this profile + apps: + allOf: + - $ref: '#/components/schemas/BillingProfileApps' + title: The applications used by this billing profile default: type: boolean title: Is this the default profile? description: Profile represents a billing profile + BillingProfileApps: + type: object + required: + - tax + - invoicing + - payment + properties: + tax: + allOf: + - $ref: '#/components/schemas/App' + title: The tax app used for this workflow + invoicing: + allOf: + - $ref: '#/components/schemas/App' + title: The invoicing app used for this workflow + payment: + allOf: + - $ref: '#/components/schemas/App' + title: The payment app used for this workflow + description: ProfileApps represents the applications used by a billing profile + BillingProfileCreateAppsInput: + type: object + required: + - tax + - invoicing + - payment + properties: + tax: + allOf: + - $ref: '#/components/schemas/BillingWorkflowAppIdOrType' + title: The tax app used for this workflow + invoicing: + allOf: + - $ref: '#/components/schemas/BillingWorkflowAppIdOrType' + title: The invoicing app used for this workflow + payment: + allOf: + - $ref: '#/components/schemas/BillingWorkflowAppIdOrType' + title: The payment app used for this workflow + description: ProfileCreateAppsInput represents the input for creating a billing profile's apps BillingProfileCreateInput: type: object required: - name - supplier - - default - workflow + - default + - apps properties: name: type: string @@ -8270,17 +8322,69 @@ components: allOf: - $ref: '#/components/schemas/BillingPartyCreate' title: The name and contact information for the supplier this billing profile represents + workflow: + allOf: + - $ref: '#/components/schemas/BillingWorkflow' + title: The billing workflow settings for this profile default: type: boolean title: Is this the default profile? - workflow: - $ref: '#/components/schemas/BillingWorkflowCreateInput' + apps: + $ref: '#/components/schemas/BillingProfileCreateAppsInput' description: ProfileCreateInput represents the input for creating a billing profile + BillingProfileCreateOrUpdate: + type: object + required: + - name + - updatedAt + - supplier + - workflow + - default + properties: + name: + type: string + minLength: 1 + maxLength: 256 + description: Human-readable name for the resource. Between 1 and 256 characters. + title: Display name + description: + type: string + maxLength: 1024 + description: Optional description of the resource. Maximum 1024 characters. + title: Description + metadata: + allOf: + - $ref: '#/components/schemas/Metadata' + description: Additional metadata for the resource. + title: Metadata + updatedAt: + type: string + format: date-time + example: 2023-01-01T01:01:01.001Z + description: |- + When the resource was last updated. + + For updates this field must be set to the last update time to detect conflicts. + title: Last update time of the resource + supplier: + allOf: + - $ref: '#/components/schemas/BillingParty' + title: The name and contact information for the supplier this billing profile represents + workflow: + allOf: + - $ref: '#/components/schemas/BillingWorkflow' + title: The billing workflow settings for this profile + default: + type: boolean + title: Is this the default profile? + description: Profile represents a billing profile BillingProfileOrderBy: type: string enum: - createdAt - updatedAt + - default + - name description: ProfileOrderBy specifies the ordering options for profiles BillingTaxBehavior: type: string @@ -8294,13 +8398,7 @@ components: pattern: ^[A-Za-z0-9]+([\.\-\/ _]?[A-Za-z0-9]+)*$ BillingTaxIdentity: type: object - required: - - country properties: - country: - allOf: - - $ref: '#/components/schemas/CountryCode' - title: Tax country code for Where the tax identity was issued. code: allOf: - $ref: '#/components/schemas/BillingTaxIdentificationCode' @@ -8473,9 +8571,6 @@ components: required: - createdAt - updatedAt - - taxApp - - invoicingApp - - paymentApp - id properties: createdAt: @@ -8499,31 +8594,18 @@ components: description: Timestamp of when the resource was permanently deleted. title: Deletion Time readOnly: true - collectionAlignment: - allOf: - - $ref: '#/components/schemas/BillingWorkflowCollectionAlignment' - description: When to collect the pending line items into an invoice. - default: subscription - itemCollectionPeriod: - type: string - format: ISO8601 - example: P1D - description: The period for collecting the pending line items into an invoice. - default: PT1H - invoice: - $ref: '#/components/schemas/BillingWorkflowInvoice' - taxApp: + collection: allOf: - - $ref: '#/components/schemas/App' - title: The tax app used for this workflow - invoicingApp: + - $ref: '#/components/schemas/BillingWorkflowCollectionSettings' + title: The collection settings for this workflow + invoicing: allOf: - - $ref: '#/components/schemas/App' - title: The invoicing app used for this workflow - paymentApp: + - $ref: '#/components/schemas/BillingWorkflowInvoicingSettings' + title: The invoicing settings for this workflow + payment: allOf: - - $ref: '#/components/schemas/App' - title: The payment app used for this workflow + - $ref: '#/components/schemas/BillingWorkflowPaymentSettings' + title: The payment settings for this workflow id: type: string example: 01G65Z755AFWAKHE12NY0CQ9FH @@ -8532,20 +8614,12 @@ components: title: ID readOnly: true description: Workflow represents a billing workflow - BillingWorkflowAppReference: - type: object - properties: - id: - type: string - example: 01G65Z755AFWAKHE12NY0CQ9FH - pattern: ^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$ - description: ULID (Universally Unique Lexicographically Sortable Identifier). - title: The ID of the app, if not specified the type is used to find the default app - type: - allOf: - - $ref: '#/components/schemas/AppType' - title: The type of the app, if specified the default app is used - description: AppReference can be used to reference an app during creation only. + BillingWorkflowAppIdOrType: + type: string + description: |- + AppIdOrType can be used to reference an app during creation only. + + This can be either an AppType or the ULID of an app. BillingWorkflowCollectionAlignment: type: string enum: @@ -8561,30 +8635,22 @@ components: - send_invoice description: CollectionMethod specifies how the invoice should be collected (automatic vs manual) title: Collection method - BillingWorkflowCreateInput: + BillingWorkflowCollectionSettings: type: object properties: - collectionAlignment: + alignment: allOf: - $ref: '#/components/schemas/BillingWorkflowCollectionAlignment' description: When to collect the pending line items into an invoice. default: subscription - itemCollectionPeriod: + interval: type: string format: ISO8601 example: P1D - description: The period for collecting the pending line items into an invoice. + description: The interval for collecting the pending line items into an invoice. default: PT1H - invoice: - $ref: '#/components/schemas/BillingWorkflowInvoice' - taxApp: - $ref: '#/components/schemas/BillingWorkflowAppReference' - invoicingApp: - $ref: '#/components/schemas/BillingWorkflowAppReference' - paymentApp: - $ref: '#/components/schemas/BillingWorkflowAppReference' - description: WorkflowCreate represents the workflow settings for creation of a billing profile - BillingWorkflowInvoice: + title: Workflow collection specifies how to collect the pending items for an invoice + BillingWorkflowInvoicingSettings: type: object properties: autoAdvance: @@ -8603,29 +8669,17 @@ components: example: P1D description: The period after which the invoice is due. default: P7D + description: WorkflowInvoice represents the invoice settings for a billing workflow + title: Workflow invoice settings + BillingWorkflowPaymentSettings: + type: object + properties: collectionMethod: allOf: - $ref: '#/components/schemas/BillingWorkflowCollectionMethod' - description: The method to collect the invoice. default: charge_automatically - itemResolution: - allOf: - - $ref: '#/components/schemas/BillingWorkflowItemResolution' - description: The resolution of the line items in the invoice. - default: period - itemPerSubject: - type: boolean - description: Whether to create one line item per subject in the invoice. - default: true - description: WorkflowInvoice represents the invoice settings for a billing workflow - title: Workflow invoice settings - BillingWorkflowItemResolution: - type: string - enum: - - day - - period - description: ItemResolution specifies how the line items should be resolved in the invoice - title: Item resolution + description: WorkflowPaymentSettings represents the payment settings for a billing workflow + title: Workflow payment settings CheckoutSessionCustomTextAfterSubmitParams: type: object properties: @@ -11281,9 +11335,6 @@ components: type: string pattern: ^\-?[0-9]+(\.[0-9]+)?$ description: Numeric represents an arbitrary precision number. - x-go-type-import: - path: github.com/alpacahq/alpacadecimal - x-go-type: alpacadecimal.Decimal OAuth2AuthorizationCodeGrantErrorType: type: string enum: @@ -11299,9 +11350,6 @@ components: type: string pattern: ^\-?[0-9]+(\.[0-9]+)?%$ description: Numeric representation of a percentage - x-go-type-import: - path: github.com/alpacahq/alpacadecimal - x-go-type: alpacadecimal.Decimal Period: type: object required: @@ -12317,6 +12365,76 @@ components: - If true, the overage is preserved. - If false, the overage is forgiven. description: Reset parameters + SandboxApp: + type: object + required: + - id + - name + - createdAt + - updatedAt + - listing + - status + - type + properties: + id: + type: string + example: 01G65Z755AFWAKHE12NY0CQ9FH + pattern: ^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$ + description: A unique identifier for the resource. + title: ID + readOnly: true + name: + type: string + minLength: 1 + maxLength: 256 + description: Human-readable name for the resource. Between 1 and 256 characters. + title: Display name + description: + type: string + maxLength: 1024 + description: Optional description of the resource. Maximum 1024 characters. + title: Description + metadata: + allOf: + - $ref: '#/components/schemas/Metadata' + description: Additional metadata for the resource. + title: Metadata + createdAt: + type: string + format: date-time + example: 2024-01-01T01:01:01.001Z + description: Timestamp of when the resource was created. + title: Creation Time + readOnly: true + updatedAt: + type: string + format: date-time + example: 2024-01-01T01:01:01.001Z + description: Timestamp of when the resource was last updated. + title: Last Update Time + readOnly: true + deletedAt: + type: string + format: date-time + example: 2024-01-01T01:01:01.001Z + description: Timestamp of when the resource was permanently deleted. + title: Deletion Time + readOnly: true + listing: + allOf: + - $ref: '#/components/schemas/MarketplaceListing' + description: The marketplace listing that this installed app is based on. + readOnly: true + status: + allOf: + - $ref: '#/components/schemas/AppStatus' + description: Status of the app connection. + readOnly: true + type: + type: string + enum: + - sandbox + description: The app's type is Sandbox. ServiceUnavailableProblemResponse: type: object allOf: diff --git a/api/spec/src/app/app.tsp b/api/spec/src/app/app.tsp index 53cc3e73f..47fa89036 100644 --- a/api/spec/src/app/app.tsp +++ b/api/spec/src/app/app.tsp @@ -61,6 +61,7 @@ model ListAppsRequest extends PaginatedQuery {} @friendlyName("AppType") enum Type { Stripe: "stripe", + Sandbox: "sandbox", } /** @@ -71,6 +72,7 @@ enum Type { @discriminator("type") union App { stripe: StripeApp, + sandbox: SandboxApp, } /** diff --git a/api/spec/src/app/main.tsp b/api/spec/src/app/main.tsp index dd2e6b637..02a47713e 100644 --- a/api/spec/src/app/main.tsp +++ b/api/spec/src/app/main.tsp @@ -3,5 +3,6 @@ import "./app.tsp"; import "./capability.tsp"; import "./marketplace.tsp"; import "./stripe.tsp"; +import "./sandbox.tsp"; namespace OpenMeter.App; diff --git a/api/spec/src/app/sandbox.tsp b/api/spec/src/app/sandbox.tsp new file mode 100644 index 000000000..9cc4e1195 --- /dev/null +++ b/api/spec/src/app/sandbox.tsp @@ -0,0 +1,11 @@ +namespace OpenMeter.App; + +@friendlyName("SandboxApp") +model SandboxApp { + ...AppBase; + + /** + * The app's type is Sandbox. + */ + type: Type.Sandbox; +} diff --git a/api/spec/src/billing/invoices/tax.tsp b/api/spec/src/billing/invoices/tax.tsp index 65fe6b2e5..d14966c2c 100644 --- a/api/spec/src/billing/invoices/tax.tsp +++ b/api/spec/src/billing/invoices/tax.tsp @@ -41,9 +41,6 @@ scalar TaxIdentificationCode extends string; @friendlyName("BillingTaxIdentity") @summary("Identity stores the details required to identify an entity for tax purposes in a specific country.") model TaxIdentity { - @summary("Tax country code for Where the tax identity was issued.") - country: CountryCode; - @summary("Normalized tax code shown on the original identity document.") code?: TaxIdentificationCode; } diff --git a/api/spec/src/billing/profile.tsp b/api/spec/src/billing/profile.tsp index 604836ac9..9d7605323 100644 --- a/api/spec/src/billing/profile.tsp +++ b/api/spec/src/billing/profile.tsp @@ -78,6 +78,8 @@ interface Profiles { enum ProfileOrderBy { createdAt: "createdAt", updatedAt: "updatedAt", + default: "default", + name: "name", } /** @@ -85,7 +87,16 @@ enum ProfileOrderBy { */ @friendlyName("BillingProfile") model Profile { - ...global.Resource; + ...OmitProperties; + + /** + * When the resource was last updated. + * + * For updates this field must be set to the last update time to detect conflicts. + */ + @summary("Last update time of the resource") + @visibility("read", "query", "update") + updatedAt: DateTime; @summary("The name and contact information for the supplier this billing profile represents") supplier: Invoices.Party; @@ -93,10 +104,29 @@ model Profile { @summary("The billing workflow settings for this profile") workflow: Workflow; + @summary("The applications used by this billing profile") + @visibility("read", "query") + apps: ProfileApps; + @summary("Is this the default profile?") default: boolean; } +/** + * ProfileApps represents the applications used by a billing profile + */ +@friendlyName("BillingProfileApps") +model ProfileApps { + @summary("The tax app used for this workflow") + tax: OpenMeter.App.App; + + @summary("The invoicing app used for this workflow") + invoicing: OpenMeter.App.App; + + @summary("The payment app used for this workflow") + payment: OpenMeter.App.App; +} + /** * Workflow represents a billing workflow */ @@ -116,67 +146,78 @@ model Workflow { @friendlyName("BillingWorkflowSettings") model WorkflowSettings { + @summary("The collection settings for this workflow") + collection?: WorkflowCollectionSettings; + + @summary("The invoicing settings for this workflow") + invoicing?: WorkflowInvoicingSettings; + + @summary("The payment settings for this workflow") + payment?: WorkflowPaymentSettings; +} + +@summary("Workflow collection specifies how to collect the pending items for an invoice") +@friendlyName("BillingWorkflowCollectionSettings") +model WorkflowCollectionSettings { /** * When to collect the pending line items into an invoice. */ - collectionAlignment?: CollectionAlignment = CollectionAlignment.subscription; + alignment?: CollectionAlignment = CollectionAlignment.subscription; /** - * The period for collecting the pending line items into an invoice. + * The interval for collecting the pending line items into an invoice. */ @encode(DurationKnownEncoding.ISO8601) @example("P1D") - itemCollectionPeriod?: string = "PT1H"; - - invoice?: WorkflowInvoice; - - @summary("The tax app used for this workflow") - taxApp: OpenMeter.App.App; - - @summary("The invoicing app used for this workflow") - invoicingApp: OpenMeter.App.App; - - @summary("The payment app used for this workflow") - paymentApp: OpenMeter.App.App; + interval?: string = "PT1H"; } /** - * AppReference can be used to reference an app during creation only. + * WorkflowPaymentSettings represents the payment settings for a billing workflow */ -@friendlyName("BillingWorkflowAppReference") -model AppReference { - @summary("The ID of the app, if not specified the type is used to find the default app") - id?: ULID; +@summary("Workflow payment settings") +@friendlyName("BillingWorkflowPaymentSettings") +model WorkflowPaymentSettings { + collectionMethod?: CollectionMethod = CollectionMethod.chargeAutomatically; +} - @summary("The type of the app, if specified the default app is used") - type?: OpenMeter.App.Type; +@summary("App reference type specifies the type of reference inside an app reference") +@friendlyName("BillingWorkflowAppReferenceType") +enum AppReferenceType { + appId: "app_id", + appType: "app_type", } +/** + * AppIdOrType can be used to reference an app during creation only. + * + * This can be either an AppType or the ULID of an app. + */ +@friendlyName("BillingWorkflowAppIdOrType") +scalar AppIdOrType extends string; + /** * ProfileCreateInput represents the input for creating a billing profile */ @friendlyName("BillingProfileCreateInput") model ProfileCreateInput { - ...OmitProperties; - workflow: WorkflowCreateInput; + ...OmitProperties; + apps: ProfileCreateAppsInput; } /** - * WorkflowCreate represents the workflow settings for creation of a billing profile + * ProfileCreateAppsInput represents the input for creating a billing profile's apps */ -@friendlyName("BillingWorkflowCreateInput") -model WorkflowCreateInput { - ...OmitProperties; - - // provider settings for creation (update is not supported) - @visibility("create") - taxApp?: AppReference; +@friendlyName("BillingProfileCreateAppsInput") +model ProfileCreateAppsInput { + @summary("The tax app used for this workflow") + tax: AppIdOrType; - @visibility("create") - invoicingApp?: AppReference; + @summary("The invoicing app used for this workflow") + invoicing: AppIdOrType; - @visibility("create") - paymentApp?: AppReference; + @summary("The payment app used for this workflow") + payment: AppIdOrType; } /** @@ -196,8 +237,8 @@ enum CollectionAlignment { * WorkflowInvoice represents the invoice settings for a billing workflow */ @summary("Workflow invoice settings") -@friendlyName("BillingWorkflowInvoice") -model WorkflowInvoice { +@friendlyName("BillingWorkflowInvoicingSettings") +model WorkflowInvoicingSettings { /** * Whether to automatically issue the invoice after the draftPeriod has passed. */ @@ -216,21 +257,6 @@ model WorkflowInvoice { @encode(DurationKnownEncoding.ISO8601) @example("P1D") dueAfter?: string = "P7D"; - - /** - * The method to collect the invoice. - */ - collectionMethod?: CollectionMethod = CollectionMethod.chargeAutomatically; - - /** - * The resolution of the line items in the invoice. - */ - itemResolution?: ItemResolution = ItemResolution.period; - - /** - * Whether to create one line item per subject in the invoice. - */ - itemPerSubject?: boolean = true; } /** diff --git a/api/spec/src/types.tsp b/api/spec/src/types.tsp index 55e0364b4..74ad56e69 100644 --- a/api/spec/src/types.tsp +++ b/api/spec/src/types.tsp @@ -283,13 +283,6 @@ model Annotations { /** * Numeric represents an arbitrary precision number. */ -@extension("x-go-type", "alpacadecimal.Decimal") -@extension( - "x-go-type-import", - { - path: "github.com/alpacahq/alpacadecimal", - } -) @pattern("^\\-?[0-9]+(\\.[0-9]+)?$") @friendlyName("Numeric") scalar Numeric extends string; @@ -300,7 +293,6 @@ alias Money = Numeric; */ @friendlyName("Percentage") @pattern("^\\-?[0-9]+(\\.[0-9]+)?%$") -// TODO: let's add some default go implementation scalar Percentage extends Numeric; /** diff --git a/app/config/apps.go b/app/config/apps.go new file mode 100644 index 000000000..fd9db6f75 --- /dev/null +++ b/app/config/apps.go @@ -0,0 +1,15 @@ +package config + +import "github.com/spf13/viper" + +type AppsConfiguration struct { + Enabled bool +} + +func (c AppsConfiguration) Validate() error { + return nil +} + +func ConfigureApps(v *viper.Viper) { + v.SetDefault("apps.enabled", false) +} diff --git a/app/config/billing.go b/app/config/billing.go new file mode 100644 index 000000000..3ff38cb8e --- /dev/null +++ b/app/config/billing.go @@ -0,0 +1,15 @@ +package config + +import "github.com/spf13/viper" + +type BillingConfiguration struct { + Enabled bool +} + +func (c BillingConfiguration) Validate() error { + return nil +} + +func ConfigureBilling(v *viper.Viper) { + v.SetDefault("billing.enabled", false) +} diff --git a/app/config/config.go b/app/config/config.go index e46218b19..f84e1544f 100644 --- a/app/config/config.go +++ b/app/config/config.go @@ -32,6 +32,8 @@ type Configuration struct { Sink SinkConfiguration BalanceWorker BalanceWorkerConfiguration Notification NotificationConfiguration + Billing BillingConfiguration + Apps AppsConfiguration StripeApp StripeAppConfig Svix SvixConfig } @@ -112,6 +114,10 @@ func (c Configuration) Validate() error { errs = append(errs, errorsx.WithPrefix(err, "stripe app")) } + if err := c.Apps.Validate(); err != nil { + errs = append(errs, errorsx.WithPrefix(err, "apps")) + } + return errors.Join(errs...) } @@ -148,4 +154,6 @@ func SetViperDefaults(v *viper.Viper, flags *pflag.FlagSet) { ConfigureBalanceWorker(v) ConfigureNotification(v) ConfigureStripe(v) + ConfigureBilling(v) + ConfigureApps(v) } diff --git a/cmd/server/main.go b/cmd/server/main.go index 26479b4ea..bac9d9dd6 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -18,10 +18,14 @@ import ( "github.com/openmeterio/openmeter/app/config" apppkg "github.com/openmeterio/openmeter/openmeter/app" appadapter "github.com/openmeterio/openmeter/openmeter/app/adapter" + appsandbox "github.com/openmeterio/openmeter/openmeter/app/sandbox" appservice "github.com/openmeterio/openmeter/openmeter/app/service" appstripe "github.com/openmeterio/openmeter/openmeter/app/stripe" appstripeadapter "github.com/openmeterio/openmeter/openmeter/app/stripe/adapter" appstripeservice "github.com/openmeterio/openmeter/openmeter/app/stripe/service" + "github.com/openmeterio/openmeter/openmeter/billing" + billingadapter "github.com/openmeterio/openmeter/openmeter/billing/adapter" + billingservice "github.com/openmeterio/openmeter/openmeter/billing/service" "github.com/openmeterio/openmeter/openmeter/customer" customeradapter "github.com/openmeterio/openmeter/openmeter/customer/adapter" customerservice "github.com/openmeterio/openmeter/openmeter/customer/service" @@ -197,7 +201,7 @@ func main() { // Initialize App var appService apppkg.Service - if app.EntClient != nil { + if conf.Apps.Enabled { var appAdapter apppkg.Adapter appAdapter, err = appadapter.New(appadapter.Config{ Client: app.EntClient, @@ -220,7 +224,7 @@ func main() { // Initialize AppStripe var appStripeService appstripe.Service - if app.EntClient != nil { + if conf.Apps.Enabled { var appStripeAdapter appstripe.Adapter appStripeAdapter, err = appstripeadapter.New(appstripeadapter.Config{ Client: app.EntClient, @@ -242,6 +246,28 @@ func main() { } } + // Initialize AppSandbox + if conf.Apps.Enabled { + _, err = appsandbox.NewFactory(appsandbox.Config{ + AppService: appService, + }) + if err != nil { + logger.Error("failed to initialize app sandbox factory", "error", err) + os.Exit(1) + } + + app, err := appsandbox.AutoProvision(ctx, appsandbox.AutoProvisionInput{ + Namespace: app.NamespaceManager.GetDefaultNamespace(), + AppService: appService, + }) + if err != nil { + logger.Error("failed to auto-provision sandbox app", "error", err) + os.Exit(1) + } + + logger.Info("sandbox app auto-provisioned", "app_id", app.GetID().ID) + } + // Initialize Notification var notificationService notification.Service @@ -296,6 +322,29 @@ func main() { }() } + // Initialize billing + var billingService billing.Service + if conf.Billing.Enabled { + adapter, err := billingadapter.New(billingadapter.Config{ + Client: app.EntClient, + Logger: logger.With("subsystem", "billing.adapter"), + }) + if err != nil { + logger.Error("failed to initialize billing adapter", "error", err) + os.Exit(1) + } + + billingService, err = billingservice.New(billingservice.Config{ + Adapter: adapter, + CustomerService: customerService, + AppService: appService, + }) + if err != nil { + logger.Error("failed to initialize billing service", "error", err) + os.Exit(1) + } + } + s, err := server.NewServer(&server.Config{ RouterConfig: router.Config{ NamespaceManager: app.NamespaceManager, @@ -308,6 +357,7 @@ func main() { // deps App: appService, AppStripe: appStripeService, + Billing: billingService, Customer: customerService, DebugConnector: debugConnector, FeatureConnector: entitlementConnRegistry.Feature, @@ -319,6 +369,8 @@ func main() { // modules EntitlementsEnabled: conf.Entitlements.Enabled, NotificationEnabled: conf.Notification.Enabled, + AppsEnabled: conf.Apps.Enabled, + BillingEnabled: conf.Billing.Enabled, }, RouterHook: app.RouterHook, }) diff --git a/config.example.yaml b/config.example.yaml index df1fc52e2..fa10d41ea 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -40,6 +40,12 @@ telemetry: entitlements: enabled: true +billing: + enabled: true + +apps: + enabled: true + # System event generation events: enabled: false diff --git a/go.mod b/go.mod index 18145fdea..cadd7e33e 100644 --- a/go.mod +++ b/go.mod @@ -49,6 +49,7 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 github.com/redis/go-redis/extra/redisotel/v9 v9.5.3 github.com/redis/go-redis/v9 v9.6.1 + github.com/rickb777/period v1.0.6 github.com/sagikazarmark/mapstructurex v0.1.0 github.com/sagikazarmark/slog-shim v0.1.0 github.com/samber/lo v1.47.0 @@ -69,7 +70,7 @@ require ( go.opentelemetry.io/otel/sdk/metric v1.31.0 go.opentelemetry.io/otel/trace v1.31.0 go.opentelemetry.io/proto/otlp v1.3.1 - golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 + golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa golang.org/x/net v0.30.0 google.golang.org/grpc v1.67.1 google.golang.org/protobuf v1.35.1 @@ -247,6 +248,7 @@ require ( github.com/gorilla/websocket v1.5.1 // indirect github.com/gosimple/slug v1.13.1 // indirect github.com/gosimple/unidecode v1.0.1 // indirect + github.com/govalues/decimal v0.1.29 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect @@ -347,7 +349,7 @@ require ( github.com/redis/go-redis/extra/rediscmd/v9 v9.5.3 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rickb777/date v1.20.5 // indirect - github.com/rickb777/plural v1.4.1 // indirect + github.com/rickb777/plural v1.4.2 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/robfig/cron/v3 v3.0.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect diff --git a/go.sum b/go.sum index 314c50784..977b59711 100644 --- a/go.sum +++ b/go.sum @@ -721,6 +721,8 @@ github.com/gosimple/slug v1.13.1 h1:bQ+kpX9Qa6tHRaK+fZR0A0M2Kd7Pa5eHPPsb1JpHD+Q= github.com/gosimple/slug v1.13.1/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ= github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o= github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc= +github.com/govalues/decimal v0.1.29 h1:GKC5g9y9oWxKIy51czdHTShOABwHm/shVuOVPwG415M= +github.com/govalues/decimal v0.1.29/go.mod h1:LUlHHucpCmA4rJfNrDvMgrWibDpYnDNWqJuNU1/gxW8= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= @@ -1080,8 +1082,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= -github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= -github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= +github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= +github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= @@ -1173,8 +1175,10 @@ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rickb777/date v1.20.5 h1:Ybjz7J7ga9ui4VJizQpil0l330r6wkn6CicaoattIxQ= github.com/rickb777/date v1.20.5/go.mod h1:6BPrm3/aQI0I8jvlD1fAlm/86k5eSeTQ2mR5FEmTnSw= -github.com/rickb777/plural v1.4.1 h1:5MMLcbIaapLFmvDGRT5iPk8877hpTPt8Y9cdSKRw9sU= -github.com/rickb777/plural v1.4.1/go.mod h1:kdmXUpmKBJTS0FtG/TFumd//VBWsNTD7zOw7x4umxNw= +github.com/rickb777/period v1.0.6 h1:f4TcHBtL/4qa4D44eqgxs7785/kfLKUjRI7XYI2HCvk= +github.com/rickb777/period v1.0.6/go.mod h1:TKkPHI/WSyjjVdeVCyqwBoQg0Cdb/jRvnc8FFdq2cgw= +github.com/rickb777/plural v1.4.2 h1:Kl/syFGLFZ5EbuV8c9SVud8s5HI2HpCCtOMw2U1kS+A= +github.com/rickb777/plural v1.4.2/go.mod h1:kdmXUpmKBJTS0FtG/TFumd//VBWsNTD7zOw7x4umxNw= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= @@ -1504,8 +1508,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 h1:hNQpMuAJe5CtcUqCXaWga3FHu+kQvCqcsoVaQgSV60o= -golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= diff --git a/openmeter/app/entity/app.go b/openmeter/app/entity/app.go index b113ae603..958b8264b 100644 --- a/openmeter/app/entity/app.go +++ b/openmeter/app/entity/app.go @@ -20,7 +20,7 @@ type App interface { GetListing() appentitybase.MarketplaceListing // ValidateCapabilities validates if the app can run for the given capabilities - ValidateCapabilities(capabilities []appentitybase.CapabilityType) error + ValidateCapabilities(capabilities ...appentitybase.CapabilityType) error } // GetAppInput is the input for getting an installed app @@ -60,10 +60,6 @@ func (i CreateAppInput) Validate() error { return errors.New("name is required") } - if i.Description == "" { - return errors.New("description is required") - } - return nil } diff --git a/openmeter/app/entity/base/app.go b/openmeter/app/entity/base/app.go index 48b96a36f..08e6c0426 100644 --- a/openmeter/app/entity/base/app.go +++ b/openmeter/app/entity/base/app.go @@ -11,7 +11,8 @@ import ( type AppType string const ( - AppTypeStripe AppType = "stripe" + AppTypeStripe AppType = "stripe" + AppTypeSandbox AppType = "sandbox" ) // AppStatus represents the status of an app @@ -78,7 +79,7 @@ func (a AppBase) GetMetadata() map[string]string { } // ValidateCapabilities validates if the app can run for the given capabilities -func (a AppBase) ValidateCapabilities(capabilities []CapabilityType) error { +func (a AppBase) ValidateCapabilities(capabilities ...CapabilityType) error { for _, capability := range capabilities { found := false diff --git a/openmeter/app/httpdriver/app.go b/openmeter/app/httpdriver/app.go index 761ded518..ce41294ee 100644 --- a/openmeter/app/httpdriver/app.go +++ b/openmeter/app/httpdriver/app.go @@ -11,6 +11,7 @@ import ( "github.com/openmeterio/openmeter/openmeter/app" appentity "github.com/openmeterio/openmeter/openmeter/app/entity" appentitybase "github.com/openmeterio/openmeter/openmeter/app/entity/base" + appsandbox "github.com/openmeterio/openmeter/openmeter/app/sandbox" appstripeentityapp "github.com/openmeterio/openmeter/openmeter/app/stripe/entity/app" "github.com/openmeterio/openmeter/pkg/framework/commonhttp" "github.com/openmeterio/openmeter/pkg/framework/transport/httptransport" @@ -49,13 +50,21 @@ func (h *handler) ListApps() ListAppsHandler { return ListAppsResponse{}, fmt.Errorf("failed to list apps: %w", err) } + items := make([]api.App, 0, len(result.Items)) + for _, item := range result.Items { + app, err := MapAppToAPI(item) + if err != nil { + return ListAppsResponse{}, fmt.Errorf("failed to map app to api: %w", err) + } + + items = append(items, app) + } + return ListAppsResponse{ Page: result.Page.PageNumber, PageSize: result.Page.PageSize, TotalCount: result.TotalCount, - Items: lo.Map(result.Items, func(item appentity.App, _ int) api.App { - return mapAppToAPI(item) - }), + Items: items, }, nil }, commonhttp.JSONResponseEncoderWithStatus[ListAppsResponse](http.StatusOK), @@ -95,7 +104,7 @@ func (h *handler) GetApp() GetAppHandler { return GetAppResponse{}, fmt.Errorf("failed to get app: %w", err) } - return mapAppToAPI(app), nil + return MapAppToAPI(app) }, commonhttp.JSONResponseEncoderWithStatus[GetAppResponse](http.StatusOK), httptransport.AppendOptions( @@ -145,30 +154,41 @@ func (h *handler) UninstallApp() UninstallAppHandler { ) } -func mapAppToAPI(item appentity.App) api.App { +func MapAppToAPI(item appentity.App) (api.App, error) { switch item.GetType() { case appentitybase.AppTypeStripe: stripeApp := item.(appstripeentityapp.App) - return mapStripeAppToAPI(stripeApp) - default: - apiApp := api.App{ - Id: item.GetID().ID, - Type: api.StripeAppType(item.GetType()), - Name: item.GetName(), - Status: api.AppStatus(item.GetStatus()), - Listing: mapMarketplaceListing(item.GetListing()), - CreatedAt: item.GetAppBase().CreatedAt, - UpdatedAt: item.GetAppBase().UpdatedAt, - DeletedAt: item.GetAppBase().DeletedAt, + + app := api.App{} + if err := app.FromStripeApp(mapStripeAppToAPI(stripeApp)); err != nil { + return app, err } - apiApp.Description = item.GetDescription() + return app, nil + case appentitybase.AppTypeSandbox: + sandboxApp := item.(appsandbox.App) - if item.GetMetadata() != nil { - apiApp.Metadata = lo.ToPtr(item.GetMetadata()) + app := api.App{} + if err := app.FromSandboxApp(mapSandboxAppToAPI(sandboxApp)); err != nil { + return app, err } - return apiApp + return app, nil + default: + return api.App{}, fmt.Errorf("unsupported app type: %s", item.GetType()) + } +} + +func mapSandboxAppToAPI(app appsandbox.App) api.SandboxApp { + return api.SandboxApp{ + Id: app.GetID().ID, + Type: api.SandboxAppTypeSandbox, + Name: app.GetName(), + Status: api.AppStatus(app.GetStatus()), + Listing: mapMarketplaceListing(app.GetListing()), + CreatedAt: app.CreatedAt, + UpdatedAt: app.UpdatedAt, + DeletedAt: app.DeletedAt, } } diff --git a/openmeter/app/sandbox/app.go b/openmeter/app/sandbox/app.go new file mode 100644 index 000000000..aceeb4cef --- /dev/null +++ b/openmeter/app/sandbox/app.go @@ -0,0 +1,90 @@ +package appsandbox + +import ( + "context" + "fmt" + + "github.com/openmeterio/openmeter/openmeter/app" + appentity "github.com/openmeterio/openmeter/openmeter/app/entity" + appentitybase "github.com/openmeterio/openmeter/openmeter/app/entity/base" + customerentity "github.com/openmeterio/openmeter/openmeter/customer/entity" +) + +var _ customerentity.App = (*App)(nil) + +type App struct { + appentitybase.AppBase +} + +func (a App) ValidateCustomer(ctx context.Context, customer *customerentity.Customer, capabilities []appentitybase.CapabilityType) error { + if err := a.ValidateCapabilities(capabilities...); err != nil { + return fmt.Errorf("error validating capabilities: %w", err) + } + + return nil +} + +type Factory struct { + appService app.Service +} + +type Config struct { + AppService app.Service +} + +func (c Config) Validate() error { + if c.AppService == nil { + return fmt.Errorf("app service is required") + } + + return nil +} + +func NewFactory(config Config) (*Factory, error) { + if err := config.Validate(); err != nil { + return nil, fmt.Errorf("failed to validate config: %w", err) + } + + fact := &Factory{ + appService: config.AppService, + } + + err := config.AppService.RegisterMarketplaceListing(appentity.RegistryItem{ + Listing: MarketplaceListing, + Factory: fact, + }) + if err != nil { + return nil, fmt.Errorf("failed to register marketplace listing: %w", err) + } + + return fact, nil +} + +// Factory +func (a *Factory) NewApp(ctx context.Context, appBase appentitybase.AppBase) (appentity.App, error) { + return App{ + AppBase: appBase, + }, nil +} + +func (a *Factory) InstallAppWithAPIKey(ctx context.Context, input appentity.AppFactoryInstallAppWithAPIKeyInput) (appentity.App, error) { + // Validate input + if err := input.Validate(); err != nil { + return nil, fmt.Errorf("invalid input: %w", err) + } + + appBase, err := a.appService.CreateApp(ctx, appentity.CreateAppInput{ + Namespace: input.Namespace, + Name: input.Name, + Type: appentitybase.AppTypeSandbox, + }) + if err != nil { + return nil, fmt.Errorf("failed to create app: %w", err) + } + + return appBase, nil +} + +func (a *Factory) UninstallApp(ctx context.Context, input appentity.UninstallAppInput) error { + return nil +} diff --git a/openmeter/app/sandbox/helpers.go b/openmeter/app/sandbox/helpers.go new file mode 100644 index 000000000..bbf46daa9 --- /dev/null +++ b/openmeter/app/sandbox/helpers.go @@ -0,0 +1,67 @@ +package appsandbox + +import ( + "context" + "errors" + "fmt" + + "github.com/samber/lo" + + "github.com/openmeterio/openmeter/openmeter/app" + appentity "github.com/openmeterio/openmeter/openmeter/app/entity" + appentitybase "github.com/openmeterio/openmeter/openmeter/app/entity/base" +) + +type AutoProvisionInput struct { + Namespace string + AppService app.Service +} + +func (a AutoProvisionInput) Validate() error { + if a.Namespace == "" { + return errors.New("namespace is required") + } + + if a.AppService == nil { + return errors.New("app service is required") + } + + return nil +} + +// AutoProvision creates a new default sandbox app if it doesn't exist, otherwise returns the existing one. +// +// We install the sandbox app by default in the system, so that the user can start trying out the system +// right away. +func AutoProvision(ctx context.Context, input AutoProvisionInput) (appentity.App, error) { + if err := input.Validate(); err != nil { + return nil, app.ValidationError{ + Err: err, + } + } + + // Let's try to resolve the default app + defaultApp, err := input.AppService.GetDefaultApp(ctx, appentity.GetDefaultAppInput{ + Namespace: input.Namespace, + Type: appentitybase.AppTypeSandbox, + }) + if err != nil { + if _, ok := lo.ErrorsAs[app.AppDefaultNotFoundError](err); ok { + // Let's provision the new app + defaultApp, err = input.AppService.CreateApp(ctx, appentity.CreateAppInput{ + Namespace: input.Namespace, + Name: "Sandbox", + Description: "OpenMeter Sandbox App to be used for testing purposes.", + Type: appentitybase.AppTypeSandbox, + }) + if err != nil { + return nil, fmt.Errorf("cannot create sandbox app: %w", err) + } + + return defaultApp, nil + } + return nil, err + } + + return defaultApp, nil +} diff --git a/openmeter/app/sandbox/marketplace.go b/openmeter/app/sandbox/marketplace.go new file mode 100644 index 000000000..26bfe8bb9 --- /dev/null +++ b/openmeter/app/sandbox/marketplace.go @@ -0,0 +1,40 @@ +package appsandbox + +import ( + appentitybase "github.com/openmeterio/openmeter/openmeter/app/entity/base" +) + +var ( + MarketplaceListing = appentitybase.MarketplaceListing{ + Type: appentitybase.AppTypeSandbox, + Name: "Sandbox", + Description: "Sandbox can be used to test OpenMeter without external connections.", + IconURL: "https://openmeter.cloud/favicon.ico", + Capabilities: []appentitybase.Capability{ + CollectPaymentCapability, + CalculateTaxCapability, + InvoiceCustomerCapability, + }, + } + + CollectPaymentCapability = appentitybase.Capability{ + Type: appentitybase.CapabilityTypeCollectPayments, + Key: "sandbox_collect_payment", + Name: "Payment", + Description: "Process payments", + } + + CalculateTaxCapability = appentitybase.Capability{ + Type: appentitybase.CapabilityTypeCalculateTax, + Key: "sandbox_calculate_tax", + Name: "Calculate Tax", + Description: "Calculate tax for a payment", + } + + InvoiceCustomerCapability = appentitybase.Capability{ + Type: appentitybase.CapabilityTypeInvoiceCustomers, + Key: "sandbox_invoice_customer", + Name: "Invoice Customer", + Description: "Invoice a customer", + } +) diff --git a/openmeter/app/stripe/entity/app/app.go b/openmeter/app/stripe/entity/app/app.go index 5e8d92fc6..160d45f54 100644 --- a/openmeter/app/stripe/entity/app/app.go +++ b/openmeter/app/stripe/entity/app/app.go @@ -69,7 +69,7 @@ func (a App) Validate() error { // ValidateCustomer validates if the app can run for the given customer func (a App) ValidateCustomer(ctx context.Context, customer *customerentity.Customer, capabilities []appentitybase.CapabilityType) error { // Validate if the app supports the given capabilities - if err := a.ValidateCapabilities(capabilities); err != nil { + if err := a.ValidateCapabilities(capabilities...); err != nil { return fmt.Errorf("error validating capabilities: %w", err) } diff --git a/openmeter/app/stripe/entity/input.go b/openmeter/app/stripe/entity/input.go index 7a0e4c6a1..3b5fdb38a 100644 --- a/openmeter/app/stripe/entity/input.go +++ b/openmeter/app/stripe/entity/input.go @@ -43,10 +43,6 @@ func (i CreateAppStripeInput) Validate() error { return errors.New("name is required") } - if i.Description == "" { - return errors.New("description is required") - } - if i.StripeAccountID == "" { return errors.New("stripe account id is required") } diff --git a/openmeter/billing/adapter.go b/openmeter/billing/adapter.go index b8be9652d..5e424f9e0 100644 --- a/openmeter/billing/adapter.go +++ b/openmeter/billing/adapter.go @@ -4,71 +4,43 @@ import ( "context" "fmt" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" customerentity "github.com/openmeterio/openmeter/openmeter/customer/entity" + "github.com/openmeterio/openmeter/pkg/framework/entutils" + "github.com/openmeterio/openmeter/pkg/framework/transaction" + "github.com/openmeterio/openmeter/pkg/pagination" ) -type TxAdapter interface { - ProfileAdapter - CustomerOverrideAdapter - InvoiceItemAdapter - - Commit() error - Rollback() error -} - type Adapter interface { ProfileAdapter CustomerOverrideAdapter InvoiceItemAdapter - WithTx(context.Context) (TxAdapter, error) + Tx(ctx context.Context) (context.Context, transaction.Driver, error) + WithTx(ctx context.Context, tx *entutils.TxDriver) Adapter } type ProfileAdapter interface { - CreateProfile(ctx context.Context, input CreateProfileInput) (*Profile, error) - GetProfile(ctx context.Context, input GetProfileInput) (*Profile, error) - GetDefaultProfile(ctx context.Context, input GetDefaultProfileInput) (*Profile, error) + CreateProfile(ctx context.Context, input CreateProfileInput) (*billingentity.BaseProfile, error) + ListProfiles(ctx context.Context, input ListProfilesInput) (pagination.PagedResponse[billingentity.BaseProfile], error) + GetProfile(ctx context.Context, input GetProfileInput) (*billingentity.BaseProfile, error) + GetDefaultProfile(ctx context.Context, input GetDefaultProfileInput) (*billingentity.BaseProfile, error) DeleteProfile(ctx context.Context, input DeleteProfileInput) error - UpdateProfile(ctx context.Context, input UpdateProfileAdapterInput) (*Profile, error) + UpdateProfile(ctx context.Context, input UpdateProfileAdapterInput) (*billingentity.BaseProfile, error) } type CustomerOverrideAdapter interface { - CreateCustomerOverride(ctx context.Context, input CreateCustomerOverrideInput) (*CustomerOverride, error) - GetCustomerOverride(ctx context.Context, input GetCustomerOverrideAdapterInput) (*CustomerOverride, error) - UpdateCustomerOverride(ctx context.Context, input UpdateCustomerOverrideAdapterInput) (*CustomerOverride, error) + CreateCustomerOverride(ctx context.Context, input CreateCustomerOverrideInput) (*billingentity.CustomerOverride, error) + GetCustomerOverride(ctx context.Context, input GetCustomerOverrideAdapterInput) (*billingentity.CustomerOverride, error) + UpdateCustomerOverride(ctx context.Context, input UpdateCustomerOverrideAdapterInput) (*billingentity.CustomerOverride, error) DeleteCustomerOverride(ctx context.Context, input DeleteCustomerOverrideInput) error GetCustomerOverrideReferencingProfile(ctx context.Context, input HasCustomerOverrideReferencingProfileAdapterInput) ([]customerentity.CustomerID, error) } type InvoiceItemAdapter interface { - CreateInvoiceItems(ctx context.Context, input CreateInvoiceItemsInput) ([]InvoiceItem, error) - GetPendingInvoiceItems(ctx context.Context, customerID customerentity.CustomerID) ([]InvoiceItem, error) -} - -type UpdateProfileAdapterInput struct { - TargetState Profile - WorkflowConfigID string -} - -func (i UpdateProfileAdapterInput) Validate() error { - if err := i.TargetState.Validate(); err != nil { - return fmt.Errorf("error validating target state profile: %w", err) - } - - if i.TargetState.ID == "" { - return fmt.Errorf("id is required") - } - - if i.TargetState.UpdatedAt.IsZero() { - return fmt.Errorf("updated at is required") - } - - if i.WorkflowConfigID == "" { - return fmt.Errorf("workflow config id is required") - } - - return nil + CreateInvoiceItems(ctx context.Context, input CreateInvoiceItemsInput) ([]billingentity.InvoiceItem, error) + GetPendingInvoiceItems(ctx context.Context, customerID customerentity.CustomerID) ([]billingentity.InvoiceItem, error) } type GetCustomerOverrideAdapterInput struct { @@ -109,59 +81,3 @@ type HasCustomerOverrideReferencingProfileAdapterInput genericNamespaceID func (i HasCustomerOverrideReferencingProfileAdapterInput) Validate() error { return genericNamespaceID(i).Validate() } - -func WithTxNoValue(ctx context.Context, repo Adapter, fn func(ctx context.Context, repo TxAdapter) error) error { - var err error - - wrapped := func(ctx context.Context, repo TxAdapter) (interface{}, error) { - if err = fn(ctx, repo); err != nil { - return nil, err - } - - return nil, nil - } - - _, err = WithTx(ctx, repo, wrapped) - - return err -} - -func WithTx[T any](ctx context.Context, repo Adapter, fn func(ctx context.Context, repo TxAdapter) (T, error)) (resp T, err error) { - var txRepo TxAdapter - - txRepo, err = repo.WithTx(ctx) - if err != nil { - return resp, fmt.Errorf("failed to start transaction: %w", err) - } - defer func() { - if r := recover(); r != nil { - err = fmt.Errorf("recovered from panic: %v: %w", r, err) - - if e := txRepo.Rollback(); e != nil { - err = fmt.Errorf("failed to rollback transaction: %w: %w", e, err) - } - - return - } - - if err != nil { - if e := txRepo.Rollback(); e != nil { - err = fmt.Errorf("failed to rollback transaction: %w: %w", e, err) - } - - return - } - - if e := txRepo.Commit(); e != nil { - err = fmt.Errorf("failed to commit transaction: %w", e) - } - }() - - resp, err = fn(ctx, txRepo) - if err != nil { - err = fmt.Errorf("failed to execute transaction: %w", err) - return - } - - return -} diff --git a/openmeter/billing/adapter/adapter.go b/openmeter/billing/adapter/adapter.go index ae60962c5..9fc81894e 100644 --- a/openmeter/billing/adapter/adapter.go +++ b/openmeter/billing/adapter/adapter.go @@ -2,15 +2,21 @@ package billingadapter import ( "context" + "database/sql" "errors" "fmt" + "log/slog" "github.com/openmeterio/openmeter/openmeter/billing" + "github.com/openmeterio/openmeter/openmeter/ent/db" entdb "github.com/openmeterio/openmeter/openmeter/ent/db" + "github.com/openmeterio/openmeter/pkg/framework/entutils" + "github.com/openmeterio/openmeter/pkg/framework/transaction" ) type Config struct { Client *entdb.Client + Logger *slog.Logger } func (c Config) Validate() error { @@ -18,6 +24,10 @@ func (c Config) Validate() error { return errors.New("ent client is required") } + if c.Logger == nil { + return errors.New("logger is required") + } + return nil } @@ -27,53 +37,33 @@ func New(config Config) (billing.Adapter, error) { } return &adapter{ - db: config.Client, + db: config.Client, + logger: config.Logger, }, nil } var _ billing.Adapter = (*adapter)(nil) type adapter struct { - db *entdb.Client - tx *entdb.Tx -} - -func (r adapter) Commit() error { - if r.tx != nil { - return r.tx.Commit() - } - - return nil -} - -func (r adapter) Rollback() error { - if r.tx != nil { - return r.tx.Rollback() - } - - return nil + db *entdb.Client + logger *slog.Logger } -func (r adapter) client() *entdb.Client { - if r.tx != nil { - return r.tx.Client() +func (a adapter) Tx(ctx context.Context) (context.Context, transaction.Driver, error) { + txCtx, rawConfig, eDriver, err := a.db.HijackTx(ctx, &sql.TxOptions{ + ReadOnly: false, + }) + if err != nil { + return nil, nil, fmt.Errorf("failed to hijack transaction: %w", err) } - - return r.db + return txCtx, entutils.NewTxDriver(eDriver, rawConfig), nil } -func (r adapter) WithTx(ctx context.Context) (billing.TxAdapter, error) { - if r.tx != nil { - return r, nil - } - - tx, err := r.db.Tx(ctx) - if err != nil { - return nil, fmt.Errorf("failed to create transaction: %w", err) - } +func (a adapter) WithTx(ctx context.Context, tx *entutils.TxDriver) billing.Adapter { + txDb := db.NewTxClientFromRawConfig(ctx, *tx.GetConfig()) return &adapter{ - db: r.db, - tx: tx, - }, nil + db: txDb.Client(), + logger: a.logger, + } } diff --git a/openmeter/billing/adapter/customeroverride.go b/openmeter/billing/adapter/customeroverride.go index aa5f868b3..e69d3f333 100644 --- a/openmeter/billing/adapter/customeroverride.go +++ b/openmeter/billing/adapter/customeroverride.go @@ -3,11 +3,11 @@ package billingadapter import ( "context" "fmt" - "time" "github.com/samber/lo" "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" customerentity "github.com/openmeterio/openmeter/openmeter/customer/entity" "github.com/openmeterio/openmeter/openmeter/ent/db" "github.com/openmeterio/openmeter/openmeter/ent/db/billingcustomeroverride" @@ -16,22 +16,16 @@ import ( var _ billing.CustomerOverrideAdapter = (*adapter)(nil) -func (r adapter) CreateCustomerOverride(ctx context.Context, input billing.CreateCustomerOverrideInput) (*billing.CustomerOverride, error) { - if r.tx == nil { - return nil, fmt.Errorf("create customer override: %w", ErrTransactionRequired) - } - - _, err := r.client().BillingCustomerOverride.Create(). +func (r *adapter) CreateCustomerOverride(ctx context.Context, input billing.CreateCustomerOverrideInput) (*billingentity.CustomerOverride, error) { + _, err := r.db.BillingCustomerOverride.Create(). SetNamespace(input.Namespace). SetCustomerID(input.CustomerID). SetNillableBillingProfileID(lo.EmptyableToPtr(input.ProfileID)). SetNillableCollectionAlignment(input.Collection.Alignment). - SetNillableItemCollectionPeriodSeconds(durationPtrToSecondsPtr(input.Collection.ItemCollectionPeriod)). + SetNillableItemCollectionPeriod(input.Collection.Interval.ISOStringPtrOrNil()). SetNillableInvoiceAutoAdvance(input.Invoicing.AutoAdvance). - SetNillableInvoiceDraftPeriodSeconds(durationPtrToSecondsPtr(input.Invoicing.DraftPeriod)). - SetNillableInvoiceDueAfterSeconds(durationPtrToSecondsPtr(input.Invoicing.DueAfter)). - SetNillableInvoiceItemResolution(input.Invoicing.ItemResolution). - SetNillableInvoiceItemPerSubject(input.Invoicing.ItemPerSubject). + SetNillableInvoiceDraftPeriod(input.Invoicing.DraftPeriod.ISOStringPtrOrNil()). + SetNillableInvoiceDueAfter(input.Invoicing.DueAfter.ISOStringPtrOrNil()). SetNillableInvoiceCollectionMethod(input.Payment.CollectionMethod). Save(ctx) if err != nil { @@ -45,21 +39,29 @@ func (r adapter) CreateCustomerOverride(ctx context.Context, input billing.Creat }) } -func (r adapter) UpdateCustomerOverride(ctx context.Context, input billing.UpdateCustomerOverrideAdapterInput) (*billing.CustomerOverride, error) { - if r.tx == nil { - return nil, fmt.Errorf("update customer override: %w", ErrTransactionRequired) +func (r *adapter) UpdateCustomerOverride(ctx context.Context, input billing.UpdateCustomerOverrideAdapterInput) (*billingentity.CustomerOverride, error) { + if input.ProfileID == "" { + // Let's resolve the default profile + defaultProfile, err := r.GetDefaultProfile(ctx, billing.GetDefaultProfileInput{ + Namespace: input.Namespace, + }) + if err != nil { + return nil, billing.NotFoundError{ + Entity: billing.EntityDefaultProfile, + Err: billing.ErrDefaultProfileNotFound, + } + } + + input.ProfileID = defaultProfile.ID } - update := r.client().BillingCustomerOverride.Update(). + update := r.db.BillingCustomerOverride.Update(). Where(billingcustomeroverride.CustomerID(input.CustomerID)). - SetOrClearBillingProfileID(lo.EmptyableToPtr(input.ProfileID)). SetOrClearCollectionAlignment(input.Collection.Alignment). - SetOrClearItemCollectionPeriodSeconds(durationPtrToSecondsPtr(input.Collection.ItemCollectionPeriod)). + SetOrClearItemCollectionPeriod(input.Collection.Interval.ISOStringPtrOrNil()). SetOrClearInvoiceAutoAdvance(input.Invoicing.AutoAdvance). - SetOrClearInvoiceDraftPeriodSeconds(durationPtrToSecondsPtr(input.Invoicing.DraftPeriod)). - SetOrClearInvoiceDueAfterSeconds(durationPtrToSecondsPtr(input.Invoicing.DueAfter)). - SetOrClearInvoiceItemResolution(input.Invoicing.ItemResolution). - SetOrClearInvoiceItemPerSubject(input.Invoicing.ItemPerSubject). + SetOrClearInvoiceDraftPeriod(input.Invoicing.DraftPeriod.ISOStringPtrOrNil()). + SetOrClearInvoiceDueAfter(input.Invoicing.DueAfter.ISOStringPtrOrNil()). SetOrClearInvoiceCollectionMethod(input.Payment.CollectionMethod) if input.ResetDeletedAt { @@ -85,8 +87,8 @@ func (r adapter) UpdateCustomerOverride(ctx context.Context, input billing.Updat }) } -func (r adapter) GetCustomerOverride(ctx context.Context, input billing.GetCustomerOverrideAdapterInput) (*billing.CustomerOverride, error) { - query := r.client().BillingCustomerOverride.Query(). +func (r *adapter) GetCustomerOverride(ctx context.Context, input billing.GetCustomerOverrideAdapterInput) (*billingentity.CustomerOverride, error) { + query := r.db.BillingCustomerOverride.Query(). Where(billingcustomeroverride.Namespace(input.Namespace)). Where(billingcustomeroverride.CustomerID(input.CustomerID)). WithBillingProfile(func(bpq *db.BillingProfileQuery) { @@ -115,11 +117,11 @@ func (r adapter) GetCustomerOverride(ctx context.Context, input billing.GetCusto } } - return mapCustomerOverrideFromDB(dbCustomerOverride), nil + return mapCustomerOverrideFromDB(dbCustomerOverride) } -func (r adapter) DeleteCustomerOverride(ctx context.Context, input billing.DeleteCustomerOverrideInput) error { - rowsAffected, err := r.client().BillingCustomerOverride.Update(). +func (r *adapter) DeleteCustomerOverride(ctx context.Context, input billing.DeleteCustomerOverrideInput) error { + rowsAffected, err := r.db.BillingCustomerOverride.Update(). Where(billingcustomeroverride.CustomerID(input.CustomerID)). Where(billingcustomeroverride.Namespace(input.Namespace)). Where(billingcustomeroverride.DeletedAtIsNil()). @@ -148,8 +150,8 @@ func (r adapter) DeleteCustomerOverride(ctx context.Context, input billing.Delet return nil } -func (r adapter) GetCustomerOverrideReferencingProfile(ctx context.Context, input billing.HasCustomerOverrideReferencingProfileAdapterInput) ([]customerentity.CustomerID, error) { - dbCustomerOverrides, err := r.client().BillingCustomerOverride.Query(). +func (r *adapter) GetCustomerOverrideReferencingProfile(ctx context.Context, input billing.HasCustomerOverrideReferencingProfileAdapterInput) ([]customerentity.CustomerID, error) { + dbCustomerOverrides, err := r.db.BillingCustomerOverride.Query(). Where(billingcustomeroverride.Namespace(input.Namespace)). Where(billingcustomeroverride.BillingProfileID(input.ID)). Where(billingcustomeroverride.DeletedAtIsNil()). @@ -170,8 +172,28 @@ func (r adapter) GetCustomerOverrideReferencingProfile(ctx context.Context, inpu return customerIDs, nil } -func mapCustomerOverrideFromDB(dbOverride *db.BillingCustomerOverride) *billing.CustomerOverride { - return &billing.CustomerOverride{ +func mapCustomerOverrideFromDB(dbOverride *db.BillingCustomerOverride) (*billingentity.CustomerOverride, error) { + collectionInterval, err := dbOverride.ItemCollectionPeriod.ParsePtrOrNil() + if err != nil { + return nil, fmt.Errorf("cannot parse collection.interval: %w", err) + } + + draftPeriod, err := dbOverride.InvoiceDraftPeriod.ParsePtrOrNil() + if err != nil { + return nil, fmt.Errorf("cannot parse invoicing.draftPeriod: %w", err) + } + + dueAfter, err := dbOverride.InvoiceDueAfter.ParsePtrOrNil() + if err != nil { + return nil, fmt.Errorf("cannot parse invoicing.dueAfter: %w", err) + } + + baseProfile, err := mapProfileFromDB(dbOverride.Edges.BillingProfile) + if err != nil { + return nil, fmt.Errorf("cannot map profile: %w", err) + } + + return &billingentity.CustomerOverride{ ID: dbOverride.ID, Namespace: dbOverride.Namespace, @@ -179,40 +201,23 @@ func mapCustomerOverrideFromDB(dbOverride *db.BillingCustomerOverride) *billing. UpdatedAt: dbOverride.UpdatedAt, CustomerID: dbOverride.CustomerID, - Profile: mapProfileFromDB(dbOverride.Edges.BillingProfile), - Collection: billing.CollectionOverrideConfig{ - Alignment: dbOverride.CollectionAlignment, - ItemCollectionPeriod: secondsPtrToDurationPtr(dbOverride.ItemCollectionPeriodSeconds), + Collection: billingentity.CollectionOverrideConfig{ + Alignment: dbOverride.CollectionAlignment, + Interval: collectionInterval, }, - Invoicing: billing.InvoicingOverrideConfig{ - AutoAdvance: dbOverride.InvoiceAutoAdvance, - DraftPeriod: secondsPtrToDurationPtr(dbOverride.InvoiceDraftPeriodSeconds), - DueAfter: secondsPtrToDurationPtr(dbOverride.InvoiceDueAfterSeconds), - ItemResolution: dbOverride.InvoiceItemResolution, - ItemPerSubject: dbOverride.InvoiceItemPerSubject, + Invoicing: billingentity.InvoicingOverrideConfig{ + AutoAdvance: dbOverride.InvoiceAutoAdvance, + DraftPeriod: draftPeriod, + DueAfter: dueAfter, }, - Payment: billing.PaymentOverrideConfig{ + Payment: billingentity.PaymentOverrideConfig{ CollectionMethod: dbOverride.InvoiceCollectionMethod, }, - } -} -func durationPtrToSecondsPtr(d *time.Duration) *int64 { - if d == nil { - return nil - } - - v := int64(*d / time.Second) - return &v -} - -func secondsPtrToDurationPtr(s *int64) *time.Duration { - if s == nil { - return nil - } - - v := time.Duration(*s) * time.Second - return &v + Profile: &billingentity.Profile{ + BaseProfile: *baseProfile, + }, + }, nil } diff --git a/openmeter/billing/adapter/invoiceitems.go b/openmeter/billing/adapter/invoiceitems.go index 6fb57d323..10cd8c677 100644 --- a/openmeter/billing/adapter/invoiceitems.go +++ b/openmeter/billing/adapter/invoiceitems.go @@ -2,23 +2,19 @@ package billingadapter import ( "context" - "fmt" "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" customerentity "github.com/openmeterio/openmeter/openmeter/customer/entity" "github.com/openmeterio/openmeter/openmeter/ent/db" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoiceitem" ) -func (r adapter) CreateInvoiceItems(ctx context.Context, input billing.CreateInvoiceItemsInput) ([]billing.InvoiceItem, error) { - if r.tx == nil { - return nil, fmt.Errorf("create invoice items: %w", ErrTransactionRequired) - } - - result := make([]billing.InvoiceItem, 0, len(input.Items)) +func (r adapter) CreateInvoiceItems(ctx context.Context, input billing.CreateInvoiceItemsInput) ([]billingentity.InvoiceItem, error) { + result := make([]billingentity.InvoiceItem, 0, len(input.Items)) for _, item := range input.Items { - item := r.tx.BillingInvoiceItem.Create(). + item := r.db.BillingInvoiceItem.Create(). SetNamespace(input.Namespace). SetCustomerID(item.CustomerID). SetPeriodStart(item.PeriodStart). @@ -48,7 +44,7 @@ func (r adapter) CreateInvoiceItems(ctx context.Context, input billing.CreateInv return result, nil } -func (r adapter) GetPendingInvoiceItems(ctx context.Context, customerID customerentity.CustomerID) ([]billing.InvoiceItem, error) { +func (r adapter) GetPendingInvoiceItems(ctx context.Context, customerID customerentity.CustomerID) ([]billingentity.InvoiceItem, error) { items, err := r.db.BillingInvoiceItem.Query(). Where(billinginvoiceitem.CustomerID(customerID.ID)). Where(billinginvoiceitem.Namespace(customerID.Namespace)). @@ -58,7 +54,7 @@ func (r adapter) GetPendingInvoiceItems(ctx context.Context, customerID customer return nil, err } - res := make([]billing.InvoiceItem, 0, len(items)) + res := make([]billingentity.InvoiceItem, 0, len(items)) for _, item := range items { res = append(res, mapInvoiceItemFromDB(item)) } @@ -66,8 +62,8 @@ func (r adapter) GetPendingInvoiceItems(ctx context.Context, customerID customer return res, nil } -func mapInvoiceItemFromDB(dbItem *db.BillingInvoiceItem) billing.InvoiceItem { - invoiceItem := billing.InvoiceItem{ +func mapInvoiceItemFromDB(dbItem *db.BillingInvoiceItem) billingentity.InvoiceItem { + invoiceItem := billingentity.InvoiceItem{ Namespace: dbItem.Namespace, ID: dbItem.ID, diff --git a/openmeter/billing/adapter/profile.go b/openmeter/billing/adapter/profile.go index ef38f12f1..f3920fea3 100644 --- a/openmeter/billing/adapter/profile.go +++ b/openmeter/billing/adapter/profile.go @@ -3,50 +3,51 @@ package billingadapter import ( "context" "fmt" - "time" + "github.com/samber/lo" + + "github.com/openmeterio/openmeter/api" "github.com/openmeterio/openmeter/openmeter/billing" - "github.com/openmeterio/openmeter/openmeter/billing/provider" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db" "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" "github.com/openmeterio/openmeter/openmeter/ent/db/billingworkflowconfig" + "github.com/openmeterio/openmeter/pkg/clock" + "github.com/openmeterio/openmeter/pkg/framework/entutils" "github.com/openmeterio/openmeter/pkg/models" + "github.com/openmeterio/openmeter/pkg/pagination" + "github.com/openmeterio/openmeter/pkg/sortx" ) var _ billing.ProfileAdapter = (*adapter)(nil) -func (a adapter) CreateProfile(ctx context.Context, input billing.CreateProfileInput) (*billing.Profile, error) { - if a.tx == nil { - return nil, fmt.Errorf("cannot create profile: %w", ErrTransactionRequired) +func (a *adapter) CreateProfile(ctx context.Context, input billing.CreateProfileInput) (*billingentity.BaseProfile, error) { + if err := input.Validate(); err != nil { + return nil, billing.ValidationError{ + Err: err, + } } - c := a.client() - - dbWorkflowConfig, err := c.BillingWorkflowConfig.Create(). + dbWorkflowConfig, err := a.db.BillingWorkflowConfig.Create(). SetNamespace(input.Namespace). - SetNillableTimezone(input.WorkflowConfig.Timezone). SetCollectionAlignment(input.WorkflowConfig.Collection.Alignment). - SetItemCollectionPeriodSeconds(int64(input.WorkflowConfig.Collection.ItemCollectionPeriod / time.Second)). - SetInvoiceAutoAdvance(input.WorkflowConfig.Invoicing.AutoAdvance). - SetInvoiceDraftPeriodSeconds(int64(input.WorkflowConfig.Invoicing.DraftPeriod / time.Second)). - SetInvoiceDueAfterSeconds(int64(input.WorkflowConfig.Invoicing.DueAfter / time.Second)). - SetInvoiceItemResolution(input.WorkflowConfig.Invoicing.ItemResolution). - SetInvoiceItemPerSubject(input.WorkflowConfig.Invoicing.ItemPerSubject). + SetItemCollectionPeriod(input.WorkflowConfig.Collection.Interval.ISOString()). + SetInvoiceAutoAdvance(*input.WorkflowConfig.Invoicing.AutoAdvance). + SetInvoiceDraftPeriod(input.WorkflowConfig.Invoicing.DraftPeriod.ISOString()). + SetInvoiceDueAfter(input.WorkflowConfig.Invoicing.DueAfter.ISOString()). SetInvoiceCollectionMethod(input.WorkflowConfig.Payment.CollectionMethod). Save(ctx) if err != nil { return nil, err } - dbProfile, err := c.BillingProfile.Create(). + dbProfile, err := a.db.BillingProfile.Create(). SetNamespace(input.Namespace). SetDefault(input.Default). SetName(input.Name). SetNillableDescription(input.Description). - SetTaxProvider(input.TaxConfiguration.Type). - SetInvoicingProvider(input.InvoicingConfiguration.Type). - SetPaymentProvider(input.PaymentConfiguration.Type). SetSupplierName(input.Supplier.Name). + SetNillableSupplierTaxCode(input.Supplier.TaxCode). SetSupplierAddressCountry(*input.Supplier.Address.Country). // Validation is done at service level SetNillableSupplierAddressState(input.Supplier.Address.State). SetNillableSupplierAddressCity(input.Supplier.Address.City). @@ -55,6 +56,10 @@ func (a adapter) CreateProfile(ctx context.Context, input billing.CreateProfileI SetNillableSupplierAddressLine2(input.Supplier.Address.Line2). SetNillableSupplierAddressPhoneNumber(input.Supplier.Address.PhoneNumber). SetWorkflowConfig(dbWorkflowConfig). + SetInvoicingAppID(input.Apps.Invoicing.ID). + SetPaymentAppID(input.Apps.Payment.ID). + SetTaxAppID(input.Apps.Tax.ID). + SetMetadata(input.Metadata). Save(ctx) if err != nil { return nil, err @@ -63,15 +68,16 @@ func (a adapter) CreateProfile(ctx context.Context, input billing.CreateProfileI // Hack: we need to add the edges back dbProfile.Edges.WorkflowConfig = dbWorkflowConfig - return mapProfileFromDB(dbProfile), nil + return mapProfileFromDB(dbProfile) } -func (a adapter) GetProfile(ctx context.Context, input billing.GetProfileInput) (*billing.Profile, error) { +func (a *adapter) GetProfile(ctx context.Context, input billing.GetProfileInput) (*billingentity.BaseProfile, error) { + // This needs to be wrapped, as the service expects this to be atomic if err := input.Validate(); err != nil { return nil, err } - dbProfile, err := a.client().BillingProfile.Query(). + dbProfile, err := a.db.BillingProfile.Query(). Where(billingprofile.Namespace(input.Namespace)). Where(billingprofile.ID(input.ID)). WithWorkflowConfig().First(ctx) @@ -83,15 +89,71 @@ func (a adapter) GetProfile(ctx context.Context, input billing.GetProfileInput) return nil, err } - return mapProfileFromDB(dbProfile), nil + return mapProfileFromDB(dbProfile) } -func (a adapter) GetDefaultProfile(ctx context.Context, input billing.GetDefaultProfileInput) (*billing.Profile, error) { +func (a *adapter) ListProfiles(ctx context.Context, input billing.ListProfilesInput) (pagination.PagedResponse[billingentity.BaseProfile], error) { + query := a.db.BillingProfile.Query(). + Where(billingprofile.Namespace(input.Namespace)) + + if !input.IncludeArchived { + query = query.Where(billingprofile.DeletedAtIsNil()) + } + + order := entutils.GetOrdering(sortx.OrderDefault) + if !input.Order.IsDefaultValue() { + order = entutils.GetOrdering(input.Order) + } + + switch input.OrderBy { + case api.BillingProfileOrderByCreatedAt: + query = query.Order(billingprofile.ByCreatedAt(order...)) + case api.BillingProfileOrderByUpdatedAt: + query = query.Order(billingprofile.ByUpdatedAt(order...)) + case api.BillingProfileOrderByName: + query = query.Order(billingprofile.ByName(order...)) + case api.BillingProfileOrderByDefault: + query = query.Order(billingprofile.ByDefault(order...)) + default: + query = query.Order(billingprofile.ByCreatedAt(order...)) + } + + response := pagination.PagedResponse[billingentity.BaseProfile]{ + Page: input.Page, + } + + paged, err := query.Paginate(ctx, input.Page) + if err != nil { + return response, err + } + + result := make([]billingentity.BaseProfile, 0, len(paged.Items)) + for _, item := range paged.Items { + if item == nil { + a.logger.Warn("invalid query result: nil billing profile received") + continue + } + + profile, err := mapProfileFromDB(item) + if err != nil { + return response, fmt.Errorf("cannot map profile: %w", err) + } + + result = append(result, *profile) + } + + response.TotalCount = paged.TotalCount + response.Items = result + + return response, nil +} + +func (a adapter) GetDefaultProfile(ctx context.Context, input billing.GetDefaultProfileInput) (*billingentity.BaseProfile, error) { if err := input.Validate(); err != nil { return nil, err } - dbProfile, err := a.client().BillingProfile.Query(). + dbProfile, err := a.db.BillingProfile.Query(). Where(billingprofile.Namespace(input.Namespace)). Where(billingprofile.Default(true)). Where(billingprofile.DeletedAtIsNil()). @@ -105,36 +167,30 @@ func (a adapter) GetDefaultProfile(ctx context.Context, input billing.GetDefault return nil, err } - return mapProfileFromDB(dbProfile), nil + return mapProfileFromDB(dbProfile) } -func (a adapter) DeleteProfile(ctx context.Context, input billing.DeleteProfileInput) error { +func (a *adapter) DeleteProfile(ctx context.Context, input billing.DeleteProfileInput) error { if err := input.Validate(); err != nil { return err } - if a.tx == nil { - return fmt.Errorf("cannot delete profile: %w", ErrTransactionRequired) - } - profile, err := a.GetProfile(ctx, billing.GetProfileInput(input)) if err != nil { return err } - c := a.client() - - _, err = c.BillingWorkflowConfig.UpdateOneID(profile.WorkflowConfig.ID). + _, err = a.db.BillingWorkflowConfig.UpdateOneID(profile.WorkflowConfig.ID). Where(billingworkflowconfig.Namespace(profile.Namespace)). - SetDeletedAt(time.Now()). + SetDeletedAt(clock.Now()). Save(ctx) if err != nil { return err } - _, err = c.BillingProfile.UpdateOneID(input.ID). + _, err = a.db.BillingProfile.UpdateOneID(input.ID). Where(billingprofile.Namespace(input.Namespace)). - SetDeletedAt(time.Now()). + SetDeletedAt(clock.Now()). Save(ctx) if err != nil { return err @@ -143,11 +199,7 @@ func (a adapter) DeleteProfile(ctx context.Context, input billing.DeleteProfileI return nil } -func (a adapter) UpdateProfile(ctx context.Context, input billing.UpdateProfileAdapterInput) (*billing.Profile, error) { - if a.tx == nil { - return nil, fmt.Errorf("cannot update profile: %w", ErrTransactionRequired) - } - +func (a adapter) UpdateProfile(ctx context.Context, input billing.UpdateProfileAdapterInput) (*billingentity.BaseProfile, error) { if err := input.Validate(); err != nil { return nil, billing.ValidationError{ Err: err, @@ -156,64 +208,67 @@ func (a adapter) UpdateProfile(ctx context.Context, input billing.UpdateProfileA targetState := input.TargetState - update := a.client().BillingProfile.UpdateOneID(targetState.ID). + update := a.db.BillingProfile.UpdateOneID(targetState.ID). Where(billingprofile.Namespace(targetState.Namespace)). SetName(targetState.Name). SetNillableDescription(targetState.Description). - SetTaxProvider(targetState.TaxConfiguration.Type). - SetInvoicingProvider(targetState.InvoicingConfiguration.Type). - SetPaymentProvider(targetState.PaymentConfiguration.Type). SetSupplierName(targetState.Supplier.Name). SetSupplierAddressCountry(*targetState.Supplier.Address.Country). SetDefault(targetState.Default). + SetOrClearSupplierTaxCode(targetState.Supplier.TaxCode). SetOrClearSupplierAddressState(targetState.Supplier.Address.State). SetOrClearSupplierAddressCity(targetState.Supplier.Address.City). SetOrClearSupplierAddressPostalCode(targetState.Supplier.Address.PostalCode). SetOrClearSupplierAddressLine1(targetState.Supplier.Address.Line1). SetOrClearSupplierAddressLine2(targetState.Supplier.Address.Line2). - SetOrClearSupplierAddressPhoneNumber(targetState.Supplier.Address.PhoneNumber) + SetOrClearSupplierAddressPhoneNumber(targetState.Supplier.Address.PhoneNumber). + SetMetadata(targetState.Metadata) updatedProfile, err := update.Save(ctx) if err != nil { return nil, err } - updatedWorkflowConfig, err := a.client().BillingWorkflowConfig.UpdateOneID(input.WorkflowConfigID). + updatedWorkflowConfig, err := a.db.BillingWorkflowConfig.UpdateOneID(input.WorkflowConfigID). Where(billingworkflowconfig.Namespace(targetState.Namespace)). SetCollectionAlignment(targetState.WorkflowConfig.Collection.Alignment). - SetItemCollectionPeriodSeconds(int64(targetState.WorkflowConfig.Collection.ItemCollectionPeriod / time.Second)). - SetInvoiceAutoAdvance(targetState.WorkflowConfig.Invoicing.AutoAdvance). - SetInvoiceDraftPeriodSeconds(int64(targetState.WorkflowConfig.Invoicing.DraftPeriod / time.Second)). - SetInvoiceDueAfterSeconds(int64(targetState.WorkflowConfig.Invoicing.DueAfter / time.Second)). - SetInvoiceItemResolution(targetState.WorkflowConfig.Invoicing.ItemResolution). - SetInvoiceItemPerSubject(targetState.WorkflowConfig.Invoicing.ItemPerSubject). + SetItemCollectionPeriod(targetState.WorkflowConfig.Collection.Interval.ISOString()). + SetInvoiceAutoAdvance(*targetState.WorkflowConfig.Invoicing.AutoAdvance). + SetInvoiceDraftPeriod(targetState.WorkflowConfig.Invoicing.DraftPeriod.ISOString()). + SetInvoiceDueAfter(targetState.WorkflowConfig.Invoicing.DueAfter.ISOString()). SetInvoiceCollectionMethod(targetState.WorkflowConfig.Payment.CollectionMethod). - SetOrClearTimezone(targetState.WorkflowConfig.Timezone).Save(ctx) + Save(ctx) if err != nil { return nil, err } updatedProfile.Edges.WorkflowConfig = updatedWorkflowConfig - return mapProfileFromDB(updatedProfile), nil + return mapProfileFromDB(updatedProfile) } -func mapProfileFromDB(dbProfile *db.BillingProfile) *billing.Profile { +func mapProfileFromDB(dbProfile *db.BillingProfile) (*billingentity.BaseProfile, error) { if dbProfile == nil { - return nil + return nil, nil } - return &billing.Profile{ + wfConfig, err := mapWorkflowConfigFromDB(dbProfile.Edges.WorkflowConfig) + if err != nil { + return nil, fmt.Errorf("cannot map workflow config: %w", err) + } + + return &billingentity.BaseProfile{ Namespace: dbProfile.Namespace, ID: dbProfile.ID, Default: dbProfile.Default, Name: dbProfile.Name, Description: dbProfile.Description, + Metadata: dbProfile.Metadata, CreatedAt: dbProfile.CreatedAt, UpdatedAt: dbProfile.UpdatedAt, DeletedAt: dbProfile.DeletedAt, - Supplier: billing.SupplierContact{ + Supplier: billingentity.SupplierContact{ Name: dbProfile.SupplierName, Address: models.Address{ Country: dbProfile.SupplierAddressCountry, @@ -224,48 +279,55 @@ func mapProfileFromDB(dbProfile *db.BillingProfile) *billing.Profile { Line2: dbProfile.SupplierAddressLine2, PhoneNumber: dbProfile.SupplierAddressPhoneNumber, }, + TaxCode: dbProfile.SupplierTaxCode, }, - TaxConfiguration: provider.TaxConfiguration{ - Type: dbProfile.TaxProvider, - }, - InvoicingConfiguration: provider.InvoicingConfiguration{ - Type: dbProfile.InvoicingProvider, - }, - PaymentConfiguration: provider.PaymentConfiguration{ - Type: dbProfile.PaymentProvider, + WorkflowConfig: wfConfig, + + AppReferences: &billingentity.ProfileAppReferences{ + Tax: billingentity.AppReference{ID: dbProfile.TaxAppID}, + Invoicing: billingentity.AppReference{ID: dbProfile.InvoicingAppID}, + Payment: billingentity.AppReference{ID: dbProfile.PaymentAppID}, }, + }, nil +} - WorkflowConfig: mapWorkflowConfigFromDB(dbProfile.Edges.WorkflowConfig), +func mapWorkflowConfigFromDB(dbWC *db.BillingWorkflowConfig) (billingentity.WorkflowConfig, error) { + collectionInterval, err := dbWC.ItemCollectionPeriod.Parse() + if err != nil { + return billingentity.WorkflowConfig{}, fmt.Errorf("cannot parse collection.interval: %w", err) + } + + draftPeriod, err := dbWC.InvoiceDraftPeriod.Parse() + if err != nil { + return billingentity.WorkflowConfig{}, fmt.Errorf("cannot parse invoicing.draftPeriod: %w", err) } -} -func mapWorkflowConfigFromDB(dbWC *db.BillingWorkflowConfig) billing.WorkflowConfig { - return billing.WorkflowConfig{ + dueAfter, err := dbWC.InvoiceDueAfter.Parse() + if err != nil { + return billingentity.WorkflowConfig{}, fmt.Errorf("cannot parse invoicing.dueAfter: %w", err) + } + + return billingentity.WorkflowConfig{ ID: dbWC.ID, CreatedAt: dbWC.CreatedAt, UpdatedAt: dbWC.UpdatedAt, DeletedAt: dbWC.DeletedAt, - Timezone: dbWC.Timezone, - - Collection: billing.CollectionConfig{ - Alignment: dbWC.CollectionAlignment, - ItemCollectionPeriod: time.Duration(dbWC.ItemCollectionPeriodSeconds) * time.Second, + Collection: billingentity.CollectionConfig{ + Alignment: dbWC.CollectionAlignment, + Interval: collectionInterval, }, - Invoicing: billing.InvoicingConfig{ - AutoAdvance: dbWC.InvoiceAutoAdvance, - DraftPeriod: time.Duration(dbWC.InvoiceDraftPeriodSeconds) * time.Second, - DueAfter: time.Duration(dbWC.InvoiceDueAfterSeconds) * time.Second, - - ItemResolution: dbWC.InvoiceItemResolution, - ItemPerSubject: dbWC.InvoiceItemPerSubject, + Invoicing: billingentity.InvoicingConfig{ + AutoAdvance: lo.ToPtr(dbWC.InvoiceAutoAdvance), + DraftPeriod: draftPeriod, + DueAfter: dueAfter, }, - Payment: billing.PaymentConfig{ + Payment: billingentity.PaymentConfig{ CollectionMethod: dbWC.InvoiceCollectionMethod, }, - } + }, nil } diff --git a/openmeter/billing/customeroverride.go b/openmeter/billing/customeroverride.go index 2360197c4..7d76bb6ae 100644 --- a/openmeter/billing/customeroverride.go +++ b/openmeter/billing/customeroverride.go @@ -3,119 +3,9 @@ package billing import ( "fmt" "time" -) - -type CustomerOverride struct { - Namespace string `json:"namespace"` - ID string `json:"id"` - - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - DeletedAt *time.Time `json:"deletedAt,omitempty"` - - CustomerID string `json:"customerID"` - Profile *Profile `json:"billingProfile,omitempty"` - - Collection CollectionOverrideConfig `json:"collection"` - Invoicing InvoicingOverrideConfig `json:"invoicing"` - Payment PaymentOverrideConfig `json:"payment"` -} - -func (c CustomerOverride) Validate() error { - if c.Namespace == "" { - return fmt.Errorf("namespace is required") - } - - if c.ID == "" { - return fmt.Errorf("id is required") - } - - if c.CustomerID == "" { - return fmt.Errorf("customer id is required") - } - - if c.Profile != nil { - if err := c.Profile.Validate(); err != nil { - return fmt.Errorf("invalid profile: %w", err) - } - } - - if err := c.Collection.Validate(); err != nil { - return fmt.Errorf("invalid collection: %w", err) - } - - if err := c.Invoicing.Validate(); err != nil { - return fmt.Errorf("invalid invoicing: %w", err) - } - - if err := c.Payment.Validate(); err != nil { - return fmt.Errorf("invalid payment: %w", err) - } - return nil -} - -type CollectionOverrideConfig struct { - Alignment *AlignmentKind `json:"alignment,omitempty"` - ItemCollectionPeriod *time.Duration `json:"itemCollectionPeriod,omitempty"` -} - -func (c *CollectionOverrideConfig) Validate() error { - if c.Alignment != nil && *c.Alignment != AlignmentKindSubscription { - return fmt.Errorf("invalid alignment: %s", *c.Alignment) - } - - if c.ItemCollectionPeriod != nil && *c.ItemCollectionPeriod < 0 { - return fmt.Errorf("item collection period must be greater or equal to 0") - } - - return nil -} - -type InvoicingOverrideConfig struct { - AutoAdvance *bool `json:"autoAdvance,omitempty"` - DraftPeriod *time.Duration `json:"draftPeriod,omitempty"` - DueAfter *time.Duration `json:"dueAfter,omitempty"` - - ItemResolution *GranularityResolution `json:"itemResolution,omitempty"` - ItemPerSubject *bool `json:"itemPerSubject,omitempty"` -} - -func (c *InvoicingOverrideConfig) Validate() error { - if c.AutoAdvance != nil && *c.AutoAdvance { - return fmt.Errorf("auto advance is not supported") - } - - if c.DueAfter != nil && *c.DueAfter < 0 { - return fmt.Errorf("due after must be greater or equal to 0") - } - - if c.ItemResolution != nil { - switch *c.ItemResolution { - case GranularityResolutionDay, GranularityResolutionPeriod: - default: - return fmt.Errorf("invalid item resolution: %s", *c.ItemResolution) - } - } - - return nil -} - -type PaymentOverrideConfig struct { - CollectionMethod *CollectionMethod -} - -func (c *PaymentOverrideConfig) Validate() error { - if c.CollectionMethod != nil { - switch *c.CollectionMethod { - case CollectionMethodChargeAutomatically, CollectionMethodSendInvoice: - default: - return fmt.Errorf("invalid collection method: %s", *c.CollectionMethod) - } - } - - return nil -} + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" +) type CreateCustomerOverrideInput struct { Namespace string `json:"namespace"` @@ -123,9 +13,9 @@ type CreateCustomerOverrideInput struct { CustomerID string `json:"customerID"` ProfileID string `json:"billingProfile,omitempty"` - Collection CollectionOverrideConfig `json:"collection"` - Invoicing InvoicingOverrideConfig `json:"invoicing"` - Payment PaymentOverrideConfig `json:"payment"` + Collection billingentity.CollectionOverrideConfig `json:"collection"` + Invoicing billingentity.InvoicingOverrideConfig `json:"invoicing"` + Payment billingentity.PaymentOverrideConfig `json:"payment"` } func (c CreateCustomerOverrideInput) Validate() error { @@ -160,9 +50,9 @@ type UpdateCustomerOverrideInput struct { ProfileID string `json:"billingProfileID"` - Collection CollectionOverrideConfig `json:"collection"` - Invoicing InvoicingOverrideConfig `json:"invoicing"` - Payment PaymentOverrideConfig `json:"payment"` + Collection billingentity.CollectionOverrideConfig `json:"collection"` + Invoicing billingentity.InvoicingOverrideConfig `json:"invoicing"` + Payment billingentity.PaymentOverrideConfig `json:"payment"` } func (u UpdateCustomerOverrideInput) Validate() error { diff --git a/openmeter/billing/entity/customeroverride.go b/openmeter/billing/entity/customeroverride.go new file mode 100644 index 000000000..7179dd825 --- /dev/null +++ b/openmeter/billing/entity/customeroverride.go @@ -0,0 +1,113 @@ +package billingentity + +import ( + "fmt" + "time" + + "github.com/openmeterio/openmeter/pkg/datex" +) + +type CustomerOverride struct { + Namespace string `json:"namespace"` + ID string `json:"id"` + + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + DeletedAt *time.Time `json:"deletedAt,omitempty"` + + CustomerID string `json:"customerID"` + Profile *Profile `json:"billingProfile,omitempty"` + + Collection CollectionOverrideConfig `json:"collection"` + Invoicing InvoicingOverrideConfig `json:"invoicing"` + Payment PaymentOverrideConfig `json:"payment"` +} + +func (c CustomerOverride) Validate() error { + if c.Namespace == "" { + return fmt.Errorf("namespace is required") + } + + if c.ID == "" { + return fmt.Errorf("id is required") + } + + if c.CustomerID == "" { + return fmt.Errorf("customer id is required") + } + + if c.Profile != nil { + if err := c.Profile.Validate(); err != nil { + return fmt.Errorf("invalid profile: %w", err) + } + } + + if err := c.Collection.Validate(); err != nil { + return fmt.Errorf("invalid collection: %w", err) + } + + if err := c.Invoicing.Validate(); err != nil { + return fmt.Errorf("invalid invoicing: %w", err) + } + + if err := c.Payment.Validate(); err != nil { + return fmt.Errorf("invalid payment: %w", err) + } + + return nil +} + +type CollectionOverrideConfig struct { + Alignment *AlignmentKind `json:"alignment,omitempty"` + Interval *datex.Period `json:"interval,omitempty"` +} + +func (c *CollectionOverrideConfig) Validate() error { + if c.Alignment != nil && *c.Alignment != AlignmentKindSubscription { + return fmt.Errorf("invalid alignment: %s", *c.Alignment) + } + + if c.Interval != nil && c.Interval.IsNegative() { + return fmt.Errorf("item collection period must be greater or equal to 0") + } + + return nil +} + +type InvoicingOverrideConfig struct { + AutoAdvance *bool `json:"autoAdvance,omitempty"` + DraftPeriod *datex.Period `json:"draftPeriod,omitempty"` + DueAfter *datex.Period `json:"dueAfter,omitempty"` +} + +func (c *InvoicingOverrideConfig) Validate() error { + if c.AutoAdvance != nil && *c.AutoAdvance { + return fmt.Errorf("auto advance is not supported") + } + + if c.DueAfter != nil && c.DueAfter.IsNegative() { + return fmt.Errorf("due after must be greater or equal to 0") + } + + if c.DraftPeriod != nil && c.DraftPeriod.IsNegative() { + return fmt.Errorf("draft period must be greater or equal to 0") + } + + return nil +} + +type PaymentOverrideConfig struct { + CollectionMethod *CollectionMethod +} + +func (c *PaymentOverrideConfig) Validate() error { + if c.CollectionMethod != nil { + switch *c.CollectionMethod { + case CollectionMethodChargeAutomatically, CollectionMethodSendInvoice: + default: + return fmt.Errorf("invalid collection method: %s", *c.CollectionMethod) + } + } + + return nil +} diff --git a/openmeter/billing/invoice.go b/openmeter/billing/entity/invoice.go similarity index 99% rename from openmeter/billing/invoice.go rename to openmeter/billing/entity/invoice.go index 2107eb5ec..35a1bdfd2 100644 --- a/openmeter/billing/invoice.go +++ b/openmeter/billing/entity/invoice.go @@ -1,4 +1,4 @@ -package billing +package billingentity import ( "fmt" diff --git a/openmeter/billing/entity/invoiceitem.go b/openmeter/billing/entity/invoiceitem.go new file mode 100644 index 000000000..0a3673d7c --- /dev/null +++ b/openmeter/billing/entity/invoiceitem.go @@ -0,0 +1,102 @@ +package billingentity + +import ( + "errors" + "time" + + "github.com/alpacahq/alpacadecimal" + + "github.com/openmeterio/openmeter/pkg/currencyx" +) + +type InvoiceItemType string + +const ( + // InvoiceItemTypeStatic is a static item that is not calculated based on usage. + InvoiceItemTypeStatic InvoiceItemType = "static" + // InvoiceItemTypeUsage is an item that is calculated based on usage. + InvoiceItemTypeUsage InvoiceItemType = "usage" +) + +func (InvoiceItemType) Values() []string { + return []string{ + string(InvoiceItemTypeStatic), + string(InvoiceItemTypeUsage), + } +} + +type InvoiceItem struct { + Namespace string `json:"namespace"` + ID string `json:"id"` + + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + DeletedAt *time.Time `json:"deletedAt,omitempty"` + + Metadata map[string]string `json:"metadata"` + InvoiceID *string `json:"invoiceID,omitempty"` + CustomerID string `json:"customer"` + + // Lifecycle + PeriodStart time.Time `json:"periodStart"` + PeriodEnd time.Time `json:"periodEnd"` + InvoiceAt time.Time `json:"invoiceAt"` + + // Item details + Name string `json:"name"` + Type InvoiceItemType `json:"type"` + Quantity *alpacadecimal.Decimal `json:"quantity"` + UnitPrice alpacadecimal.Decimal `json:"unitPrice"` + Currency currencyx.Code `json:"currency"` + + TaxCodeOverride TaxOverrides `json:"taxCodeOverride"` +} + +func (i InvoiceItem) Validate() error { + if i.Namespace == "" { + return errors.New("namespace is required") + } + + if i.CustomerID == "" { + return errors.New("customer id is required") + } + + if i.PeriodStart.IsZero() { + return errors.New("period start is required") + } + + if i.PeriodEnd.IsZero() { + return errors.New("period end is required") + } + + if i.InvoiceAt.IsZero() { + return errors.New("invoice at is required") + } + + if i.Name == "" { + return errors.New("name is required") + } + + if i.Type == "" { + return errors.New("type is required") + } + + if i.Type != InvoiceItemTypeStatic { + // TODO: support usage items + return errors.New("only static items are supported") + } + + if i.Type == InvoiceItemTypeStatic && (i.Quantity == nil || i.Quantity.IsZero()) { + return errors.New("quantity is required for static items") + } + + if i.UnitPrice.IsZero() { + return errors.New("unit price is required") + } + + if i.Currency == "" { + return errors.New("currency is required") + } + + return nil +} diff --git a/openmeter/billing/entity/profile.go b/openmeter/billing/entity/profile.go new file mode 100644 index 000000000..d97948d6a --- /dev/null +++ b/openmeter/billing/entity/profile.go @@ -0,0 +1,315 @@ +package billingentity + +import ( + "errors" + "fmt" + "time" + + "github.com/samber/lo" + + appentity "github.com/openmeterio/openmeter/openmeter/app/entity" + appentitybase "github.com/openmeterio/openmeter/openmeter/app/entity/base" + customerentity "github.com/openmeterio/openmeter/openmeter/customer/entity" + "github.com/openmeterio/openmeter/pkg/datex" + "github.com/openmeterio/openmeter/pkg/models" + "github.com/openmeterio/openmeter/pkg/timezone" +) + +// AlignmentKind specifies what governs when an invoice is issued +type AlignmentKind string + +type Metadata map[string]string + +const ( + // AlignmentKindSubscription specifies that the invoice is issued based on the subscription period ( + // e.g. whenever a due line item is added, it will trigger an invoice generation after the collection period) + AlignmentKindSubscription AlignmentKind = "subscription" +) + +var DefaultWorkflowConfig = WorkflowConfig{ + Collection: CollectionConfig{ + Alignment: AlignmentKindSubscription, + Interval: lo.Must(datex.ISOString("PT2H").Parse()), + }, + Invoicing: InvoicingConfig{ + AutoAdvance: lo.ToPtr(true), + DraftPeriod: lo.Must(datex.ISOString("P1D").Parse()), + DueAfter: lo.Must(datex.ISOString("P1W").Parse()), + }, + Payment: PaymentConfig{ + CollectionMethod: CollectionMethodChargeAutomatically, + }, +} + +func (k AlignmentKind) Values() []string { + return []string{ + string(AlignmentKindSubscription), + } +} + +type WorkflowConfig struct { + ID string `json:"id"` + + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + DeletedAt *time.Time `json:"deletedAt"` + + Timezone *timezone.Timezone `json:"timezone,omitempty"` + + Collection CollectionConfig `json:"collection"` + Invoicing InvoicingConfig `json:"invoicing"` + Payment PaymentConfig `json:"payment"` +} + +func (c WorkflowConfig) Validate() error { + if err := c.Collection.Validate(); err != nil { + return fmt.Errorf("invalid collection config: %w", err) + } + + if err := c.Invoicing.Validate(); err != nil { + return fmt.Errorf("invalid invoice config: %w", err) + } + + if err := c.Payment.Validate(); err != nil { + return fmt.Errorf("invalid payment config: %w", err) + } + + return nil +} + +type AppReference struct { + ID string `json:"id"` + Type appentitybase.AppType `json:"type"` +} + +func (a AppReference) Validate() error { + if a.ID == "" && a.Type == "" { + return errors.New("id or type is required") + } + + if a.ID != "" && a.Type != "" { + return errors.New("only one of id or type is allowed") + } + + return nil +} + +// CollectionConfig groups fields related to item collection. +type CollectionConfig struct { + Alignment AlignmentKind `json:"alignment"` + Interval datex.Period `json:"period,omitempty"` +} + +func (c *CollectionConfig) Validate() error { + if c.Alignment != AlignmentKindSubscription { + return fmt.Errorf("invalid alignment: %s", c.Alignment) + } + + if !c.Interval.IsPositive() { + return fmt.Errorf("item collection period must be greater or equal to 0") + } + + return nil +} + +// InvoiceConfig groups fields related to invoice settings. +type InvoicingConfig struct { + AutoAdvance *bool `json:"autoAdvance"` + DraftPeriod datex.Period `json:"draftPeriod,omitempty"` + DueAfter datex.Period `json:"dueAfter"` +} + +func (c *InvoicingConfig) Validate() error { + if c.DraftPeriod.IsNegative() && c.AutoAdvance != nil && *c.AutoAdvance { + return fmt.Errorf("draft period must be greater or equal to 0") + } + + if c.DueAfter.IsNegative() { + return fmt.Errorf("due after must be greater or equal to 0") + } + + return nil +} + +type GranularityResolution string + +const ( + // GranularityResolutionDay provides line items for metered data per day + GranularityResolutionDay GranularityResolution = "day" + // GranularityResolutionPeriod provides one line item per period + GranularityResolutionPeriod GranularityResolution = "period" +) + +func (r GranularityResolution) Values() []string { + return []string{ + string(GranularityResolutionDay), + string(GranularityResolutionPeriod), + } +} + +type PaymentConfig struct { + CollectionMethod CollectionMethod +} + +func (c *PaymentConfig) Validate() error { + switch c.CollectionMethod { + case CollectionMethodChargeAutomatically, CollectionMethodSendInvoice: + default: + return fmt.Errorf("invalid collection method: %s", c.CollectionMethod) + } + + return nil +} + +type CollectionMethod string + +const ( + // CollectionMethodChargeAutomatically charges the customer automatically based on previously saved card data + CollectionMethodChargeAutomatically CollectionMethod = "charge_automatically" + // CollectionMethodSendInvoice sends an invoice to the customer along with the payment instructions/links + CollectionMethodSendInvoice CollectionMethod = "send_invoice" +) + +func (c CollectionMethod) Values() []string { + return []string{ + string(CollectionMethodChargeAutomatically), + string(CollectionMethodSendInvoice), + } +} + +type SupplierContact struct { + ID string `json:"id"` + Name string `json:"name"` + Address models.Address `json:"address"` + TaxCode *string `json:"taxCode,omitempty"` +} + +// Validate checks if the supplier contact is valid for invoice generation (e.g. Country is required) +func (c SupplierContact) Validate() error { + if c.Name == "" { + return errors.New("name is required") + } + + if c.Address.Country == nil { + return errors.New("country is required") + } + + return nil +} + +type BaseProfile struct { + ID string `json:"id"` + Namespace string `json:"namespace"` + + Name string `json:"name"` + Description *string `json:"description"` + + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + DeletedAt *time.Time `json:"deletedAt"` + + WorkflowConfig WorkflowConfig `json:"workflow"` + + Supplier SupplierContact `json:"supplier"` + + Default bool `json:"default"` + Metadata Metadata `json:"metadata"` + + AppReferences *ProfileAppReferences `json:"appReferences,omitempty"` +} + +func (p BaseProfile) Validate() error { + if p.Namespace == "" { + return errors.New("namespace is required") + } + + if p.Name == "" { + return errors.New("name is required") + } + + if err := p.WorkflowConfig.Validate(); err != nil { + return fmt.Errorf("invalid workflow configuration: %w", err) + } + + if err := p.Supplier.Validate(); err != nil { + return fmt.Errorf("invalid supplier: %w", err) + } + + return nil +} + +type Profile struct { + BaseProfile + + // Optionaly expanded fields + Apps *ProfileApps `json:"-"` + Customer *customerentity.Customer `json:"-"` +} + +type ProfileApps struct { + Tax appentity.App `json:"tax"` + Invoicing appentity.App `json:"invoicing"` + Payment appentity.App `json:"payment"` +} + +func (p Profile) Validate() error { + if err := p.BaseProfile.Validate(); err != nil { + return err + } + + return nil +} + +func (p Profile) Merge(o *CustomerOverride) Profile { + p.WorkflowConfig.Collection = CollectionConfig{ + Alignment: lo.FromPtrOr(o.Collection.Alignment, p.WorkflowConfig.Collection.Alignment), + Interval: lo.FromPtrOr(o.Collection.Interval, p.WorkflowConfig.Collection.Interval), + } + + p.WorkflowConfig.Invoicing = InvoicingConfig{ + AutoAdvance: lo.CoalesceOrEmpty(o.Invoicing.AutoAdvance, p.WorkflowConfig.Invoicing.AutoAdvance), + DraftPeriod: lo.FromPtrOr(o.Invoicing.DraftPeriod, p.WorkflowConfig.Invoicing.DraftPeriod), + DueAfter: lo.FromPtrOr(o.Invoicing.DueAfter, p.WorkflowConfig.Invoicing.DueAfter), + } + + p.WorkflowConfig.Payment = PaymentConfig{ + CollectionMethod: lo.FromPtrOr(o.Payment.CollectionMethod, p.WorkflowConfig.Payment.CollectionMethod), + } + + return p +} + +type ProfileWithCustomerDetails struct { + Profile Profile `json:"profile"` + Customer customerentity.Customer `json:"customer"` +} + +func (p ProfileWithCustomerDetails) Validate() error { + if err := p.Profile.Validate(); err != nil { + return fmt.Errorf("invalid profile: %w", err) + } + + return nil +} + +type ProfileAppReferences struct { + Tax AppReference `json:"tax"` + Invoicing AppReference `json:"invoicing"` + Payment AppReference `json:"payment"` +} + +func (i ProfileAppReferences) Validate() error { + if err := i.Tax.Validate(); err != nil { + return fmt.Errorf("invalid tax app reference: %w", err) + } + + if err := i.Invoicing.Validate(); err != nil { + return fmt.Errorf("invalid invoicing app reference: %w", err) + } + + if err := i.Payment.Validate(); err != nil { + return fmt.Errorf("invalid payment app reference: %w", err) + } + + return nil +} diff --git a/openmeter/billing/tax.go b/openmeter/billing/entity/tax.go similarity index 89% rename from openmeter/billing/tax.go rename to openmeter/billing/entity/tax.go index 4571e4233..c5aa1f687 100644 --- a/openmeter/billing/tax.go +++ b/openmeter/billing/entity/tax.go @@ -1,4 +1,4 @@ -package billing +package billingentity type StripeTaxCode string diff --git a/openmeter/billing/gobldriver/invoice.go b/openmeter/billing/gobldriver/invoice.go index 05b6cbf00..637dd4868 100644 --- a/openmeter/billing/gobldriver/invoice.go +++ b/openmeter/billing/gobldriver/invoice.go @@ -22,7 +22,7 @@ import ( "github.com/invopop/validation" "github.com/samber/lo" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/pkg/gobl" ) @@ -60,7 +60,7 @@ type invoiceWithValidation struct { // if error is set, then a non-recordable error occurred // if the invoice has validation issues then the Invoice's ValidationError will be set // and the Invoice's Complements will contain the validation notes -func (d *Driver) Generate(ctx context.Context, invoice billing.InvoiceWithValidation) (*bill.Invoice, error) { +func (d *Driver) Generate(ctx context.Context, invoice billingentity.InvoiceWithValidation) (*bill.Invoice, error) { inv := d.invoiceToGOBL(invoice) if err := inv.Invoice.Validate(); err != nil { @@ -93,7 +93,7 @@ func (d *Driver) Generate(ctx context.Context, invoice billing.InvoiceWithValida // invoiceToGOBL converts a billing.Invoice to a gobl invoice. If error is set, then // a fatal error has occurred, which should be reported to the caller instead of putting // it into the validation errors. -func (d *Driver) invoiceToGOBL(input billing.InvoiceWithValidation) invoiceWithValidation { +func (d *Driver) invoiceToGOBL(input billingentity.InvoiceWithValidation) invoiceWithValidation { validationErrors := slices.Clone(input.ValidationErrors) inv := input.Invoice @@ -134,14 +134,14 @@ func (d *Driver) invoiceToGOBL(input billing.InvoiceWithValidation) invoiceWithV invoice.Meta[InvoiceIDKey] = inv.ID switch inv.Profile.WorkflowConfig.Payment.CollectionMethod { - case billing.CollectionMethodChargeAutomatically: + case billingentity.CollectionMethodChargeAutomatically: invoice.Payment = &bill.Payment{ Terms: &pay.Terms{ Key: pay.TermKeyInstant, }, } - case billing.CollectionMethodSendInvoice: + case billingentity.CollectionMethodSendInvoice: invoice.Payment = &bill.Payment{ Terms: &pay.Terms{ Key: pay.TermKeyDueDate, @@ -190,7 +190,7 @@ func (d *Driver) invoiceToGOBL(input billing.InvoiceWithValidation) invoiceWithV } } -func (d *Driver) invoiceItemToLine(item billing.InvoiceItem, loc *time.Location) (*bill.Line, validation.Errors) { +func (d *Driver) invoiceItemToLine(item billingentity.InvoiceItem, loc *time.Location) (*bill.Line, validation.Errors) { var validationErrs validation.Errors // TODO: for usage based items we need to add a different logic @@ -231,7 +231,7 @@ func (d *Driver) invoiceItemToLine(item billing.InvoiceItem, loc *time.Location) }, validationErrs } -func (d *Driver) invoiceItemLifecycleNote(item billing.InvoiceItem, loc *time.Location) *cbc.Note { +func (d *Driver) invoiceItemLifecycleNote(item billingentity.InvoiceItem, loc *time.Location) *cbc.Note { note := &cbc.Note{ Key: cbc.NoteKeyReason, Code: InvoiceItemCodeLifecycle, @@ -254,7 +254,7 @@ func (d *Driver) invoiceItemLifecycleNote(item billing.InvoiceItem, loc *time.Lo return note } -func (d *Driver) invoiceItemEntityNote(item billing.InvoiceItem) *cbc.Note { +func (d *Driver) invoiceItemEntityNote(item billingentity.InvoiceItem) *cbc.Note { note := &cbc.Note{ Key: cbc.NoteKeyGeneral, Code: InvoiceItemCodeEntity, @@ -268,7 +268,7 @@ func (d *Driver) invoiceItemEntityNote(item billing.InvoiceItem) *cbc.Note { return note } -func (d *Driver) invoiceCustomerToParty(i billing.InvoiceCustomer) (*org.Party, validation.Errors) { +func (d *Driver) invoiceCustomerToParty(i billingentity.InvoiceCustomer) (*org.Party, validation.Errors) { if i.BillingAddress == nil { return nil, validation.Errors{ "billingAddress": ErrMissingCustomerBillingAddress, @@ -303,7 +303,7 @@ func (d *Driver) invoiceCustomerToParty(i billing.InvoiceCustomer) (*org.Party, return party, nil } -func (d *Driver) invoiceSupplierContactToParty(c billing.SupplierContact) *org.Party { +func (d *Driver) invoiceSupplierContactToParty(c billingentity.SupplierContact) *org.Party { party := &org.Party{ Name: c.Name, Addresses: []*org.Address{ diff --git a/openmeter/billing/gobldriver/invoice_test.go b/openmeter/billing/gobldriver/invoice_test.go index 3114bdbc2..fc973aac4 100644 --- a/openmeter/billing/gobldriver/invoice_test.go +++ b/openmeter/billing/gobldriver/invoice_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/require" "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/pkg/currencyx" ) @@ -22,10 +23,10 @@ func TestValidationErrors(t *testing.T) { billingPeriodStart := now.AddDate(0, -1, 0) billingPeriodEnd := now.AddDate(0, 1, 0) - invoice := billing.InvoiceWithValidation{ - Invoice: &billing.Invoice{ + invoice := billingentity.InvoiceWithValidation{ + Invoice: &billingentity.Invoice{ Currency: currencyx.Code(currency.USD), - Items: []billing.InvoiceItem{ + Items: []billingentity.InvoiceItem{ { Name: "item in usd", Quantity: lo.ToPtr(alpacadecimal.NewFromFloat(1)), diff --git a/openmeter/billing/httpdriver/defaults.go b/openmeter/billing/httpdriver/defaults.go new file mode 100644 index 000000000..73e45bdc7 --- /dev/null +++ b/openmeter/billing/httpdriver/defaults.go @@ -0,0 +1,7 @@ +package httpdriver + +const ( + DefaultPageSize = 100 + DefaultPageNumber = 1 + DefaultIncludeArchived = false +) diff --git a/openmeter/billing/httpdriver/errors.go b/openmeter/billing/httpdriver/errors.go new file mode 100644 index 000000000..6e33e898f --- /dev/null +++ b/openmeter/billing/httpdriver/errors.go @@ -0,0 +1,20 @@ +package httpdriver + +import ( + "context" + "net/http" + + "github.com/openmeterio/openmeter/openmeter/billing" + "github.com/openmeterio/openmeter/pkg/framework/commonhttp" + "github.com/openmeterio/openmeter/pkg/framework/transport/httptransport" + "github.com/openmeterio/openmeter/pkg/models" +) + +func errorEncoder() httptransport.ErrorEncoder { + return func(ctx context.Context, err error, w http.ResponseWriter, r *http.Request) bool { + return commonhttp.HandleErrorIfTypeMatches[*models.GenericUserError](ctx, http.StatusBadRequest, err, w) || + commonhttp.HandleErrorIfTypeMatches[billing.NotFoundError](ctx, http.StatusNotFound, err, w) || + commonhttp.HandleErrorIfTypeMatches[billing.ValidationError](ctx, http.StatusBadRequest, err, w) || + commonhttp.HandleErrorIfTypeMatches[billing.UpdateAfterDeleteError](ctx, http.StatusConflict, err, w) + } +} diff --git a/openmeter/billing/httpdriver/handler.go b/openmeter/billing/httpdriver/handler.go new file mode 100644 index 000000000..2802bc583 --- /dev/null +++ b/openmeter/billing/httpdriver/handler.go @@ -0,0 +1,51 @@ +package httpdriver + +import ( + "context" + "errors" + "net/http" + + "github.com/openmeterio/openmeter/openmeter/billing" + "github.com/openmeterio/openmeter/openmeter/namespace/namespacedriver" + "github.com/openmeterio/openmeter/pkg/framework/commonhttp" + "github.com/openmeterio/openmeter/pkg/framework/transport/httptransport" +) + +type Handler interface { + ProfileHandler +} + +type ProfileHandler interface { + CreateProfile() CreateProfileHandler + GetProfile() GetProfileHandler + ArchiveProfile() ArchiveProfileHandler + UpdateProfile() UpdateProfileHandler + ListProfiles() ListProfilesHandler +} + +type handler struct { + service billing.Service + namespaceDecoder namespacedriver.NamespaceDecoder + options []httptransport.HandlerOption +} + +func (h *handler) resolveNamespace(ctx context.Context) (string, error) { + ns, ok := h.namespaceDecoder.GetNamespace(ctx) + if !ok { + return "", commonhttp.NewHTTPError(http.StatusInternalServerError, errors.New("internal server error")) + } + + return ns, nil +} + +func New( + namespaceDecoder namespacedriver.NamespaceDecoder, + service billing.Service, + options ...httptransport.HandlerOption, +) Handler { + return &handler{ + service: service, + namespaceDecoder: namespaceDecoder, + options: options, + } +} diff --git a/openmeter/billing/httpdriver/profile.go b/openmeter/billing/httpdriver/profile.go new file mode 100644 index 000000000..db2ca45fb --- /dev/null +++ b/openmeter/billing/httpdriver/profile.go @@ -0,0 +1,506 @@ +package httpdriver + +import ( + "context" + "errors" + "fmt" + "net/http" + + "github.com/oklog/ulid/v2" + "github.com/samber/lo" + + "github.com/openmeterio/openmeter/api" + appentitybase "github.com/openmeterio/openmeter/openmeter/app/entity/base" + appshttpdriver "github.com/openmeterio/openmeter/openmeter/app/httpdriver" + "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" + "github.com/openmeterio/openmeter/pkg/datex" + "github.com/openmeterio/openmeter/pkg/defaultx" + "github.com/openmeterio/openmeter/pkg/framework/commonhttp" + "github.com/openmeterio/openmeter/pkg/framework/transport/httptransport" + "github.com/openmeterio/openmeter/pkg/models" + "github.com/openmeterio/openmeter/pkg/pagination" + "github.com/openmeterio/openmeter/pkg/sortx" +) + +type ( + CreateProfileRequest = billing.CreateProfileInput + CreateProfileResponse = api.BillingProfile + CreateProfileHandler httptransport.Handler[CreateProfileRequest, CreateProfileResponse] +) + +func (h *handler) CreateProfile() CreateProfileHandler { + return httptransport.NewHandler( + func(ctx context.Context, r *http.Request) (CreateProfileRequest, error) { + body := api.BillingProfileCreateInput{} + if err := commonhttp.JSONRequestBodyDecoder(r, &body); err != nil { + return CreateProfileRequest{}, fmt.Errorf("failed to decode request body: %w", err) + } + + ns, err := h.resolveNamespace(ctx) + if err != nil { + return CreateProfileRequest{}, fmt.Errorf("failed to resolve namespace: %w", err) + } + + workflow, err := fromAPIBillingWorkflow(body.Workflow) + if err != nil { + return CreateProfileRequest{}, fmt.Errorf("failed to parse workflow: %w", err) + } + + return CreateProfileRequest{ + Namespace: ns, + + Name: body.Name, + Description: body.Description, + + Metadata: lo.FromPtrOr(body.Metadata, map[string]string{}), + + Supplier: apiBillingPartyCreateToSupplierContact(body.Supplier), + + Default: body.Default, + + WorkflowConfig: workflow, + Apps: fromAPIBillingProfileCreateAppsInput(body.Apps), + }, nil + }, + func(ctx context.Context, request CreateProfileRequest) (CreateProfileResponse, error) { + profile, err := h.service.CreateProfile(ctx, request) + if err != nil { + return CreateProfileResponse{}, fmt.Errorf("failed to create profile: %w", err) + } + + return MapProfileToApi(profile) + }, + commonhttp.JSONResponseEncoderWithStatus[CreateProfileResponse](http.StatusCreated), + httptransport.AppendOptions( + h.options, + httptransport.WithOperationName("billingCreateProfile"), + httptransport.WithErrorEncoder(errorEncoder()), + )..., + ) +} + +type ( + GetProfileRequest = billing.GetProfileInput + GetProfileResponse = api.BillingProfile + GetProfileHandler httptransport.HandlerWithArgs[GetProfileRequest, GetProfileResponse, string] +) + +func (h *handler) GetProfile() GetProfileHandler { + return httptransport.NewHandlerWithArgs( + func(ctx context.Context, r *http.Request, id string) (GetProfileRequest, error) { + ns, err := h.resolveNamespace(ctx) + if err != nil { + return GetProfileRequest{}, fmt.Errorf("failed to resolve namespace: %w", err) + } + + return GetProfileRequest{ + Namespace: ns, + ID: id, + }, nil + }, + func(ctx context.Context, request GetProfileRequest) (GetProfileResponse, error) { + profile, err := h.service.GetProfile(ctx, request) + if err != nil { + return GetProfileResponse{}, fmt.Errorf("failed to get profile: %w", err) + } + + return MapProfileToApi(profile) + }, + commonhttp.JSONResponseEncoderWithStatus[CreateProfileResponse](http.StatusOK), + httptransport.AppendOptions( + h.options, + httptransport.WithOperationName("billingGetProfile"), + httptransport.WithErrorEncoder(errorEncoder()), + )..., + ) +} + +type ( + ArchiveProfileRequest = billing.DeleteProfileInput + ArchiveProfileResponse = struct{} + ArchiveProfileHandler httptransport.HandlerWithArgs[ArchiveProfileRequest, ArchiveProfileResponse, string] +) + +func (h *handler) ArchiveProfile() ArchiveProfileHandler { + return httptransport.NewHandlerWithArgs( + func(ctx context.Context, r *http.Request, id string) (ArchiveProfileRequest, error) { + ns, err := h.resolveNamespace(ctx) + if err != nil { + return ArchiveProfileRequest{}, fmt.Errorf("failed to resolve namespace: %w", err) + } + + return ArchiveProfileRequest{ + Namespace: ns, + ID: id, + }, nil + }, + func(ctx context.Context, request ArchiveProfileRequest) (ArchiveProfileResponse, error) { + if err := h.service.DeleteProfile(ctx, request); err != nil { + return ArchiveProfileResponse{}, fmt.Errorf("failed to archive profile: %w", err) + } + + return ArchiveProfileResponse{}, nil + }, + commonhttp.JSONResponseEncoderWithStatus[ArchiveProfileResponse](http.StatusNoContent), + httptransport.AppendOptions( + h.options, + httptransport.WithOperationName("billingArchiveProfile"), + httptransport.WithErrorEncoder(errorEncoder()), + )..., + ) +} + +type ( + UpdateProfileRequest = billing.UpdateProfileInput + UpdateProfileResponse = api.BillingProfile + UpdateProfileHandler httptransport.HandlerWithArgs[UpdateProfileRequest, UpdateProfileResponse, string] +) + +func (h *handler) UpdateProfile() UpdateProfileHandler { + return httptransport.NewHandlerWithArgs( + func(ctx context.Context, r *http.Request, id string) (UpdateProfileRequest, error) { + body := api.BillingUpdateProfileJSONRequestBody{} + if err := commonhttp.JSONRequestBodyDecoder(r, &body); err != nil { + return UpdateProfileRequest{}, fmt.Errorf("failed to decode request body: %w", err) + } + + ns, err := h.resolveNamespace(ctx) + if err != nil { + return UpdateProfileRequest{}, fmt.Errorf("failed to resolve namespace: %w", err) + } + + workflow, err := fromAPIBillingWorkflow(body.Workflow) + if err != nil { + return UpdateProfileRequest{}, fmt.Errorf("failed to parse workflow: %w", err) + } + + return UpdateProfileRequest{ + Namespace: ns, + ID: id, + + Name: body.Name, + Description: body.Description, + UpdatedAt: body.UpdatedAt, + + Metadata: lo.FromPtrOr(body.Metadata, map[string]string{}), + + Supplier: apiBillingPartyToSupplierContact(body.Supplier), + + Default: body.Default, + + WorkflowConfig: workflow, + }, nil + }, + func(ctx context.Context, request UpdateProfileRequest) (UpdateProfileResponse, error) { + profile, err := h.service.UpdateProfile(ctx, request) + if err != nil { + return UpdateProfileResponse{}, fmt.Errorf("failed to update profile: %w", err) + } + + return MapProfileToApi(profile) + }, + commonhttp.JSONResponseEncoderWithStatus[UpdateProfileResponse](http.StatusOK), + httptransport.AppendOptions( + h.options, + httptransport.WithOperationName("billingArchiveProfile"), + httptransport.WithErrorEncoder(errorEncoder()), + )..., + ) +} + +type ( + ListProfilesRequest = billing.ListProfilesInput + ListProfilesResponse = api.ProfilePaginatedResponse + ListProfilesParams = api.BillingListProfilesParams + ListProfilesHandler httptransport.HandlerWithArgs[ListProfilesRequest, ListProfilesResponse, ListProfilesParams] +) + +func (h *handler) ListProfiles() ListProfilesHandler { + return httptransport.NewHandlerWithArgs( + func(ctx context.Context, r *http.Request, params ListProfilesParams) (ListProfilesRequest, error) { + ns, err := h.resolveNamespace(ctx) + if err != nil { + return ListProfilesRequest{}, fmt.Errorf("failed to resolve namespace: %w", err) + } + + return ListProfilesRequest{ + Namespace: ns, + IncludeArchived: lo.FromPtrOr(params.IncludeArchived, DefaultIncludeArchived), + OrderBy: lo.FromPtrOr(params.OrderBy, api.BillingProfileOrderByCreatedAt), + Order: sortx.Order(lo.FromPtrOr(params.Order, api.SortOrderDESC)), + + Page: pagination.Page{ + PageSize: defaultx.WithDefault(params.PageSize, DefaultPageSize), + PageNumber: defaultx.WithDefault(params.Page, DefaultPageNumber), + }, + }, nil + }, + func(ctx context.Context, request ListProfilesRequest) (ListProfilesResponse, error) { + profiles, err := h.service.ListProfiles(ctx, request) + if err != nil { + return ListProfilesResponse{}, fmt.Errorf("failed to list profiles: %w", err) + } + + out := ListProfilesResponse{ + Items: make([]api.BillingProfile, 0, len(profiles.Items)), + Page: profiles.Page.PageNumber, + PageSize: profiles.Page.PageSize, + TotalCount: profiles.TotalCount, + } + + for _, profile := range profiles.Items { + apiProfile, err := MapProfileToApi(&profile) + if err != nil { + return ListProfilesResponse{}, fmt.Errorf("failed to convert profile to API: %w", err) + } + + out.Items = append(out.Items, apiProfile) + } + + return out, nil + }, + commonhttp.JSONResponseEncoderWithStatus[ListProfilesResponse](http.StatusOK), + httptransport.AppendOptions( + h.options, + httptransport.WithOperationName("billingArchiveProfile"), + httptransport.WithErrorEncoder(errorEncoder()), + )..., + ) +} + +func apiBillingPartyCreateToSupplierContact(c api.BillingPartyCreate) billingentity.SupplierContact { + out := billingentity.SupplierContact{ + Name: lo.FromPtrOr(c.Name, ""), + } + + if c.Addresses == nil || len(*c.Addresses) == 0 { + return out + } + + if c.TaxId != nil { + out.TaxCode = c.TaxId.Code + } + + addr := (*c.Addresses)[0] + + out.Address = models.Address{ + Country: (*models.CountryCode)(addr.Country), + City: addr.City, + State: addr.State, + PostalCode: addr.PostalCode, + Line1: addr.Line1, + Line2: addr.Line2, + PhoneNumber: addr.PhoneNumber, + } + + return out +} + +func apiBillingPartyToSupplierContact(c api.BillingParty) billingentity.SupplierContact { + out := billingentity.SupplierContact{ + ID: c.Id, + Name: lo.FromPtrOr(c.Name, ""), + } + + if c.Addresses == nil || len(*c.Addresses) == 0 { + return out + } + + if c.TaxId != nil { + out.TaxCode = c.TaxId.Code + } + + addr := (*c.Addresses)[0] + + out.Address = models.Address{ + Country: (*models.CountryCode)(addr.Country), + City: addr.City, + State: addr.State, + PostalCode: addr.PostalCode, + Line1: addr.Line1, + Line2: addr.Line2, + PhoneNumber: addr.PhoneNumber, + } + + return out +} + +func fromAPIBillingProfileCreateAppsInput(i api.BillingProfileCreateAppsInput) billing.CreateProfileAppsInput { + return billing.CreateProfileAppsInput{ + Tax: fromAPIBillingAppIdOrType(i.Tax), + Invoicing: fromAPIBillingAppIdOrType(i.Invoicing), + Payment: fromAPIBillingAppIdOrType(i.Payment), + } +} + +func fromAPIBillingAppIdOrType(i string) billingentity.AppReference { + _, err := ulid.Parse(i) + if err != nil { + return billingentity.AppReference{ + Type: appentitybase.AppType(i), + } + } + + return billingentity.AppReference{ + ID: i, + } +} + +func fromAPIBillingWorkflow(i api.BillingWorkflow) (billingentity.WorkflowConfig, error) { + def := billingentity.DefaultWorkflowConfig + + if i.Collection == nil { + i.Collection = &api.BillingWorkflowCollectionSettings{} + } + + if i.Invoicing == nil { + i.Invoicing = &api.BillingWorkflowInvoicingSettings{} + } + + if i.Payment == nil { + i.Payment = &api.BillingWorkflowPaymentSettings{} + } + + collInterval, err := parseDurationPtr(i.Collection.Interval, def.Collection.Interval) + if err != nil { + return billingentity.WorkflowConfig{}, fmt.Errorf("failed to parse collection interval: %w", err) + } + + draftPeriod, err := parseDurationPtr(i.Invoicing.DraftPeriod, def.Invoicing.DraftPeriod) + if err != nil { + return billingentity.WorkflowConfig{}, fmt.Errorf("failed to parse draft period: %w", err) + } + + dueAfter, err := parseDurationPtr(i.Invoicing.DueAfter, def.Invoicing.DueAfter) + if err != nil { + return billingentity.WorkflowConfig{}, fmt.Errorf("failed to parse due after: %w", err) + } + + return billingentity.WorkflowConfig{ + ID: i.Id, + CreatedAt: i.CreatedAt, + UpdatedAt: i.UpdatedAt, + DeletedAt: i.DeletedAt, + + Collection: billingentity.CollectionConfig{ + Alignment: lo.FromPtrOr((*billingentity.AlignmentKind)(i.Collection.Alignment), def.Collection.Alignment), + Interval: collInterval, + }, + + Invoicing: billingentity.InvoicingConfig{ + AutoAdvance: lo.CoalesceOrEmpty(i.Invoicing.AutoAdvance, def.Invoicing.AutoAdvance), + DraftPeriod: draftPeriod, + DueAfter: dueAfter, + }, + + Payment: billingentity.PaymentConfig{ + CollectionMethod: lo.FromPtrOr((*billingentity.CollectionMethod)(i.Payment.CollectionMethod), def.Payment.CollectionMethod), + }, + }, nil +} + +func parseDurationPtr(d *string, defaultDuration datex.Period) (datex.Period, error) { + if d == nil { + return defaultDuration, nil + } + + return datex.ISOString(*d).Parse() +} + +func MapProfileToApi(p *billingentity.Profile) (api.BillingProfile, error) { + if p == nil { + return api.BillingProfile{}, errors.New("profile is nil") + } + + out := api.BillingProfile{ + Id: p.ID, + CreatedAt: p.CreatedAt, + UpdatedAt: p.UpdatedAt, + DeletedAt: p.DeletedAt, + + Description: p.Description, + Metadata: (*api.Metadata)(lo.EmptyableToPtr(p.Metadata)), + Default: p.Default, + + Name: p.Name, + Supplier: MapSupplierContactToAPI(p.Supplier), + Workflow: MapWorkflowConfigToAPI(p.WorkflowConfig), + } + + if p.Apps != nil { + tax, err := appshttpdriver.MapAppToAPI(p.Apps.Tax) + if err != nil { + return api.BillingProfile{}, fmt.Errorf("cannot map tax app: %w", err) + } + + invoicing, err := appshttpdriver.MapAppToAPI(p.Apps.Invoicing) + if err != nil { + return api.BillingProfile{}, fmt.Errorf("cannot map invoicing app: %w", err) + } + + payment, err := appshttpdriver.MapAppToAPI(p.Apps.Payment) + if err != nil { + return api.BillingProfile{}, fmt.Errorf("cannot map payment app: %w", err) + } + + out.Apps = api.BillingProfileApps{ + Tax: tax, + Invoicing: invoicing, + Payment: payment, + } + } + + return out, nil +} + +func MapSupplierContactToAPI(c billingentity.SupplierContact) api.BillingParty { + a := c.Address + + out := api.BillingParty{ + Name: lo.EmptyableToPtr(c.Name), + Addresses: lo.ToPtr([]api.Address{ + { + Country: (*string)(a.Country), + PostalCode: a.PostalCode, + State: a.State, + City: a.City, + Line1: a.Line1, + Line2: a.Line2, + PhoneNumber: a.PhoneNumber, + }, + }), + } + + if c.TaxCode != nil { + out.TaxId = &api.BillingTaxIdentity{ + Code: c.TaxCode, + } + } + + return out +} + +func MapWorkflowConfigToAPI(c billingentity.WorkflowConfig) api.BillingWorkflow { + return api.BillingWorkflow{ + Id: c.ID, + CreatedAt: c.CreatedAt, + UpdatedAt: c.UpdatedAt, + DeletedAt: c.DeletedAt, + + Collection: &api.BillingWorkflowCollectionSettings{ + Alignment: (*api.BillingWorkflowCollectionAlignment)(lo.EmptyableToPtr(c.Collection.Alignment)), + Interval: lo.EmptyableToPtr(c.Collection.Interval.String()), + }, + + Invoicing: &api.BillingWorkflowInvoicingSettings{ + AutoAdvance: c.Invoicing.AutoAdvance, + DraftPeriod: lo.EmptyableToPtr(c.Invoicing.DraftPeriod.String()), + DueAfter: lo.EmptyableToPtr(c.Invoicing.DueAfter.String()), + }, + + Payment: &api.BillingWorkflowPaymentSettings{ + CollectionMethod: (*api.BillingWorkflowCollectionMethod)(lo.EmptyableToPtr(string(c.Payment.CollectionMethod))), + }, + } +} diff --git a/openmeter/billing/invoiceitem.go b/openmeter/billing/invoiceitem.go index ad8c7edfc..52b79b2a9 100644 --- a/openmeter/billing/invoiceitem.go +++ b/openmeter/billing/invoiceitem.go @@ -3,109 +3,14 @@ package billing import ( "errors" "fmt" - "time" - "github.com/alpacahq/alpacadecimal" - - "github.com/openmeterio/openmeter/pkg/currencyx" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" ) -type InvoiceItemType string - -const ( - // InvoiceItemTypeStatic is a static item that is not calculated based on usage. - InvoiceItemTypeStatic InvoiceItemType = "static" - // InvoiceItemTypeUsage is an item that is calculated based on usage. - InvoiceItemTypeUsage InvoiceItemType = "usage" -) - -func (InvoiceItemType) Values() []string { - return []string{ - string(InvoiceItemTypeStatic), - string(InvoiceItemTypeUsage), - } -} - -type InvoiceItem struct { - Namespace string `json:"namespace"` - ID string `json:"id"` - - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - DeletedAt *time.Time `json:"deletedAt,omitempty"` - - Metadata map[string]string `json:"metadata"` - InvoiceID *string `json:"invoiceID,omitempty"` - CustomerID string `json:"customer"` - - // Lifecycle - PeriodStart time.Time `json:"periodStart"` - PeriodEnd time.Time `json:"periodEnd"` - InvoiceAt time.Time `json:"invoiceAt"` - - // Item details - Name string `json:"name"` - Type InvoiceItemType `json:"type"` - Quantity *alpacadecimal.Decimal `json:"quantity"` - UnitPrice alpacadecimal.Decimal `json:"unitPrice"` - Currency currencyx.Code `json:"currency"` - - TaxCodeOverride TaxOverrides `json:"taxCodeOverride"` -} - -func (i InvoiceItem) Validate() error { - if i.Namespace == "" { - return errors.New("namespace is required") - } - - if i.CustomerID == "" { - return errors.New("customer id is required") - } - - if i.PeriodStart.IsZero() { - return errors.New("period start is required") - } - - if i.PeriodEnd.IsZero() { - return errors.New("period end is required") - } - - if i.InvoiceAt.IsZero() { - return errors.New("invoice at is required") - } - - if i.Name == "" { - return errors.New("name is required") - } - - if i.Type == "" { - return errors.New("type is required") - } - - if i.Type != InvoiceItemTypeStatic { - // TODO: support usage items - return errors.New("only static items are supported") - } - - if i.Type == InvoiceItemTypeStatic && (i.Quantity == nil || i.Quantity.IsZero()) { - return errors.New("quantity is required for static items") - } - - if i.UnitPrice.IsZero() { - return errors.New("unit price is required") - } - - if i.Currency == "" { - return errors.New("currency is required") - } - - return nil -} - type CreateInvoiceItemsInput struct { InvoiceID *string Namespace string - Items []InvoiceItem + Items []billingentity.InvoiceItem } func (c CreateInvoiceItemsInput) Validate() error { diff --git a/openmeter/billing/profile.go b/openmeter/billing/profile.go index eaed543b1..b6a14a22b 100644 --- a/openmeter/billing/profile.go +++ b/openmeter/billing/profile.go @@ -3,289 +3,109 @@ package billing import ( "errors" "fmt" - "time" "github.com/samber/lo" - "github.com/openmeterio/openmeter/openmeter/billing/provider" - customerentity "github.com/openmeterio/openmeter/openmeter/customer/entity" - "github.com/openmeterio/openmeter/pkg/models" - "github.com/openmeterio/openmeter/pkg/timezone" + "github.com/openmeterio/openmeter/api" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" + "github.com/openmeterio/openmeter/pkg/pagination" + "github.com/openmeterio/openmeter/pkg/sortx" ) -// AlignmentKind specifies what governs when an invoice is issued -type AlignmentKind string - -const ( - // AlignmentKindSubscription specifies that the invoice is issued based on the subscription period ( - // e.g. whenever a due line item is added, it will trigger an invoice generation after the collection period) - AlignmentKindSubscription AlignmentKind = "subscription" -) - -func (k AlignmentKind) Values() []string { - return []string{ - string(AlignmentKindSubscription), - } -} - -type WorkflowConfig struct { - ID string `json:"id"` - - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - DeletedAt *time.Time `json:"deletedAt"` - - Timezone *timezone.Timezone `json:"timezone,omitempty"` - - Collection CollectionConfig `json:"collection"` - Invoicing InvoicingConfig `json:"invoicing"` - Payment PaymentConfig `json:"payment"` +type CreateWorkflowConfigInput struct { + billingentity.WorkflowConfig } -func (c WorkflowConfig) Validate() error { - if err := c.Collection.Validate(); err != nil { - return fmt.Errorf("invalid collection config: %w", err) - } - - if err := c.Invoicing.Validate(); err != nil { - return fmt.Errorf("invalid invoice config: %w", err) - } - - if err := c.Payment.Validate(); err != nil { - return fmt.Errorf("invalid payment config: %w", err) - } +type CreateProfileInput struct { + Namespace string `json:"namespace"` + Name string `json:"name"` + Description *string `json:"description"` + Metadata map[string]string `json:"metadata"` + Supplier billingentity.SupplierContact `json:"supplier"` + Default bool `json:"default"` - return nil + WorkflowConfig billingentity.WorkflowConfig `json:"workflowConfig"` + Apps CreateProfileAppsInput `json:"apps"` } -// CollectionConfig groups fields related to item collection. -type CollectionConfig struct { - Alignment AlignmentKind `json:"alignment"` - ItemCollectionPeriod time.Duration `json:"itemCollectionPeriod,omitempty"` -} - -func (c *CollectionConfig) Validate() error { - if c.Alignment != AlignmentKindSubscription { - return fmt.Errorf("invalid alignment: %s", c.Alignment) - } - - if c.ItemCollectionPeriod < 0 { - return fmt.Errorf("item collection period must be greater or equal to 0") - } - - return nil -} - -// InvoiceConfig groups fields related to invoice settings. -type InvoicingConfig struct { - AutoAdvance bool `json:"autoAdvance"` - DraftPeriod time.Duration `json:"draftPeriod,omitempty"` - DueAfter time.Duration `json:"dueAfter"` - - ItemResolution GranularityResolution `json:"itemResolution"` - ItemPerSubject bool `json:"itemPerSubject"` -} - -func (c *InvoicingConfig) Validate() error { - if c.DraftPeriod < 0 && c.AutoAdvance { - return fmt.Errorf("draft period must be greater or equal to 0") - } - - if c.DueAfter < 0 { - return fmt.Errorf("due after must be greater or equal to 0") - } - - switch c.ItemResolution { - case GranularityResolutionDay, GranularityResolutionPeriod: - default: - return fmt.Errorf("invalid line item resolution: %s", c.ItemResolution) - } - - return nil -} - -type GranularityResolution string - -const ( - // GranularityResolutionDay provides line items for metered data per day - GranularityResolutionDay GranularityResolution = "day" - // GranularityResolutionPeriod provides one line item per period - GranularityResolutionPeriod GranularityResolution = "period" -) - -func (r GranularityResolution) Values() []string { - return []string{ - string(GranularityResolutionDay), - string(GranularityResolutionPeriod), - } -} - -type PaymentConfig struct { - CollectionMethod CollectionMethod -} - -func (c *PaymentConfig) Validate() error { - switch c.CollectionMethod { - case CollectionMethodChargeAutomatically, CollectionMethodSendInvoice: - default: - return fmt.Errorf("invalid collection method: %s", c.CollectionMethod) - } - - return nil -} - -type CollectionMethod string - -const ( - // CollectionMethodChargeAutomatically charges the customer automatically based on previously saved card data - CollectionMethodChargeAutomatically CollectionMethod = "charge_automatically" - // CollectionMethodSendInvoice sends an invoice to the customer along with the payment instructions/links - CollectionMethodSendInvoice CollectionMethod = "send_invoice" -) - -func (c CollectionMethod) Values() []string { - return []string{ - string(CollectionMethodChargeAutomatically), - string(CollectionMethodSendInvoice), - } -} - -type SupplierContact struct { - Name string `json:"name"` - Address models.Address `json:"address"` -} - -// Validate checks if the supplier contact is valid for invoice generation (e.g. Country is required) -func (c SupplierContact) Validate() error { - if c.Name == "" { - return errors.New("name is required") - } - - if c.Address.Country == nil { - return errors.New("country is required") - } - - return nil -} - -type Profile struct { - ID string `json:"id"` - Namespace string `json:"namespace"` - - Name string `json:"name"` - Description *string `json:"description"` - - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - DeletedAt *time.Time `json:"deletedAt"` - - TaxConfiguration provider.TaxConfiguration `json:"tax"` - InvoicingConfiguration provider.InvoicingConfiguration `json:"invoicing"` - PaymentConfiguration provider.PaymentConfiguration `json:"payment"` - - WorkflowConfig WorkflowConfig `json:"workflow"` - - Supplier SupplierContact `json:"supplier"` - - Default bool `json:"default"` -} - -func (p Profile) Validate() error { - if p.Namespace == "" { +func (i CreateProfileInput) Validate() error { + if i.Namespace == "" { return errors.New("namespace is required") } - if p.Name == "" { + if i.Name == "" { return errors.New("name is required") } - if err := p.TaxConfiguration.Validate(); err != nil { - return fmt.Errorf("invalid tax configuration: %w", err) - } - - if err := p.InvoicingConfiguration.Validate(); err != nil { - return fmt.Errorf("invalid invoicing configuration: %w", err) - } - - if err := p.PaymentConfiguration.Validate(); err != nil { - return fmt.Errorf("invalid payment configuration: %w", err) + if err := i.Supplier.Validate(); err != nil { + return fmt.Errorf("invalid supplier: %w", err) } - if err := p.WorkflowConfig.Validate(); err != nil { - return fmt.Errorf("invalid workflow configuration: %w", err) + if err := i.WorkflowConfig.Validate(); err != nil { + return fmt.Errorf("invalid workflow config: %w", err) } - if err := p.Supplier.Validate(); err != nil { - return fmt.Errorf("invalid supplier: %w", err) + if err := i.Apps.Validate(); err != nil { + return fmt.Errorf("invalid apps: %w", err) } return nil } -func (p Profile) Merge(o *CustomerOverride) Profile { - p.WorkflowConfig.Collection = CollectionConfig{ - Alignment: lo.FromPtrOr(o.Collection.Alignment, p.WorkflowConfig.Collection.Alignment), - ItemCollectionPeriod: lo.FromPtrOr(o.Collection.ItemCollectionPeriod, p.WorkflowConfig.Collection.ItemCollectionPeriod), - } - - p.WorkflowConfig.Invoicing = InvoicingConfig{ - AutoAdvance: lo.FromPtrOr(o.Invoicing.AutoAdvance, p.WorkflowConfig.Invoicing.AutoAdvance), - DraftPeriod: lo.FromPtrOr(o.Invoicing.DraftPeriod, p.WorkflowConfig.Invoicing.DraftPeriod), - DueAfter: lo.FromPtrOr(o.Invoicing.DueAfter, p.WorkflowConfig.Invoicing.DueAfter), - ItemResolution: lo.FromPtrOr(o.Invoicing.ItemResolution, p.WorkflowConfig.Invoicing.ItemResolution), - ItemPerSubject: lo.FromPtrOr(o.Invoicing.ItemPerSubject, p.WorkflowConfig.Invoicing.ItemPerSubject), - } - - p.WorkflowConfig.Payment = PaymentConfig{ - CollectionMethod: lo.FromPtrOr(o.Payment.CollectionMethod, p.WorkflowConfig.Payment.CollectionMethod), +func (i CreateProfileInput) WithDefaults() CreateProfileInput { + i.WorkflowConfig = billingentity.WorkflowConfig{ + Collection: billingentity.CollectionConfig{ + Alignment: lo.CoalesceOrEmpty( + i.WorkflowConfig.Collection.Alignment, + billingentity.DefaultWorkflowConfig.Collection.Alignment), + Interval: lo.CoalesceOrEmpty( + i.WorkflowConfig.Collection.Interval, + billingentity.DefaultWorkflowConfig.Collection.Interval), + }, + Invoicing: billingentity.InvoicingConfig{ + AutoAdvance: lo.CoalesceOrEmpty( + i.WorkflowConfig.Invoicing.AutoAdvance, + billingentity.DefaultWorkflowConfig.Invoicing.AutoAdvance), + DraftPeriod: lo.CoalesceOrEmpty( + i.WorkflowConfig.Invoicing.DraftPeriod, + billingentity.DefaultWorkflowConfig.Invoicing.DraftPeriod), + DueAfter: lo.CoalesceOrEmpty( + i.WorkflowConfig.Invoicing.DueAfter, + billingentity.DefaultWorkflowConfig.Invoicing.DueAfter), + }, + Payment: billingentity.PaymentConfig{ + CollectionMethod: lo.CoalesceOrEmpty( + i.WorkflowConfig.Payment.CollectionMethod, + billingentity.DefaultWorkflowConfig.Payment.CollectionMethod), + }, } - return p -} - -type ProfileWithCustomerDetails struct { - Profile Profile `json:"profile"` - Customer customerentity.Customer `json:"customer"` + return i } -func (p ProfileWithCustomerDetails) Validate() error { - if err := p.Profile.Validate(); err != nil { - return fmt.Errorf("invalid profile: %w", err) - } +type CreateProfileAppsInput = billingentity.ProfileAppReferences - return nil -} +type ListProfilesResult = pagination.PagedResponse[billingentity.Profile] -type CreateProfileInput Profile +type ListProfilesInput struct { + pagination.Page -func (i CreateProfileInput) Validate() error { - return Profile(i).Validate() + Namespace string + IncludeArchived bool + OrderBy api.BillingProfileOrderBy + Order sortx.Order } -// WithDefaults sets the default values for the profile input if not provided, -// this is useful as the object is pretty big and we don't want to set all the fields -func (i CreateProfileInput) WithDefaults() CreateProfileInput { - if i.WorkflowConfig.Invoicing.ItemResolution == "" { - i.WorkflowConfig.Invoicing.ItemResolution = GranularityResolutionPeriod - } - - if i.WorkflowConfig.Collection.Alignment == "" { - i.WorkflowConfig.Collection.Alignment = AlignmentKindSubscription - } - - if i.WorkflowConfig.Payment.CollectionMethod == "" { - i.WorkflowConfig.Payment.CollectionMethod = CollectionMethodChargeAutomatically - } - - if i.WorkflowConfig.Invoicing.DueAfter == 0 { - i.WorkflowConfig.Invoicing.DueAfter = 30 * 24 * time.Hour +func (i ListProfilesInput) Validate() error { + if i.Namespace == "" { + return errors.New("namespace is required") } - if i.WorkflowConfig.Invoicing.DraftPeriod == 0 { - i.WorkflowConfig.Invoicing.DraftPeriod = 24 * time.Hour + if err := i.Page.Validate(); err != nil { + return fmt.Errorf("error validating page: %w", err) } - return i + return nil } type GetDefaultProfileInput struct { @@ -329,12 +149,45 @@ func (i DeleteProfileInput) Validate() error { return genericNamespaceID(i).Validate() } -type UpdateProfileInput Profile +type UpdateProfileInput billingentity.BaseProfile func (i UpdateProfileInput) Validate() error { if i.ID == "" { return errors.New("id is required") } - return Profile(i).Validate() + if i.AppReferences != nil { + return errors.New("apps cannot be updated") + } + + return billingentity.BaseProfile(i).Validate() +} + +type UpdateProfileAdapterInput struct { + TargetState billingentity.BaseProfile + WorkflowConfigID string +} + +func (i UpdateProfileAdapterInput) Validate() error { + if err := i.TargetState.Validate(); err != nil { + return fmt.Errorf("error validating target state profile: %w", err) + } + + if i.TargetState.ID == "" { + return fmt.Errorf("id is required") + } + + if i.TargetState.UpdatedAt.IsZero() { + return fmt.Errorf("updated at is required") + } + + if i.WorkflowConfigID == "" { + return fmt.Errorf("workflow config id is required") + } + + if i.TargetState.WorkflowConfig.Invoicing.AutoAdvance == nil { + return fmt.Errorf("invoicing auto advance is required") + } + + return nil } diff --git a/openmeter/billing/provider/api/api.go b/openmeter/billing/provider/api/api.go deleted file mode 100644 index 2ee4afa8d..000000000 --- a/openmeter/billing/provider/api/api.go +++ /dev/null @@ -1,28 +0,0 @@ -package providerapi - -import ( - "context" - - "github.com/openmeterio/openmeter/openmeter/billing" -) - -type InvoiceValidator interface { - // ValidateInvoice validates the given invoice, called by the gobldriver and the returned - // error(s) are added to the global error list. Notes: - // - please use errors.join to combine multiple errors, they will be unwrapped by the gobldriver - // - please use github.com/invopop/validation.NewError to create new errors, so that error codes are present - // in the validation results - ValidateInvoice(context.Context, billing.Invoice) error -} - -type TaxProvider interface { - InvoiceValidator -} - -type InvoiceProvider interface { - InvoiceValidator -} - -type PaymentProvider interface { - InvoiceValidator -} diff --git a/openmeter/billing/provider/config.go b/openmeter/billing/provider/config.go deleted file mode 100644 index 376e7cdb8..000000000 --- a/openmeter/billing/provider/config.go +++ /dev/null @@ -1,122 +0,0 @@ -package provider - -import ( - "fmt" - - "github.com/openmeterio/openmeter/openmeter/billing/provider/openmetersandbox" - "github.com/openmeterio/openmeter/openmeter/billing/provider/stripe" -) - -// Type specifies the provider used for billing -type Type string - -const ( - // TypeOpenMeterSandbox specifies the OpenMeter billing provider, which is a dummy billing provider mostly useful for testing and - // initial OpenMeter assessment - TypeOpenMeterSandbox Type = "openmeter_sandbox" - // TypeStripe specifies the Stripe billing provider, which is a real billing provider that can be used in production - TypeStripe Type = "stripe" -) - -func (t Type) Values() []string { - return []string{ - string(TypeOpenMeterSandbox), - string(TypeStripe), - } -} - -type TaxProvider string - -var ( - TaxProviderOpenMeterSandbox TaxProvider = TaxProvider(TypeOpenMeterSandbox) - TaxProviderStripeTax TaxProvider = TaxProvider(TypeStripe) -) - -func (k TaxProvider) Values() []string { - return []string{ - string(TaxProviderOpenMeterSandbox), - string(TaxProviderStripeTax), - } -} - -type TaxConfiguration struct { - Type TaxProvider `json:"type"` - - OpenMeter openmetersandbox.TaxConfiguration - Stripe stripe.TaxConfiguration -} - -func (c *TaxConfiguration) Validate() error { - switch c.Type { - case TaxProviderOpenMeterSandbox: - return c.OpenMeter.Validate() - case TaxProviderStripeTax: - return c.Stripe.Validate() - default: - return fmt.Errorf("unknown tax provider: %s", c.Type) - } -} - -type InvoicingProvider string - -var ( - InvoicingProviderOpenMeterSandbox InvoicingProvider = InvoicingProvider(TypeOpenMeterSandbox) - InvoicingProviderStripeInvoicing InvoicingProvider = InvoicingProvider(TypeStripe) -) - -func (k InvoicingProvider) Values() []string { - return []string{ - string(InvoicingProviderOpenMeterSandbox), - string(InvoicingProviderStripeInvoicing), - } -} - -type InvoicingConfiguration struct { - Type InvoicingProvider `json:"type"` - - OpenMeter openmetersandbox.InvoicingConfiguration - Stripe stripe.InvoicingConfiguration -} - -func (c *InvoicingConfiguration) Validate() error { - switch c.Type { - case InvoicingProviderOpenMeterSandbox: - return c.OpenMeter.Validate() - case InvoicingProviderStripeInvoicing: - return c.Stripe.Validate() - default: - return fmt.Errorf("unknown invoicing provider: %s", c.Type) - } -} - -type PaymentProvider string - -var ( - PaymentProviderOpenMeterSandbox PaymentProvider = "openmeter_sandbox" - PaymentProviderStripePayments PaymentProvider = "stripe_payments" -) - -func (k PaymentProvider) Values() []string { - return []string{ - string(PaymentProviderOpenMeterSandbox), - string(PaymentProviderStripePayments), - } -} - -type PaymentConfiguration struct { - Type PaymentProvider `json:"type"` - - OpenMeter openmetersandbox.PaymentConfiguration - Stripe stripe.PaymentConfiguration -} - -func (c *PaymentConfiguration) Validate() error { - switch c.Type { - case PaymentProviderOpenMeterSandbox: - return c.OpenMeter.Validate() - case PaymentProviderStripePayments: - return c.Stripe.Validate() - default: - return fmt.Errorf("unknown payment provider: %s", c.Type) - } -} diff --git a/openmeter/billing/provider/openmetersandbox/provider.go b/openmeter/billing/provider/openmetersandbox/provider.go deleted file mode 100644 index fce4293da..000000000 --- a/openmeter/billing/provider/openmetersandbox/provider.go +++ /dev/null @@ -1,37 +0,0 @@ -package openmetersandbox - -type TaxConfiguration struct{} - -func (t *TaxConfiguration) Validate() error { - return nil -} - -type InvoicingConfiguration struct{} - -func (t *InvoicingConfiguration) Validate() error { - return nil -} - -type PaymentConfiguration struct{} - -func (t *PaymentConfiguration) Validate() error { - return nil -} - -type TaxState struct{} - -func (t *TaxState) Validate() error { - return nil -} - -type InvoicingState struct{} - -func (t *InvoicingState) Validate() error { - return nil -} - -type PaymentState struct{} - -func (t *PaymentState) Validate() error { - return nil -} diff --git a/openmeter/billing/provider/stripe/provider.go b/openmeter/billing/provider/stripe/provider.go deleted file mode 100644 index b5918e47c..000000000 --- a/openmeter/billing/provider/stripe/provider.go +++ /dev/null @@ -1,37 +0,0 @@ -package stripe - -type TaxConfiguration struct{} - -func (t *TaxConfiguration) Validate() error { - return nil -} - -type InvoicingConfiguration struct{} - -func (t *InvoicingConfiguration) Validate() error { - return nil -} - -type PaymentConfiguration struct{} - -func (t *PaymentConfiguration) Validate() error { - return nil -} - -type TaxState struct{} - -func (t *TaxState) Validate() error { - return nil -} - -type InvoicingState struct{} - -func (t *InvoicingState) Validate() error { - return nil -} - -type PaymentState struct{} - -func (t *PaymentState) Validate() error { - return nil -} diff --git a/openmeter/billing/service.go b/openmeter/billing/service.go index 2d600a0ad..ab72a24f2 100644 --- a/openmeter/billing/service.go +++ b/openmeter/billing/service.go @@ -3,6 +3,7 @@ package billing import ( "context" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" customerentity "github.com/openmeterio/openmeter/openmeter/customer/entity" ) @@ -14,24 +15,25 @@ type Service interface { } type ProfileService interface { - CreateProfile(ctx context.Context, param CreateProfileInput) (*Profile, error) - GetDefaultProfile(ctx context.Context, input GetDefaultProfileInput) (*Profile, error) - GetProfile(ctx context.Context, input GetProfileInput) (*Profile, error) + CreateProfile(ctx context.Context, param CreateProfileInput) (*billingentity.Profile, error) + GetDefaultProfile(ctx context.Context, input GetDefaultProfileInput) (*billingentity.Profile, error) + GetProfile(ctx context.Context, input GetProfileInput) (*billingentity.Profile, error) + ListProfiles(ctx context.Context, input ListProfilesInput) (ListProfilesResult, error) DeleteProfile(ctx context.Context, input DeleteProfileInput) error - UpdateProfile(ctx context.Context, input UpdateProfileInput) (*Profile, error) + UpdateProfile(ctx context.Context, input UpdateProfileInput) (*billingentity.Profile, error) } type CustomerOverrideService interface { - CreateCustomerOverride(ctx context.Context, input CreateCustomerOverrideInput) (*CustomerOverride, error) - UpdateCustomerOverride(ctx context.Context, input UpdateCustomerOverrideInput) (*CustomerOverride, error) - GetCustomerOverride(ctx context.Context, input GetCustomerOverrideInput) (*CustomerOverride, error) + CreateCustomerOverride(ctx context.Context, input CreateCustomerOverrideInput) (*billingentity.CustomerOverride, error) + UpdateCustomerOverride(ctx context.Context, input UpdateCustomerOverrideInput) (*billingentity.CustomerOverride, error) + GetCustomerOverride(ctx context.Context, input GetCustomerOverrideInput) (*billingentity.CustomerOverride, error) DeleteCustomerOverride(ctx context.Context, input DeleteCustomerOverrideInput) error - GetProfileWithCustomerOverride(ctx context.Context, input GetProfileWithCustomerOverrideInput) (*ProfileWithCustomerDetails, error) + GetProfileWithCustomerOverride(ctx context.Context, input GetProfileWithCustomerOverrideInput) (*billingentity.ProfileWithCustomerDetails, error) } type InvoiceItemService interface { - CreateInvoiceItems(ctx context.Context, input CreateInvoiceItemsInput) ([]InvoiceItem, error) + CreateInvoiceItems(ctx context.Context, input CreateInvoiceItemsInput) ([]billingentity.InvoiceItem, error) } type InvoiceService interface { @@ -39,5 +41,5 @@ type InvoiceService interface { // The call can return any number of invoices based on multiple factors: // - The customer has multiple currencies (e.g. USD and EUR) // - [later] The provider can also mandate separate invoices if needed - GetPendingInvoiceItems(ctx context.Context, customerID customerentity.CustomerID) ([]InvoiceWithValidation, error) + GetPendingInvoiceItems(ctx context.Context, customerID customerentity.CustomerID) ([]billingentity.InvoiceWithValidation, error) } diff --git a/openmeter/billing/service/customeroverride.go b/openmeter/billing/service/customeroverride.go index 9bfcfcc23..c2b2013fd 100644 --- a/openmeter/billing/service/customeroverride.go +++ b/openmeter/billing/service/customeroverride.go @@ -4,20 +4,22 @@ import ( "context" "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" customerentity "github.com/openmeterio/openmeter/openmeter/customer/entity" + "github.com/openmeterio/openmeter/pkg/framework/entutils" ) var _ billing.CustomerOverrideService = (*Service)(nil) -func (s *Service) CreateCustomerOverride(ctx context.Context, input billing.CreateCustomerOverrideInput) (*billing.CustomerOverride, error) { +func (s *Service) CreateCustomerOverride(ctx context.Context, input billing.CreateCustomerOverrideInput) (*billingentity.CustomerOverride, error) { if err := input.Validate(); err != nil { return nil, billing.ValidationError{ Err: err, } } - return billing.WithTx(ctx, s.adapter, func(ctx context.Context, adapter billing.TxAdapter) (*billing.CustomerOverride, error) { - existingOverride, err := adapter.GetCustomerOverride(ctx, billing.GetCustomerOverrideAdapterInput{ + adapterOverride, err := entutils.TransactingRepo(ctx, s.adapter, func(ctx context.Context, txAdapter billing.Adapter) (*billingentity.CustomerOverride, error) { + existingOverride, err := txAdapter.GetCustomerOverride(ctx, billing.GetCustomerOverrideAdapterInput{ Namespace: input.Namespace, CustomerID: input.CustomerID, @@ -27,9 +29,28 @@ func (s *Service) CreateCustomerOverride(ctx context.Context, input billing.Crea return nil, err } + // The user doesn't specified a profile, let's use the default + if input.ProfileID == "" { + defaultProfile, err := txAdapter.GetDefaultProfile(ctx, billing.GetDefaultProfileInput{ + Namespace: input.Namespace, + }) + if err != nil { + return nil, err + } + + if defaultProfile == nil { + return nil, billing.NotFoundError{ + Entity: billing.EntityDefaultProfile, + Err: billing.ErrDefaultProfileNotFound, + } + } + + input.ProfileID = defaultProfile.ID + } + if existingOverride != nil { // We have an existing override, let's rather update it - return adapter.UpdateCustomerOverride(ctx, billing.UpdateCustomerOverrideAdapterInput{ + return txAdapter.UpdateCustomerOverride(ctx, billing.UpdateCustomerOverrideAdapterInput{ UpdateCustomerOverrideInput: billing.UpdateCustomerOverrideInput{ Namespace: input.Namespace, CustomerID: input.CustomerID, @@ -45,19 +66,24 @@ func (s *Service) CreateCustomerOverride(ctx context.Context, input billing.Crea }) } - return adapter.CreateCustomerOverride(ctx, input) + return txAdapter.CreateCustomerOverride(ctx, input) }) + if err != nil { + return nil, err + } + + return s.resolveCustomerOverride(ctx, adapterOverride) } -func (s *Service) UpdateCustomerOverride(ctx context.Context, input billing.UpdateCustomerOverrideInput) (*billing.CustomerOverride, error) { +func (s *Service) UpdateCustomerOverride(ctx context.Context, input billing.UpdateCustomerOverrideInput) (*billingentity.CustomerOverride, error) { if err := input.Validate(); err != nil { return nil, billing.ValidationError{ Err: err, } } - return billing.WithTx(ctx, s.adapter, func(ctx context.Context, adapter billing.TxAdapter) (*billing.CustomerOverride, error) { - existingOverride, err := adapter.GetCustomerOverride(ctx, billing.GetCustomerOverrideAdapterInput{ + return entutils.TransactingRepo(ctx, s.adapter, func(ctx context.Context, txAdapter billing.Adapter) (*billingentity.CustomerOverride, error) { + existingOverride, err := txAdapter.GetCustomerOverride(ctx, billing.GetCustomerOverrideAdapterInput{ Namespace: input.Namespace, CustomerID: input.CustomerID, }) @@ -79,20 +105,25 @@ func (s *Service) UpdateCustomerOverride(ctx context.Context, input billing.Upda } } - return adapter.UpdateCustomerOverride(ctx, billing.UpdateCustomerOverrideAdapterInput{ + override, err := txAdapter.UpdateCustomerOverride(ctx, billing.UpdateCustomerOverrideAdapterInput{ UpdateCustomerOverrideInput: input, }) + if err != nil { + return nil, err + } + + return s.resolveCustomerOverride(ctx, override) }) } -func (s *Service) GetCustomerOverride(ctx context.Context, input billing.GetCustomerOverrideInput) (*billing.CustomerOverride, error) { +func (s *Service) GetCustomerOverride(ctx context.Context, input billing.GetCustomerOverrideInput) (*billingentity.CustomerOverride, error) { if err := input.Validate(); err != nil { return nil, billing.ValidationError{ Err: err, } } - override, err := s.adapter.GetCustomerOverride(ctx, billing.GetCustomerOverrideAdapterInput{ + adapterOverride, err := s.adapter.GetCustomerOverride(ctx, billing.GetCustomerOverrideAdapterInput{ Namespace: input.Namespace, CustomerID: input.CustomerID, @@ -102,7 +133,7 @@ func (s *Service) GetCustomerOverride(ctx context.Context, input billing.GetCust return nil, err } - if override == nil { + if adapterOverride == nil { return nil, billing.NotFoundError{ ID: input.CustomerID, Entity: billing.EntityCustomerOverride, @@ -110,7 +141,7 @@ func (s *Service) GetCustomerOverride(ctx context.Context, input billing.GetCust } } - return override, nil + return s.resolveCustomerOverride(ctx, adapterOverride) } func (s *Service) DeleteCustomerOverride(ctx context.Context, input billing.DeleteCustomerOverrideInput) error { @@ -120,8 +151,8 @@ func (s *Service) DeleteCustomerOverride(ctx context.Context, input billing.Dele } } - return billing.WithTxNoValue(ctx, s.adapter, func(ctx context.Context, adapter billing.TxAdapter) error { - existingOverride, err := adapter.GetCustomerOverride(ctx, billing.GetCustomerOverrideAdapterInput{ + return entutils.TransactingRepoWithNoValue(ctx, s.adapter, func(ctx context.Context, txAdapter billing.Adapter) error { + existingOverride, err := txAdapter.GetCustomerOverride(ctx, billing.GetCustomerOverrideAdapterInput{ Namespace: input.Namespace, CustomerID: input.CustomerID, @@ -147,17 +178,17 @@ func (s *Service) DeleteCustomerOverride(ctx context.Context, input billing.Dele } } - return adapter.DeleteCustomerOverride(ctx, input) + return txAdapter.DeleteCustomerOverride(ctx, input) }) } -func (s *Service) GetProfileWithCustomerOverride(ctx context.Context, input billing.GetProfileWithCustomerOverrideInput) (*billing.ProfileWithCustomerDetails, error) { - return billing.WithTx(ctx, s.adapter, func(ctx context.Context, adapter billing.TxAdapter) (*billing.ProfileWithCustomerDetails, error) { - return s.getProfileWithCustomerOverride(ctx, adapter, input) +func (s *Service) GetProfileWithCustomerOverride(ctx context.Context, input billing.GetProfileWithCustomerOverrideInput) (*billingentity.ProfileWithCustomerDetails, error) { + return entutils.TransactingRepo(ctx, s.adapter, func(ctx context.Context, txAdapter billing.Adapter) (*billingentity.ProfileWithCustomerDetails, error) { + return s.getProfileWithCustomerOverride(ctx, txAdapter, input) }) } -func (s *Service) getProfileWithCustomerOverride(ctx context.Context, adapter billing.TxAdapter, input billing.GetProfileWithCustomerOverrideInput) (*billing.ProfileWithCustomerDetails, error) { +func (s *Service) getProfileWithCustomerOverride(ctx context.Context, adapter billing.Adapter, input billing.GetProfileWithCustomerOverrideInput) (*billingentity.ProfileWithCustomerDetails, error) { if err := input.Validate(); err != nil { return nil, billing.ValidationError{ Err: err, @@ -184,7 +215,7 @@ func (s *Service) getProfileWithCustomerOverride(ctx context.Context, adapter bi billingProfileWithOverrides.WorkflowConfig.Timezone = customer.Timezone } - return &billing.ProfileWithCustomerDetails{ + return &billingentity.ProfileWithCustomerDetails{ Profile: *billingProfileWithOverrides, Customer: *customer, }, nil @@ -194,8 +225,8 @@ func (s *Service) getProfileWithCustomerOverride(ctx context.Context, adapter bi // if any. If there are no overrides, it returns the default billing profile. // // This function does not perform validations or customer entity overrides. -func (s *Service) getProfileWithCustomerOverrideMerges(ctx context.Context, adapter billing.TxAdapter, input billing.GetProfileWithCustomerOverrideInput) (*billing.Profile, error) { - override, err := adapter.GetCustomerOverride(ctx, billing.GetCustomerOverrideAdapterInput{ +func (s *Service) getProfileWithCustomerOverrideMerges(ctx context.Context, adapter billing.Adapter, input billing.GetProfileWithCustomerOverrideInput) (*billingentity.Profile, error) { + adapterOverride, err := adapter.GetCustomerOverride(ctx, billing.GetCustomerOverrideAdapterInput{ Namespace: input.Namespace, CustomerID: input.CustomerID, }) @@ -203,6 +234,11 @@ func (s *Service) getProfileWithCustomerOverrideMerges(ctx context.Context, adap return nil, err } + override, err := s.resolveCustomerOverride(ctx, adapterOverride) + if err != nil { + return nil, err + } + if override == nil || override.DeletedAt != nil { // Let's fetch the default billing profile defaultProfile, err := adapter.GetDefaultProfile(ctx, billing.GetDefaultProfileInput{ @@ -219,20 +255,25 @@ func (s *Service) getProfileWithCustomerOverrideMerges(ctx context.Context, adap } } - return defaultProfile, nil + return s.resolveBaseProfile(ctx, defaultProfile) } // We have an active override, let's see what's the baseline profile baselineProfile := override.Profile if baselineProfile == nil { // Let's fetch the default billing profile - baselineProfile, err = adapter.GetDefaultProfile(ctx, billing.GetDefaultProfileInput{ + defaultBaseProfile, err := adapter.GetDefaultProfile(ctx, billing.GetDefaultProfileInput{ Namespace: input.Namespace, }) if err != nil { return nil, err } + baselineProfile, err = s.resolveBaseProfile(ctx, defaultBaseProfile) + if err != nil { + return nil, err + } + if baselineProfile == nil { return nil, billing.NotFoundError{ Entity: billing.EntityDefaultProfile, @@ -252,3 +293,22 @@ func (s *Service) getProfileWithCustomerOverrideMerges(ctx context.Context, adap return &profile, nil } + +func (s *Service) resolveCustomerOverride(ctx context.Context, input *billingentity.CustomerOverride) (*billingentity.CustomerOverride, error) { + if input == nil { + return nil, nil + } + + out := *input + + if input.Profile != nil { + profile, err := s.resolveBaseProfile(ctx, &input.Profile.BaseProfile) + if err != nil { + return nil, err + } + + out.Profile = profile + } + + return &out, nil +} diff --git a/openmeter/billing/service/invoice.go b/openmeter/billing/service/invoice.go index f05d8a490..3d042b074 100644 --- a/openmeter/billing/service/invoice.go +++ b/openmeter/billing/service/invoice.go @@ -8,13 +8,15 @@ import ( "github.com/samber/lo" "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" customerentity "github.com/openmeterio/openmeter/openmeter/customer/entity" "github.com/openmeterio/openmeter/pkg/currencyx" + "github.com/openmeterio/openmeter/pkg/framework/transaction" ) var _ billing.InvoiceService = (*Service)(nil) -func (s *Service) GetPendingInvoiceItems(ctx context.Context, customerID customerentity.CustomerID) ([]billing.InvoiceWithValidation, error) { +func (s *Service) GetPendingInvoiceItems(ctx context.Context, customerID customerentity.CustomerID) ([]billingentity.InvoiceWithValidation, error) { customerEntity, err := s.customerService.GetCustomer(ctx, customerentity.GetCustomerInput(customerID)) if err != nil { if err, ok := lo.ErrorsAs[customerentity.NotFoundError](err); ok { @@ -26,10 +28,10 @@ func (s *Service) GetPendingInvoiceItems(ctx context.Context, customerID custome return nil, err } - return billing.WithTx(ctx, s.adapter, func(ctx context.Context, adapter billing.TxAdapter) ([]billing.InvoiceWithValidation, error) { + return transaction.Run(ctx, s.adapter, func(ctx context.Context) ([]billingentity.InvoiceWithValidation, error) { validationErrors := []error{} - billingProfile, err := s.getProfileWithCustomerOverride(ctx, adapter, billing.GetProfileWithCustomerOverrideInput{ + billingProfile, err := s.getProfileWithCustomerOverride(ctx, s.adapter, billing.GetProfileWithCustomerOverrideInput{ Namespace: customerEntity.Namespace, CustomerID: customerEntity.ID, }) @@ -55,19 +57,19 @@ func (s *Service) GetPendingInvoiceItems(ctx context.Context, customerID custome byCurrency := splitInvoicesByCurrency(pendingItems) - res := make([]billing.InvoiceWithValidation, 0, len(byCurrency)) + res := make([]billingentity.InvoiceWithValidation, 0, len(byCurrency)) for currency, items := range byCurrency { - res = append(res, billing.InvoiceWithValidation{ - Invoice: &billing.Invoice{ + res = append(res, billingentity.InvoiceWithValidation{ + Invoice: &billingentity.Invoice{ Namespace: customerEntity.Namespace, - InvoiceNumber: billing.InvoiceNumber{ + InvoiceNumber: billingentity.InvoiceNumber{ Series: "INV", Code: "DRAFT", }, - Status: billing.InvoiceStatusPendingCreation, + Status: billingentity.InvoiceStatusPendingCreation, Items: items, - Type: billing.InvoiceTypeStandard, + Type: billingentity.InvoiceTypeStandard, // TODO[OM-931]: Timezone @@ -77,7 +79,7 @@ func (s *Service) GetPendingInvoiceItems(ctx context.Context, customerID custome UpdatedAt: time.Now(), Profile: billingProfile.Profile, - Customer: billing.InvoiceCustomer(billingProfile.Customer), + Customer: billingentity.InvoiceCustomer(billingProfile.Customer), }, ValidationErrors: validationErrors, }, @@ -88,15 +90,15 @@ func (s *Service) GetPendingInvoiceItems(ctx context.Context, customerID custome }) } -func splitInvoicesByCurrency(items []billing.InvoiceItem) map[currencyx.Code][]billing.InvoiceItem { - byCurrency := make(map[currencyx.Code][]billing.InvoiceItem) +func splitInvoicesByCurrency(items []billingentity.InvoiceItem) map[currencyx.Code][]billingentity.InvoiceItem { + byCurrency := make(map[currencyx.Code][]billingentity.InvoiceItem) if len(items) == 0 { return byCurrency } // Optimization: pre-allocate the first currency, assuming that there will be not more than one currency - byCurrency[items[0].Currency] = make([]billing.InvoiceItem, 0, len(items)) + byCurrency[items[0].Currency] = make([]billingentity.InvoiceItem, 0, len(items)) for _, item := range items { byCurrency[item.Currency] = append(byCurrency[item.Currency], item) diff --git a/openmeter/billing/service/invoiceitem.go b/openmeter/billing/service/invoiceitem.go index 04db0218b..edfc8d0e8 100644 --- a/openmeter/billing/service/invoiceitem.go +++ b/openmeter/billing/service/invoiceitem.go @@ -4,18 +4,20 @@ import ( "context" "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" + "github.com/openmeterio/openmeter/pkg/framework/transaction" ) var _ billing.InvoiceItemService = (*Service)(nil) -func (s *Service) CreateInvoiceItems(ctx context.Context, input billing.CreateInvoiceItemsInput) ([]billing.InvoiceItem, error) { +func (s *Service) CreateInvoiceItems(ctx context.Context, input billing.CreateInvoiceItemsInput) ([]billingentity.InvoiceItem, error) { if err := input.Validate(); err != nil { return nil, billing.ValidationError{ Err: err, } } - return billing.WithTx(ctx, s.adapter, func(ctx context.Context, adapter billing.TxAdapter) ([]billing.InvoiceItem, error) { - return adapter.CreateInvoiceItems(ctx, input) + return transaction.Run(ctx, s.adapter, func(ctx context.Context) ([]billingentity.InvoiceItem, error) { + return s.adapter.CreateInvoiceItems(ctx, input) }) } diff --git a/openmeter/billing/service/profile.go b/openmeter/billing/service/profile.go index bbd57e75d..380d7b913 100644 --- a/openmeter/billing/service/profile.go +++ b/openmeter/billing/service/profile.go @@ -6,13 +6,18 @@ import ( "github.com/samber/lo" + appentity "github.com/openmeterio/openmeter/openmeter/app/entity" + appentitybase "github.com/openmeterio/openmeter/openmeter/app/entity/base" "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" customerentity "github.com/openmeterio/openmeter/openmeter/customer/entity" + "github.com/openmeterio/openmeter/pkg/framework/entutils" + "github.com/openmeterio/openmeter/pkg/pagination" ) var _ billing.ProfileService = (*Service)(nil) -func (s *Service) CreateProfile(ctx context.Context, input billing.CreateProfileInput) (*billing.Profile, error) { +func (s *Service) CreateProfile(ctx context.Context, input billing.CreateProfileInput) (*billingentity.Profile, error) { input = input.WithDefaults() if err := input.Validate(); err != nil { @@ -21,10 +26,10 @@ func (s *Service) CreateProfile(ctx context.Context, input billing.CreateProfile } } - return billing.WithTx(ctx, s.adapter, func(ctx context.Context, adapter billing.TxAdapter) (*billing.Profile, error) { + return entutils.TransactingRepo(ctx, s.adapter, func(ctx context.Context, txAdapter billing.Adapter) (*billingentity.Profile, error) { // Given that we have multiple constraints let's validate those here for better error reporting if input.Default { - defaultProfile, err := adapter.GetDefaultProfile(ctx, billing.GetDefaultProfileInput{ + defaultProfile, err := txAdapter.GetDefaultProfile(ctx, billing.GetDefaultProfileInput{ Namespace: input.Namespace, }) if err != nil { @@ -38,7 +43,35 @@ func (s *Service) CreateProfile(ctx context.Context, input billing.CreateProfile } } - profile, err := adapter.CreateProfile(ctx, input) + // let's resolve the applications + taxApp, err := s.validateAppReference(ctx, input.Namespace, input.Apps.Tax, appentitybase.CapabilityTypeCalculateTax) + if err != nil { + return nil, billing.ValidationError{ + Err: fmt.Errorf("error resolving tax app: %w", err), + } + } + + invocingApp, err := s.validateAppReference(ctx, input.Namespace, input.Apps.Invoicing, appentitybase.CapabilityTypeInvoiceCustomers) + if err != nil { + return nil, billing.ValidationError{ + Err: fmt.Errorf("error resolving invocing app: %w", err), + } + } + + paymentsApp, err := s.validateAppReference(ctx, input.Namespace, input.Apps.Payment, appentitybase.CapabilityTypeCollectPayments) + if err != nil { + return nil, billing.ValidationError{ + Err: fmt.Errorf("error resolving payments app: %w", err), + } + } + + input.Apps = billing.CreateProfileAppsInput{ + Tax: taxApp.Reference, + Invoicing: invocingApp.Reference, + Payment: paymentsApp.Reference, + } + + profile, err := txAdapter.CreateProfile(ctx, input) if err != nil { return nil, err } @@ -49,29 +82,100 @@ func (s *Service) CreateProfile(ctx context.Context, input billing.CreateProfile } } - return profile, nil + return s.resolveBaseProfile(ctx, profile) }) } -func (s *Service) GetDefaultProfile(ctx context.Context, input billing.GetDefaultProfileInput) (*billing.Profile, error) { +func (s *Service) validateAppReference(ctx context.Context, ns string, ref billingentity.AppReference, capabilities ...appentitybase.CapabilityType) (*resolvedAppReference, error) { + if err := ref.Validate(); err != nil { + return nil, fmt.Errorf("invalid app reference: %w", err) + } + + resolved, err := s.resolveAppReference(ctx, ns, ref) + if err != nil { + return nil, err + } + + if err := resolved.App.ValidateCapabilities(capabilities...); err != nil { + return nil, err + } + + return resolved, nil +} + +type resolvedAppReference struct { + Reference billingentity.AppReference + App appentity.App +} + +func (s *Service) resolveAppReference(ctx context.Context, ns string, ref billingentity.AppReference) (*resolvedAppReference, error) { + if ref.ID != "" { + app, err := s.appService.GetApp(ctx, appentity.GetAppInput{ + Namespace: ns, + ID: ref.ID, + }) + if err != nil { + return nil, fmt.Errorf("cannot find application[id=%s]: %w", ref.ID, err) + } + + return &resolvedAppReference{ + Reference: billingentity.AppReference{ + ID: app.GetID().ID, + }, + App: app, + }, nil + } + + if ref.Type != "" { + app, err := s.appService.GetDefaultApp(ctx, appentity.GetDefaultAppInput{ + Namespace: ns, + Type: ref.Type, + }) + if err != nil { + return nil, fmt.Errorf("cannot find default application[type=%s]: %w", ref.Type, err) + } + + return &resolvedAppReference{ + Reference: billingentity.AppReference{ + ID: app.GetID().ID, + }, + App: app, + }, nil + } + + return nil, fmt.Errorf("invalid app reference: %v", ref) +} + +func (s *Service) GetDefaultProfile(ctx context.Context, input billing.GetDefaultProfileInput) (*billingentity.Profile, error) { if err := input.Validate(); err != nil { return nil, billing.ValidationError{ Err: err, } } - return s.adapter.GetDefaultProfile(ctx, billing.GetDefaultProfileInput{ + profile, err := s.adapter.GetDefaultProfile(ctx, billing.GetDefaultProfileInput{ Namespace: input.Namespace, }) + if err != nil { + return nil, err + } + + return s.resolveBaseProfile(ctx, profile) } -func (s *Service) GetProfile(ctx context.Context, input billing.GetProfileInput) (*billing.Profile, error) { +func (s *Service) GetProfile(ctx context.Context, input billing.GetProfileInput) (*billingentity.Profile, error) { if err := input.Validate(); err != nil { return nil, billing.ValidationError{ Err: err, } } - return s.adapter.GetProfile(ctx, input) + + profile, err := s.adapter.GetProfile(ctx, input) + if err != nil { + return nil, err + } + + return s.resolveBaseProfile(ctx, profile) } func (s *Service) DeleteProfile(ctx context.Context, input billing.DeleteProfileInput) error { @@ -81,8 +185,8 @@ func (s *Service) DeleteProfile(ctx context.Context, input billing.DeleteProfile } } - return billing.WithTxNoValue(ctx, s.adapter, func(ctx context.Context, adapter billing.TxAdapter) error { - profile, err := s.adapter.GetProfile(ctx, billing.GetProfileInput(input)) + return entutils.TransactingRepoWithNoValue(ctx, s.adapter, func(ctx context.Context, txAdapter billing.Adapter) error { + profile, err := txAdapter.GetProfile(ctx, billing.GetProfileInput(input)) if err != nil { return err } @@ -99,7 +203,7 @@ func (s *Service) DeleteProfile(ctx context.Context, input billing.DeleteProfile } } - referringCustomerIDs, err := adapter.GetCustomerOverrideReferencingProfile(ctx, billing.HasCustomerOverrideReferencingProfileAdapterInput(input)) + referringCustomerIDs, err := txAdapter.GetCustomerOverrideReferencingProfile(ctx, billing.HasCustomerOverrideReferencingProfileAdapterInput(input)) if err != nil { return err } @@ -116,22 +220,52 @@ func (s *Service) DeleteProfile(ctx context.Context, input billing.DeleteProfile } } - return adapter.DeleteProfile(ctx, billing.DeleteProfileInput{ + return txAdapter.DeleteProfile(ctx, billing.DeleteProfileInput{ Namespace: input.Namespace, ID: profile.ID, }) }) } -func (s *Service) UpdateProfile(ctx context.Context, input billing.UpdateProfileInput) (*billing.Profile, error) { +func (s *Service) ListProfiles(ctx context.Context, input billing.ListProfilesInput) (billing.ListProfilesResult, error) { + if err := input.Validate(); err != nil { + return billing.ListProfilesResult{}, billing.ValidationError{ + Err: err, + } + } + + profiles, err := s.adapter.ListProfiles(ctx, input) + if err != nil { + return billing.ListProfilesResult{}, err + } + + response := pagination.PagedResponse[billingentity.Profile]{ + Page: profiles.Page, + TotalCount: profiles.TotalCount, + Items: make([]billingentity.Profile, 0, len(profiles.Items)), + } + + for _, profile := range profiles.Items { + resolvedProfile, err := s.resolveBaseProfile(ctx, &profile) + if err != nil { + return billing.ListProfilesResult{}, fmt.Errorf("error resolving profile: %w", err) + } + + response.Items = append(response.Items, *resolvedProfile) + } + + return response, nil +} + +func (s *Service) UpdateProfile(ctx context.Context, input billing.UpdateProfileInput) (*billingentity.Profile, error) { if err := input.Validate(); err != nil { return nil, billing.ValidationError{ Err: err, } } - return billing.WithTx(ctx, s.adapter, func(ctx context.Context, adapter billing.TxAdapter) (*billing.Profile, error) { - profile, err := adapter.GetProfile(ctx, billing.GetProfileInput{ + return entutils.TransactingRepo(ctx, s.adapter, func(ctx context.Context, txAdapter billing.Adapter) (*billingentity.Profile, error) { + profile, err := txAdapter.GetProfile(ctx, billing.GetProfileInput{ Namespace: input.Namespace, ID: input.ID, }) @@ -158,7 +292,7 @@ func (s *Service) UpdateProfile(ctx context.Context, input billing.UpdateProfile } if !profile.Default && input.Default { - defaultProfile, err := adapter.GetDefaultProfile(ctx, billing.GetDefaultProfileInput{ + defaultProfile, err := txAdapter.GetDefaultProfile(ctx, billing.GetDefaultProfileInput{ Namespace: input.Namespace, }) if err != nil { @@ -172,28 +306,8 @@ func (s *Service) UpdateProfile(ctx context.Context, input billing.UpdateProfile } } - // Let's force our users to create new profiles instead of updating the existing ones when a provider change is required - // this helps with internal consistency, but also guides them into a granual migration path - if profile.TaxConfiguration.Type != input.TaxConfiguration.Type { - return nil, billing.ValidationError{ - Err: fmt.Errorf("%w [id=%s]", billing.ErrProfileTaxTypeChange, input.ID), - } - } - - if profile.InvoicingConfiguration.Type != input.InvoicingConfiguration.Type { - return nil, billing.ValidationError{ - Err: fmt.Errorf("%w [id=%s]", billing.ErrProfileInvoicingTypeChange, input.ID), - } - } - - if profile.PaymentConfiguration.Type != input.PaymentConfiguration.Type { - return nil, billing.ValidationError{ - Err: fmt.Errorf("%w [id=%s]", billing.ErrProfilePaymentTypeChange, input.ID), - } - } - - profile, err = adapter.UpdateProfile(ctx, billing.UpdateProfileAdapterInput{ - TargetState: billing.Profile(input), + profile, err = txAdapter.UpdateProfile(ctx, billing.UpdateProfileAdapterInput{ + TargetState: billingentity.BaseProfile(input), WorkflowConfigID: profile.WorkflowConfig.ID, }) if err != nil { @@ -206,6 +320,47 @@ func (s *Service) UpdateProfile(ctx context.Context, input billing.UpdateProfile } } - return profile, nil + return s.resolveBaseProfile(ctx, profile) + }) +} + +func (s *Service) resolveBaseProfile(ctx context.Context, input *billingentity.BaseProfile) (*billingentity.Profile, error) { + if input == nil { + return nil, nil + } + + out := billingentity.Profile{ + BaseProfile: *input, + } + + out.Apps = &billingentity.ProfileApps{} + + taxApp, err := s.appService.GetApp(ctx, appentity.GetAppInput{ + Namespace: out.Namespace, + ID: input.AppReferences.Tax.ID, + }) + if err != nil { + return nil, fmt.Errorf("cannot resolve tax app: %w", err) + } + out.Apps.Tax = taxApp + + invoiceApp, err := s.appService.GetApp(ctx, appentity.GetAppInput{ + Namespace: out.Namespace, + ID: input.AppReferences.Invoicing.ID, }) + if err != nil { + return nil, fmt.Errorf("cannot resolve invoicing app: %w", err) + } + out.Apps.Invoicing = invoiceApp + + paymentApp, err := s.appService.GetApp(ctx, appentity.GetAppInput{ + Namespace: out.Namespace, + ID: input.AppReferences.Payment.ID, + }) + if err != nil { + return nil, fmt.Errorf("cannot resolve payments app: %w", err) + } + out.Apps.Payment = paymentApp + + return &out, nil } diff --git a/openmeter/billing/service/service.go b/openmeter/billing/service/service.go index 8a5930410..412bb10e6 100644 --- a/openmeter/billing/service/service.go +++ b/openmeter/billing/service/service.go @@ -3,6 +3,7 @@ package billingservice import ( "errors" + "github.com/openmeterio/openmeter/openmeter/app" "github.com/openmeterio/openmeter/openmeter/billing" "github.com/openmeterio/openmeter/openmeter/customer" ) @@ -12,11 +13,13 @@ var _ billing.Service = (*Service)(nil) type Service struct { adapter billing.Adapter customerService customer.CustomerService + appService app.Service } type Config struct { Adapter billing.Adapter CustomerService customer.CustomerService + AppService app.Service } func (c Config) Validate() error { @@ -28,6 +31,10 @@ func (c Config) Validate() error { return errors.New("customer service cannot be null") } + if c.AppService == nil { + return errors.New("app service cannot be null") + } + return nil } @@ -39,5 +46,6 @@ func New(config Config) (*Service, error) { return &Service{ adapter: config.Adapter, customerService: config.CustomerService, + appService: config.AppService, }, nil } diff --git a/openmeter/ent/db/app.go b/openmeter/ent/db/app.go index c66183573..aa2cca71f 100644 --- a/openmeter/ent/db/app.go +++ b/openmeter/ent/db/app.go @@ -49,9 +49,15 @@ type App struct { type AppEdges struct { // CustomerApps holds the value of the customer_apps edge. CustomerApps []*AppCustomer `json:"customer_apps,omitempty"` + // TaxApp holds the value of the tax_app edge. + TaxApp []*BillingProfile `json:"tax_app,omitempty"` + // InvoicingApp holds the value of the invoicing_app edge. + InvoicingApp []*BillingProfile `json:"invoicing_app,omitempty"` + // PaymentApp holds the value of the payment_app edge. + PaymentApp []*BillingProfile `json:"payment_app,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool + loadedTypes [4]bool } // CustomerAppsOrErr returns the CustomerApps value or an error if the edge @@ -63,6 +69,33 @@ func (e AppEdges) CustomerAppsOrErr() ([]*AppCustomer, error) { return nil, &NotLoadedError{edge: "customer_apps"} } +// TaxAppOrErr returns the TaxApp value or an error if the edge +// was not loaded in eager-loading. +func (e AppEdges) TaxAppOrErr() ([]*BillingProfile, error) { + if e.loadedTypes[1] { + return e.TaxApp, nil + } + return nil, &NotLoadedError{edge: "tax_app"} +} + +// InvoicingAppOrErr returns the InvoicingApp value or an error if the edge +// was not loaded in eager-loading. +func (e AppEdges) InvoicingAppOrErr() ([]*BillingProfile, error) { + if e.loadedTypes[2] { + return e.InvoicingApp, nil + } + return nil, &NotLoadedError{edge: "invoicing_app"} +} + +// PaymentAppOrErr returns the PaymentApp value or an error if the edge +// was not loaded in eager-loading. +func (e AppEdges) PaymentAppOrErr() ([]*BillingProfile, error) { + if e.loadedTypes[3] { + return e.PaymentApp, nil + } + return nil, &NotLoadedError{edge: "payment_app"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*App) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -179,6 +212,21 @@ func (a *App) QueryCustomerApps() *AppCustomerQuery { return NewAppClient(a.config).QueryCustomerApps(a) } +// QueryTaxApp queries the "tax_app" edge of the App entity. +func (a *App) QueryTaxApp() *BillingProfileQuery { + return NewAppClient(a.config).QueryTaxApp(a) +} + +// QueryInvoicingApp queries the "invoicing_app" edge of the App entity. +func (a *App) QueryInvoicingApp() *BillingProfileQuery { + return NewAppClient(a.config).QueryInvoicingApp(a) +} + +// QueryPaymentApp queries the "payment_app" edge of the App entity. +func (a *App) QueryPaymentApp() *BillingProfileQuery { + return NewAppClient(a.config).QueryPaymentApp(a) +} + // Update returns a builder for updating this App. // Note that you need to call App.Unwrap() before calling this method if this App // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/openmeter/ent/db/app/app.go b/openmeter/ent/db/app/app.go index 31e5944a9..f99bd1996 100644 --- a/openmeter/ent/db/app/app.go +++ b/openmeter/ent/db/app/app.go @@ -36,6 +36,12 @@ const ( FieldIsDefault = "is_default" // EdgeCustomerApps holds the string denoting the customer_apps edge name in mutations. EdgeCustomerApps = "customer_apps" + // EdgeTaxApp holds the string denoting the tax_app edge name in mutations. + EdgeTaxApp = "tax_app" + // EdgeInvoicingApp holds the string denoting the invoicing_app edge name in mutations. + EdgeInvoicingApp = "invoicing_app" + // EdgePaymentApp holds the string denoting the payment_app edge name in mutations. + EdgePaymentApp = "payment_app" // Table holds the table name of the app in the database. Table = "apps" // CustomerAppsTable is the table that holds the customer_apps relation/edge. @@ -45,6 +51,27 @@ const ( CustomerAppsInverseTable = "app_customers" // CustomerAppsColumn is the table column denoting the customer_apps relation/edge. CustomerAppsColumn = "app_id" + // TaxAppTable is the table that holds the tax_app relation/edge. + TaxAppTable = "billing_profiles" + // TaxAppInverseTable is the table name for the BillingProfile entity. + // It exists in this package in order to avoid circular dependency with the "billingprofile" package. + TaxAppInverseTable = "billing_profiles" + // TaxAppColumn is the table column denoting the tax_app relation/edge. + TaxAppColumn = "tax_app_id" + // InvoicingAppTable is the table that holds the invoicing_app relation/edge. + InvoicingAppTable = "billing_profiles" + // InvoicingAppInverseTable is the table name for the BillingProfile entity. + // It exists in this package in order to avoid circular dependency with the "billingprofile" package. + InvoicingAppInverseTable = "billing_profiles" + // InvoicingAppColumn is the table column denoting the invoicing_app relation/edge. + InvoicingAppColumn = "invoicing_app_id" + // PaymentAppTable is the table that holds the payment_app relation/edge. + PaymentAppTable = "billing_profiles" + // PaymentAppInverseTable is the table name for the BillingProfile entity. + // It exists in this package in order to avoid circular dependency with the "billingprofile" package. + PaymentAppInverseTable = "billing_profiles" + // PaymentAppColumn is the table column denoting the payment_app relation/edge. + PaymentAppColumn = "payment_app_id" ) // Columns holds all SQL columns for app fields. @@ -153,6 +180,48 @@ func ByCustomerApps(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newCustomerAppsStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByTaxAppCount orders the results by tax_app count. +func ByTaxAppCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newTaxAppStep(), opts...) + } +} + +// ByTaxApp orders the results by tax_app terms. +func ByTaxApp(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newTaxAppStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByInvoicingAppCount orders the results by invoicing_app count. +func ByInvoicingAppCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newInvoicingAppStep(), opts...) + } +} + +// ByInvoicingApp orders the results by invoicing_app terms. +func ByInvoicingApp(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newInvoicingAppStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPaymentAppCount orders the results by payment_app count. +func ByPaymentAppCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPaymentAppStep(), opts...) + } +} + +// ByPaymentApp orders the results by payment_app terms. +func ByPaymentApp(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPaymentAppStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newCustomerAppsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -160,3 +229,24 @@ func newCustomerAppsStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, CustomerAppsTable, CustomerAppsColumn), ) } +func newTaxAppStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TaxAppInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, TaxAppTable, TaxAppColumn), + ) +} +func newInvoicingAppStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(InvoicingAppInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, InvoicingAppTable, InvoicingAppColumn), + ) +} +func newPaymentAppStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PaymentAppInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, PaymentAppTable, PaymentAppColumn), + ) +} diff --git a/openmeter/ent/db/app/where.go b/openmeter/ent/db/app/where.go index cbb4945e2..1dd4b03c2 100644 --- a/openmeter/ent/db/app/where.go +++ b/openmeter/ent/db/app/where.go @@ -659,6 +659,75 @@ func HasCustomerAppsWith(preds ...predicate.AppCustomer) predicate.App { }) } +// HasTaxApp applies the HasEdge predicate on the "tax_app" edge. +func HasTaxApp() predicate.App { + return predicate.App(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, TaxAppTable, TaxAppColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTaxAppWith applies the HasEdge predicate on the "tax_app" edge with a given conditions (other predicates). +func HasTaxAppWith(preds ...predicate.BillingProfile) predicate.App { + return predicate.App(func(s *sql.Selector) { + step := newTaxAppStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasInvoicingApp applies the HasEdge predicate on the "invoicing_app" edge. +func HasInvoicingApp() predicate.App { + return predicate.App(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, InvoicingAppTable, InvoicingAppColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasInvoicingAppWith applies the HasEdge predicate on the "invoicing_app" edge with a given conditions (other predicates). +func HasInvoicingAppWith(preds ...predicate.BillingProfile) predicate.App { + return predicate.App(func(s *sql.Selector) { + step := newInvoicingAppStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPaymentApp applies the HasEdge predicate on the "payment_app" edge. +func HasPaymentApp() predicate.App { + return predicate.App(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, PaymentAppTable, PaymentAppColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPaymentAppWith applies the HasEdge predicate on the "payment_app" edge with a given conditions (other predicates). +func HasPaymentAppWith(preds ...predicate.BillingProfile) predicate.App { + return predicate.App(func(s *sql.Selector) { + step := newPaymentAppStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.App) predicate.App { return predicate.App(sql.AndPredicates(predicates...)) diff --git a/openmeter/ent/db/app_create.go b/openmeter/ent/db/app_create.go index 024949090..cb33c9441 100644 --- a/openmeter/ent/db/app_create.go +++ b/openmeter/ent/db/app_create.go @@ -15,6 +15,7 @@ import ( appentitybase "github.com/openmeterio/openmeter/openmeter/app/entity/base" "github.com/openmeterio/openmeter/openmeter/ent/db/app" "github.com/openmeterio/openmeter/openmeter/ent/db/appcustomer" + "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" ) // AppCreate is the builder for creating a App entity. @@ -154,6 +155,51 @@ func (ac *AppCreate) AddCustomerApps(a ...*AppCustomer) *AppCreate { return ac.AddCustomerAppIDs(ids...) } +// AddTaxAppIDs adds the "tax_app" edge to the BillingProfile entity by IDs. +func (ac *AppCreate) AddTaxAppIDs(ids ...string) *AppCreate { + ac.mutation.AddTaxAppIDs(ids...) + return ac +} + +// AddTaxApp adds the "tax_app" edges to the BillingProfile entity. +func (ac *AppCreate) AddTaxApp(b ...*BillingProfile) *AppCreate { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return ac.AddTaxAppIDs(ids...) +} + +// AddInvoicingAppIDs adds the "invoicing_app" edge to the BillingProfile entity by IDs. +func (ac *AppCreate) AddInvoicingAppIDs(ids ...string) *AppCreate { + ac.mutation.AddInvoicingAppIDs(ids...) + return ac +} + +// AddInvoicingApp adds the "invoicing_app" edges to the BillingProfile entity. +func (ac *AppCreate) AddInvoicingApp(b ...*BillingProfile) *AppCreate { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return ac.AddInvoicingAppIDs(ids...) +} + +// AddPaymentAppIDs adds the "payment_app" edge to the BillingProfile entity by IDs. +func (ac *AppCreate) AddPaymentAppIDs(ids ...string) *AppCreate { + ac.mutation.AddPaymentAppIDs(ids...) + return ac +} + +// AddPaymentApp adds the "payment_app" edges to the BillingProfile entity. +func (ac *AppCreate) AddPaymentApp(b ...*BillingProfile) *AppCreate { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return ac.AddPaymentAppIDs(ids...) +} + // Mutation returns the AppMutation object of the builder. func (ac *AppCreate) Mutation() *AppMutation { return ac.mutation @@ -327,6 +373,54 @@ func (ac *AppCreate) createSpec() (*App, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := ac.mutation.TaxAppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.TaxAppTable, + Columns: []string{app.TaxAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := ac.mutation.InvoicingAppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.InvoicingAppTable, + Columns: []string{app.InvoicingAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := ac.mutation.PaymentAppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.PaymentAppTable, + Columns: []string{app.PaymentAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/openmeter/ent/db/app_query.go b/openmeter/ent/db/app_query.go index 639d1530a..ee6f0bbe7 100644 --- a/openmeter/ent/db/app_query.go +++ b/openmeter/ent/db/app_query.go @@ -15,6 +15,7 @@ import ( "entgo.io/ent/schema/field" "github.com/openmeterio/openmeter/openmeter/ent/db/app" "github.com/openmeterio/openmeter/openmeter/ent/db/appcustomer" + "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" ) @@ -26,6 +27,9 @@ type AppQuery struct { inters []Interceptor predicates []predicate.App withCustomerApps *AppCustomerQuery + withTaxApp *BillingProfileQuery + withInvoicingApp *BillingProfileQuery + withPaymentApp *BillingProfileQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector @@ -85,6 +89,72 @@ func (aq *AppQuery) QueryCustomerApps() *AppCustomerQuery { return query } +// QueryTaxApp chains the current query on the "tax_app" edge. +func (aq *AppQuery) QueryTaxApp() *BillingProfileQuery { + query := (&BillingProfileClient{config: aq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := aq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := aq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(app.Table, app.FieldID, selector), + sqlgraph.To(billingprofile.Table, billingprofile.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, app.TaxAppTable, app.TaxAppColumn), + ) + fromU = sqlgraph.SetNeighbors(aq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryInvoicingApp chains the current query on the "invoicing_app" edge. +func (aq *AppQuery) QueryInvoicingApp() *BillingProfileQuery { + query := (&BillingProfileClient{config: aq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := aq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := aq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(app.Table, app.FieldID, selector), + sqlgraph.To(billingprofile.Table, billingprofile.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, app.InvoicingAppTable, app.InvoicingAppColumn), + ) + fromU = sqlgraph.SetNeighbors(aq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryPaymentApp chains the current query on the "payment_app" edge. +func (aq *AppQuery) QueryPaymentApp() *BillingProfileQuery { + query := (&BillingProfileClient{config: aq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := aq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := aq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(app.Table, app.FieldID, selector), + sqlgraph.To(billingprofile.Table, billingprofile.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, app.PaymentAppTable, app.PaymentAppColumn), + ) + fromU = sqlgraph.SetNeighbors(aq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first App entity from the query. // Returns a *NotFoundError when no App was found. func (aq *AppQuery) First(ctx context.Context) (*App, error) { @@ -278,6 +348,9 @@ func (aq *AppQuery) Clone() *AppQuery { inters: append([]Interceptor{}, aq.inters...), predicates: append([]predicate.App{}, aq.predicates...), withCustomerApps: aq.withCustomerApps.Clone(), + withTaxApp: aq.withTaxApp.Clone(), + withInvoicingApp: aq.withInvoicingApp.Clone(), + withPaymentApp: aq.withPaymentApp.Clone(), // clone intermediate query. sql: aq.sql.Clone(), path: aq.path, @@ -295,6 +368,39 @@ func (aq *AppQuery) WithCustomerApps(opts ...func(*AppCustomerQuery)) *AppQuery return aq } +// WithTaxApp tells the query-builder to eager-load the nodes that are connected to +// the "tax_app" edge. The optional arguments are used to configure the query builder of the edge. +func (aq *AppQuery) WithTaxApp(opts ...func(*BillingProfileQuery)) *AppQuery { + query := (&BillingProfileClient{config: aq.config}).Query() + for _, opt := range opts { + opt(query) + } + aq.withTaxApp = query + return aq +} + +// WithInvoicingApp tells the query-builder to eager-load the nodes that are connected to +// the "invoicing_app" edge. The optional arguments are used to configure the query builder of the edge. +func (aq *AppQuery) WithInvoicingApp(opts ...func(*BillingProfileQuery)) *AppQuery { + query := (&BillingProfileClient{config: aq.config}).Query() + for _, opt := range opts { + opt(query) + } + aq.withInvoicingApp = query + return aq +} + +// WithPaymentApp tells the query-builder to eager-load the nodes that are connected to +// the "payment_app" edge. The optional arguments are used to configure the query builder of the edge. +func (aq *AppQuery) WithPaymentApp(opts ...func(*BillingProfileQuery)) *AppQuery { + query := (&BillingProfileClient{config: aq.config}).Query() + for _, opt := range opts { + opt(query) + } + aq.withPaymentApp = query + return aq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -373,8 +479,11 @@ func (aq *AppQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*App, err var ( nodes = []*App{} _spec = aq.querySpec() - loadedTypes = [1]bool{ + loadedTypes = [4]bool{ aq.withCustomerApps != nil, + aq.withTaxApp != nil, + aq.withInvoicingApp != nil, + aq.withPaymentApp != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -405,6 +514,27 @@ func (aq *AppQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*App, err return nil, err } } + if query := aq.withTaxApp; query != nil { + if err := aq.loadTaxApp(ctx, query, nodes, + func(n *App) { n.Edges.TaxApp = []*BillingProfile{} }, + func(n *App, e *BillingProfile) { n.Edges.TaxApp = append(n.Edges.TaxApp, e) }); err != nil { + return nil, err + } + } + if query := aq.withInvoicingApp; query != nil { + if err := aq.loadInvoicingApp(ctx, query, nodes, + func(n *App) { n.Edges.InvoicingApp = []*BillingProfile{} }, + func(n *App, e *BillingProfile) { n.Edges.InvoicingApp = append(n.Edges.InvoicingApp, e) }); err != nil { + return nil, err + } + } + if query := aq.withPaymentApp; query != nil { + if err := aq.loadPaymentApp(ctx, query, nodes, + func(n *App) { n.Edges.PaymentApp = []*BillingProfile{} }, + func(n *App, e *BillingProfile) { n.Edges.PaymentApp = append(n.Edges.PaymentApp, e) }); err != nil { + return nil, err + } + } return nodes, nil } @@ -438,6 +568,96 @@ func (aq *AppQuery) loadCustomerApps(ctx context.Context, query *AppCustomerQuer } return nil } +func (aq *AppQuery) loadTaxApp(ctx context.Context, query *BillingProfileQuery, nodes []*App, init func(*App), assign func(*App, *BillingProfile)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*App) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(billingprofile.FieldTaxAppID) + } + query.Where(predicate.BillingProfile(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(app.TaxAppColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.TaxAppID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "tax_app_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (aq *AppQuery) loadInvoicingApp(ctx context.Context, query *BillingProfileQuery, nodes []*App, init func(*App), assign func(*App, *BillingProfile)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*App) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(billingprofile.FieldInvoicingAppID) + } + query.Where(predicate.BillingProfile(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(app.InvoicingAppColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.InvoicingAppID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "invoicing_app_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (aq *AppQuery) loadPaymentApp(ctx context.Context, query *BillingProfileQuery, nodes []*App, init func(*App), assign func(*App, *BillingProfile)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*App) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(billingprofile.FieldPaymentAppID) + } + query.Where(predicate.BillingProfile(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(app.PaymentAppColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.PaymentAppID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "payment_app_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} func (aq *AppQuery) sqlCount(ctx context.Context) (int, error) { _spec := aq.querySpec() diff --git a/openmeter/ent/db/app_update.go b/openmeter/ent/db/app_update.go index 62d769abc..516459d08 100644 --- a/openmeter/ent/db/app_update.go +++ b/openmeter/ent/db/app_update.go @@ -14,6 +14,7 @@ import ( appentitybase "github.com/openmeterio/openmeter/openmeter/app/entity/base" "github.com/openmeterio/openmeter/openmeter/ent/db/app" "github.com/openmeterio/openmeter/openmeter/ent/db/appcustomer" + "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" ) @@ -145,6 +146,51 @@ func (au *AppUpdate) AddCustomerApps(a ...*AppCustomer) *AppUpdate { return au.AddCustomerAppIDs(ids...) } +// AddTaxAppIDs adds the "tax_app" edge to the BillingProfile entity by IDs. +func (au *AppUpdate) AddTaxAppIDs(ids ...string) *AppUpdate { + au.mutation.AddTaxAppIDs(ids...) + return au +} + +// AddTaxApp adds the "tax_app" edges to the BillingProfile entity. +func (au *AppUpdate) AddTaxApp(b ...*BillingProfile) *AppUpdate { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return au.AddTaxAppIDs(ids...) +} + +// AddInvoicingAppIDs adds the "invoicing_app" edge to the BillingProfile entity by IDs. +func (au *AppUpdate) AddInvoicingAppIDs(ids ...string) *AppUpdate { + au.mutation.AddInvoicingAppIDs(ids...) + return au +} + +// AddInvoicingApp adds the "invoicing_app" edges to the BillingProfile entity. +func (au *AppUpdate) AddInvoicingApp(b ...*BillingProfile) *AppUpdate { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return au.AddInvoicingAppIDs(ids...) +} + +// AddPaymentAppIDs adds the "payment_app" edge to the BillingProfile entity by IDs. +func (au *AppUpdate) AddPaymentAppIDs(ids ...string) *AppUpdate { + au.mutation.AddPaymentAppIDs(ids...) + return au +} + +// AddPaymentApp adds the "payment_app" edges to the BillingProfile entity. +func (au *AppUpdate) AddPaymentApp(b ...*BillingProfile) *AppUpdate { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return au.AddPaymentAppIDs(ids...) +} + // Mutation returns the AppMutation object of the builder. func (au *AppUpdate) Mutation() *AppMutation { return au.mutation @@ -171,6 +217,69 @@ func (au *AppUpdate) RemoveCustomerApps(a ...*AppCustomer) *AppUpdate { return au.RemoveCustomerAppIDs(ids...) } +// ClearTaxApp clears all "tax_app" edges to the BillingProfile entity. +func (au *AppUpdate) ClearTaxApp() *AppUpdate { + au.mutation.ClearTaxApp() + return au +} + +// RemoveTaxAppIDs removes the "tax_app" edge to BillingProfile entities by IDs. +func (au *AppUpdate) RemoveTaxAppIDs(ids ...string) *AppUpdate { + au.mutation.RemoveTaxAppIDs(ids...) + return au +} + +// RemoveTaxApp removes "tax_app" edges to BillingProfile entities. +func (au *AppUpdate) RemoveTaxApp(b ...*BillingProfile) *AppUpdate { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return au.RemoveTaxAppIDs(ids...) +} + +// ClearInvoicingApp clears all "invoicing_app" edges to the BillingProfile entity. +func (au *AppUpdate) ClearInvoicingApp() *AppUpdate { + au.mutation.ClearInvoicingApp() + return au +} + +// RemoveInvoicingAppIDs removes the "invoicing_app" edge to BillingProfile entities by IDs. +func (au *AppUpdate) RemoveInvoicingAppIDs(ids ...string) *AppUpdate { + au.mutation.RemoveInvoicingAppIDs(ids...) + return au +} + +// RemoveInvoicingApp removes "invoicing_app" edges to BillingProfile entities. +func (au *AppUpdate) RemoveInvoicingApp(b ...*BillingProfile) *AppUpdate { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return au.RemoveInvoicingAppIDs(ids...) +} + +// ClearPaymentApp clears all "payment_app" edges to the BillingProfile entity. +func (au *AppUpdate) ClearPaymentApp() *AppUpdate { + au.mutation.ClearPaymentApp() + return au +} + +// RemovePaymentAppIDs removes the "payment_app" edge to BillingProfile entities by IDs. +func (au *AppUpdate) RemovePaymentAppIDs(ids ...string) *AppUpdate { + au.mutation.RemovePaymentAppIDs(ids...) + return au +} + +// RemovePaymentApp removes "payment_app" edges to BillingProfile entities. +func (au *AppUpdate) RemovePaymentApp(b ...*BillingProfile) *AppUpdate { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return au.RemovePaymentAppIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (au *AppUpdate) Save(ctx context.Context) (int, error) { au.defaults() @@ -291,6 +400,141 @@ func (au *AppUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if au.mutation.TaxAppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.TaxAppTable, + Columns: []string{app.TaxAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.RemovedTaxAppIDs(); len(nodes) > 0 && !au.mutation.TaxAppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.TaxAppTable, + Columns: []string{app.TaxAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.TaxAppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.TaxAppTable, + Columns: []string{app.TaxAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if au.mutation.InvoicingAppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.InvoicingAppTable, + Columns: []string{app.InvoicingAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.RemovedInvoicingAppIDs(); len(nodes) > 0 && !au.mutation.InvoicingAppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.InvoicingAppTable, + Columns: []string{app.InvoicingAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.InvoicingAppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.InvoicingAppTable, + Columns: []string{app.InvoicingAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if au.mutation.PaymentAppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.PaymentAppTable, + Columns: []string{app.PaymentAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.RemovedPaymentAppIDs(); len(nodes) > 0 && !au.mutation.PaymentAppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.PaymentAppTable, + Columns: []string{app.PaymentAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := au.mutation.PaymentAppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.PaymentAppTable, + Columns: []string{app.PaymentAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if n, err = sqlgraph.UpdateNodes(ctx, au.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{app.Label} @@ -426,6 +670,51 @@ func (auo *AppUpdateOne) AddCustomerApps(a ...*AppCustomer) *AppUpdateOne { return auo.AddCustomerAppIDs(ids...) } +// AddTaxAppIDs adds the "tax_app" edge to the BillingProfile entity by IDs. +func (auo *AppUpdateOne) AddTaxAppIDs(ids ...string) *AppUpdateOne { + auo.mutation.AddTaxAppIDs(ids...) + return auo +} + +// AddTaxApp adds the "tax_app" edges to the BillingProfile entity. +func (auo *AppUpdateOne) AddTaxApp(b ...*BillingProfile) *AppUpdateOne { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return auo.AddTaxAppIDs(ids...) +} + +// AddInvoicingAppIDs adds the "invoicing_app" edge to the BillingProfile entity by IDs. +func (auo *AppUpdateOne) AddInvoicingAppIDs(ids ...string) *AppUpdateOne { + auo.mutation.AddInvoicingAppIDs(ids...) + return auo +} + +// AddInvoicingApp adds the "invoicing_app" edges to the BillingProfile entity. +func (auo *AppUpdateOne) AddInvoicingApp(b ...*BillingProfile) *AppUpdateOne { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return auo.AddInvoicingAppIDs(ids...) +} + +// AddPaymentAppIDs adds the "payment_app" edge to the BillingProfile entity by IDs. +func (auo *AppUpdateOne) AddPaymentAppIDs(ids ...string) *AppUpdateOne { + auo.mutation.AddPaymentAppIDs(ids...) + return auo +} + +// AddPaymentApp adds the "payment_app" edges to the BillingProfile entity. +func (auo *AppUpdateOne) AddPaymentApp(b ...*BillingProfile) *AppUpdateOne { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return auo.AddPaymentAppIDs(ids...) +} + // Mutation returns the AppMutation object of the builder. func (auo *AppUpdateOne) Mutation() *AppMutation { return auo.mutation @@ -452,6 +741,69 @@ func (auo *AppUpdateOne) RemoveCustomerApps(a ...*AppCustomer) *AppUpdateOne { return auo.RemoveCustomerAppIDs(ids...) } +// ClearTaxApp clears all "tax_app" edges to the BillingProfile entity. +func (auo *AppUpdateOne) ClearTaxApp() *AppUpdateOne { + auo.mutation.ClearTaxApp() + return auo +} + +// RemoveTaxAppIDs removes the "tax_app" edge to BillingProfile entities by IDs. +func (auo *AppUpdateOne) RemoveTaxAppIDs(ids ...string) *AppUpdateOne { + auo.mutation.RemoveTaxAppIDs(ids...) + return auo +} + +// RemoveTaxApp removes "tax_app" edges to BillingProfile entities. +func (auo *AppUpdateOne) RemoveTaxApp(b ...*BillingProfile) *AppUpdateOne { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return auo.RemoveTaxAppIDs(ids...) +} + +// ClearInvoicingApp clears all "invoicing_app" edges to the BillingProfile entity. +func (auo *AppUpdateOne) ClearInvoicingApp() *AppUpdateOne { + auo.mutation.ClearInvoicingApp() + return auo +} + +// RemoveInvoicingAppIDs removes the "invoicing_app" edge to BillingProfile entities by IDs. +func (auo *AppUpdateOne) RemoveInvoicingAppIDs(ids ...string) *AppUpdateOne { + auo.mutation.RemoveInvoicingAppIDs(ids...) + return auo +} + +// RemoveInvoicingApp removes "invoicing_app" edges to BillingProfile entities. +func (auo *AppUpdateOne) RemoveInvoicingApp(b ...*BillingProfile) *AppUpdateOne { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return auo.RemoveInvoicingAppIDs(ids...) +} + +// ClearPaymentApp clears all "payment_app" edges to the BillingProfile entity. +func (auo *AppUpdateOne) ClearPaymentApp() *AppUpdateOne { + auo.mutation.ClearPaymentApp() + return auo +} + +// RemovePaymentAppIDs removes the "payment_app" edge to BillingProfile entities by IDs. +func (auo *AppUpdateOne) RemovePaymentAppIDs(ids ...string) *AppUpdateOne { + auo.mutation.RemovePaymentAppIDs(ids...) + return auo +} + +// RemovePaymentApp removes "payment_app" edges to BillingProfile entities. +func (auo *AppUpdateOne) RemovePaymentApp(b ...*BillingProfile) *AppUpdateOne { + ids := make([]string, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return auo.RemovePaymentAppIDs(ids...) +} + // Where appends a list predicates to the AppUpdate builder. func (auo *AppUpdateOne) Where(ps ...predicate.App) *AppUpdateOne { auo.mutation.Where(ps...) @@ -602,6 +954,141 @@ func (auo *AppUpdateOne) sqlSave(ctx context.Context) (_node *App, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if auo.mutation.TaxAppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.TaxAppTable, + Columns: []string{app.TaxAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.RemovedTaxAppIDs(); len(nodes) > 0 && !auo.mutation.TaxAppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.TaxAppTable, + Columns: []string{app.TaxAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.TaxAppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.TaxAppTable, + Columns: []string{app.TaxAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if auo.mutation.InvoicingAppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.InvoicingAppTable, + Columns: []string{app.InvoicingAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.RemovedInvoicingAppIDs(); len(nodes) > 0 && !auo.mutation.InvoicingAppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.InvoicingAppTable, + Columns: []string{app.InvoicingAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.InvoicingAppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.InvoicingAppTable, + Columns: []string{app.InvoicingAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if auo.mutation.PaymentAppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.PaymentAppTable, + Columns: []string{app.PaymentAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.RemovedPaymentAppIDs(); len(nodes) > 0 && !auo.mutation.PaymentAppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.PaymentAppTable, + Columns: []string{app.PaymentAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := auo.mutation.PaymentAppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: app.PaymentAppTable, + Columns: []string{app.PaymentAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(billingprofile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _node = &App{config: auo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/openmeter/ent/db/billingcustomeroverride.go b/openmeter/ent/db/billingcustomeroverride.go index 2e8ea5478..85b66bb1f 100644 --- a/openmeter/ent/db/billingcustomeroverride.go +++ b/openmeter/ent/db/billingcustomeroverride.go @@ -9,10 +9,11 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/billingcustomeroverride" "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" "github.com/openmeterio/openmeter/openmeter/ent/db/customer" + "github.com/openmeterio/openmeter/pkg/datex" ) // BillingCustomerOverride is the model entity for the BillingCustomerOverride schema. @@ -33,21 +34,17 @@ type BillingCustomerOverride struct { // BillingProfileID holds the value of the "billing_profile_id" field. BillingProfileID *string `json:"billing_profile_id,omitempty"` // CollectionAlignment holds the value of the "collection_alignment" field. - CollectionAlignment *billing.AlignmentKind `json:"collection_alignment,omitempty"` - // ItemCollectionPeriodSeconds holds the value of the "item_collection_period_seconds" field. - ItemCollectionPeriodSeconds *int64 `json:"item_collection_period_seconds,omitempty"` + CollectionAlignment *billingentity.AlignmentKind `json:"collection_alignment,omitempty"` + // ItemCollectionPeriod holds the value of the "item_collection_period" field. + ItemCollectionPeriod *datex.ISOString `json:"item_collection_period,omitempty"` // InvoiceAutoAdvance holds the value of the "invoice_auto_advance" field. InvoiceAutoAdvance *bool `json:"invoice_auto_advance,omitempty"` - // InvoiceDraftPeriodSeconds holds the value of the "invoice_draft_period_seconds" field. - InvoiceDraftPeriodSeconds *int64 `json:"invoice_draft_period_seconds,omitempty"` - // InvoiceDueAfterSeconds holds the value of the "invoice_due_after_seconds" field. - InvoiceDueAfterSeconds *int64 `json:"invoice_due_after_seconds,omitempty"` + // InvoiceDraftPeriod holds the value of the "invoice_draft_period" field. + InvoiceDraftPeriod *datex.ISOString `json:"invoice_draft_period,omitempty"` + // InvoiceDueAfter holds the value of the "invoice_due_after" field. + InvoiceDueAfter *datex.ISOString `json:"invoice_due_after,omitempty"` // InvoiceCollectionMethod holds the value of the "invoice_collection_method" field. - InvoiceCollectionMethod *billing.CollectionMethod `json:"invoice_collection_method,omitempty"` - // InvoiceItemResolution holds the value of the "invoice_item_resolution" field. - InvoiceItemResolution *billing.GranularityResolution `json:"invoice_item_resolution,omitempty"` - // InvoiceItemPerSubject holds the value of the "invoice_item_per_subject" field. - InvoiceItemPerSubject *bool `json:"invoice_item_per_subject,omitempty"` + InvoiceCollectionMethod *billingentity.CollectionMethod `json:"invoice_collection_method,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the BillingCustomerOverrideQuery when eager-loading is set. Edges BillingCustomerOverrideEdges `json:"edges"` @@ -92,11 +89,9 @@ func (*BillingCustomerOverride) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case billingcustomeroverride.FieldInvoiceAutoAdvance, billingcustomeroverride.FieldInvoiceItemPerSubject: + case billingcustomeroverride.FieldInvoiceAutoAdvance: values[i] = new(sql.NullBool) - case billingcustomeroverride.FieldItemCollectionPeriodSeconds, billingcustomeroverride.FieldInvoiceDraftPeriodSeconds, billingcustomeroverride.FieldInvoiceDueAfterSeconds: - values[i] = new(sql.NullInt64) - case billingcustomeroverride.FieldID, billingcustomeroverride.FieldNamespace, billingcustomeroverride.FieldCustomerID, billingcustomeroverride.FieldBillingProfileID, billingcustomeroverride.FieldCollectionAlignment, billingcustomeroverride.FieldInvoiceCollectionMethod, billingcustomeroverride.FieldInvoiceItemResolution: + case billingcustomeroverride.FieldID, billingcustomeroverride.FieldNamespace, billingcustomeroverride.FieldCustomerID, billingcustomeroverride.FieldBillingProfileID, billingcustomeroverride.FieldCollectionAlignment, billingcustomeroverride.FieldItemCollectionPeriod, billingcustomeroverride.FieldInvoiceDraftPeriod, billingcustomeroverride.FieldInvoiceDueAfter, billingcustomeroverride.FieldInvoiceCollectionMethod: values[i] = new(sql.NullString) case billingcustomeroverride.FieldCreatedAt, billingcustomeroverride.FieldUpdatedAt, billingcustomeroverride.FieldDeletedAt: values[i] = new(sql.NullTime) @@ -163,15 +158,15 @@ func (bco *BillingCustomerOverride) assignValues(columns []string, values []any) if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field collection_alignment", values[i]) } else if value.Valid { - bco.CollectionAlignment = new(billing.AlignmentKind) - *bco.CollectionAlignment = billing.AlignmentKind(value.String) + bco.CollectionAlignment = new(billingentity.AlignmentKind) + *bco.CollectionAlignment = billingentity.AlignmentKind(value.String) } - case billingcustomeroverride.FieldItemCollectionPeriodSeconds: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field item_collection_period_seconds", values[i]) + case billingcustomeroverride.FieldItemCollectionPeriod: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field item_collection_period", values[i]) } else if value.Valid { - bco.ItemCollectionPeriodSeconds = new(int64) - *bco.ItemCollectionPeriodSeconds = value.Int64 + bco.ItemCollectionPeriod = new(datex.ISOString) + *bco.ItemCollectionPeriod = datex.ISOString(value.String) } case billingcustomeroverride.FieldInvoiceAutoAdvance: if value, ok := values[i].(*sql.NullBool); !ok { @@ -180,40 +175,26 @@ func (bco *BillingCustomerOverride) assignValues(columns []string, values []any) bco.InvoiceAutoAdvance = new(bool) *bco.InvoiceAutoAdvance = value.Bool } - case billingcustomeroverride.FieldInvoiceDraftPeriodSeconds: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field invoice_draft_period_seconds", values[i]) + case billingcustomeroverride.FieldInvoiceDraftPeriod: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field invoice_draft_period", values[i]) } else if value.Valid { - bco.InvoiceDraftPeriodSeconds = new(int64) - *bco.InvoiceDraftPeriodSeconds = value.Int64 + bco.InvoiceDraftPeriod = new(datex.ISOString) + *bco.InvoiceDraftPeriod = datex.ISOString(value.String) } - case billingcustomeroverride.FieldInvoiceDueAfterSeconds: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field invoice_due_after_seconds", values[i]) + case billingcustomeroverride.FieldInvoiceDueAfter: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field invoice_due_after", values[i]) } else if value.Valid { - bco.InvoiceDueAfterSeconds = new(int64) - *bco.InvoiceDueAfterSeconds = value.Int64 + bco.InvoiceDueAfter = new(datex.ISOString) + *bco.InvoiceDueAfter = datex.ISOString(value.String) } case billingcustomeroverride.FieldInvoiceCollectionMethod: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field invoice_collection_method", values[i]) } else if value.Valid { - bco.InvoiceCollectionMethod = new(billing.CollectionMethod) - *bco.InvoiceCollectionMethod = billing.CollectionMethod(value.String) - } - case billingcustomeroverride.FieldInvoiceItemResolution: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field invoice_item_resolution", values[i]) - } else if value.Valid { - bco.InvoiceItemResolution = new(billing.GranularityResolution) - *bco.InvoiceItemResolution = billing.GranularityResolution(value.String) - } - case billingcustomeroverride.FieldInvoiceItemPerSubject: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field invoice_item_per_subject", values[i]) - } else if value.Valid { - bco.InvoiceItemPerSubject = new(bool) - *bco.InvoiceItemPerSubject = value.Bool + bco.InvoiceCollectionMethod = new(billingentity.CollectionMethod) + *bco.InvoiceCollectionMethod = billingentity.CollectionMethod(value.String) } default: bco.selectValues.Set(columns[i], values[i]) @@ -288,8 +269,8 @@ func (bco *BillingCustomerOverride) String() string { builder.WriteString(fmt.Sprintf("%v", *v)) } builder.WriteString(", ") - if v := bco.ItemCollectionPeriodSeconds; v != nil { - builder.WriteString("item_collection_period_seconds=") + if v := bco.ItemCollectionPeriod; v != nil { + builder.WriteString("item_collection_period=") builder.WriteString(fmt.Sprintf("%v", *v)) } builder.WriteString(", ") @@ -298,13 +279,13 @@ func (bco *BillingCustomerOverride) String() string { builder.WriteString(fmt.Sprintf("%v", *v)) } builder.WriteString(", ") - if v := bco.InvoiceDraftPeriodSeconds; v != nil { - builder.WriteString("invoice_draft_period_seconds=") + if v := bco.InvoiceDraftPeriod; v != nil { + builder.WriteString("invoice_draft_period=") builder.WriteString(fmt.Sprintf("%v", *v)) } builder.WriteString(", ") - if v := bco.InvoiceDueAfterSeconds; v != nil { - builder.WriteString("invoice_due_after_seconds=") + if v := bco.InvoiceDueAfter; v != nil { + builder.WriteString("invoice_due_after=") builder.WriteString(fmt.Sprintf("%v", *v)) } builder.WriteString(", ") @@ -312,16 +293,6 @@ func (bco *BillingCustomerOverride) String() string { builder.WriteString("invoice_collection_method=") builder.WriteString(fmt.Sprintf("%v", *v)) } - builder.WriteString(", ") - if v := bco.InvoiceItemResolution; v != nil { - builder.WriteString("invoice_item_resolution=") - builder.WriteString(fmt.Sprintf("%v", *v)) - } - builder.WriteString(", ") - if v := bco.InvoiceItemPerSubject; v != nil { - builder.WriteString("invoice_item_per_subject=") - builder.WriteString(fmt.Sprintf("%v", *v)) - } builder.WriteByte(')') return builder.String() } diff --git a/openmeter/ent/db/billingcustomeroverride/billingcustomeroverride.go b/openmeter/ent/db/billingcustomeroverride/billingcustomeroverride.go index 353e173a5..4b1187529 100644 --- a/openmeter/ent/db/billingcustomeroverride/billingcustomeroverride.go +++ b/openmeter/ent/db/billingcustomeroverride/billingcustomeroverride.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" ) const ( @@ -30,20 +30,16 @@ const ( FieldBillingProfileID = "billing_profile_id" // FieldCollectionAlignment holds the string denoting the collection_alignment field in the database. FieldCollectionAlignment = "collection_alignment" - // FieldItemCollectionPeriodSeconds holds the string denoting the item_collection_period_seconds field in the database. - FieldItemCollectionPeriodSeconds = "item_collection_period_seconds" + // FieldItemCollectionPeriod holds the string denoting the item_collection_period field in the database. + FieldItemCollectionPeriod = "item_collection_period" // FieldInvoiceAutoAdvance holds the string denoting the invoice_auto_advance field in the database. FieldInvoiceAutoAdvance = "invoice_auto_advance" - // FieldInvoiceDraftPeriodSeconds holds the string denoting the invoice_draft_period_seconds field in the database. - FieldInvoiceDraftPeriodSeconds = "invoice_draft_period_seconds" - // FieldInvoiceDueAfterSeconds holds the string denoting the invoice_due_after_seconds field in the database. - FieldInvoiceDueAfterSeconds = "invoice_due_after_seconds" + // FieldInvoiceDraftPeriod holds the string denoting the invoice_draft_period field in the database. + FieldInvoiceDraftPeriod = "invoice_draft_period" + // FieldInvoiceDueAfter holds the string denoting the invoice_due_after field in the database. + FieldInvoiceDueAfter = "invoice_due_after" // FieldInvoiceCollectionMethod holds the string denoting the invoice_collection_method field in the database. FieldInvoiceCollectionMethod = "invoice_collection_method" - // FieldInvoiceItemResolution holds the string denoting the invoice_item_resolution field in the database. - FieldInvoiceItemResolution = "invoice_item_resolution" - // FieldInvoiceItemPerSubject holds the string denoting the invoice_item_per_subject field in the database. - FieldInvoiceItemPerSubject = "invoice_item_per_subject" // EdgeCustomer holds the string denoting the customer edge name in mutations. EdgeCustomer = "customer" // EdgeBillingProfile holds the string denoting the billing_profile edge name in mutations. @@ -76,13 +72,11 @@ var Columns = []string{ FieldCustomerID, FieldBillingProfileID, FieldCollectionAlignment, - FieldItemCollectionPeriodSeconds, + FieldItemCollectionPeriod, FieldInvoiceAutoAdvance, - FieldInvoiceDraftPeriodSeconds, - FieldInvoiceDueAfterSeconds, + FieldInvoiceDraftPeriod, + FieldInvoiceDueAfter, FieldInvoiceCollectionMethod, - FieldInvoiceItemResolution, - FieldInvoiceItemPerSubject, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -109,7 +103,7 @@ var ( ) // CollectionAlignmentValidator is a validator for the "collection_alignment" field enum values. It is called by the builders before save. -func CollectionAlignmentValidator(ca billing.AlignmentKind) error { +func CollectionAlignmentValidator(ca billingentity.AlignmentKind) error { switch ca { case "subscription": return nil @@ -119,7 +113,7 @@ func CollectionAlignmentValidator(ca billing.AlignmentKind) error { } // InvoiceCollectionMethodValidator is a validator for the "invoice_collection_method" field enum values. It is called by the builders before save. -func InvoiceCollectionMethodValidator(icm billing.CollectionMethod) error { +func InvoiceCollectionMethodValidator(icm billingentity.CollectionMethod) error { switch icm { case "charge_automatically", "send_invoice": return nil @@ -128,16 +122,6 @@ func InvoiceCollectionMethodValidator(icm billing.CollectionMethod) error { } } -// InvoiceItemResolutionValidator is a validator for the "invoice_item_resolution" field enum values. It is called by the builders before save. -func InvoiceItemResolutionValidator(iir billing.GranularityResolution) error { - switch iir { - case "day", "period": - return nil - default: - return fmt.Errorf("billingcustomeroverride: invalid enum value for invoice_item_resolution field: %q", iir) - } -} - // OrderOption defines the ordering options for the BillingCustomerOverride queries. type OrderOption func(*sql.Selector) @@ -181,9 +165,9 @@ func ByCollectionAlignment(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCollectionAlignment, opts...).ToFunc() } -// ByItemCollectionPeriodSeconds orders the results by the item_collection_period_seconds field. -func ByItemCollectionPeriodSeconds(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldItemCollectionPeriodSeconds, opts...).ToFunc() +// ByItemCollectionPeriod orders the results by the item_collection_period field. +func ByItemCollectionPeriod(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldItemCollectionPeriod, opts...).ToFunc() } // ByInvoiceAutoAdvance orders the results by the invoice_auto_advance field. @@ -191,14 +175,14 @@ func ByInvoiceAutoAdvance(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldInvoiceAutoAdvance, opts...).ToFunc() } -// ByInvoiceDraftPeriodSeconds orders the results by the invoice_draft_period_seconds field. -func ByInvoiceDraftPeriodSeconds(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldInvoiceDraftPeriodSeconds, opts...).ToFunc() +// ByInvoiceDraftPeriod orders the results by the invoice_draft_period field. +func ByInvoiceDraftPeriod(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldInvoiceDraftPeriod, opts...).ToFunc() } -// ByInvoiceDueAfterSeconds orders the results by the invoice_due_after_seconds field. -func ByInvoiceDueAfterSeconds(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldInvoiceDueAfterSeconds, opts...).ToFunc() +// ByInvoiceDueAfter orders the results by the invoice_due_after field. +func ByInvoiceDueAfter(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldInvoiceDueAfter, opts...).ToFunc() } // ByInvoiceCollectionMethod orders the results by the invoice_collection_method field. @@ -206,16 +190,6 @@ func ByInvoiceCollectionMethod(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldInvoiceCollectionMethod, opts...).ToFunc() } -// ByInvoiceItemResolution orders the results by the invoice_item_resolution field. -func ByInvoiceItemResolution(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldInvoiceItemResolution, opts...).ToFunc() -} - -// ByInvoiceItemPerSubject orders the results by the invoice_item_per_subject field. -func ByInvoiceItemPerSubject(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldInvoiceItemPerSubject, opts...).ToFunc() -} - // ByCustomerField orders the results by customer field. func ByCustomerField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/openmeter/ent/db/billingcustomeroverride/where.go b/openmeter/ent/db/billingcustomeroverride/where.go index 7fc83294c..500517ce5 100644 --- a/openmeter/ent/db/billingcustomeroverride/where.go +++ b/openmeter/ent/db/billingcustomeroverride/where.go @@ -7,8 +7,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" + "github.com/openmeterio/openmeter/pkg/datex" ) // ID filters vertices based on their ID field. @@ -96,9 +97,10 @@ func BillingProfileID(v string) predicate.BillingCustomerOverride { return predicate.BillingCustomerOverride(sql.FieldEQ(FieldBillingProfileID, v)) } -// ItemCollectionPeriodSeconds applies equality check predicate on the "item_collection_period_seconds" field. It's identical to ItemCollectionPeriodSecondsEQ. -func ItemCollectionPeriodSeconds(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldEQ(FieldItemCollectionPeriodSeconds, v)) +// ItemCollectionPeriod applies equality check predicate on the "item_collection_period" field. It's identical to ItemCollectionPeriodEQ. +func ItemCollectionPeriod(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldEQ(FieldItemCollectionPeriod, vc)) } // InvoiceAutoAdvance applies equality check predicate on the "invoice_auto_advance" field. It's identical to InvoiceAutoAdvanceEQ. @@ -106,19 +108,16 @@ func InvoiceAutoAdvance(v bool) predicate.BillingCustomerOverride { return predicate.BillingCustomerOverride(sql.FieldEQ(FieldInvoiceAutoAdvance, v)) } -// InvoiceDraftPeriodSeconds applies equality check predicate on the "invoice_draft_period_seconds" field. It's identical to InvoiceDraftPeriodSecondsEQ. -func InvoiceDraftPeriodSeconds(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldEQ(FieldInvoiceDraftPeriodSeconds, v)) +// InvoiceDraftPeriod applies equality check predicate on the "invoice_draft_period" field. It's identical to InvoiceDraftPeriodEQ. +func InvoiceDraftPeriod(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldEQ(FieldInvoiceDraftPeriod, vc)) } -// InvoiceDueAfterSeconds applies equality check predicate on the "invoice_due_after_seconds" field. It's identical to InvoiceDueAfterSecondsEQ. -func InvoiceDueAfterSeconds(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldEQ(FieldInvoiceDueAfterSeconds, v)) -} - -// InvoiceItemPerSubject applies equality check predicate on the "invoice_item_per_subject" field. It's identical to InvoiceItemPerSubjectEQ. -func InvoiceItemPerSubject(v bool) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldEQ(FieldInvoiceItemPerSubject, v)) +// InvoiceDueAfter applies equality check predicate on the "invoice_due_after" field. It's identical to InvoiceDueAfterEQ. +func InvoiceDueAfter(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldEQ(FieldInvoiceDueAfter, vc)) } // NamespaceEQ applies the EQ predicate on the "namespace" field. @@ -457,19 +456,19 @@ func BillingProfileIDContainsFold(v string) predicate.BillingCustomerOverride { } // CollectionAlignmentEQ applies the EQ predicate on the "collection_alignment" field. -func CollectionAlignmentEQ(v billing.AlignmentKind) predicate.BillingCustomerOverride { +func CollectionAlignmentEQ(v billingentity.AlignmentKind) predicate.BillingCustomerOverride { vc := v return predicate.BillingCustomerOverride(sql.FieldEQ(FieldCollectionAlignment, vc)) } // CollectionAlignmentNEQ applies the NEQ predicate on the "collection_alignment" field. -func CollectionAlignmentNEQ(v billing.AlignmentKind) predicate.BillingCustomerOverride { +func CollectionAlignmentNEQ(v billingentity.AlignmentKind) predicate.BillingCustomerOverride { vc := v return predicate.BillingCustomerOverride(sql.FieldNEQ(FieldCollectionAlignment, vc)) } // CollectionAlignmentIn applies the In predicate on the "collection_alignment" field. -func CollectionAlignmentIn(vs ...billing.AlignmentKind) predicate.BillingCustomerOverride { +func CollectionAlignmentIn(vs ...billingentity.AlignmentKind) predicate.BillingCustomerOverride { v := make([]any, len(vs)) for i := range v { v[i] = vs[i] @@ -478,7 +477,7 @@ func CollectionAlignmentIn(vs ...billing.AlignmentKind) predicate.BillingCustome } // CollectionAlignmentNotIn applies the NotIn predicate on the "collection_alignment" field. -func CollectionAlignmentNotIn(vs ...billing.AlignmentKind) predicate.BillingCustomerOverride { +func CollectionAlignmentNotIn(vs ...billingentity.AlignmentKind) predicate.BillingCustomerOverride { v := make([]any, len(vs)) for i := range v { v[i] = vs[i] @@ -496,54 +495,98 @@ func CollectionAlignmentNotNil() predicate.BillingCustomerOverride { return predicate.BillingCustomerOverride(sql.FieldNotNull(FieldCollectionAlignment)) } -// ItemCollectionPeriodSecondsEQ applies the EQ predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsEQ(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldEQ(FieldItemCollectionPeriodSeconds, v)) +// ItemCollectionPeriodEQ applies the EQ predicate on the "item_collection_period" field. +func ItemCollectionPeriodEQ(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldEQ(FieldItemCollectionPeriod, vc)) +} + +// ItemCollectionPeriodNEQ applies the NEQ predicate on the "item_collection_period" field. +func ItemCollectionPeriodNEQ(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldNEQ(FieldItemCollectionPeriod, vc)) +} + +// ItemCollectionPeriodIn applies the In predicate on the "item_collection_period" field. +func ItemCollectionPeriodIn(vs ...datex.ISOString) predicate.BillingCustomerOverride { + v := make([]any, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.BillingCustomerOverride(sql.FieldIn(FieldItemCollectionPeriod, v...)) +} + +// ItemCollectionPeriodNotIn applies the NotIn predicate on the "item_collection_period" field. +func ItemCollectionPeriodNotIn(vs ...datex.ISOString) predicate.BillingCustomerOverride { + v := make([]any, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.BillingCustomerOverride(sql.FieldNotIn(FieldItemCollectionPeriod, v...)) +} + +// ItemCollectionPeriodGT applies the GT predicate on the "item_collection_period" field. +func ItemCollectionPeriodGT(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldGT(FieldItemCollectionPeriod, vc)) +} + +// ItemCollectionPeriodGTE applies the GTE predicate on the "item_collection_period" field. +func ItemCollectionPeriodGTE(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldGTE(FieldItemCollectionPeriod, vc)) } -// ItemCollectionPeriodSecondsNEQ applies the NEQ predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsNEQ(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldNEQ(FieldItemCollectionPeriodSeconds, v)) +// ItemCollectionPeriodLT applies the LT predicate on the "item_collection_period" field. +func ItemCollectionPeriodLT(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldLT(FieldItemCollectionPeriod, vc)) } -// ItemCollectionPeriodSecondsIn applies the In predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsIn(vs ...int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldIn(FieldItemCollectionPeriodSeconds, vs...)) +// ItemCollectionPeriodLTE applies the LTE predicate on the "item_collection_period" field. +func ItemCollectionPeriodLTE(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldLTE(FieldItemCollectionPeriod, vc)) } -// ItemCollectionPeriodSecondsNotIn applies the NotIn predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsNotIn(vs ...int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldNotIn(FieldItemCollectionPeriodSeconds, vs...)) +// ItemCollectionPeriodContains applies the Contains predicate on the "item_collection_period" field. +func ItemCollectionPeriodContains(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldContains(FieldItemCollectionPeriod, vc)) } -// ItemCollectionPeriodSecondsGT applies the GT predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsGT(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldGT(FieldItemCollectionPeriodSeconds, v)) +// ItemCollectionPeriodHasPrefix applies the HasPrefix predicate on the "item_collection_period" field. +func ItemCollectionPeriodHasPrefix(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldHasPrefix(FieldItemCollectionPeriod, vc)) } -// ItemCollectionPeriodSecondsGTE applies the GTE predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsGTE(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldGTE(FieldItemCollectionPeriodSeconds, v)) +// ItemCollectionPeriodHasSuffix applies the HasSuffix predicate on the "item_collection_period" field. +func ItemCollectionPeriodHasSuffix(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldHasSuffix(FieldItemCollectionPeriod, vc)) } -// ItemCollectionPeriodSecondsLT applies the LT predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsLT(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldLT(FieldItemCollectionPeriodSeconds, v)) +// ItemCollectionPeriodIsNil applies the IsNil predicate on the "item_collection_period" field. +func ItemCollectionPeriodIsNil() predicate.BillingCustomerOverride { + return predicate.BillingCustomerOverride(sql.FieldIsNull(FieldItemCollectionPeriod)) } -// ItemCollectionPeriodSecondsLTE applies the LTE predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsLTE(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldLTE(FieldItemCollectionPeriodSeconds, v)) +// ItemCollectionPeriodNotNil applies the NotNil predicate on the "item_collection_period" field. +func ItemCollectionPeriodNotNil() predicate.BillingCustomerOverride { + return predicate.BillingCustomerOverride(sql.FieldNotNull(FieldItemCollectionPeriod)) } -// ItemCollectionPeriodSecondsIsNil applies the IsNil predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsIsNil() predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldIsNull(FieldItemCollectionPeriodSeconds)) +// ItemCollectionPeriodEqualFold applies the EqualFold predicate on the "item_collection_period" field. +func ItemCollectionPeriodEqualFold(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldEqualFold(FieldItemCollectionPeriod, vc)) } -// ItemCollectionPeriodSecondsNotNil applies the NotNil predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsNotNil() predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldNotNull(FieldItemCollectionPeriodSeconds)) +// ItemCollectionPeriodContainsFold applies the ContainsFold predicate on the "item_collection_period" field. +func ItemCollectionPeriodContainsFold(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldContainsFold(FieldItemCollectionPeriod, vc)) } // InvoiceAutoAdvanceEQ applies the EQ predicate on the "invoice_auto_advance" field. @@ -566,120 +609,208 @@ func InvoiceAutoAdvanceNotNil() predicate.BillingCustomerOverride { return predicate.BillingCustomerOverride(sql.FieldNotNull(FieldInvoiceAutoAdvance)) } -// InvoiceDraftPeriodSecondsEQ applies the EQ predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsEQ(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldEQ(FieldInvoiceDraftPeriodSeconds, v)) +// InvoiceDraftPeriodEQ applies the EQ predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodEQ(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldEQ(FieldInvoiceDraftPeriod, vc)) +} + +// InvoiceDraftPeriodNEQ applies the NEQ predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodNEQ(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldNEQ(FieldInvoiceDraftPeriod, vc)) +} + +// InvoiceDraftPeriodIn applies the In predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodIn(vs ...datex.ISOString) predicate.BillingCustomerOverride { + v := make([]any, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.BillingCustomerOverride(sql.FieldIn(FieldInvoiceDraftPeriod, v...)) +} + +// InvoiceDraftPeriodNotIn applies the NotIn predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodNotIn(vs ...datex.ISOString) predicate.BillingCustomerOverride { + v := make([]any, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.BillingCustomerOverride(sql.FieldNotIn(FieldInvoiceDraftPeriod, v...)) +} + +// InvoiceDraftPeriodGT applies the GT predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodGT(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldGT(FieldInvoiceDraftPeriod, vc)) +} + +// InvoiceDraftPeriodGTE applies the GTE predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodGTE(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldGTE(FieldInvoiceDraftPeriod, vc)) +} + +// InvoiceDraftPeriodLT applies the LT predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodLT(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldLT(FieldInvoiceDraftPeriod, vc)) +} + +// InvoiceDraftPeriodLTE applies the LTE predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodLTE(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldLTE(FieldInvoiceDraftPeriod, vc)) +} + +// InvoiceDraftPeriodContains applies the Contains predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodContains(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldContains(FieldInvoiceDraftPeriod, vc)) } -// InvoiceDraftPeriodSecondsNEQ applies the NEQ predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsNEQ(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldNEQ(FieldInvoiceDraftPeriodSeconds, v)) +// InvoiceDraftPeriodHasPrefix applies the HasPrefix predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodHasPrefix(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldHasPrefix(FieldInvoiceDraftPeriod, vc)) } -// InvoiceDraftPeriodSecondsIn applies the In predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsIn(vs ...int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldIn(FieldInvoiceDraftPeriodSeconds, vs...)) +// InvoiceDraftPeriodHasSuffix applies the HasSuffix predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodHasSuffix(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldHasSuffix(FieldInvoiceDraftPeriod, vc)) } -// InvoiceDraftPeriodSecondsNotIn applies the NotIn predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsNotIn(vs ...int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldNotIn(FieldInvoiceDraftPeriodSeconds, vs...)) +// InvoiceDraftPeriodIsNil applies the IsNil predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodIsNil() predicate.BillingCustomerOverride { + return predicate.BillingCustomerOverride(sql.FieldIsNull(FieldInvoiceDraftPeriod)) } -// InvoiceDraftPeriodSecondsGT applies the GT predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsGT(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldGT(FieldInvoiceDraftPeriodSeconds, v)) +// InvoiceDraftPeriodNotNil applies the NotNil predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodNotNil() predicate.BillingCustomerOverride { + return predicate.BillingCustomerOverride(sql.FieldNotNull(FieldInvoiceDraftPeriod)) } -// InvoiceDraftPeriodSecondsGTE applies the GTE predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsGTE(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldGTE(FieldInvoiceDraftPeriodSeconds, v)) +// InvoiceDraftPeriodEqualFold applies the EqualFold predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodEqualFold(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldEqualFold(FieldInvoiceDraftPeriod, vc)) } -// InvoiceDraftPeriodSecondsLT applies the LT predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsLT(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldLT(FieldInvoiceDraftPeriodSeconds, v)) +// InvoiceDraftPeriodContainsFold applies the ContainsFold predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodContainsFold(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldContainsFold(FieldInvoiceDraftPeriod, vc)) } -// InvoiceDraftPeriodSecondsLTE applies the LTE predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsLTE(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldLTE(FieldInvoiceDraftPeriodSeconds, v)) +// InvoiceDueAfterEQ applies the EQ predicate on the "invoice_due_after" field. +func InvoiceDueAfterEQ(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldEQ(FieldInvoiceDueAfter, vc)) } -// InvoiceDraftPeriodSecondsIsNil applies the IsNil predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsIsNil() predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldIsNull(FieldInvoiceDraftPeriodSeconds)) +// InvoiceDueAfterNEQ applies the NEQ predicate on the "invoice_due_after" field. +func InvoiceDueAfterNEQ(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldNEQ(FieldInvoiceDueAfter, vc)) } -// InvoiceDraftPeriodSecondsNotNil applies the NotNil predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsNotNil() predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldNotNull(FieldInvoiceDraftPeriodSeconds)) +// InvoiceDueAfterIn applies the In predicate on the "invoice_due_after" field. +func InvoiceDueAfterIn(vs ...datex.ISOString) predicate.BillingCustomerOverride { + v := make([]any, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.BillingCustomerOverride(sql.FieldIn(FieldInvoiceDueAfter, v...)) +} + +// InvoiceDueAfterNotIn applies the NotIn predicate on the "invoice_due_after" field. +func InvoiceDueAfterNotIn(vs ...datex.ISOString) predicate.BillingCustomerOverride { + v := make([]any, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.BillingCustomerOverride(sql.FieldNotIn(FieldInvoiceDueAfter, v...)) +} + +// InvoiceDueAfterGT applies the GT predicate on the "invoice_due_after" field. +func InvoiceDueAfterGT(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldGT(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsEQ applies the EQ predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsEQ(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldEQ(FieldInvoiceDueAfterSeconds, v)) +// InvoiceDueAfterGTE applies the GTE predicate on the "invoice_due_after" field. +func InvoiceDueAfterGTE(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldGTE(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsNEQ applies the NEQ predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsNEQ(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldNEQ(FieldInvoiceDueAfterSeconds, v)) +// InvoiceDueAfterLT applies the LT predicate on the "invoice_due_after" field. +func InvoiceDueAfterLT(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldLT(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsIn applies the In predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsIn(vs ...int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldIn(FieldInvoiceDueAfterSeconds, vs...)) +// InvoiceDueAfterLTE applies the LTE predicate on the "invoice_due_after" field. +func InvoiceDueAfterLTE(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldLTE(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsNotIn applies the NotIn predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsNotIn(vs ...int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldNotIn(FieldInvoiceDueAfterSeconds, vs...)) +// InvoiceDueAfterContains applies the Contains predicate on the "invoice_due_after" field. +func InvoiceDueAfterContains(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldContains(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsGT applies the GT predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsGT(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldGT(FieldInvoiceDueAfterSeconds, v)) +// InvoiceDueAfterHasPrefix applies the HasPrefix predicate on the "invoice_due_after" field. +func InvoiceDueAfterHasPrefix(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldHasPrefix(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsGTE applies the GTE predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsGTE(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldGTE(FieldInvoiceDueAfterSeconds, v)) +// InvoiceDueAfterHasSuffix applies the HasSuffix predicate on the "invoice_due_after" field. +func InvoiceDueAfterHasSuffix(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldHasSuffix(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsLT applies the LT predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsLT(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldLT(FieldInvoiceDueAfterSeconds, v)) +// InvoiceDueAfterIsNil applies the IsNil predicate on the "invoice_due_after" field. +func InvoiceDueAfterIsNil() predicate.BillingCustomerOverride { + return predicate.BillingCustomerOverride(sql.FieldIsNull(FieldInvoiceDueAfter)) } -// InvoiceDueAfterSecondsLTE applies the LTE predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsLTE(v int64) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldLTE(FieldInvoiceDueAfterSeconds, v)) +// InvoiceDueAfterNotNil applies the NotNil predicate on the "invoice_due_after" field. +func InvoiceDueAfterNotNil() predicate.BillingCustomerOverride { + return predicate.BillingCustomerOverride(sql.FieldNotNull(FieldInvoiceDueAfter)) } -// InvoiceDueAfterSecondsIsNil applies the IsNil predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsIsNil() predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldIsNull(FieldInvoiceDueAfterSeconds)) +// InvoiceDueAfterEqualFold applies the EqualFold predicate on the "invoice_due_after" field. +func InvoiceDueAfterEqualFold(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldEqualFold(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsNotNil applies the NotNil predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsNotNil() predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldNotNull(FieldInvoiceDueAfterSeconds)) +// InvoiceDueAfterContainsFold applies the ContainsFold predicate on the "invoice_due_after" field. +func InvoiceDueAfterContainsFold(v datex.ISOString) predicate.BillingCustomerOverride { + vc := string(v) + return predicate.BillingCustomerOverride(sql.FieldContainsFold(FieldInvoiceDueAfter, vc)) } // InvoiceCollectionMethodEQ applies the EQ predicate on the "invoice_collection_method" field. -func InvoiceCollectionMethodEQ(v billing.CollectionMethod) predicate.BillingCustomerOverride { +func InvoiceCollectionMethodEQ(v billingentity.CollectionMethod) predicate.BillingCustomerOverride { vc := v return predicate.BillingCustomerOverride(sql.FieldEQ(FieldInvoiceCollectionMethod, vc)) } // InvoiceCollectionMethodNEQ applies the NEQ predicate on the "invoice_collection_method" field. -func InvoiceCollectionMethodNEQ(v billing.CollectionMethod) predicate.BillingCustomerOverride { +func InvoiceCollectionMethodNEQ(v billingentity.CollectionMethod) predicate.BillingCustomerOverride { vc := v return predicate.BillingCustomerOverride(sql.FieldNEQ(FieldInvoiceCollectionMethod, vc)) } // InvoiceCollectionMethodIn applies the In predicate on the "invoice_collection_method" field. -func InvoiceCollectionMethodIn(vs ...billing.CollectionMethod) predicate.BillingCustomerOverride { +func InvoiceCollectionMethodIn(vs ...billingentity.CollectionMethod) predicate.BillingCustomerOverride { v := make([]any, len(vs)) for i := range v { v[i] = vs[i] @@ -688,7 +819,7 @@ func InvoiceCollectionMethodIn(vs ...billing.CollectionMethod) predicate.Billing } // InvoiceCollectionMethodNotIn applies the NotIn predicate on the "invoice_collection_method" field. -func InvoiceCollectionMethodNotIn(vs ...billing.CollectionMethod) predicate.BillingCustomerOverride { +func InvoiceCollectionMethodNotIn(vs ...billingentity.CollectionMethod) predicate.BillingCustomerOverride { v := make([]any, len(vs)) for i := range v { v[i] = vs[i] @@ -706,66 +837,6 @@ func InvoiceCollectionMethodNotNil() predicate.BillingCustomerOverride { return predicate.BillingCustomerOverride(sql.FieldNotNull(FieldInvoiceCollectionMethod)) } -// InvoiceItemResolutionEQ applies the EQ predicate on the "invoice_item_resolution" field. -func InvoiceItemResolutionEQ(v billing.GranularityResolution) predicate.BillingCustomerOverride { - vc := v - return predicate.BillingCustomerOverride(sql.FieldEQ(FieldInvoiceItemResolution, vc)) -} - -// InvoiceItemResolutionNEQ applies the NEQ predicate on the "invoice_item_resolution" field. -func InvoiceItemResolutionNEQ(v billing.GranularityResolution) predicate.BillingCustomerOverride { - vc := v - return predicate.BillingCustomerOverride(sql.FieldNEQ(FieldInvoiceItemResolution, vc)) -} - -// InvoiceItemResolutionIn applies the In predicate on the "invoice_item_resolution" field. -func InvoiceItemResolutionIn(vs ...billing.GranularityResolution) predicate.BillingCustomerOverride { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingCustomerOverride(sql.FieldIn(FieldInvoiceItemResolution, v...)) -} - -// InvoiceItemResolutionNotIn applies the NotIn predicate on the "invoice_item_resolution" field. -func InvoiceItemResolutionNotIn(vs ...billing.GranularityResolution) predicate.BillingCustomerOverride { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingCustomerOverride(sql.FieldNotIn(FieldInvoiceItemResolution, v...)) -} - -// InvoiceItemResolutionIsNil applies the IsNil predicate on the "invoice_item_resolution" field. -func InvoiceItemResolutionIsNil() predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldIsNull(FieldInvoiceItemResolution)) -} - -// InvoiceItemResolutionNotNil applies the NotNil predicate on the "invoice_item_resolution" field. -func InvoiceItemResolutionNotNil() predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldNotNull(FieldInvoiceItemResolution)) -} - -// InvoiceItemPerSubjectEQ applies the EQ predicate on the "invoice_item_per_subject" field. -func InvoiceItemPerSubjectEQ(v bool) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldEQ(FieldInvoiceItemPerSubject, v)) -} - -// InvoiceItemPerSubjectNEQ applies the NEQ predicate on the "invoice_item_per_subject" field. -func InvoiceItemPerSubjectNEQ(v bool) predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldNEQ(FieldInvoiceItemPerSubject, v)) -} - -// InvoiceItemPerSubjectIsNil applies the IsNil predicate on the "invoice_item_per_subject" field. -func InvoiceItemPerSubjectIsNil() predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldIsNull(FieldInvoiceItemPerSubject)) -} - -// InvoiceItemPerSubjectNotNil applies the NotNil predicate on the "invoice_item_per_subject" field. -func InvoiceItemPerSubjectNotNil() predicate.BillingCustomerOverride { - return predicate.BillingCustomerOverride(sql.FieldNotNull(FieldInvoiceItemPerSubject)) -} - // HasCustomer applies the HasEdge predicate on the "customer" edge. func HasCustomer() predicate.BillingCustomerOverride { return predicate.BillingCustomerOverride(func(s *sql.Selector) { diff --git a/openmeter/ent/db/billingcustomeroverride_create.go b/openmeter/ent/db/billingcustomeroverride_create.go index 1551905f9..3f25b19df 100644 --- a/openmeter/ent/db/billingcustomeroverride_create.go +++ b/openmeter/ent/db/billingcustomeroverride_create.go @@ -12,10 +12,11 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/billingcustomeroverride" "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" "github.com/openmeterio/openmeter/openmeter/ent/db/customer" + "github.com/openmeterio/openmeter/pkg/datex" ) // BillingCustomerOverrideCreate is the builder for creating a BillingCustomerOverride entity. @@ -95,29 +96,29 @@ func (bcoc *BillingCustomerOverrideCreate) SetNillableBillingProfileID(s *string } // SetCollectionAlignment sets the "collection_alignment" field. -func (bcoc *BillingCustomerOverrideCreate) SetCollectionAlignment(bk billing.AlignmentKind) *BillingCustomerOverrideCreate { +func (bcoc *BillingCustomerOverrideCreate) SetCollectionAlignment(bk billingentity.AlignmentKind) *BillingCustomerOverrideCreate { bcoc.mutation.SetCollectionAlignment(bk) return bcoc } // SetNillableCollectionAlignment sets the "collection_alignment" field if the given value is not nil. -func (bcoc *BillingCustomerOverrideCreate) SetNillableCollectionAlignment(bk *billing.AlignmentKind) *BillingCustomerOverrideCreate { +func (bcoc *BillingCustomerOverrideCreate) SetNillableCollectionAlignment(bk *billingentity.AlignmentKind) *BillingCustomerOverrideCreate { if bk != nil { bcoc.SetCollectionAlignment(*bk) } return bcoc } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (bcoc *BillingCustomerOverrideCreate) SetItemCollectionPeriodSeconds(i int64) *BillingCustomerOverrideCreate { - bcoc.mutation.SetItemCollectionPeriodSeconds(i) +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (bcoc *BillingCustomerOverrideCreate) SetItemCollectionPeriod(ds datex.ISOString) *BillingCustomerOverrideCreate { + bcoc.mutation.SetItemCollectionPeriod(ds) return bcoc } -// SetNillableItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field if the given value is not nil. -func (bcoc *BillingCustomerOverrideCreate) SetNillableItemCollectionPeriodSeconds(i *int64) *BillingCustomerOverrideCreate { - if i != nil { - bcoc.SetItemCollectionPeriodSeconds(*i) +// SetNillableItemCollectionPeriod sets the "item_collection_period" field if the given value is not nil. +func (bcoc *BillingCustomerOverrideCreate) SetNillableItemCollectionPeriod(ds *datex.ISOString) *BillingCustomerOverrideCreate { + if ds != nil { + bcoc.SetItemCollectionPeriod(*ds) } return bcoc } @@ -136,76 +137,48 @@ func (bcoc *BillingCustomerOverrideCreate) SetNillableInvoiceAutoAdvance(b *bool return bcoc } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (bcoc *BillingCustomerOverrideCreate) SetInvoiceDraftPeriodSeconds(i int64) *BillingCustomerOverrideCreate { - bcoc.mutation.SetInvoiceDraftPeriodSeconds(i) +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (bcoc *BillingCustomerOverrideCreate) SetInvoiceDraftPeriod(ds datex.ISOString) *BillingCustomerOverrideCreate { + bcoc.mutation.SetInvoiceDraftPeriod(ds) return bcoc } -// SetNillableInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field if the given value is not nil. -func (bcoc *BillingCustomerOverrideCreate) SetNillableInvoiceDraftPeriodSeconds(i *int64) *BillingCustomerOverrideCreate { - if i != nil { - bcoc.SetInvoiceDraftPeriodSeconds(*i) +// SetNillableInvoiceDraftPeriod sets the "invoice_draft_period" field if the given value is not nil. +func (bcoc *BillingCustomerOverrideCreate) SetNillableInvoiceDraftPeriod(ds *datex.ISOString) *BillingCustomerOverrideCreate { + if ds != nil { + bcoc.SetInvoiceDraftPeriod(*ds) } return bcoc } -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (bcoc *BillingCustomerOverrideCreate) SetInvoiceDueAfterSeconds(i int64) *BillingCustomerOverrideCreate { - bcoc.mutation.SetInvoiceDueAfterSeconds(i) +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (bcoc *BillingCustomerOverrideCreate) SetInvoiceDueAfter(ds datex.ISOString) *BillingCustomerOverrideCreate { + bcoc.mutation.SetInvoiceDueAfter(ds) return bcoc } -// SetNillableInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field if the given value is not nil. -func (bcoc *BillingCustomerOverrideCreate) SetNillableInvoiceDueAfterSeconds(i *int64) *BillingCustomerOverrideCreate { - if i != nil { - bcoc.SetInvoiceDueAfterSeconds(*i) +// SetNillableInvoiceDueAfter sets the "invoice_due_after" field if the given value is not nil. +func (bcoc *BillingCustomerOverrideCreate) SetNillableInvoiceDueAfter(ds *datex.ISOString) *BillingCustomerOverrideCreate { + if ds != nil { + bcoc.SetInvoiceDueAfter(*ds) } return bcoc } // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (bcoc *BillingCustomerOverrideCreate) SetInvoiceCollectionMethod(bm billing.CollectionMethod) *BillingCustomerOverrideCreate { +func (bcoc *BillingCustomerOverrideCreate) SetInvoiceCollectionMethod(bm billingentity.CollectionMethod) *BillingCustomerOverrideCreate { bcoc.mutation.SetInvoiceCollectionMethod(bm) return bcoc } // SetNillableInvoiceCollectionMethod sets the "invoice_collection_method" field if the given value is not nil. -func (bcoc *BillingCustomerOverrideCreate) SetNillableInvoiceCollectionMethod(bm *billing.CollectionMethod) *BillingCustomerOverrideCreate { +func (bcoc *BillingCustomerOverrideCreate) SetNillableInvoiceCollectionMethod(bm *billingentity.CollectionMethod) *BillingCustomerOverrideCreate { if bm != nil { bcoc.SetInvoiceCollectionMethod(*bm) } return bcoc } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (bcoc *BillingCustomerOverrideCreate) SetInvoiceItemResolution(br billing.GranularityResolution) *BillingCustomerOverrideCreate { - bcoc.mutation.SetInvoiceItemResolution(br) - return bcoc -} - -// SetNillableInvoiceItemResolution sets the "invoice_item_resolution" field if the given value is not nil. -func (bcoc *BillingCustomerOverrideCreate) SetNillableInvoiceItemResolution(br *billing.GranularityResolution) *BillingCustomerOverrideCreate { - if br != nil { - bcoc.SetInvoiceItemResolution(*br) - } - return bcoc -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (bcoc *BillingCustomerOverrideCreate) SetInvoiceItemPerSubject(b bool) *BillingCustomerOverrideCreate { - bcoc.mutation.SetInvoiceItemPerSubject(b) - return bcoc -} - -// SetNillableInvoiceItemPerSubject sets the "invoice_item_per_subject" field if the given value is not nil. -func (bcoc *BillingCustomerOverrideCreate) SetNillableInvoiceItemPerSubject(b *bool) *BillingCustomerOverrideCreate { - if b != nil { - bcoc.SetInvoiceItemPerSubject(*b) - } - return bcoc -} - // SetID sets the "id" field. func (bcoc *BillingCustomerOverrideCreate) SetID(s string) *BillingCustomerOverrideCreate { bcoc.mutation.SetID(s) @@ -308,11 +281,6 @@ func (bcoc *BillingCustomerOverrideCreate) check() error { return &ValidationError{Name: "invoice_collection_method", err: fmt.Errorf(`db: validator failed for field "BillingCustomerOverride.invoice_collection_method": %w`, err)} } } - if v, ok := bcoc.mutation.InvoiceItemResolution(); ok { - if err := billingcustomeroverride.InvoiceItemResolutionValidator(v); err != nil { - return &ValidationError{Name: "invoice_item_resolution", err: fmt.Errorf(`db: validator failed for field "BillingCustomerOverride.invoice_item_resolution": %w`, err)} - } - } if len(bcoc.mutation.CustomerIDs()) == 0 { return &ValidationError{Name: "customer", err: errors.New(`db: missing required edge "BillingCustomerOverride.customer"`)} } @@ -372,34 +340,26 @@ func (bcoc *BillingCustomerOverrideCreate) createSpec() (*BillingCustomerOverrid _spec.SetField(billingcustomeroverride.FieldCollectionAlignment, field.TypeEnum, value) _node.CollectionAlignment = &value } - if value, ok := bcoc.mutation.ItemCollectionPeriodSeconds(); ok { - _spec.SetField(billingcustomeroverride.FieldItemCollectionPeriodSeconds, field.TypeInt64, value) - _node.ItemCollectionPeriodSeconds = &value + if value, ok := bcoc.mutation.ItemCollectionPeriod(); ok { + _spec.SetField(billingcustomeroverride.FieldItemCollectionPeriod, field.TypeString, value) + _node.ItemCollectionPeriod = &value } if value, ok := bcoc.mutation.InvoiceAutoAdvance(); ok { _spec.SetField(billingcustomeroverride.FieldInvoiceAutoAdvance, field.TypeBool, value) _node.InvoiceAutoAdvance = &value } - if value, ok := bcoc.mutation.InvoiceDraftPeriodSeconds(); ok { - _spec.SetField(billingcustomeroverride.FieldInvoiceDraftPeriodSeconds, field.TypeInt64, value) - _node.InvoiceDraftPeriodSeconds = &value + if value, ok := bcoc.mutation.InvoiceDraftPeriod(); ok { + _spec.SetField(billingcustomeroverride.FieldInvoiceDraftPeriod, field.TypeString, value) + _node.InvoiceDraftPeriod = &value } - if value, ok := bcoc.mutation.InvoiceDueAfterSeconds(); ok { - _spec.SetField(billingcustomeroverride.FieldInvoiceDueAfterSeconds, field.TypeInt64, value) - _node.InvoiceDueAfterSeconds = &value + if value, ok := bcoc.mutation.InvoiceDueAfter(); ok { + _spec.SetField(billingcustomeroverride.FieldInvoiceDueAfter, field.TypeString, value) + _node.InvoiceDueAfter = &value } if value, ok := bcoc.mutation.InvoiceCollectionMethod(); ok { _spec.SetField(billingcustomeroverride.FieldInvoiceCollectionMethod, field.TypeEnum, value) _node.InvoiceCollectionMethod = &value } - if value, ok := bcoc.mutation.InvoiceItemResolution(); ok { - _spec.SetField(billingcustomeroverride.FieldInvoiceItemResolution, field.TypeEnum, value) - _node.InvoiceItemResolution = &value - } - if value, ok := bcoc.mutation.InvoiceItemPerSubject(); ok { - _spec.SetField(billingcustomeroverride.FieldInvoiceItemPerSubject, field.TypeBool, value) - _node.InvoiceItemPerSubject = &value - } if nodes := bcoc.mutation.CustomerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2O, @@ -535,7 +495,7 @@ func (u *BillingCustomerOverrideUpsert) ClearBillingProfileID() *BillingCustomer } // SetCollectionAlignment sets the "collection_alignment" field. -func (u *BillingCustomerOverrideUpsert) SetCollectionAlignment(v billing.AlignmentKind) *BillingCustomerOverrideUpsert { +func (u *BillingCustomerOverrideUpsert) SetCollectionAlignment(v billingentity.AlignmentKind) *BillingCustomerOverrideUpsert { u.Set(billingcustomeroverride.FieldCollectionAlignment, v) return u } @@ -552,27 +512,21 @@ func (u *BillingCustomerOverrideUpsert) ClearCollectionAlignment() *BillingCusto return u } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (u *BillingCustomerOverrideUpsert) SetItemCollectionPeriodSeconds(v int64) *BillingCustomerOverrideUpsert { - u.Set(billingcustomeroverride.FieldItemCollectionPeriodSeconds, v) +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (u *BillingCustomerOverrideUpsert) SetItemCollectionPeriod(v datex.ISOString) *BillingCustomerOverrideUpsert { + u.Set(billingcustomeroverride.FieldItemCollectionPeriod, v) return u } -// UpdateItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsert) UpdateItemCollectionPeriodSeconds() *BillingCustomerOverrideUpsert { - u.SetExcluded(billingcustomeroverride.FieldItemCollectionPeriodSeconds) +// UpdateItemCollectionPeriod sets the "item_collection_period" field to the value that was provided on create. +func (u *BillingCustomerOverrideUpsert) UpdateItemCollectionPeriod() *BillingCustomerOverrideUpsert { + u.SetExcluded(billingcustomeroverride.FieldItemCollectionPeriod) return u } -// AddItemCollectionPeriodSeconds adds v to the "item_collection_period_seconds" field. -func (u *BillingCustomerOverrideUpsert) AddItemCollectionPeriodSeconds(v int64) *BillingCustomerOverrideUpsert { - u.Add(billingcustomeroverride.FieldItemCollectionPeriodSeconds, v) - return u -} - -// ClearItemCollectionPeriodSeconds clears the value of the "item_collection_period_seconds" field. -func (u *BillingCustomerOverrideUpsert) ClearItemCollectionPeriodSeconds() *BillingCustomerOverrideUpsert { - u.SetNull(billingcustomeroverride.FieldItemCollectionPeriodSeconds) +// ClearItemCollectionPeriod clears the value of the "item_collection_period" field. +func (u *BillingCustomerOverrideUpsert) ClearItemCollectionPeriod() *BillingCustomerOverrideUpsert { + u.SetNull(billingcustomeroverride.FieldItemCollectionPeriod) return u } @@ -594,56 +548,44 @@ func (u *BillingCustomerOverrideUpsert) ClearInvoiceAutoAdvance() *BillingCustom return u } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (u *BillingCustomerOverrideUpsert) SetInvoiceDraftPeriodSeconds(v int64) *BillingCustomerOverrideUpsert { - u.Set(billingcustomeroverride.FieldInvoiceDraftPeriodSeconds, v) +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (u *BillingCustomerOverrideUpsert) SetInvoiceDraftPeriod(v datex.ISOString) *BillingCustomerOverrideUpsert { + u.Set(billingcustomeroverride.FieldInvoiceDraftPeriod, v) return u } -// UpdateInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsert) UpdateInvoiceDraftPeriodSeconds() *BillingCustomerOverrideUpsert { - u.SetExcluded(billingcustomeroverride.FieldInvoiceDraftPeriodSeconds) +// UpdateInvoiceDraftPeriod sets the "invoice_draft_period" field to the value that was provided on create. +func (u *BillingCustomerOverrideUpsert) UpdateInvoiceDraftPeriod() *BillingCustomerOverrideUpsert { + u.SetExcluded(billingcustomeroverride.FieldInvoiceDraftPeriod) return u } -// AddInvoiceDraftPeriodSeconds adds v to the "invoice_draft_period_seconds" field. -func (u *BillingCustomerOverrideUpsert) AddInvoiceDraftPeriodSeconds(v int64) *BillingCustomerOverrideUpsert { - u.Add(billingcustomeroverride.FieldInvoiceDraftPeriodSeconds, v) +// ClearInvoiceDraftPeriod clears the value of the "invoice_draft_period" field. +func (u *BillingCustomerOverrideUpsert) ClearInvoiceDraftPeriod() *BillingCustomerOverrideUpsert { + u.SetNull(billingcustomeroverride.FieldInvoiceDraftPeriod) return u } -// ClearInvoiceDraftPeriodSeconds clears the value of the "invoice_draft_period_seconds" field. -func (u *BillingCustomerOverrideUpsert) ClearInvoiceDraftPeriodSeconds() *BillingCustomerOverrideUpsert { - u.SetNull(billingcustomeroverride.FieldInvoiceDraftPeriodSeconds) +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (u *BillingCustomerOverrideUpsert) SetInvoiceDueAfter(v datex.ISOString) *BillingCustomerOverrideUpsert { + u.Set(billingcustomeroverride.FieldInvoiceDueAfter, v) return u } -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (u *BillingCustomerOverrideUpsert) SetInvoiceDueAfterSeconds(v int64) *BillingCustomerOverrideUpsert { - u.Set(billingcustomeroverride.FieldInvoiceDueAfterSeconds, v) +// UpdateInvoiceDueAfter sets the "invoice_due_after" field to the value that was provided on create. +func (u *BillingCustomerOverrideUpsert) UpdateInvoiceDueAfter() *BillingCustomerOverrideUpsert { + u.SetExcluded(billingcustomeroverride.FieldInvoiceDueAfter) return u } -// UpdateInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsert) UpdateInvoiceDueAfterSeconds() *BillingCustomerOverrideUpsert { - u.SetExcluded(billingcustomeroverride.FieldInvoiceDueAfterSeconds) - return u -} - -// AddInvoiceDueAfterSeconds adds v to the "invoice_due_after_seconds" field. -func (u *BillingCustomerOverrideUpsert) AddInvoiceDueAfterSeconds(v int64) *BillingCustomerOverrideUpsert { - u.Add(billingcustomeroverride.FieldInvoiceDueAfterSeconds, v) - return u -} - -// ClearInvoiceDueAfterSeconds clears the value of the "invoice_due_after_seconds" field. -func (u *BillingCustomerOverrideUpsert) ClearInvoiceDueAfterSeconds() *BillingCustomerOverrideUpsert { - u.SetNull(billingcustomeroverride.FieldInvoiceDueAfterSeconds) +// ClearInvoiceDueAfter clears the value of the "invoice_due_after" field. +func (u *BillingCustomerOverrideUpsert) ClearInvoiceDueAfter() *BillingCustomerOverrideUpsert { + u.SetNull(billingcustomeroverride.FieldInvoiceDueAfter) return u } // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (u *BillingCustomerOverrideUpsert) SetInvoiceCollectionMethod(v billing.CollectionMethod) *BillingCustomerOverrideUpsert { +func (u *BillingCustomerOverrideUpsert) SetInvoiceCollectionMethod(v billingentity.CollectionMethod) *BillingCustomerOverrideUpsert { u.Set(billingcustomeroverride.FieldInvoiceCollectionMethod, v) return u } @@ -660,42 +602,6 @@ func (u *BillingCustomerOverrideUpsert) ClearInvoiceCollectionMethod() *BillingC return u } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (u *BillingCustomerOverrideUpsert) SetInvoiceItemResolution(v billing.GranularityResolution) *BillingCustomerOverrideUpsert { - u.Set(billingcustomeroverride.FieldInvoiceItemResolution, v) - return u -} - -// UpdateInvoiceItemResolution sets the "invoice_item_resolution" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsert) UpdateInvoiceItemResolution() *BillingCustomerOverrideUpsert { - u.SetExcluded(billingcustomeroverride.FieldInvoiceItemResolution) - return u -} - -// ClearInvoiceItemResolution clears the value of the "invoice_item_resolution" field. -func (u *BillingCustomerOverrideUpsert) ClearInvoiceItemResolution() *BillingCustomerOverrideUpsert { - u.SetNull(billingcustomeroverride.FieldInvoiceItemResolution) - return u -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (u *BillingCustomerOverrideUpsert) SetInvoiceItemPerSubject(v bool) *BillingCustomerOverrideUpsert { - u.Set(billingcustomeroverride.FieldInvoiceItemPerSubject, v) - return u -} - -// UpdateInvoiceItemPerSubject sets the "invoice_item_per_subject" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsert) UpdateInvoiceItemPerSubject() *BillingCustomerOverrideUpsert { - u.SetExcluded(billingcustomeroverride.FieldInvoiceItemPerSubject) - return u -} - -// ClearInvoiceItemPerSubject clears the value of the "invoice_item_per_subject" field. -func (u *BillingCustomerOverrideUpsert) ClearInvoiceItemPerSubject() *BillingCustomerOverrideUpsert { - u.SetNull(billingcustomeroverride.FieldInvoiceItemPerSubject) - return u -} - // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // @@ -810,7 +716,7 @@ func (u *BillingCustomerOverrideUpsertOne) ClearBillingProfileID() *BillingCusto } // SetCollectionAlignment sets the "collection_alignment" field. -func (u *BillingCustomerOverrideUpsertOne) SetCollectionAlignment(v billing.AlignmentKind) *BillingCustomerOverrideUpsertOne { +func (u *BillingCustomerOverrideUpsertOne) SetCollectionAlignment(v billingentity.AlignmentKind) *BillingCustomerOverrideUpsertOne { return u.Update(func(s *BillingCustomerOverrideUpsert) { s.SetCollectionAlignment(v) }) @@ -830,31 +736,24 @@ func (u *BillingCustomerOverrideUpsertOne) ClearCollectionAlignment() *BillingCu }) } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (u *BillingCustomerOverrideUpsertOne) SetItemCollectionPeriodSeconds(v int64) *BillingCustomerOverrideUpsertOne { +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (u *BillingCustomerOverrideUpsertOne) SetItemCollectionPeriod(v datex.ISOString) *BillingCustomerOverrideUpsertOne { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.SetItemCollectionPeriodSeconds(v) + s.SetItemCollectionPeriod(v) }) } -// AddItemCollectionPeriodSeconds adds v to the "item_collection_period_seconds" field. -func (u *BillingCustomerOverrideUpsertOne) AddItemCollectionPeriodSeconds(v int64) *BillingCustomerOverrideUpsertOne { +// UpdateItemCollectionPeriod sets the "item_collection_period" field to the value that was provided on create. +func (u *BillingCustomerOverrideUpsertOne) UpdateItemCollectionPeriod() *BillingCustomerOverrideUpsertOne { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.AddItemCollectionPeriodSeconds(v) + s.UpdateItemCollectionPeriod() }) } -// UpdateItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsertOne) UpdateItemCollectionPeriodSeconds() *BillingCustomerOverrideUpsertOne { +// ClearItemCollectionPeriod clears the value of the "item_collection_period" field. +func (u *BillingCustomerOverrideUpsertOne) ClearItemCollectionPeriod() *BillingCustomerOverrideUpsertOne { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.UpdateItemCollectionPeriodSeconds() - }) -} - -// ClearItemCollectionPeriodSeconds clears the value of the "item_collection_period_seconds" field. -func (u *BillingCustomerOverrideUpsertOne) ClearItemCollectionPeriodSeconds() *BillingCustomerOverrideUpsertOne { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.ClearItemCollectionPeriodSeconds() + s.ClearItemCollectionPeriod() }) } @@ -879,64 +778,50 @@ func (u *BillingCustomerOverrideUpsertOne) ClearInvoiceAutoAdvance() *BillingCus }) } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (u *BillingCustomerOverrideUpsertOne) SetInvoiceDraftPeriodSeconds(v int64) *BillingCustomerOverrideUpsertOne { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.SetInvoiceDraftPeriodSeconds(v) - }) -} - -// AddInvoiceDraftPeriodSeconds adds v to the "invoice_draft_period_seconds" field. -func (u *BillingCustomerOverrideUpsertOne) AddInvoiceDraftPeriodSeconds(v int64) *BillingCustomerOverrideUpsertOne { +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (u *BillingCustomerOverrideUpsertOne) SetInvoiceDraftPeriod(v datex.ISOString) *BillingCustomerOverrideUpsertOne { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.AddInvoiceDraftPeriodSeconds(v) + s.SetInvoiceDraftPeriod(v) }) } -// UpdateInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsertOne) UpdateInvoiceDraftPeriodSeconds() *BillingCustomerOverrideUpsertOne { +// UpdateInvoiceDraftPeriod sets the "invoice_draft_period" field to the value that was provided on create. +func (u *BillingCustomerOverrideUpsertOne) UpdateInvoiceDraftPeriod() *BillingCustomerOverrideUpsertOne { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.UpdateInvoiceDraftPeriodSeconds() + s.UpdateInvoiceDraftPeriod() }) } -// ClearInvoiceDraftPeriodSeconds clears the value of the "invoice_draft_period_seconds" field. -func (u *BillingCustomerOverrideUpsertOne) ClearInvoiceDraftPeriodSeconds() *BillingCustomerOverrideUpsertOne { +// ClearInvoiceDraftPeriod clears the value of the "invoice_draft_period" field. +func (u *BillingCustomerOverrideUpsertOne) ClearInvoiceDraftPeriod() *BillingCustomerOverrideUpsertOne { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.ClearInvoiceDraftPeriodSeconds() + s.ClearInvoiceDraftPeriod() }) } -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (u *BillingCustomerOverrideUpsertOne) SetInvoiceDueAfterSeconds(v int64) *BillingCustomerOverrideUpsertOne { +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (u *BillingCustomerOverrideUpsertOne) SetInvoiceDueAfter(v datex.ISOString) *BillingCustomerOverrideUpsertOne { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.SetInvoiceDueAfterSeconds(v) + s.SetInvoiceDueAfter(v) }) } -// AddInvoiceDueAfterSeconds adds v to the "invoice_due_after_seconds" field. -func (u *BillingCustomerOverrideUpsertOne) AddInvoiceDueAfterSeconds(v int64) *BillingCustomerOverrideUpsertOne { +// UpdateInvoiceDueAfter sets the "invoice_due_after" field to the value that was provided on create. +func (u *BillingCustomerOverrideUpsertOne) UpdateInvoiceDueAfter() *BillingCustomerOverrideUpsertOne { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.AddInvoiceDueAfterSeconds(v) + s.UpdateInvoiceDueAfter() }) } -// UpdateInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsertOne) UpdateInvoiceDueAfterSeconds() *BillingCustomerOverrideUpsertOne { +// ClearInvoiceDueAfter clears the value of the "invoice_due_after" field. +func (u *BillingCustomerOverrideUpsertOne) ClearInvoiceDueAfter() *BillingCustomerOverrideUpsertOne { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.UpdateInvoiceDueAfterSeconds() - }) -} - -// ClearInvoiceDueAfterSeconds clears the value of the "invoice_due_after_seconds" field. -func (u *BillingCustomerOverrideUpsertOne) ClearInvoiceDueAfterSeconds() *BillingCustomerOverrideUpsertOne { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.ClearInvoiceDueAfterSeconds() + s.ClearInvoiceDueAfter() }) } // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (u *BillingCustomerOverrideUpsertOne) SetInvoiceCollectionMethod(v billing.CollectionMethod) *BillingCustomerOverrideUpsertOne { +func (u *BillingCustomerOverrideUpsertOne) SetInvoiceCollectionMethod(v billingentity.CollectionMethod) *BillingCustomerOverrideUpsertOne { return u.Update(func(s *BillingCustomerOverrideUpsert) { s.SetInvoiceCollectionMethod(v) }) @@ -956,48 +841,6 @@ func (u *BillingCustomerOverrideUpsertOne) ClearInvoiceCollectionMethod() *Billi }) } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (u *BillingCustomerOverrideUpsertOne) SetInvoiceItemResolution(v billing.GranularityResolution) *BillingCustomerOverrideUpsertOne { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.SetInvoiceItemResolution(v) - }) -} - -// UpdateInvoiceItemResolution sets the "invoice_item_resolution" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsertOne) UpdateInvoiceItemResolution() *BillingCustomerOverrideUpsertOne { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.UpdateInvoiceItemResolution() - }) -} - -// ClearInvoiceItemResolution clears the value of the "invoice_item_resolution" field. -func (u *BillingCustomerOverrideUpsertOne) ClearInvoiceItemResolution() *BillingCustomerOverrideUpsertOne { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.ClearInvoiceItemResolution() - }) -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (u *BillingCustomerOverrideUpsertOne) SetInvoiceItemPerSubject(v bool) *BillingCustomerOverrideUpsertOne { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.SetInvoiceItemPerSubject(v) - }) -} - -// UpdateInvoiceItemPerSubject sets the "invoice_item_per_subject" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsertOne) UpdateInvoiceItemPerSubject() *BillingCustomerOverrideUpsertOne { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.UpdateInvoiceItemPerSubject() - }) -} - -// ClearInvoiceItemPerSubject clears the value of the "invoice_item_per_subject" field. -func (u *BillingCustomerOverrideUpsertOne) ClearInvoiceItemPerSubject() *BillingCustomerOverrideUpsertOne { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.ClearInvoiceItemPerSubject() - }) -} - // Exec executes the query. func (u *BillingCustomerOverrideUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -1279,7 +1122,7 @@ func (u *BillingCustomerOverrideUpsertBulk) ClearBillingProfileID() *BillingCust } // SetCollectionAlignment sets the "collection_alignment" field. -func (u *BillingCustomerOverrideUpsertBulk) SetCollectionAlignment(v billing.AlignmentKind) *BillingCustomerOverrideUpsertBulk { +func (u *BillingCustomerOverrideUpsertBulk) SetCollectionAlignment(v billingentity.AlignmentKind) *BillingCustomerOverrideUpsertBulk { return u.Update(func(s *BillingCustomerOverrideUpsert) { s.SetCollectionAlignment(v) }) @@ -1299,31 +1142,24 @@ func (u *BillingCustomerOverrideUpsertBulk) ClearCollectionAlignment() *BillingC }) } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (u *BillingCustomerOverrideUpsertBulk) SetItemCollectionPeriodSeconds(v int64) *BillingCustomerOverrideUpsertBulk { +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (u *BillingCustomerOverrideUpsertBulk) SetItemCollectionPeriod(v datex.ISOString) *BillingCustomerOverrideUpsertBulk { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.SetItemCollectionPeriodSeconds(v) + s.SetItemCollectionPeriod(v) }) } -// AddItemCollectionPeriodSeconds adds v to the "item_collection_period_seconds" field. -func (u *BillingCustomerOverrideUpsertBulk) AddItemCollectionPeriodSeconds(v int64) *BillingCustomerOverrideUpsertBulk { +// UpdateItemCollectionPeriod sets the "item_collection_period" field to the value that was provided on create. +func (u *BillingCustomerOverrideUpsertBulk) UpdateItemCollectionPeriod() *BillingCustomerOverrideUpsertBulk { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.AddItemCollectionPeriodSeconds(v) + s.UpdateItemCollectionPeriod() }) } -// UpdateItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsertBulk) UpdateItemCollectionPeriodSeconds() *BillingCustomerOverrideUpsertBulk { +// ClearItemCollectionPeriod clears the value of the "item_collection_period" field. +func (u *BillingCustomerOverrideUpsertBulk) ClearItemCollectionPeriod() *BillingCustomerOverrideUpsertBulk { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.UpdateItemCollectionPeriodSeconds() - }) -} - -// ClearItemCollectionPeriodSeconds clears the value of the "item_collection_period_seconds" field. -func (u *BillingCustomerOverrideUpsertBulk) ClearItemCollectionPeriodSeconds() *BillingCustomerOverrideUpsertBulk { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.ClearItemCollectionPeriodSeconds() + s.ClearItemCollectionPeriod() }) } @@ -1348,64 +1184,50 @@ func (u *BillingCustomerOverrideUpsertBulk) ClearInvoiceAutoAdvance() *BillingCu }) } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (u *BillingCustomerOverrideUpsertBulk) SetInvoiceDraftPeriodSeconds(v int64) *BillingCustomerOverrideUpsertBulk { +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (u *BillingCustomerOverrideUpsertBulk) SetInvoiceDraftPeriod(v datex.ISOString) *BillingCustomerOverrideUpsertBulk { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.SetInvoiceDraftPeriodSeconds(v) + s.SetInvoiceDraftPeriod(v) }) } -// AddInvoiceDraftPeriodSeconds adds v to the "invoice_draft_period_seconds" field. -func (u *BillingCustomerOverrideUpsertBulk) AddInvoiceDraftPeriodSeconds(v int64) *BillingCustomerOverrideUpsertBulk { +// UpdateInvoiceDraftPeriod sets the "invoice_draft_period" field to the value that was provided on create. +func (u *BillingCustomerOverrideUpsertBulk) UpdateInvoiceDraftPeriod() *BillingCustomerOverrideUpsertBulk { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.AddInvoiceDraftPeriodSeconds(v) + s.UpdateInvoiceDraftPeriod() }) } -// UpdateInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsertBulk) UpdateInvoiceDraftPeriodSeconds() *BillingCustomerOverrideUpsertBulk { +// ClearInvoiceDraftPeriod clears the value of the "invoice_draft_period" field. +func (u *BillingCustomerOverrideUpsertBulk) ClearInvoiceDraftPeriod() *BillingCustomerOverrideUpsertBulk { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.UpdateInvoiceDraftPeriodSeconds() + s.ClearInvoiceDraftPeriod() }) } -// ClearInvoiceDraftPeriodSeconds clears the value of the "invoice_draft_period_seconds" field. -func (u *BillingCustomerOverrideUpsertBulk) ClearInvoiceDraftPeriodSeconds() *BillingCustomerOverrideUpsertBulk { +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (u *BillingCustomerOverrideUpsertBulk) SetInvoiceDueAfter(v datex.ISOString) *BillingCustomerOverrideUpsertBulk { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.ClearInvoiceDraftPeriodSeconds() + s.SetInvoiceDueAfter(v) }) } -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (u *BillingCustomerOverrideUpsertBulk) SetInvoiceDueAfterSeconds(v int64) *BillingCustomerOverrideUpsertBulk { +// UpdateInvoiceDueAfter sets the "invoice_due_after" field to the value that was provided on create. +func (u *BillingCustomerOverrideUpsertBulk) UpdateInvoiceDueAfter() *BillingCustomerOverrideUpsertBulk { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.SetInvoiceDueAfterSeconds(v) + s.UpdateInvoiceDueAfter() }) } -// AddInvoiceDueAfterSeconds adds v to the "invoice_due_after_seconds" field. -func (u *BillingCustomerOverrideUpsertBulk) AddInvoiceDueAfterSeconds(v int64) *BillingCustomerOverrideUpsertBulk { +// ClearInvoiceDueAfter clears the value of the "invoice_due_after" field. +func (u *BillingCustomerOverrideUpsertBulk) ClearInvoiceDueAfter() *BillingCustomerOverrideUpsertBulk { return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.AddInvoiceDueAfterSeconds(v) - }) -} - -// UpdateInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsertBulk) UpdateInvoiceDueAfterSeconds() *BillingCustomerOverrideUpsertBulk { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.UpdateInvoiceDueAfterSeconds() - }) -} - -// ClearInvoiceDueAfterSeconds clears the value of the "invoice_due_after_seconds" field. -func (u *BillingCustomerOverrideUpsertBulk) ClearInvoiceDueAfterSeconds() *BillingCustomerOverrideUpsertBulk { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.ClearInvoiceDueAfterSeconds() + s.ClearInvoiceDueAfter() }) } // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (u *BillingCustomerOverrideUpsertBulk) SetInvoiceCollectionMethod(v billing.CollectionMethod) *BillingCustomerOverrideUpsertBulk { +func (u *BillingCustomerOverrideUpsertBulk) SetInvoiceCollectionMethod(v billingentity.CollectionMethod) *BillingCustomerOverrideUpsertBulk { return u.Update(func(s *BillingCustomerOverrideUpsert) { s.SetInvoiceCollectionMethod(v) }) @@ -1425,48 +1247,6 @@ func (u *BillingCustomerOverrideUpsertBulk) ClearInvoiceCollectionMethod() *Bill }) } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (u *BillingCustomerOverrideUpsertBulk) SetInvoiceItemResolution(v billing.GranularityResolution) *BillingCustomerOverrideUpsertBulk { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.SetInvoiceItemResolution(v) - }) -} - -// UpdateInvoiceItemResolution sets the "invoice_item_resolution" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsertBulk) UpdateInvoiceItemResolution() *BillingCustomerOverrideUpsertBulk { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.UpdateInvoiceItemResolution() - }) -} - -// ClearInvoiceItemResolution clears the value of the "invoice_item_resolution" field. -func (u *BillingCustomerOverrideUpsertBulk) ClearInvoiceItemResolution() *BillingCustomerOverrideUpsertBulk { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.ClearInvoiceItemResolution() - }) -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (u *BillingCustomerOverrideUpsertBulk) SetInvoiceItemPerSubject(v bool) *BillingCustomerOverrideUpsertBulk { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.SetInvoiceItemPerSubject(v) - }) -} - -// UpdateInvoiceItemPerSubject sets the "invoice_item_per_subject" field to the value that was provided on create. -func (u *BillingCustomerOverrideUpsertBulk) UpdateInvoiceItemPerSubject() *BillingCustomerOverrideUpsertBulk { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.UpdateInvoiceItemPerSubject() - }) -} - -// ClearInvoiceItemPerSubject clears the value of the "invoice_item_per_subject" field. -func (u *BillingCustomerOverrideUpsertBulk) ClearInvoiceItemPerSubject() *BillingCustomerOverrideUpsertBulk { - return u.Update(func(s *BillingCustomerOverrideUpsert) { - s.ClearInvoiceItemPerSubject() - }) -} - // Exec executes the query. func (u *BillingCustomerOverrideUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/openmeter/ent/db/billingcustomeroverride_update.go b/openmeter/ent/db/billingcustomeroverride_update.go index f58c950a2..38cee0e07 100644 --- a/openmeter/ent/db/billingcustomeroverride_update.go +++ b/openmeter/ent/db/billingcustomeroverride_update.go @@ -11,10 +11,11 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/billingcustomeroverride" "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" + "github.com/openmeterio/openmeter/pkg/datex" ) // BillingCustomerOverrideUpdate is the builder for updating BillingCustomerOverride entities. @@ -77,13 +78,13 @@ func (bcou *BillingCustomerOverrideUpdate) ClearBillingProfileID() *BillingCusto } // SetCollectionAlignment sets the "collection_alignment" field. -func (bcou *BillingCustomerOverrideUpdate) SetCollectionAlignment(bk billing.AlignmentKind) *BillingCustomerOverrideUpdate { +func (bcou *BillingCustomerOverrideUpdate) SetCollectionAlignment(bk billingentity.AlignmentKind) *BillingCustomerOverrideUpdate { bcou.mutation.SetCollectionAlignment(bk) return bcou } // SetNillableCollectionAlignment sets the "collection_alignment" field if the given value is not nil. -func (bcou *BillingCustomerOverrideUpdate) SetNillableCollectionAlignment(bk *billing.AlignmentKind) *BillingCustomerOverrideUpdate { +func (bcou *BillingCustomerOverrideUpdate) SetNillableCollectionAlignment(bk *billingentity.AlignmentKind) *BillingCustomerOverrideUpdate { if bk != nil { bcou.SetCollectionAlignment(*bk) } @@ -96,30 +97,23 @@ func (bcou *BillingCustomerOverrideUpdate) ClearCollectionAlignment() *BillingCu return bcou } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (bcou *BillingCustomerOverrideUpdate) SetItemCollectionPeriodSeconds(i int64) *BillingCustomerOverrideUpdate { - bcou.mutation.ResetItemCollectionPeriodSeconds() - bcou.mutation.SetItemCollectionPeriodSeconds(i) +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (bcou *BillingCustomerOverrideUpdate) SetItemCollectionPeriod(ds datex.ISOString) *BillingCustomerOverrideUpdate { + bcou.mutation.SetItemCollectionPeriod(ds) return bcou } -// SetNillableItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field if the given value is not nil. -func (bcou *BillingCustomerOverrideUpdate) SetNillableItemCollectionPeriodSeconds(i *int64) *BillingCustomerOverrideUpdate { - if i != nil { - bcou.SetItemCollectionPeriodSeconds(*i) +// SetNillableItemCollectionPeriod sets the "item_collection_period" field if the given value is not nil. +func (bcou *BillingCustomerOverrideUpdate) SetNillableItemCollectionPeriod(ds *datex.ISOString) *BillingCustomerOverrideUpdate { + if ds != nil { + bcou.SetItemCollectionPeriod(*ds) } return bcou } -// AddItemCollectionPeriodSeconds adds i to the "item_collection_period_seconds" field. -func (bcou *BillingCustomerOverrideUpdate) AddItemCollectionPeriodSeconds(i int64) *BillingCustomerOverrideUpdate { - bcou.mutation.AddItemCollectionPeriodSeconds(i) - return bcou -} - -// ClearItemCollectionPeriodSeconds clears the value of the "item_collection_period_seconds" field. -func (bcou *BillingCustomerOverrideUpdate) ClearItemCollectionPeriodSeconds() *BillingCustomerOverrideUpdate { - bcou.mutation.ClearItemCollectionPeriodSeconds() +// ClearItemCollectionPeriod clears the value of the "item_collection_period" field. +func (bcou *BillingCustomerOverrideUpdate) ClearItemCollectionPeriod() *BillingCustomerOverrideUpdate { + bcou.mutation.ClearItemCollectionPeriod() return bcou } @@ -143,68 +137,54 @@ func (bcou *BillingCustomerOverrideUpdate) ClearInvoiceAutoAdvance() *BillingCus return bcou } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (bcou *BillingCustomerOverrideUpdate) SetInvoiceDraftPeriodSeconds(i int64) *BillingCustomerOverrideUpdate { - bcou.mutation.ResetInvoiceDraftPeriodSeconds() - bcou.mutation.SetInvoiceDraftPeriodSeconds(i) +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (bcou *BillingCustomerOverrideUpdate) SetInvoiceDraftPeriod(ds datex.ISOString) *BillingCustomerOverrideUpdate { + bcou.mutation.SetInvoiceDraftPeriod(ds) return bcou } -// SetNillableInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field if the given value is not nil. -func (bcou *BillingCustomerOverrideUpdate) SetNillableInvoiceDraftPeriodSeconds(i *int64) *BillingCustomerOverrideUpdate { - if i != nil { - bcou.SetInvoiceDraftPeriodSeconds(*i) +// SetNillableInvoiceDraftPeriod sets the "invoice_draft_period" field if the given value is not nil. +func (bcou *BillingCustomerOverrideUpdate) SetNillableInvoiceDraftPeriod(ds *datex.ISOString) *BillingCustomerOverrideUpdate { + if ds != nil { + bcou.SetInvoiceDraftPeriod(*ds) } return bcou } -// AddInvoiceDraftPeriodSeconds adds i to the "invoice_draft_period_seconds" field. -func (bcou *BillingCustomerOverrideUpdate) AddInvoiceDraftPeriodSeconds(i int64) *BillingCustomerOverrideUpdate { - bcou.mutation.AddInvoiceDraftPeriodSeconds(i) - return bcou -} - -// ClearInvoiceDraftPeriodSeconds clears the value of the "invoice_draft_period_seconds" field. -func (bcou *BillingCustomerOverrideUpdate) ClearInvoiceDraftPeriodSeconds() *BillingCustomerOverrideUpdate { - bcou.mutation.ClearInvoiceDraftPeriodSeconds() +// ClearInvoiceDraftPeriod clears the value of the "invoice_draft_period" field. +func (bcou *BillingCustomerOverrideUpdate) ClearInvoiceDraftPeriod() *BillingCustomerOverrideUpdate { + bcou.mutation.ClearInvoiceDraftPeriod() return bcou } -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (bcou *BillingCustomerOverrideUpdate) SetInvoiceDueAfterSeconds(i int64) *BillingCustomerOverrideUpdate { - bcou.mutation.ResetInvoiceDueAfterSeconds() - bcou.mutation.SetInvoiceDueAfterSeconds(i) +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (bcou *BillingCustomerOverrideUpdate) SetInvoiceDueAfter(ds datex.ISOString) *BillingCustomerOverrideUpdate { + bcou.mutation.SetInvoiceDueAfter(ds) return bcou } -// SetNillableInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field if the given value is not nil. -func (bcou *BillingCustomerOverrideUpdate) SetNillableInvoiceDueAfterSeconds(i *int64) *BillingCustomerOverrideUpdate { - if i != nil { - bcou.SetInvoiceDueAfterSeconds(*i) +// SetNillableInvoiceDueAfter sets the "invoice_due_after" field if the given value is not nil. +func (bcou *BillingCustomerOverrideUpdate) SetNillableInvoiceDueAfter(ds *datex.ISOString) *BillingCustomerOverrideUpdate { + if ds != nil { + bcou.SetInvoiceDueAfter(*ds) } return bcou } -// AddInvoiceDueAfterSeconds adds i to the "invoice_due_after_seconds" field. -func (bcou *BillingCustomerOverrideUpdate) AddInvoiceDueAfterSeconds(i int64) *BillingCustomerOverrideUpdate { - bcou.mutation.AddInvoiceDueAfterSeconds(i) - return bcou -} - -// ClearInvoiceDueAfterSeconds clears the value of the "invoice_due_after_seconds" field. -func (bcou *BillingCustomerOverrideUpdate) ClearInvoiceDueAfterSeconds() *BillingCustomerOverrideUpdate { - bcou.mutation.ClearInvoiceDueAfterSeconds() +// ClearInvoiceDueAfter clears the value of the "invoice_due_after" field. +func (bcou *BillingCustomerOverrideUpdate) ClearInvoiceDueAfter() *BillingCustomerOverrideUpdate { + bcou.mutation.ClearInvoiceDueAfter() return bcou } // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (bcou *BillingCustomerOverrideUpdate) SetInvoiceCollectionMethod(bm billing.CollectionMethod) *BillingCustomerOverrideUpdate { +func (bcou *BillingCustomerOverrideUpdate) SetInvoiceCollectionMethod(bm billingentity.CollectionMethod) *BillingCustomerOverrideUpdate { bcou.mutation.SetInvoiceCollectionMethod(bm) return bcou } // SetNillableInvoiceCollectionMethod sets the "invoice_collection_method" field if the given value is not nil. -func (bcou *BillingCustomerOverrideUpdate) SetNillableInvoiceCollectionMethod(bm *billing.CollectionMethod) *BillingCustomerOverrideUpdate { +func (bcou *BillingCustomerOverrideUpdate) SetNillableInvoiceCollectionMethod(bm *billingentity.CollectionMethod) *BillingCustomerOverrideUpdate { if bm != nil { bcou.SetInvoiceCollectionMethod(*bm) } @@ -217,46 +197,6 @@ func (bcou *BillingCustomerOverrideUpdate) ClearInvoiceCollectionMethod() *Billi return bcou } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (bcou *BillingCustomerOverrideUpdate) SetInvoiceItemResolution(br billing.GranularityResolution) *BillingCustomerOverrideUpdate { - bcou.mutation.SetInvoiceItemResolution(br) - return bcou -} - -// SetNillableInvoiceItemResolution sets the "invoice_item_resolution" field if the given value is not nil. -func (bcou *BillingCustomerOverrideUpdate) SetNillableInvoiceItemResolution(br *billing.GranularityResolution) *BillingCustomerOverrideUpdate { - if br != nil { - bcou.SetInvoiceItemResolution(*br) - } - return bcou -} - -// ClearInvoiceItemResolution clears the value of the "invoice_item_resolution" field. -func (bcou *BillingCustomerOverrideUpdate) ClearInvoiceItemResolution() *BillingCustomerOverrideUpdate { - bcou.mutation.ClearInvoiceItemResolution() - return bcou -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (bcou *BillingCustomerOverrideUpdate) SetInvoiceItemPerSubject(b bool) *BillingCustomerOverrideUpdate { - bcou.mutation.SetInvoiceItemPerSubject(b) - return bcou -} - -// SetNillableInvoiceItemPerSubject sets the "invoice_item_per_subject" field if the given value is not nil. -func (bcou *BillingCustomerOverrideUpdate) SetNillableInvoiceItemPerSubject(b *bool) *BillingCustomerOverrideUpdate { - if b != nil { - bcou.SetInvoiceItemPerSubject(*b) - } - return bcou -} - -// ClearInvoiceItemPerSubject clears the value of the "invoice_item_per_subject" field. -func (bcou *BillingCustomerOverrideUpdate) ClearInvoiceItemPerSubject() *BillingCustomerOverrideUpdate { - bcou.mutation.ClearInvoiceItemPerSubject() - return bcou -} - // SetBillingProfile sets the "billing_profile" edge to the BillingProfile entity. func (bcou *BillingCustomerOverrideUpdate) SetBillingProfile(b *BillingProfile) *BillingCustomerOverrideUpdate { return bcou.SetBillingProfileID(b.ID) @@ -321,11 +261,6 @@ func (bcou *BillingCustomerOverrideUpdate) check() error { return &ValidationError{Name: "invoice_collection_method", err: fmt.Errorf(`db: validator failed for field "BillingCustomerOverride.invoice_collection_method": %w`, err)} } } - if v, ok := bcou.mutation.InvoiceItemResolution(); ok { - if err := billingcustomeroverride.InvoiceItemResolutionValidator(v); err != nil { - return &ValidationError{Name: "invoice_item_resolution", err: fmt.Errorf(`db: validator failed for field "BillingCustomerOverride.invoice_item_resolution": %w`, err)} - } - } if bcou.mutation.CustomerCleared() && len(bcou.mutation.CustomerIDs()) > 0 { return errors.New(`db: clearing a required unique edge "BillingCustomerOverride.customer"`) } @@ -359,14 +294,11 @@ func (bcou *BillingCustomerOverrideUpdate) sqlSave(ctx context.Context) (n int, if bcou.mutation.CollectionAlignmentCleared() { _spec.ClearField(billingcustomeroverride.FieldCollectionAlignment, field.TypeEnum) } - if value, ok := bcou.mutation.ItemCollectionPeriodSeconds(); ok { - _spec.SetField(billingcustomeroverride.FieldItemCollectionPeriodSeconds, field.TypeInt64, value) - } - if value, ok := bcou.mutation.AddedItemCollectionPeriodSeconds(); ok { - _spec.AddField(billingcustomeroverride.FieldItemCollectionPeriodSeconds, field.TypeInt64, value) + if value, ok := bcou.mutation.ItemCollectionPeriod(); ok { + _spec.SetField(billingcustomeroverride.FieldItemCollectionPeriod, field.TypeString, value) } - if bcou.mutation.ItemCollectionPeriodSecondsCleared() { - _spec.ClearField(billingcustomeroverride.FieldItemCollectionPeriodSeconds, field.TypeInt64) + if bcou.mutation.ItemCollectionPeriodCleared() { + _spec.ClearField(billingcustomeroverride.FieldItemCollectionPeriod, field.TypeString) } if value, ok := bcou.mutation.InvoiceAutoAdvance(); ok { _spec.SetField(billingcustomeroverride.FieldInvoiceAutoAdvance, field.TypeBool, value) @@ -374,23 +306,17 @@ func (bcou *BillingCustomerOverrideUpdate) sqlSave(ctx context.Context) (n int, if bcou.mutation.InvoiceAutoAdvanceCleared() { _spec.ClearField(billingcustomeroverride.FieldInvoiceAutoAdvance, field.TypeBool) } - if value, ok := bcou.mutation.InvoiceDraftPeriodSeconds(); ok { - _spec.SetField(billingcustomeroverride.FieldInvoiceDraftPeriodSeconds, field.TypeInt64, value) - } - if value, ok := bcou.mutation.AddedInvoiceDraftPeriodSeconds(); ok { - _spec.AddField(billingcustomeroverride.FieldInvoiceDraftPeriodSeconds, field.TypeInt64, value) - } - if bcou.mutation.InvoiceDraftPeriodSecondsCleared() { - _spec.ClearField(billingcustomeroverride.FieldInvoiceDraftPeriodSeconds, field.TypeInt64) + if value, ok := bcou.mutation.InvoiceDraftPeriod(); ok { + _spec.SetField(billingcustomeroverride.FieldInvoiceDraftPeriod, field.TypeString, value) } - if value, ok := bcou.mutation.InvoiceDueAfterSeconds(); ok { - _spec.SetField(billingcustomeroverride.FieldInvoiceDueAfterSeconds, field.TypeInt64, value) + if bcou.mutation.InvoiceDraftPeriodCleared() { + _spec.ClearField(billingcustomeroverride.FieldInvoiceDraftPeriod, field.TypeString) } - if value, ok := bcou.mutation.AddedInvoiceDueAfterSeconds(); ok { - _spec.AddField(billingcustomeroverride.FieldInvoiceDueAfterSeconds, field.TypeInt64, value) + if value, ok := bcou.mutation.InvoiceDueAfter(); ok { + _spec.SetField(billingcustomeroverride.FieldInvoiceDueAfter, field.TypeString, value) } - if bcou.mutation.InvoiceDueAfterSecondsCleared() { - _spec.ClearField(billingcustomeroverride.FieldInvoiceDueAfterSeconds, field.TypeInt64) + if bcou.mutation.InvoiceDueAfterCleared() { + _spec.ClearField(billingcustomeroverride.FieldInvoiceDueAfter, field.TypeString) } if value, ok := bcou.mutation.InvoiceCollectionMethod(); ok { _spec.SetField(billingcustomeroverride.FieldInvoiceCollectionMethod, field.TypeEnum, value) @@ -398,18 +324,6 @@ func (bcou *BillingCustomerOverrideUpdate) sqlSave(ctx context.Context) (n int, if bcou.mutation.InvoiceCollectionMethodCleared() { _spec.ClearField(billingcustomeroverride.FieldInvoiceCollectionMethod, field.TypeEnum) } - if value, ok := bcou.mutation.InvoiceItemResolution(); ok { - _spec.SetField(billingcustomeroverride.FieldInvoiceItemResolution, field.TypeEnum, value) - } - if bcou.mutation.InvoiceItemResolutionCleared() { - _spec.ClearField(billingcustomeroverride.FieldInvoiceItemResolution, field.TypeEnum) - } - if value, ok := bcou.mutation.InvoiceItemPerSubject(); ok { - _spec.SetField(billingcustomeroverride.FieldInvoiceItemPerSubject, field.TypeBool, value) - } - if bcou.mutation.InvoiceItemPerSubjectCleared() { - _spec.ClearField(billingcustomeroverride.FieldInvoiceItemPerSubject, field.TypeBool) - } if bcou.mutation.BillingProfileCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -506,13 +420,13 @@ func (bcouo *BillingCustomerOverrideUpdateOne) ClearBillingProfileID() *BillingC } // SetCollectionAlignment sets the "collection_alignment" field. -func (bcouo *BillingCustomerOverrideUpdateOne) SetCollectionAlignment(bk billing.AlignmentKind) *BillingCustomerOverrideUpdateOne { +func (bcouo *BillingCustomerOverrideUpdateOne) SetCollectionAlignment(bk billingentity.AlignmentKind) *BillingCustomerOverrideUpdateOne { bcouo.mutation.SetCollectionAlignment(bk) return bcouo } // SetNillableCollectionAlignment sets the "collection_alignment" field if the given value is not nil. -func (bcouo *BillingCustomerOverrideUpdateOne) SetNillableCollectionAlignment(bk *billing.AlignmentKind) *BillingCustomerOverrideUpdateOne { +func (bcouo *BillingCustomerOverrideUpdateOne) SetNillableCollectionAlignment(bk *billingentity.AlignmentKind) *BillingCustomerOverrideUpdateOne { if bk != nil { bcouo.SetCollectionAlignment(*bk) } @@ -525,30 +439,23 @@ func (bcouo *BillingCustomerOverrideUpdateOne) ClearCollectionAlignment() *Billi return bcouo } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (bcouo *BillingCustomerOverrideUpdateOne) SetItemCollectionPeriodSeconds(i int64) *BillingCustomerOverrideUpdateOne { - bcouo.mutation.ResetItemCollectionPeriodSeconds() - bcouo.mutation.SetItemCollectionPeriodSeconds(i) +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (bcouo *BillingCustomerOverrideUpdateOne) SetItemCollectionPeriod(ds datex.ISOString) *BillingCustomerOverrideUpdateOne { + bcouo.mutation.SetItemCollectionPeriod(ds) return bcouo } -// SetNillableItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field if the given value is not nil. -func (bcouo *BillingCustomerOverrideUpdateOne) SetNillableItemCollectionPeriodSeconds(i *int64) *BillingCustomerOverrideUpdateOne { - if i != nil { - bcouo.SetItemCollectionPeriodSeconds(*i) +// SetNillableItemCollectionPeriod sets the "item_collection_period" field if the given value is not nil. +func (bcouo *BillingCustomerOverrideUpdateOne) SetNillableItemCollectionPeriod(ds *datex.ISOString) *BillingCustomerOverrideUpdateOne { + if ds != nil { + bcouo.SetItemCollectionPeriod(*ds) } return bcouo } -// AddItemCollectionPeriodSeconds adds i to the "item_collection_period_seconds" field. -func (bcouo *BillingCustomerOverrideUpdateOne) AddItemCollectionPeriodSeconds(i int64) *BillingCustomerOverrideUpdateOne { - bcouo.mutation.AddItemCollectionPeriodSeconds(i) - return bcouo -} - -// ClearItemCollectionPeriodSeconds clears the value of the "item_collection_period_seconds" field. -func (bcouo *BillingCustomerOverrideUpdateOne) ClearItemCollectionPeriodSeconds() *BillingCustomerOverrideUpdateOne { - bcouo.mutation.ClearItemCollectionPeriodSeconds() +// ClearItemCollectionPeriod clears the value of the "item_collection_period" field. +func (bcouo *BillingCustomerOverrideUpdateOne) ClearItemCollectionPeriod() *BillingCustomerOverrideUpdateOne { + bcouo.mutation.ClearItemCollectionPeriod() return bcouo } @@ -572,68 +479,54 @@ func (bcouo *BillingCustomerOverrideUpdateOne) ClearInvoiceAutoAdvance() *Billin return bcouo } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (bcouo *BillingCustomerOverrideUpdateOne) SetInvoiceDraftPeriodSeconds(i int64) *BillingCustomerOverrideUpdateOne { - bcouo.mutation.ResetInvoiceDraftPeriodSeconds() - bcouo.mutation.SetInvoiceDraftPeriodSeconds(i) +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (bcouo *BillingCustomerOverrideUpdateOne) SetInvoiceDraftPeriod(ds datex.ISOString) *BillingCustomerOverrideUpdateOne { + bcouo.mutation.SetInvoiceDraftPeriod(ds) return bcouo } -// SetNillableInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field if the given value is not nil. -func (bcouo *BillingCustomerOverrideUpdateOne) SetNillableInvoiceDraftPeriodSeconds(i *int64) *BillingCustomerOverrideUpdateOne { - if i != nil { - bcouo.SetInvoiceDraftPeriodSeconds(*i) +// SetNillableInvoiceDraftPeriod sets the "invoice_draft_period" field if the given value is not nil. +func (bcouo *BillingCustomerOverrideUpdateOne) SetNillableInvoiceDraftPeriod(ds *datex.ISOString) *BillingCustomerOverrideUpdateOne { + if ds != nil { + bcouo.SetInvoiceDraftPeriod(*ds) } return bcouo } -// AddInvoiceDraftPeriodSeconds adds i to the "invoice_draft_period_seconds" field. -func (bcouo *BillingCustomerOverrideUpdateOne) AddInvoiceDraftPeriodSeconds(i int64) *BillingCustomerOverrideUpdateOne { - bcouo.mutation.AddInvoiceDraftPeriodSeconds(i) - return bcouo -} - -// ClearInvoiceDraftPeriodSeconds clears the value of the "invoice_draft_period_seconds" field. -func (bcouo *BillingCustomerOverrideUpdateOne) ClearInvoiceDraftPeriodSeconds() *BillingCustomerOverrideUpdateOne { - bcouo.mutation.ClearInvoiceDraftPeriodSeconds() +// ClearInvoiceDraftPeriod clears the value of the "invoice_draft_period" field. +func (bcouo *BillingCustomerOverrideUpdateOne) ClearInvoiceDraftPeriod() *BillingCustomerOverrideUpdateOne { + bcouo.mutation.ClearInvoiceDraftPeriod() return bcouo } -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (bcouo *BillingCustomerOverrideUpdateOne) SetInvoiceDueAfterSeconds(i int64) *BillingCustomerOverrideUpdateOne { - bcouo.mutation.ResetInvoiceDueAfterSeconds() - bcouo.mutation.SetInvoiceDueAfterSeconds(i) +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (bcouo *BillingCustomerOverrideUpdateOne) SetInvoiceDueAfter(ds datex.ISOString) *BillingCustomerOverrideUpdateOne { + bcouo.mutation.SetInvoiceDueAfter(ds) return bcouo } -// SetNillableInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field if the given value is not nil. -func (bcouo *BillingCustomerOverrideUpdateOne) SetNillableInvoiceDueAfterSeconds(i *int64) *BillingCustomerOverrideUpdateOne { - if i != nil { - bcouo.SetInvoiceDueAfterSeconds(*i) +// SetNillableInvoiceDueAfter sets the "invoice_due_after" field if the given value is not nil. +func (bcouo *BillingCustomerOverrideUpdateOne) SetNillableInvoiceDueAfter(ds *datex.ISOString) *BillingCustomerOverrideUpdateOne { + if ds != nil { + bcouo.SetInvoiceDueAfter(*ds) } return bcouo } -// AddInvoiceDueAfterSeconds adds i to the "invoice_due_after_seconds" field. -func (bcouo *BillingCustomerOverrideUpdateOne) AddInvoiceDueAfterSeconds(i int64) *BillingCustomerOverrideUpdateOne { - bcouo.mutation.AddInvoiceDueAfterSeconds(i) - return bcouo -} - -// ClearInvoiceDueAfterSeconds clears the value of the "invoice_due_after_seconds" field. -func (bcouo *BillingCustomerOverrideUpdateOne) ClearInvoiceDueAfterSeconds() *BillingCustomerOverrideUpdateOne { - bcouo.mutation.ClearInvoiceDueAfterSeconds() +// ClearInvoiceDueAfter clears the value of the "invoice_due_after" field. +func (bcouo *BillingCustomerOverrideUpdateOne) ClearInvoiceDueAfter() *BillingCustomerOverrideUpdateOne { + bcouo.mutation.ClearInvoiceDueAfter() return bcouo } // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (bcouo *BillingCustomerOverrideUpdateOne) SetInvoiceCollectionMethod(bm billing.CollectionMethod) *BillingCustomerOverrideUpdateOne { +func (bcouo *BillingCustomerOverrideUpdateOne) SetInvoiceCollectionMethod(bm billingentity.CollectionMethod) *BillingCustomerOverrideUpdateOne { bcouo.mutation.SetInvoiceCollectionMethod(bm) return bcouo } // SetNillableInvoiceCollectionMethod sets the "invoice_collection_method" field if the given value is not nil. -func (bcouo *BillingCustomerOverrideUpdateOne) SetNillableInvoiceCollectionMethod(bm *billing.CollectionMethod) *BillingCustomerOverrideUpdateOne { +func (bcouo *BillingCustomerOverrideUpdateOne) SetNillableInvoiceCollectionMethod(bm *billingentity.CollectionMethod) *BillingCustomerOverrideUpdateOne { if bm != nil { bcouo.SetInvoiceCollectionMethod(*bm) } @@ -646,46 +539,6 @@ func (bcouo *BillingCustomerOverrideUpdateOne) ClearInvoiceCollectionMethod() *B return bcouo } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (bcouo *BillingCustomerOverrideUpdateOne) SetInvoiceItemResolution(br billing.GranularityResolution) *BillingCustomerOverrideUpdateOne { - bcouo.mutation.SetInvoiceItemResolution(br) - return bcouo -} - -// SetNillableInvoiceItemResolution sets the "invoice_item_resolution" field if the given value is not nil. -func (bcouo *BillingCustomerOverrideUpdateOne) SetNillableInvoiceItemResolution(br *billing.GranularityResolution) *BillingCustomerOverrideUpdateOne { - if br != nil { - bcouo.SetInvoiceItemResolution(*br) - } - return bcouo -} - -// ClearInvoiceItemResolution clears the value of the "invoice_item_resolution" field. -func (bcouo *BillingCustomerOverrideUpdateOne) ClearInvoiceItemResolution() *BillingCustomerOverrideUpdateOne { - bcouo.mutation.ClearInvoiceItemResolution() - return bcouo -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (bcouo *BillingCustomerOverrideUpdateOne) SetInvoiceItemPerSubject(b bool) *BillingCustomerOverrideUpdateOne { - bcouo.mutation.SetInvoiceItemPerSubject(b) - return bcouo -} - -// SetNillableInvoiceItemPerSubject sets the "invoice_item_per_subject" field if the given value is not nil. -func (bcouo *BillingCustomerOverrideUpdateOne) SetNillableInvoiceItemPerSubject(b *bool) *BillingCustomerOverrideUpdateOne { - if b != nil { - bcouo.SetInvoiceItemPerSubject(*b) - } - return bcouo -} - -// ClearInvoiceItemPerSubject clears the value of the "invoice_item_per_subject" field. -func (bcouo *BillingCustomerOverrideUpdateOne) ClearInvoiceItemPerSubject() *BillingCustomerOverrideUpdateOne { - bcouo.mutation.ClearInvoiceItemPerSubject() - return bcouo -} - // SetBillingProfile sets the "billing_profile" edge to the BillingProfile entity. func (bcouo *BillingCustomerOverrideUpdateOne) SetBillingProfile(b *BillingProfile) *BillingCustomerOverrideUpdateOne { return bcouo.SetBillingProfileID(b.ID) @@ -763,11 +616,6 @@ func (bcouo *BillingCustomerOverrideUpdateOne) check() error { return &ValidationError{Name: "invoice_collection_method", err: fmt.Errorf(`db: validator failed for field "BillingCustomerOverride.invoice_collection_method": %w`, err)} } } - if v, ok := bcouo.mutation.InvoiceItemResolution(); ok { - if err := billingcustomeroverride.InvoiceItemResolutionValidator(v); err != nil { - return &ValidationError{Name: "invoice_item_resolution", err: fmt.Errorf(`db: validator failed for field "BillingCustomerOverride.invoice_item_resolution": %w`, err)} - } - } if bcouo.mutation.CustomerCleared() && len(bcouo.mutation.CustomerIDs()) > 0 { return errors.New(`db: clearing a required unique edge "BillingCustomerOverride.customer"`) } @@ -818,14 +666,11 @@ func (bcouo *BillingCustomerOverrideUpdateOne) sqlSave(ctx context.Context) (_no if bcouo.mutation.CollectionAlignmentCleared() { _spec.ClearField(billingcustomeroverride.FieldCollectionAlignment, field.TypeEnum) } - if value, ok := bcouo.mutation.ItemCollectionPeriodSeconds(); ok { - _spec.SetField(billingcustomeroverride.FieldItemCollectionPeriodSeconds, field.TypeInt64, value) - } - if value, ok := bcouo.mutation.AddedItemCollectionPeriodSeconds(); ok { - _spec.AddField(billingcustomeroverride.FieldItemCollectionPeriodSeconds, field.TypeInt64, value) + if value, ok := bcouo.mutation.ItemCollectionPeriod(); ok { + _spec.SetField(billingcustomeroverride.FieldItemCollectionPeriod, field.TypeString, value) } - if bcouo.mutation.ItemCollectionPeriodSecondsCleared() { - _spec.ClearField(billingcustomeroverride.FieldItemCollectionPeriodSeconds, field.TypeInt64) + if bcouo.mutation.ItemCollectionPeriodCleared() { + _spec.ClearField(billingcustomeroverride.FieldItemCollectionPeriod, field.TypeString) } if value, ok := bcouo.mutation.InvoiceAutoAdvance(); ok { _spec.SetField(billingcustomeroverride.FieldInvoiceAutoAdvance, field.TypeBool, value) @@ -833,23 +678,17 @@ func (bcouo *BillingCustomerOverrideUpdateOne) sqlSave(ctx context.Context) (_no if bcouo.mutation.InvoiceAutoAdvanceCleared() { _spec.ClearField(billingcustomeroverride.FieldInvoiceAutoAdvance, field.TypeBool) } - if value, ok := bcouo.mutation.InvoiceDraftPeriodSeconds(); ok { - _spec.SetField(billingcustomeroverride.FieldInvoiceDraftPeriodSeconds, field.TypeInt64, value) - } - if value, ok := bcouo.mutation.AddedInvoiceDraftPeriodSeconds(); ok { - _spec.AddField(billingcustomeroverride.FieldInvoiceDraftPeriodSeconds, field.TypeInt64, value) - } - if bcouo.mutation.InvoiceDraftPeriodSecondsCleared() { - _spec.ClearField(billingcustomeroverride.FieldInvoiceDraftPeriodSeconds, field.TypeInt64) + if value, ok := bcouo.mutation.InvoiceDraftPeriod(); ok { + _spec.SetField(billingcustomeroverride.FieldInvoiceDraftPeriod, field.TypeString, value) } - if value, ok := bcouo.mutation.InvoiceDueAfterSeconds(); ok { - _spec.SetField(billingcustomeroverride.FieldInvoiceDueAfterSeconds, field.TypeInt64, value) + if bcouo.mutation.InvoiceDraftPeriodCleared() { + _spec.ClearField(billingcustomeroverride.FieldInvoiceDraftPeriod, field.TypeString) } - if value, ok := bcouo.mutation.AddedInvoiceDueAfterSeconds(); ok { - _spec.AddField(billingcustomeroverride.FieldInvoiceDueAfterSeconds, field.TypeInt64, value) + if value, ok := bcouo.mutation.InvoiceDueAfter(); ok { + _spec.SetField(billingcustomeroverride.FieldInvoiceDueAfter, field.TypeString, value) } - if bcouo.mutation.InvoiceDueAfterSecondsCleared() { - _spec.ClearField(billingcustomeroverride.FieldInvoiceDueAfterSeconds, field.TypeInt64) + if bcouo.mutation.InvoiceDueAfterCleared() { + _spec.ClearField(billingcustomeroverride.FieldInvoiceDueAfter, field.TypeString) } if value, ok := bcouo.mutation.InvoiceCollectionMethod(); ok { _spec.SetField(billingcustomeroverride.FieldInvoiceCollectionMethod, field.TypeEnum, value) @@ -857,18 +696,6 @@ func (bcouo *BillingCustomerOverrideUpdateOne) sqlSave(ctx context.Context) (_no if bcouo.mutation.InvoiceCollectionMethodCleared() { _spec.ClearField(billingcustomeroverride.FieldInvoiceCollectionMethod, field.TypeEnum) } - if value, ok := bcouo.mutation.InvoiceItemResolution(); ok { - _spec.SetField(billingcustomeroverride.FieldInvoiceItemResolution, field.TypeEnum, value) - } - if bcouo.mutation.InvoiceItemResolutionCleared() { - _spec.ClearField(billingcustomeroverride.FieldInvoiceItemResolution, field.TypeEnum) - } - if value, ok := bcouo.mutation.InvoiceItemPerSubject(); ok { - _spec.SetField(billingcustomeroverride.FieldInvoiceItemPerSubject, field.TypeBool, value) - } - if bcouo.mutation.InvoiceItemPerSubjectCleared() { - _spec.ClearField(billingcustomeroverride.FieldInvoiceItemPerSubject, field.TypeBool) - } if bcouo.mutation.BillingProfileCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/openmeter/ent/db/billinginvoice.go b/openmeter/ent/db/billinginvoice.go index 3eecc538a..718d3975f 100644 --- a/openmeter/ent/db/billinginvoice.go +++ b/openmeter/ent/db/billinginvoice.go @@ -10,8 +10,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/openmeterio/openmeter/openmeter/billing" - "github.com/openmeterio/openmeter/openmeter/billing/provider" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoice" "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" "github.com/openmeterio/openmeter/openmeter/ent/db/billingworkflowconfig" @@ -47,13 +46,7 @@ type BillingInvoice struct { // DueDate holds the value of the "due_date" field. DueDate time.Time `json:"due_date,omitempty"` // Status holds the value of the "status" field. - Status billing.InvoiceStatus `json:"status,omitempty"` - // TaxProvider holds the value of the "tax_provider" field. - TaxProvider *provider.TaxProvider `json:"tax_provider,omitempty"` - // InvoicingProvider holds the value of the "invoicing_provider" field. - InvoicingProvider *provider.InvoicingProvider `json:"invoicing_provider,omitempty"` - // PaymentProvider holds the value of the "payment_provider" field. - PaymentProvider *provider.PaymentProvider `json:"payment_provider,omitempty"` + Status billingentity.InvoiceStatus `json:"status,omitempty"` // WorkflowConfigID holds the value of the "workflow_config_id" field. WorkflowConfigID string `json:"workflow_config_id,omitempty"` // PeriodStart holds the value of the "period_start" field. @@ -117,7 +110,7 @@ func (*BillingInvoice) scanValues(columns []string) ([]any, error) { switch columns[i] { case billinginvoice.FieldMetadata: values[i] = new([]byte) - case billinginvoice.FieldID, billinginvoice.FieldNamespace, billinginvoice.FieldSeries, billinginvoice.FieldCode, billinginvoice.FieldCustomerID, billinginvoice.FieldBillingProfileID, billinginvoice.FieldCurrency, billinginvoice.FieldStatus, billinginvoice.FieldTaxProvider, billinginvoice.FieldInvoicingProvider, billinginvoice.FieldPaymentProvider, billinginvoice.FieldWorkflowConfigID: + case billinginvoice.FieldID, billinginvoice.FieldNamespace, billinginvoice.FieldSeries, billinginvoice.FieldCode, billinginvoice.FieldCustomerID, billinginvoice.FieldBillingProfileID, billinginvoice.FieldCurrency, billinginvoice.FieldStatus, billinginvoice.FieldWorkflowConfigID: values[i] = new(sql.NullString) case billinginvoice.FieldCreatedAt, billinginvoice.FieldUpdatedAt, billinginvoice.FieldDeletedAt, billinginvoice.FieldVoidedAt, billinginvoice.FieldDueDate, billinginvoice.FieldPeriodStart, billinginvoice.FieldPeriodEnd: values[i] = new(sql.NullTime) @@ -223,28 +216,7 @@ func (bi *BillingInvoice) assignValues(columns []string, values []any) error { if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { - bi.Status = billing.InvoiceStatus(value.String) - } - case billinginvoice.FieldTaxProvider: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field tax_provider", values[i]) - } else if value.Valid { - bi.TaxProvider = new(provider.TaxProvider) - *bi.TaxProvider = provider.TaxProvider(value.String) - } - case billinginvoice.FieldInvoicingProvider: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field invoicing_provider", values[i]) - } else if value.Valid { - bi.InvoicingProvider = new(provider.InvoicingProvider) - *bi.InvoicingProvider = provider.InvoicingProvider(value.String) - } - case billinginvoice.FieldPaymentProvider: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field payment_provider", values[i]) - } else if value.Valid { - bi.PaymentProvider = new(provider.PaymentProvider) - *bi.PaymentProvider = provider.PaymentProvider(value.String) + bi.Status = billingentity.InvoiceStatus(value.String) } case billinginvoice.FieldWorkflowConfigID: if value, ok := values[i].(*sql.NullString); !ok { @@ -360,21 +332,6 @@ func (bi *BillingInvoice) String() string { builder.WriteString("status=") builder.WriteString(fmt.Sprintf("%v", bi.Status)) builder.WriteString(", ") - if v := bi.TaxProvider; v != nil { - builder.WriteString("tax_provider=") - builder.WriteString(fmt.Sprintf("%v", *v)) - } - builder.WriteString(", ") - if v := bi.InvoicingProvider; v != nil { - builder.WriteString("invoicing_provider=") - builder.WriteString(fmt.Sprintf("%v", *v)) - } - builder.WriteString(", ") - if v := bi.PaymentProvider; v != nil { - builder.WriteString("payment_provider=") - builder.WriteString(fmt.Sprintf("%v", *v)) - } - builder.WriteString(", ") builder.WriteString("workflow_config_id=") builder.WriteString(bi.WorkflowConfigID) builder.WriteString(", ") diff --git a/openmeter/ent/db/billinginvoice/billinginvoice.go b/openmeter/ent/db/billinginvoice/billinginvoice.go index 3d07169e4..b8e46f380 100644 --- a/openmeter/ent/db/billinginvoice/billinginvoice.go +++ b/openmeter/ent/db/billinginvoice/billinginvoice.go @@ -8,8 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/openmeterio/openmeter/openmeter/billing" - "github.com/openmeterio/openmeter/openmeter/billing/provider" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" ) const ( @@ -43,12 +42,6 @@ const ( FieldDueDate = "due_date" // FieldStatus holds the string denoting the status field in the database. FieldStatus = "status" - // FieldTaxProvider holds the string denoting the tax_provider field in the database. - FieldTaxProvider = "tax_provider" - // FieldInvoicingProvider holds the string denoting the invoicing_provider field in the database. - FieldInvoicingProvider = "invoicing_provider" - // FieldPaymentProvider holds the string denoting the payment_provider field in the database. - FieldPaymentProvider = "payment_provider" // FieldWorkflowConfigID holds the string denoting the workflow_config_id field in the database. FieldWorkflowConfigID = "workflow_config_id" // FieldPeriodStart holds the string denoting the period_start field in the database. @@ -102,9 +95,6 @@ var Columns = []string{ FieldCurrency, FieldDueDate, FieldStatus, - FieldTaxProvider, - FieldInvoicingProvider, - FieldPaymentProvider, FieldWorkflowConfigID, FieldPeriodStart, FieldPeriodEnd, @@ -140,7 +130,7 @@ var ( ) // StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. -func StatusValidator(s billing.InvoiceStatus) error { +func StatusValidator(s billingentity.InvoiceStatus) error { switch s { case "created", "draft", "draft_sync", "draft_sync_failed", "issuing", "issued", "issuing_failed", "manual_approval_needed": return nil @@ -149,36 +139,6 @@ func StatusValidator(s billing.InvoiceStatus) error { } } -// TaxProviderValidator is a validator for the "tax_provider" field enum values. It is called by the builders before save. -func TaxProviderValidator(tp provider.TaxProvider) error { - switch tp { - case "openmeter_sandbox", "stripe": - return nil - default: - return fmt.Errorf("billinginvoice: invalid enum value for tax_provider field: %q", tp) - } -} - -// InvoicingProviderValidator is a validator for the "invoicing_provider" field enum values. It is called by the builders before save. -func InvoicingProviderValidator(ip provider.InvoicingProvider) error { - switch ip { - case "openmeter_sandbox", "stripe": - return nil - default: - return fmt.Errorf("billinginvoice: invalid enum value for invoicing_provider field: %q", ip) - } -} - -// PaymentProviderValidator is a validator for the "payment_provider" field enum values. It is called by the builders before save. -func PaymentProviderValidator(pp provider.PaymentProvider) error { - switch pp { - case "openmeter_sandbox", "stripe_payments": - return nil - default: - return fmt.Errorf("billinginvoice: invalid enum value for payment_provider field: %q", pp) - } -} - // OrderOption defines the ordering options for the BillingInvoice queries. type OrderOption func(*sql.Selector) @@ -247,21 +207,6 @@ func ByStatus(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldStatus, opts...).ToFunc() } -// ByTaxProvider orders the results by the tax_provider field. -func ByTaxProvider(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldTaxProvider, opts...).ToFunc() -} - -// ByInvoicingProvider orders the results by the invoicing_provider field. -func ByInvoicingProvider(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldInvoicingProvider, opts...).ToFunc() -} - -// ByPaymentProvider orders the results by the payment_provider field. -func ByPaymentProvider(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPaymentProvider, opts...).ToFunc() -} - // ByWorkflowConfigID orders the results by the workflow_config_id field. func ByWorkflowConfigID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldWorkflowConfigID, opts...).ToFunc() diff --git a/openmeter/ent/db/billinginvoice/where.go b/openmeter/ent/db/billinginvoice/where.go index e062da06e..29eb2a04a 100644 --- a/openmeter/ent/db/billinginvoice/where.go +++ b/openmeter/ent/db/billinginvoice/where.go @@ -7,8 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/openmeterio/openmeter/openmeter/billing" - "github.com/openmeterio/openmeter/openmeter/billing/provider" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" ) @@ -778,19 +777,19 @@ func DueDateLTE(v time.Time) predicate.BillingInvoice { } // StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v billing.InvoiceStatus) predicate.BillingInvoice { +func StatusEQ(v billingentity.InvoiceStatus) predicate.BillingInvoice { vc := v return predicate.BillingInvoice(sql.FieldEQ(FieldStatus, vc)) } // StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v billing.InvoiceStatus) predicate.BillingInvoice { +func StatusNEQ(v billingentity.InvoiceStatus) predicate.BillingInvoice { vc := v return predicate.BillingInvoice(sql.FieldNEQ(FieldStatus, vc)) } // StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...billing.InvoiceStatus) predicate.BillingInvoice { +func StatusIn(vs ...billingentity.InvoiceStatus) predicate.BillingInvoice { v := make([]any, len(vs)) for i := range v { v[i] = vs[i] @@ -799,7 +798,7 @@ func StatusIn(vs ...billing.InvoiceStatus) predicate.BillingInvoice { } // StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...billing.InvoiceStatus) predicate.BillingInvoice { +func StatusNotIn(vs ...billingentity.InvoiceStatus) predicate.BillingInvoice { v := make([]any, len(vs)) for i := range v { v[i] = vs[i] @@ -807,126 +806,6 @@ func StatusNotIn(vs ...billing.InvoiceStatus) predicate.BillingInvoice { return predicate.BillingInvoice(sql.FieldNotIn(FieldStatus, v...)) } -// TaxProviderEQ applies the EQ predicate on the "tax_provider" field. -func TaxProviderEQ(v provider.TaxProvider) predicate.BillingInvoice { - vc := v - return predicate.BillingInvoice(sql.FieldEQ(FieldTaxProvider, vc)) -} - -// TaxProviderNEQ applies the NEQ predicate on the "tax_provider" field. -func TaxProviderNEQ(v provider.TaxProvider) predicate.BillingInvoice { - vc := v - return predicate.BillingInvoice(sql.FieldNEQ(FieldTaxProvider, vc)) -} - -// TaxProviderIn applies the In predicate on the "tax_provider" field. -func TaxProviderIn(vs ...provider.TaxProvider) predicate.BillingInvoice { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingInvoice(sql.FieldIn(FieldTaxProvider, v...)) -} - -// TaxProviderNotIn applies the NotIn predicate on the "tax_provider" field. -func TaxProviderNotIn(vs ...provider.TaxProvider) predicate.BillingInvoice { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingInvoice(sql.FieldNotIn(FieldTaxProvider, v...)) -} - -// TaxProviderIsNil applies the IsNil predicate on the "tax_provider" field. -func TaxProviderIsNil() predicate.BillingInvoice { - return predicate.BillingInvoice(sql.FieldIsNull(FieldTaxProvider)) -} - -// TaxProviderNotNil applies the NotNil predicate on the "tax_provider" field. -func TaxProviderNotNil() predicate.BillingInvoice { - return predicate.BillingInvoice(sql.FieldNotNull(FieldTaxProvider)) -} - -// InvoicingProviderEQ applies the EQ predicate on the "invoicing_provider" field. -func InvoicingProviderEQ(v provider.InvoicingProvider) predicate.BillingInvoice { - vc := v - return predicate.BillingInvoice(sql.FieldEQ(FieldInvoicingProvider, vc)) -} - -// InvoicingProviderNEQ applies the NEQ predicate on the "invoicing_provider" field. -func InvoicingProviderNEQ(v provider.InvoicingProvider) predicate.BillingInvoice { - vc := v - return predicate.BillingInvoice(sql.FieldNEQ(FieldInvoicingProvider, vc)) -} - -// InvoicingProviderIn applies the In predicate on the "invoicing_provider" field. -func InvoicingProviderIn(vs ...provider.InvoicingProvider) predicate.BillingInvoice { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingInvoice(sql.FieldIn(FieldInvoicingProvider, v...)) -} - -// InvoicingProviderNotIn applies the NotIn predicate on the "invoicing_provider" field. -func InvoicingProviderNotIn(vs ...provider.InvoicingProvider) predicate.BillingInvoice { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingInvoice(sql.FieldNotIn(FieldInvoicingProvider, v...)) -} - -// InvoicingProviderIsNil applies the IsNil predicate on the "invoicing_provider" field. -func InvoicingProviderIsNil() predicate.BillingInvoice { - return predicate.BillingInvoice(sql.FieldIsNull(FieldInvoicingProvider)) -} - -// InvoicingProviderNotNil applies the NotNil predicate on the "invoicing_provider" field. -func InvoicingProviderNotNil() predicate.BillingInvoice { - return predicate.BillingInvoice(sql.FieldNotNull(FieldInvoicingProvider)) -} - -// PaymentProviderEQ applies the EQ predicate on the "payment_provider" field. -func PaymentProviderEQ(v provider.PaymentProvider) predicate.BillingInvoice { - vc := v - return predicate.BillingInvoice(sql.FieldEQ(FieldPaymentProvider, vc)) -} - -// PaymentProviderNEQ applies the NEQ predicate on the "payment_provider" field. -func PaymentProviderNEQ(v provider.PaymentProvider) predicate.BillingInvoice { - vc := v - return predicate.BillingInvoice(sql.FieldNEQ(FieldPaymentProvider, vc)) -} - -// PaymentProviderIn applies the In predicate on the "payment_provider" field. -func PaymentProviderIn(vs ...provider.PaymentProvider) predicate.BillingInvoice { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingInvoice(sql.FieldIn(FieldPaymentProvider, v...)) -} - -// PaymentProviderNotIn applies the NotIn predicate on the "payment_provider" field. -func PaymentProviderNotIn(vs ...provider.PaymentProvider) predicate.BillingInvoice { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingInvoice(sql.FieldNotIn(FieldPaymentProvider, v...)) -} - -// PaymentProviderIsNil applies the IsNil predicate on the "payment_provider" field. -func PaymentProviderIsNil() predicate.BillingInvoice { - return predicate.BillingInvoice(sql.FieldIsNull(FieldPaymentProvider)) -} - -// PaymentProviderNotNil applies the NotNil predicate on the "payment_provider" field. -func PaymentProviderNotNil() predicate.BillingInvoice { - return predicate.BillingInvoice(sql.FieldNotNull(FieldPaymentProvider)) -} - // WorkflowConfigIDEQ applies the EQ predicate on the "workflow_config_id" field. func WorkflowConfigIDEQ(v string) predicate.BillingInvoice { return predicate.BillingInvoice(sql.FieldEQ(FieldWorkflowConfigID, v)) diff --git a/openmeter/ent/db/billinginvoice_create.go b/openmeter/ent/db/billinginvoice_create.go index e6cadea1c..60eb51c7a 100644 --- a/openmeter/ent/db/billinginvoice_create.go +++ b/openmeter/ent/db/billinginvoice_create.go @@ -12,8 +12,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/openmeterio/openmeter/openmeter/billing" - "github.com/openmeterio/openmeter/openmeter/billing/provider" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoice" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoiceitem" "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" @@ -149,53 +148,11 @@ func (bic *BillingInvoiceCreate) SetDueDate(t time.Time) *BillingInvoiceCreate { } // SetStatus sets the "status" field. -func (bic *BillingInvoiceCreate) SetStatus(bs billing.InvoiceStatus) *BillingInvoiceCreate { +func (bic *BillingInvoiceCreate) SetStatus(bs billingentity.InvoiceStatus) *BillingInvoiceCreate { bic.mutation.SetStatus(bs) return bic } -// SetTaxProvider sets the "tax_provider" field. -func (bic *BillingInvoiceCreate) SetTaxProvider(pp provider.TaxProvider) *BillingInvoiceCreate { - bic.mutation.SetTaxProvider(pp) - return bic -} - -// SetNillableTaxProvider sets the "tax_provider" field if the given value is not nil. -func (bic *BillingInvoiceCreate) SetNillableTaxProvider(pp *provider.TaxProvider) *BillingInvoiceCreate { - if pp != nil { - bic.SetTaxProvider(*pp) - } - return bic -} - -// SetInvoicingProvider sets the "invoicing_provider" field. -func (bic *BillingInvoiceCreate) SetInvoicingProvider(pp provider.InvoicingProvider) *BillingInvoiceCreate { - bic.mutation.SetInvoicingProvider(pp) - return bic -} - -// SetNillableInvoicingProvider sets the "invoicing_provider" field if the given value is not nil. -func (bic *BillingInvoiceCreate) SetNillableInvoicingProvider(pp *provider.InvoicingProvider) *BillingInvoiceCreate { - if pp != nil { - bic.SetInvoicingProvider(*pp) - } - return bic -} - -// SetPaymentProvider sets the "payment_provider" field. -func (bic *BillingInvoiceCreate) SetPaymentProvider(pp provider.PaymentProvider) *BillingInvoiceCreate { - bic.mutation.SetPaymentProvider(pp) - return bic -} - -// SetNillablePaymentProvider sets the "payment_provider" field if the given value is not nil. -func (bic *BillingInvoiceCreate) SetNillablePaymentProvider(pp *provider.PaymentProvider) *BillingInvoiceCreate { - if pp != nil { - bic.SetPaymentProvider(*pp) - } - return bic -} - // SetWorkflowConfigID sets the "workflow_config_id" field. func (bic *BillingInvoiceCreate) SetWorkflowConfigID(s string) *BillingInvoiceCreate { bic.mutation.SetWorkflowConfigID(s) @@ -359,21 +316,6 @@ func (bic *BillingInvoiceCreate) check() error { return &ValidationError{Name: "status", err: fmt.Errorf(`db: validator failed for field "BillingInvoice.status": %w`, err)} } } - if v, ok := bic.mutation.TaxProvider(); ok { - if err := billinginvoice.TaxProviderValidator(v); err != nil { - return &ValidationError{Name: "tax_provider", err: fmt.Errorf(`db: validator failed for field "BillingInvoice.tax_provider": %w`, err)} - } - } - if v, ok := bic.mutation.InvoicingProvider(); ok { - if err := billinginvoice.InvoicingProviderValidator(v); err != nil { - return &ValidationError{Name: "invoicing_provider", err: fmt.Errorf(`db: validator failed for field "BillingInvoice.invoicing_provider": %w`, err)} - } - } - if v, ok := bic.mutation.PaymentProvider(); ok { - if err := billinginvoice.PaymentProviderValidator(v); err != nil { - return &ValidationError{Name: "payment_provider", err: fmt.Errorf(`db: validator failed for field "BillingInvoice.payment_provider": %w`, err)} - } - } if _, ok := bic.mutation.WorkflowConfigID(); !ok { return &ValidationError{Name: "workflow_config_id", err: errors.New(`db: missing required field "BillingInvoice.workflow_config_id"`)} } @@ -473,18 +415,6 @@ func (bic *BillingInvoiceCreate) createSpec() (*BillingInvoice, *sqlgraph.Create _spec.SetField(billinginvoice.FieldStatus, field.TypeEnum, value) _node.Status = value } - if value, ok := bic.mutation.TaxProvider(); ok { - _spec.SetField(billinginvoice.FieldTaxProvider, field.TypeEnum, value) - _node.TaxProvider = &value - } - if value, ok := bic.mutation.InvoicingProvider(); ok { - _spec.SetField(billinginvoice.FieldInvoicingProvider, field.TypeEnum, value) - _node.InvoicingProvider = &value - } - if value, ok := bic.mutation.PaymentProvider(); ok { - _spec.SetField(billinginvoice.FieldPaymentProvider, field.TypeEnum, value) - _node.PaymentProvider = &value - } if value, ok := bic.mutation.PeriodStart(); ok { _spec.SetField(billinginvoice.FieldPeriodStart, field.TypeTime, value) _node.PeriodStart = value @@ -710,7 +640,7 @@ func (u *BillingInvoiceUpsert) UpdateDueDate() *BillingInvoiceUpsert { } // SetStatus sets the "status" field. -func (u *BillingInvoiceUpsert) SetStatus(v billing.InvoiceStatus) *BillingInvoiceUpsert { +func (u *BillingInvoiceUpsert) SetStatus(v billingentity.InvoiceStatus) *BillingInvoiceUpsert { u.Set(billinginvoice.FieldStatus, v) return u } @@ -721,60 +651,6 @@ func (u *BillingInvoiceUpsert) UpdateStatus() *BillingInvoiceUpsert { return u } -// SetTaxProvider sets the "tax_provider" field. -func (u *BillingInvoiceUpsert) SetTaxProvider(v provider.TaxProvider) *BillingInvoiceUpsert { - u.Set(billinginvoice.FieldTaxProvider, v) - return u -} - -// UpdateTaxProvider sets the "tax_provider" field to the value that was provided on create. -func (u *BillingInvoiceUpsert) UpdateTaxProvider() *BillingInvoiceUpsert { - u.SetExcluded(billinginvoice.FieldTaxProvider) - return u -} - -// ClearTaxProvider clears the value of the "tax_provider" field. -func (u *BillingInvoiceUpsert) ClearTaxProvider() *BillingInvoiceUpsert { - u.SetNull(billinginvoice.FieldTaxProvider) - return u -} - -// SetInvoicingProvider sets the "invoicing_provider" field. -func (u *BillingInvoiceUpsert) SetInvoicingProvider(v provider.InvoicingProvider) *BillingInvoiceUpsert { - u.Set(billinginvoice.FieldInvoicingProvider, v) - return u -} - -// UpdateInvoicingProvider sets the "invoicing_provider" field to the value that was provided on create. -func (u *BillingInvoiceUpsert) UpdateInvoicingProvider() *BillingInvoiceUpsert { - u.SetExcluded(billinginvoice.FieldInvoicingProvider) - return u -} - -// ClearInvoicingProvider clears the value of the "invoicing_provider" field. -func (u *BillingInvoiceUpsert) ClearInvoicingProvider() *BillingInvoiceUpsert { - u.SetNull(billinginvoice.FieldInvoicingProvider) - return u -} - -// SetPaymentProvider sets the "payment_provider" field. -func (u *BillingInvoiceUpsert) SetPaymentProvider(v provider.PaymentProvider) *BillingInvoiceUpsert { - u.Set(billinginvoice.FieldPaymentProvider, v) - return u -} - -// UpdatePaymentProvider sets the "payment_provider" field to the value that was provided on create. -func (u *BillingInvoiceUpsert) UpdatePaymentProvider() *BillingInvoiceUpsert { - u.SetExcluded(billinginvoice.FieldPaymentProvider) - return u -} - -// ClearPaymentProvider clears the value of the "payment_provider" field. -func (u *BillingInvoiceUpsert) ClearPaymentProvider() *BillingInvoiceUpsert { - u.SetNull(billinginvoice.FieldPaymentProvider) - return u -} - // SetWorkflowConfigID sets the "workflow_config_id" field. func (u *BillingInvoiceUpsert) SetWorkflowConfigID(v string) *BillingInvoiceUpsert { u.Set(billinginvoice.FieldWorkflowConfigID, v) @@ -1008,7 +884,7 @@ func (u *BillingInvoiceUpsertOne) UpdateDueDate() *BillingInvoiceUpsertOne { } // SetStatus sets the "status" field. -func (u *BillingInvoiceUpsertOne) SetStatus(v billing.InvoiceStatus) *BillingInvoiceUpsertOne { +func (u *BillingInvoiceUpsertOne) SetStatus(v billingentity.InvoiceStatus) *BillingInvoiceUpsertOne { return u.Update(func(s *BillingInvoiceUpsert) { s.SetStatus(v) }) @@ -1021,69 +897,6 @@ func (u *BillingInvoiceUpsertOne) UpdateStatus() *BillingInvoiceUpsertOne { }) } -// SetTaxProvider sets the "tax_provider" field. -func (u *BillingInvoiceUpsertOne) SetTaxProvider(v provider.TaxProvider) *BillingInvoiceUpsertOne { - return u.Update(func(s *BillingInvoiceUpsert) { - s.SetTaxProvider(v) - }) -} - -// UpdateTaxProvider sets the "tax_provider" field to the value that was provided on create. -func (u *BillingInvoiceUpsertOne) UpdateTaxProvider() *BillingInvoiceUpsertOne { - return u.Update(func(s *BillingInvoiceUpsert) { - s.UpdateTaxProvider() - }) -} - -// ClearTaxProvider clears the value of the "tax_provider" field. -func (u *BillingInvoiceUpsertOne) ClearTaxProvider() *BillingInvoiceUpsertOne { - return u.Update(func(s *BillingInvoiceUpsert) { - s.ClearTaxProvider() - }) -} - -// SetInvoicingProvider sets the "invoicing_provider" field. -func (u *BillingInvoiceUpsertOne) SetInvoicingProvider(v provider.InvoicingProvider) *BillingInvoiceUpsertOne { - return u.Update(func(s *BillingInvoiceUpsert) { - s.SetInvoicingProvider(v) - }) -} - -// UpdateInvoicingProvider sets the "invoicing_provider" field to the value that was provided on create. -func (u *BillingInvoiceUpsertOne) UpdateInvoicingProvider() *BillingInvoiceUpsertOne { - return u.Update(func(s *BillingInvoiceUpsert) { - s.UpdateInvoicingProvider() - }) -} - -// ClearInvoicingProvider clears the value of the "invoicing_provider" field. -func (u *BillingInvoiceUpsertOne) ClearInvoicingProvider() *BillingInvoiceUpsertOne { - return u.Update(func(s *BillingInvoiceUpsert) { - s.ClearInvoicingProvider() - }) -} - -// SetPaymentProvider sets the "payment_provider" field. -func (u *BillingInvoiceUpsertOne) SetPaymentProvider(v provider.PaymentProvider) *BillingInvoiceUpsertOne { - return u.Update(func(s *BillingInvoiceUpsert) { - s.SetPaymentProvider(v) - }) -} - -// UpdatePaymentProvider sets the "payment_provider" field to the value that was provided on create. -func (u *BillingInvoiceUpsertOne) UpdatePaymentProvider() *BillingInvoiceUpsertOne { - return u.Update(func(s *BillingInvoiceUpsert) { - s.UpdatePaymentProvider() - }) -} - -// ClearPaymentProvider clears the value of the "payment_provider" field. -func (u *BillingInvoiceUpsertOne) ClearPaymentProvider() *BillingInvoiceUpsertOne { - return u.Update(func(s *BillingInvoiceUpsert) { - s.ClearPaymentProvider() - }) -} - // SetWorkflowConfigID sets the "workflow_config_id" field. func (u *BillingInvoiceUpsertOne) SetWorkflowConfigID(v string) *BillingInvoiceUpsertOne { return u.Update(func(s *BillingInvoiceUpsert) { @@ -1490,7 +1303,7 @@ func (u *BillingInvoiceUpsertBulk) UpdateDueDate() *BillingInvoiceUpsertBulk { } // SetStatus sets the "status" field. -func (u *BillingInvoiceUpsertBulk) SetStatus(v billing.InvoiceStatus) *BillingInvoiceUpsertBulk { +func (u *BillingInvoiceUpsertBulk) SetStatus(v billingentity.InvoiceStatus) *BillingInvoiceUpsertBulk { return u.Update(func(s *BillingInvoiceUpsert) { s.SetStatus(v) }) @@ -1503,69 +1316,6 @@ func (u *BillingInvoiceUpsertBulk) UpdateStatus() *BillingInvoiceUpsertBulk { }) } -// SetTaxProvider sets the "tax_provider" field. -func (u *BillingInvoiceUpsertBulk) SetTaxProvider(v provider.TaxProvider) *BillingInvoiceUpsertBulk { - return u.Update(func(s *BillingInvoiceUpsert) { - s.SetTaxProvider(v) - }) -} - -// UpdateTaxProvider sets the "tax_provider" field to the value that was provided on create. -func (u *BillingInvoiceUpsertBulk) UpdateTaxProvider() *BillingInvoiceUpsertBulk { - return u.Update(func(s *BillingInvoiceUpsert) { - s.UpdateTaxProvider() - }) -} - -// ClearTaxProvider clears the value of the "tax_provider" field. -func (u *BillingInvoiceUpsertBulk) ClearTaxProvider() *BillingInvoiceUpsertBulk { - return u.Update(func(s *BillingInvoiceUpsert) { - s.ClearTaxProvider() - }) -} - -// SetInvoicingProvider sets the "invoicing_provider" field. -func (u *BillingInvoiceUpsertBulk) SetInvoicingProvider(v provider.InvoicingProvider) *BillingInvoiceUpsertBulk { - return u.Update(func(s *BillingInvoiceUpsert) { - s.SetInvoicingProvider(v) - }) -} - -// UpdateInvoicingProvider sets the "invoicing_provider" field to the value that was provided on create. -func (u *BillingInvoiceUpsertBulk) UpdateInvoicingProvider() *BillingInvoiceUpsertBulk { - return u.Update(func(s *BillingInvoiceUpsert) { - s.UpdateInvoicingProvider() - }) -} - -// ClearInvoicingProvider clears the value of the "invoicing_provider" field. -func (u *BillingInvoiceUpsertBulk) ClearInvoicingProvider() *BillingInvoiceUpsertBulk { - return u.Update(func(s *BillingInvoiceUpsert) { - s.ClearInvoicingProvider() - }) -} - -// SetPaymentProvider sets the "payment_provider" field. -func (u *BillingInvoiceUpsertBulk) SetPaymentProvider(v provider.PaymentProvider) *BillingInvoiceUpsertBulk { - return u.Update(func(s *BillingInvoiceUpsert) { - s.SetPaymentProvider(v) - }) -} - -// UpdatePaymentProvider sets the "payment_provider" field to the value that was provided on create. -func (u *BillingInvoiceUpsertBulk) UpdatePaymentProvider() *BillingInvoiceUpsertBulk { - return u.Update(func(s *BillingInvoiceUpsert) { - s.UpdatePaymentProvider() - }) -} - -// ClearPaymentProvider clears the value of the "payment_provider" field. -func (u *BillingInvoiceUpsertBulk) ClearPaymentProvider() *BillingInvoiceUpsertBulk { - return u.Update(func(s *BillingInvoiceUpsert) { - s.ClearPaymentProvider() - }) -} - // SetWorkflowConfigID sets the "workflow_config_id" field. func (u *BillingInvoiceUpsertBulk) SetWorkflowConfigID(v string) *BillingInvoiceUpsertBulk { return u.Update(func(s *BillingInvoiceUpsert) { diff --git a/openmeter/ent/db/billinginvoice_update.go b/openmeter/ent/db/billinginvoice_update.go index 0d13eac3a..3e5e52a2b 100644 --- a/openmeter/ent/db/billinginvoice_update.go +++ b/openmeter/ent/db/billinginvoice_update.go @@ -11,8 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/openmeterio/openmeter/openmeter/billing" - "github.com/openmeterio/openmeter/openmeter/billing/provider" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoice" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoiceitem" "github.com/openmeterio/openmeter/openmeter/ent/db/billingworkflowconfig" @@ -145,79 +144,19 @@ func (biu *BillingInvoiceUpdate) SetNillableDueDate(t *time.Time) *BillingInvoic } // SetStatus sets the "status" field. -func (biu *BillingInvoiceUpdate) SetStatus(bs billing.InvoiceStatus) *BillingInvoiceUpdate { +func (biu *BillingInvoiceUpdate) SetStatus(bs billingentity.InvoiceStatus) *BillingInvoiceUpdate { biu.mutation.SetStatus(bs) return biu } // SetNillableStatus sets the "status" field if the given value is not nil. -func (biu *BillingInvoiceUpdate) SetNillableStatus(bs *billing.InvoiceStatus) *BillingInvoiceUpdate { +func (biu *BillingInvoiceUpdate) SetNillableStatus(bs *billingentity.InvoiceStatus) *BillingInvoiceUpdate { if bs != nil { biu.SetStatus(*bs) } return biu } -// SetTaxProvider sets the "tax_provider" field. -func (biu *BillingInvoiceUpdate) SetTaxProvider(pp provider.TaxProvider) *BillingInvoiceUpdate { - biu.mutation.SetTaxProvider(pp) - return biu -} - -// SetNillableTaxProvider sets the "tax_provider" field if the given value is not nil. -func (biu *BillingInvoiceUpdate) SetNillableTaxProvider(pp *provider.TaxProvider) *BillingInvoiceUpdate { - if pp != nil { - biu.SetTaxProvider(*pp) - } - return biu -} - -// ClearTaxProvider clears the value of the "tax_provider" field. -func (biu *BillingInvoiceUpdate) ClearTaxProvider() *BillingInvoiceUpdate { - biu.mutation.ClearTaxProvider() - return biu -} - -// SetInvoicingProvider sets the "invoicing_provider" field. -func (biu *BillingInvoiceUpdate) SetInvoicingProvider(pp provider.InvoicingProvider) *BillingInvoiceUpdate { - biu.mutation.SetInvoicingProvider(pp) - return biu -} - -// SetNillableInvoicingProvider sets the "invoicing_provider" field if the given value is not nil. -func (biu *BillingInvoiceUpdate) SetNillableInvoicingProvider(pp *provider.InvoicingProvider) *BillingInvoiceUpdate { - if pp != nil { - biu.SetInvoicingProvider(*pp) - } - return biu -} - -// ClearInvoicingProvider clears the value of the "invoicing_provider" field. -func (biu *BillingInvoiceUpdate) ClearInvoicingProvider() *BillingInvoiceUpdate { - biu.mutation.ClearInvoicingProvider() - return biu -} - -// SetPaymentProvider sets the "payment_provider" field. -func (biu *BillingInvoiceUpdate) SetPaymentProvider(pp provider.PaymentProvider) *BillingInvoiceUpdate { - biu.mutation.SetPaymentProvider(pp) - return biu -} - -// SetNillablePaymentProvider sets the "payment_provider" field if the given value is not nil. -func (biu *BillingInvoiceUpdate) SetNillablePaymentProvider(pp *provider.PaymentProvider) *BillingInvoiceUpdate { - if pp != nil { - biu.SetPaymentProvider(*pp) - } - return biu -} - -// ClearPaymentProvider clears the value of the "payment_provider" field. -func (biu *BillingInvoiceUpdate) ClearPaymentProvider() *BillingInvoiceUpdate { - biu.mutation.ClearPaymentProvider() - return biu -} - // SetWorkflowConfigID sets the "workflow_config_id" field. func (biu *BillingInvoiceUpdate) SetWorkflowConfigID(s string) *BillingInvoiceUpdate { biu.mutation.SetWorkflowConfigID(s) @@ -361,21 +300,6 @@ func (biu *BillingInvoiceUpdate) check() error { return &ValidationError{Name: "status", err: fmt.Errorf(`db: validator failed for field "BillingInvoice.status": %w`, err)} } } - if v, ok := biu.mutation.TaxProvider(); ok { - if err := billinginvoice.TaxProviderValidator(v); err != nil { - return &ValidationError{Name: "tax_provider", err: fmt.Errorf(`db: validator failed for field "BillingInvoice.tax_provider": %w`, err)} - } - } - if v, ok := biu.mutation.InvoicingProvider(); ok { - if err := billinginvoice.InvoicingProviderValidator(v); err != nil { - return &ValidationError{Name: "invoicing_provider", err: fmt.Errorf(`db: validator failed for field "BillingInvoice.invoicing_provider": %w`, err)} - } - } - if v, ok := biu.mutation.PaymentProvider(); ok { - if err := billinginvoice.PaymentProviderValidator(v); err != nil { - return &ValidationError{Name: "payment_provider", err: fmt.Errorf(`db: validator failed for field "BillingInvoice.payment_provider": %w`, err)} - } - } if biu.mutation.BillingProfileCleared() && len(biu.mutation.BillingProfileIDs()) > 0 { return errors.New(`db: clearing a required unique edge "BillingInvoice.billing_profile"`) } @@ -436,24 +360,6 @@ func (biu *BillingInvoiceUpdate) sqlSave(ctx context.Context) (n int, err error) if value, ok := biu.mutation.Status(); ok { _spec.SetField(billinginvoice.FieldStatus, field.TypeEnum, value) } - if value, ok := biu.mutation.TaxProvider(); ok { - _spec.SetField(billinginvoice.FieldTaxProvider, field.TypeEnum, value) - } - if biu.mutation.TaxProviderCleared() { - _spec.ClearField(billinginvoice.FieldTaxProvider, field.TypeEnum) - } - if value, ok := biu.mutation.InvoicingProvider(); ok { - _spec.SetField(billinginvoice.FieldInvoicingProvider, field.TypeEnum, value) - } - if biu.mutation.InvoicingProviderCleared() { - _spec.ClearField(billinginvoice.FieldInvoicingProvider, field.TypeEnum) - } - if value, ok := biu.mutation.PaymentProvider(); ok { - _spec.SetField(billinginvoice.FieldPaymentProvider, field.TypeEnum, value) - } - if biu.mutation.PaymentProviderCleared() { - _spec.ClearField(billinginvoice.FieldPaymentProvider, field.TypeEnum) - } if value, ok := biu.mutation.PeriodStart(); ok { _spec.SetField(billinginvoice.FieldPeriodStart, field.TypeTime, value) } @@ -667,79 +573,19 @@ func (biuo *BillingInvoiceUpdateOne) SetNillableDueDate(t *time.Time) *BillingIn } // SetStatus sets the "status" field. -func (biuo *BillingInvoiceUpdateOne) SetStatus(bs billing.InvoiceStatus) *BillingInvoiceUpdateOne { +func (biuo *BillingInvoiceUpdateOne) SetStatus(bs billingentity.InvoiceStatus) *BillingInvoiceUpdateOne { biuo.mutation.SetStatus(bs) return biuo } // SetNillableStatus sets the "status" field if the given value is not nil. -func (biuo *BillingInvoiceUpdateOne) SetNillableStatus(bs *billing.InvoiceStatus) *BillingInvoiceUpdateOne { +func (biuo *BillingInvoiceUpdateOne) SetNillableStatus(bs *billingentity.InvoiceStatus) *BillingInvoiceUpdateOne { if bs != nil { biuo.SetStatus(*bs) } return biuo } -// SetTaxProvider sets the "tax_provider" field. -func (biuo *BillingInvoiceUpdateOne) SetTaxProvider(pp provider.TaxProvider) *BillingInvoiceUpdateOne { - biuo.mutation.SetTaxProvider(pp) - return biuo -} - -// SetNillableTaxProvider sets the "tax_provider" field if the given value is not nil. -func (biuo *BillingInvoiceUpdateOne) SetNillableTaxProvider(pp *provider.TaxProvider) *BillingInvoiceUpdateOne { - if pp != nil { - biuo.SetTaxProvider(*pp) - } - return biuo -} - -// ClearTaxProvider clears the value of the "tax_provider" field. -func (biuo *BillingInvoiceUpdateOne) ClearTaxProvider() *BillingInvoiceUpdateOne { - biuo.mutation.ClearTaxProvider() - return biuo -} - -// SetInvoicingProvider sets the "invoicing_provider" field. -func (biuo *BillingInvoiceUpdateOne) SetInvoicingProvider(pp provider.InvoicingProvider) *BillingInvoiceUpdateOne { - biuo.mutation.SetInvoicingProvider(pp) - return biuo -} - -// SetNillableInvoicingProvider sets the "invoicing_provider" field if the given value is not nil. -func (biuo *BillingInvoiceUpdateOne) SetNillableInvoicingProvider(pp *provider.InvoicingProvider) *BillingInvoiceUpdateOne { - if pp != nil { - biuo.SetInvoicingProvider(*pp) - } - return biuo -} - -// ClearInvoicingProvider clears the value of the "invoicing_provider" field. -func (biuo *BillingInvoiceUpdateOne) ClearInvoicingProvider() *BillingInvoiceUpdateOne { - biuo.mutation.ClearInvoicingProvider() - return biuo -} - -// SetPaymentProvider sets the "payment_provider" field. -func (biuo *BillingInvoiceUpdateOne) SetPaymentProvider(pp provider.PaymentProvider) *BillingInvoiceUpdateOne { - biuo.mutation.SetPaymentProvider(pp) - return biuo -} - -// SetNillablePaymentProvider sets the "payment_provider" field if the given value is not nil. -func (biuo *BillingInvoiceUpdateOne) SetNillablePaymentProvider(pp *provider.PaymentProvider) *BillingInvoiceUpdateOne { - if pp != nil { - biuo.SetPaymentProvider(*pp) - } - return biuo -} - -// ClearPaymentProvider clears the value of the "payment_provider" field. -func (biuo *BillingInvoiceUpdateOne) ClearPaymentProvider() *BillingInvoiceUpdateOne { - biuo.mutation.ClearPaymentProvider() - return biuo -} - // SetWorkflowConfigID sets the "workflow_config_id" field. func (biuo *BillingInvoiceUpdateOne) SetWorkflowConfigID(s string) *BillingInvoiceUpdateOne { biuo.mutation.SetWorkflowConfigID(s) @@ -896,21 +742,6 @@ func (biuo *BillingInvoiceUpdateOne) check() error { return &ValidationError{Name: "status", err: fmt.Errorf(`db: validator failed for field "BillingInvoice.status": %w`, err)} } } - if v, ok := biuo.mutation.TaxProvider(); ok { - if err := billinginvoice.TaxProviderValidator(v); err != nil { - return &ValidationError{Name: "tax_provider", err: fmt.Errorf(`db: validator failed for field "BillingInvoice.tax_provider": %w`, err)} - } - } - if v, ok := biuo.mutation.InvoicingProvider(); ok { - if err := billinginvoice.InvoicingProviderValidator(v); err != nil { - return &ValidationError{Name: "invoicing_provider", err: fmt.Errorf(`db: validator failed for field "BillingInvoice.invoicing_provider": %w`, err)} - } - } - if v, ok := biuo.mutation.PaymentProvider(); ok { - if err := billinginvoice.PaymentProviderValidator(v); err != nil { - return &ValidationError{Name: "payment_provider", err: fmt.Errorf(`db: validator failed for field "BillingInvoice.payment_provider": %w`, err)} - } - } if biuo.mutation.BillingProfileCleared() && len(biuo.mutation.BillingProfileIDs()) > 0 { return errors.New(`db: clearing a required unique edge "BillingInvoice.billing_profile"`) } @@ -988,24 +819,6 @@ func (biuo *BillingInvoiceUpdateOne) sqlSave(ctx context.Context) (_node *Billin if value, ok := biuo.mutation.Status(); ok { _spec.SetField(billinginvoice.FieldStatus, field.TypeEnum, value) } - if value, ok := biuo.mutation.TaxProvider(); ok { - _spec.SetField(billinginvoice.FieldTaxProvider, field.TypeEnum, value) - } - if biuo.mutation.TaxProviderCleared() { - _spec.ClearField(billinginvoice.FieldTaxProvider, field.TypeEnum) - } - if value, ok := biuo.mutation.InvoicingProvider(); ok { - _spec.SetField(billinginvoice.FieldInvoicingProvider, field.TypeEnum, value) - } - if biuo.mutation.InvoicingProviderCleared() { - _spec.ClearField(billinginvoice.FieldInvoicingProvider, field.TypeEnum) - } - if value, ok := biuo.mutation.PaymentProvider(); ok { - _spec.SetField(billinginvoice.FieldPaymentProvider, field.TypeEnum, value) - } - if biuo.mutation.PaymentProviderCleared() { - _spec.ClearField(billinginvoice.FieldPaymentProvider, field.TypeEnum) - } if value, ok := biuo.mutation.PeriodStart(); ok { _spec.SetField(billinginvoice.FieldPeriodStart, field.TypeTime, value) } diff --git a/openmeter/ent/db/billinginvoiceitem.go b/openmeter/ent/db/billinginvoiceitem.go index 084b0663a..92b288257 100644 --- a/openmeter/ent/db/billinginvoiceitem.go +++ b/openmeter/ent/db/billinginvoiceitem.go @@ -11,7 +11,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/alpacahq/alpacadecimal" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoice" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoiceitem" "github.com/openmeterio/openmeter/pkg/currencyx" @@ -43,7 +43,7 @@ type BillingInvoiceItem struct { // InvoiceAt holds the value of the "invoice_at" field. InvoiceAt time.Time `json:"invoice_at,omitempty"` // Type holds the value of the "type" field. - Type billing.InvoiceItemType `json:"type,omitempty"` + Type billingentity.InvoiceItemType `json:"type,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // Quantity holds the value of the "quantity" field. @@ -53,7 +53,7 @@ type BillingInvoiceItem struct { // Currency holds the value of the "currency" field. Currency currencyx.Code `json:"currency,omitempty"` // TaxCodeOverride holds the value of the "tax_code_override" field. - TaxCodeOverride billing.TaxOverrides `json:"tax_code_override,omitempty"` + TaxCodeOverride billingentity.TaxOverrides `json:"tax_code_override,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the BillingInvoiceItemQuery when eager-loading is set. Edges BillingInvoiceItemEdges `json:"edges"` @@ -184,7 +184,7 @@ func (bii *BillingInvoiceItem) assignValues(columns []string, values []any) erro if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field type", values[i]) } else if value.Valid { - bii.Type = billing.InvoiceItemType(value.String) + bii.Type = billingentity.InvoiceItemType(value.String) } case billinginvoiceitem.FieldName: if value, ok := values[i].(*sql.NullString); !ok { diff --git a/openmeter/ent/db/billinginvoiceitem/billinginvoiceitem.go b/openmeter/ent/db/billinginvoiceitem/billinginvoiceitem.go index 466cca163..7cd1061f8 100644 --- a/openmeter/ent/db/billinginvoiceitem/billinginvoiceitem.go +++ b/openmeter/ent/db/billinginvoiceitem/billinginvoiceitem.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" ) const ( @@ -112,7 +112,7 @@ var ( ) // TypeValidator is a validator for the "type" field enum values. It is called by the builders before save. -func TypeValidator(_type billing.InvoiceItemType) error { +func TypeValidator(_type billingentity.InvoiceItemType) error { switch _type { case "static", "usage": return nil diff --git a/openmeter/ent/db/billinginvoiceitem/where.go b/openmeter/ent/db/billinginvoiceitem/where.go index d540ffe9d..ad29d92bb 100644 --- a/openmeter/ent/db/billinginvoiceitem/where.go +++ b/openmeter/ent/db/billinginvoiceitem/where.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/alpacahq/alpacadecimal" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" "github.com/openmeterio/openmeter/pkg/currencyx" ) @@ -600,19 +600,19 @@ func InvoiceAtLTE(v time.Time) predicate.BillingInvoiceItem { } // TypeEQ applies the EQ predicate on the "type" field. -func TypeEQ(v billing.InvoiceItemType) predicate.BillingInvoiceItem { +func TypeEQ(v billingentity.InvoiceItemType) predicate.BillingInvoiceItem { vc := v return predicate.BillingInvoiceItem(sql.FieldEQ(FieldType, vc)) } // TypeNEQ applies the NEQ predicate on the "type" field. -func TypeNEQ(v billing.InvoiceItemType) predicate.BillingInvoiceItem { +func TypeNEQ(v billingentity.InvoiceItemType) predicate.BillingInvoiceItem { vc := v return predicate.BillingInvoiceItem(sql.FieldNEQ(FieldType, vc)) } // TypeIn applies the In predicate on the "type" field. -func TypeIn(vs ...billing.InvoiceItemType) predicate.BillingInvoiceItem { +func TypeIn(vs ...billingentity.InvoiceItemType) predicate.BillingInvoiceItem { v := make([]any, len(vs)) for i := range v { v[i] = vs[i] @@ -621,7 +621,7 @@ func TypeIn(vs ...billing.InvoiceItemType) predicate.BillingInvoiceItem { } // TypeNotIn applies the NotIn predicate on the "type" field. -func TypeNotIn(vs ...billing.InvoiceItemType) predicate.BillingInvoiceItem { +func TypeNotIn(vs ...billingentity.InvoiceItemType) predicate.BillingInvoiceItem { v := make([]any, len(vs)) for i := range v { v[i] = vs[i] diff --git a/openmeter/ent/db/billinginvoiceitem_create.go b/openmeter/ent/db/billinginvoiceitem_create.go index 0361a1e5e..75c853289 100644 --- a/openmeter/ent/db/billinginvoiceitem_create.go +++ b/openmeter/ent/db/billinginvoiceitem_create.go @@ -13,7 +13,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/alpacahq/alpacadecimal" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoice" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoiceitem" "github.com/openmeterio/openmeter/pkg/currencyx" @@ -120,7 +120,7 @@ func (biic *BillingInvoiceItemCreate) SetInvoiceAt(t time.Time) *BillingInvoiceI } // SetType sets the "type" field. -func (biic *BillingInvoiceItemCreate) SetType(bit billing.InvoiceItemType) *BillingInvoiceItemCreate { +func (biic *BillingInvoiceItemCreate) SetType(bit billingentity.InvoiceItemType) *BillingInvoiceItemCreate { biic.mutation.SetType(bit) return biic } @@ -158,7 +158,7 @@ func (biic *BillingInvoiceItemCreate) SetCurrency(c currencyx.Code) *BillingInvo } // SetTaxCodeOverride sets the "tax_code_override" field. -func (biic *BillingInvoiceItemCreate) SetTaxCodeOverride(bo billing.TaxOverrides) *BillingInvoiceItemCreate { +func (biic *BillingInvoiceItemCreate) SetTaxCodeOverride(bo billingentity.TaxOverrides) *BillingInvoiceItemCreate { biic.mutation.SetTaxCodeOverride(bo) return biic } @@ -576,7 +576,7 @@ func (u *BillingInvoiceItemUpsert) UpdateInvoiceAt() *BillingInvoiceItemUpsert { } // SetType sets the "type" field. -func (u *BillingInvoiceItemUpsert) SetType(v billing.InvoiceItemType) *BillingInvoiceItemUpsert { +func (u *BillingInvoiceItemUpsert) SetType(v billingentity.InvoiceItemType) *BillingInvoiceItemUpsert { u.Set(billinginvoiceitem.FieldType, v) return u } @@ -630,7 +630,7 @@ func (u *BillingInvoiceItemUpsert) UpdateUnitPrice() *BillingInvoiceItemUpsert { } // SetTaxCodeOverride sets the "tax_code_override" field. -func (u *BillingInvoiceItemUpsert) SetTaxCodeOverride(v billing.TaxOverrides) *BillingInvoiceItemUpsert { +func (u *BillingInvoiceItemUpsert) SetTaxCodeOverride(v billingentity.TaxOverrides) *BillingInvoiceItemUpsert { u.Set(billinginvoiceitem.FieldTaxCodeOverride, v) return u } @@ -821,7 +821,7 @@ func (u *BillingInvoiceItemUpsertOne) UpdateInvoiceAt() *BillingInvoiceItemUpser } // SetType sets the "type" field. -func (u *BillingInvoiceItemUpsertOne) SetType(v billing.InvoiceItemType) *BillingInvoiceItemUpsertOne { +func (u *BillingInvoiceItemUpsertOne) SetType(v billingentity.InvoiceItemType) *BillingInvoiceItemUpsertOne { return u.Update(func(s *BillingInvoiceItemUpsert) { s.SetType(v) }) @@ -884,7 +884,7 @@ func (u *BillingInvoiceItemUpsertOne) UpdateUnitPrice() *BillingInvoiceItemUpser } // SetTaxCodeOverride sets the "tax_code_override" field. -func (u *BillingInvoiceItemUpsertOne) SetTaxCodeOverride(v billing.TaxOverrides) *BillingInvoiceItemUpsertOne { +func (u *BillingInvoiceItemUpsertOne) SetTaxCodeOverride(v billingentity.TaxOverrides) *BillingInvoiceItemUpsertOne { return u.Update(func(s *BillingInvoiceItemUpsert) { s.SetTaxCodeOverride(v) }) @@ -1244,7 +1244,7 @@ func (u *BillingInvoiceItemUpsertBulk) UpdateInvoiceAt() *BillingInvoiceItemUpse } // SetType sets the "type" field. -func (u *BillingInvoiceItemUpsertBulk) SetType(v billing.InvoiceItemType) *BillingInvoiceItemUpsertBulk { +func (u *BillingInvoiceItemUpsertBulk) SetType(v billingentity.InvoiceItemType) *BillingInvoiceItemUpsertBulk { return u.Update(func(s *BillingInvoiceItemUpsert) { s.SetType(v) }) @@ -1307,7 +1307,7 @@ func (u *BillingInvoiceItemUpsertBulk) UpdateUnitPrice() *BillingInvoiceItemUpse } // SetTaxCodeOverride sets the "tax_code_override" field. -func (u *BillingInvoiceItemUpsertBulk) SetTaxCodeOverride(v billing.TaxOverrides) *BillingInvoiceItemUpsertBulk { +func (u *BillingInvoiceItemUpsertBulk) SetTaxCodeOverride(v billingentity.TaxOverrides) *BillingInvoiceItemUpsertBulk { return u.Update(func(s *BillingInvoiceItemUpsert) { s.SetTaxCodeOverride(v) }) diff --git a/openmeter/ent/db/billinginvoiceitem_update.go b/openmeter/ent/db/billinginvoiceitem_update.go index 242ffc073..9832330ff 100644 --- a/openmeter/ent/db/billinginvoiceitem_update.go +++ b/openmeter/ent/db/billinginvoiceitem_update.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/alpacahq/alpacadecimal" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoice" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoiceitem" "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" @@ -132,13 +132,13 @@ func (biiu *BillingInvoiceItemUpdate) SetNillableInvoiceAt(t *time.Time) *Billin } // SetType sets the "type" field. -func (biiu *BillingInvoiceItemUpdate) SetType(bit billing.InvoiceItemType) *BillingInvoiceItemUpdate { +func (biiu *BillingInvoiceItemUpdate) SetType(bit billingentity.InvoiceItemType) *BillingInvoiceItemUpdate { biiu.mutation.SetType(bit) return biiu } // SetNillableType sets the "type" field if the given value is not nil. -func (biiu *BillingInvoiceItemUpdate) SetNillableType(bit *billing.InvoiceItemType) *BillingInvoiceItemUpdate { +func (biiu *BillingInvoiceItemUpdate) SetNillableType(bit *billingentity.InvoiceItemType) *BillingInvoiceItemUpdate { if bit != nil { biiu.SetType(*bit) } @@ -194,13 +194,13 @@ func (biiu *BillingInvoiceItemUpdate) SetNillableUnitPrice(a *alpacadecimal.Deci } // SetTaxCodeOverride sets the "tax_code_override" field. -func (biiu *BillingInvoiceItemUpdate) SetTaxCodeOverride(bo billing.TaxOverrides) *BillingInvoiceItemUpdate { +func (biiu *BillingInvoiceItemUpdate) SetTaxCodeOverride(bo billingentity.TaxOverrides) *BillingInvoiceItemUpdate { biiu.mutation.SetTaxCodeOverride(bo) return biiu } // SetNillableTaxCodeOverride sets the "tax_code_override" field if the given value is not nil. -func (biiu *BillingInvoiceItemUpdate) SetNillableTaxCodeOverride(bo *billing.TaxOverrides) *BillingInvoiceItemUpdate { +func (biiu *BillingInvoiceItemUpdate) SetNillableTaxCodeOverride(bo *billingentity.TaxOverrides) *BillingInvoiceItemUpdate { if bo != nil { biiu.SetTaxCodeOverride(*bo) } @@ -492,13 +492,13 @@ func (biiuo *BillingInvoiceItemUpdateOne) SetNillableInvoiceAt(t *time.Time) *Bi } // SetType sets the "type" field. -func (biiuo *BillingInvoiceItemUpdateOne) SetType(bit billing.InvoiceItemType) *BillingInvoiceItemUpdateOne { +func (biiuo *BillingInvoiceItemUpdateOne) SetType(bit billingentity.InvoiceItemType) *BillingInvoiceItemUpdateOne { biiuo.mutation.SetType(bit) return biiuo } // SetNillableType sets the "type" field if the given value is not nil. -func (biiuo *BillingInvoiceItemUpdateOne) SetNillableType(bit *billing.InvoiceItemType) *BillingInvoiceItemUpdateOne { +func (biiuo *BillingInvoiceItemUpdateOne) SetNillableType(bit *billingentity.InvoiceItemType) *BillingInvoiceItemUpdateOne { if bit != nil { biiuo.SetType(*bit) } @@ -554,13 +554,13 @@ func (biiuo *BillingInvoiceItemUpdateOne) SetNillableUnitPrice(a *alpacadecimal. } // SetTaxCodeOverride sets the "tax_code_override" field. -func (biiuo *BillingInvoiceItemUpdateOne) SetTaxCodeOverride(bo billing.TaxOverrides) *BillingInvoiceItemUpdateOne { +func (biiuo *BillingInvoiceItemUpdateOne) SetTaxCodeOverride(bo billingentity.TaxOverrides) *BillingInvoiceItemUpdateOne { biiuo.mutation.SetTaxCodeOverride(bo) return biiuo } // SetNillableTaxCodeOverride sets the "tax_code_override" field if the given value is not nil. -func (biiuo *BillingInvoiceItemUpdateOne) SetNillableTaxCodeOverride(bo *billing.TaxOverrides) *BillingInvoiceItemUpdateOne { +func (biiuo *BillingInvoiceItemUpdateOne) SetNillableTaxCodeOverride(bo *billingentity.TaxOverrides) *BillingInvoiceItemUpdateOne { if bo != nil { biiuo.SetTaxCodeOverride(*bo) } diff --git a/openmeter/ent/db/billingprofile.go b/openmeter/ent/db/billingprofile.go index bd6a2ff65..cafc8cf45 100644 --- a/openmeter/ent/db/billingprofile.go +++ b/openmeter/ent/db/billingprofile.go @@ -10,7 +10,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/openmeterio/openmeter/openmeter/billing/provider" + "github.com/openmeterio/openmeter/openmeter/ent/db/app" "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" "github.com/openmeterio/openmeter/openmeter/ent/db/billingworkflowconfig" "github.com/openmeterio/openmeter/pkg/models" @@ -49,18 +49,20 @@ type BillingProfile struct { SupplierAddressLine2 *string `json:"supplier_address_line2,omitempty"` // SupplierAddressPhoneNumber holds the value of the "supplier_address_phone_number" field. SupplierAddressPhoneNumber *string `json:"supplier_address_phone_number,omitempty"` - // TaxProvider holds the value of the "tax_provider" field. - TaxProvider provider.TaxProvider `json:"tax_provider,omitempty"` - // InvoicingProvider holds the value of the "invoicing_provider" field. - InvoicingProvider provider.InvoicingProvider `json:"invoicing_provider,omitempty"` - // PaymentProvider holds the value of the "payment_provider" field. - PaymentProvider provider.PaymentProvider `json:"payment_provider,omitempty"` + // TaxAppID holds the value of the "tax_app_id" field. + TaxAppID string `json:"tax_app_id,omitempty"` + // InvoicingAppID holds the value of the "invoicing_app_id" field. + InvoicingAppID string `json:"invoicing_app_id,omitempty"` + // PaymentAppID holds the value of the "payment_app_id" field. + PaymentAppID string `json:"payment_app_id,omitempty"` // WorkflowConfigID holds the value of the "workflow_config_id" field. WorkflowConfigID string `json:"workflow_config_id,omitempty"` // Default holds the value of the "default" field. Default bool `json:"default,omitempty"` // SupplierName holds the value of the "supplier_name" field. SupplierName string `json:"supplier_name,omitempty"` + // SupplierTaxCode holds the value of the "supplier_tax_code" field. + SupplierTaxCode *string `json:"supplier_tax_code,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the BillingProfileQuery when eager-loading is set. Edges BillingProfileEdges `json:"edges"` @@ -75,9 +77,15 @@ type BillingProfileEdges struct { BillingCustomerOverride []*BillingCustomerOverride `json:"billing_customer_override,omitempty"` // WorkflowConfig holds the value of the workflow_config edge. WorkflowConfig *BillingWorkflowConfig `json:"workflow_config,omitempty"` + // TaxApp holds the value of the tax_app edge. + TaxApp *App `json:"tax_app,omitempty"` + // InvoicingApp holds the value of the invoicing_app edge. + InvoicingApp *App `json:"invoicing_app,omitempty"` + // PaymentApp holds the value of the payment_app edge. + PaymentApp *App `json:"payment_app,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [3]bool + loadedTypes [6]bool } // BillingInvoicesOrErr returns the BillingInvoices value or an error if the edge @@ -109,6 +117,39 @@ func (e BillingProfileEdges) WorkflowConfigOrErr() (*BillingWorkflowConfig, erro return nil, &NotLoadedError{edge: "workflow_config"} } +// TaxAppOrErr returns the TaxApp value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e BillingProfileEdges) TaxAppOrErr() (*App, error) { + if e.TaxApp != nil { + return e.TaxApp, nil + } else if e.loadedTypes[3] { + return nil, &NotFoundError{label: app.Label} + } + return nil, &NotLoadedError{edge: "tax_app"} +} + +// InvoicingAppOrErr returns the InvoicingApp value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e BillingProfileEdges) InvoicingAppOrErr() (*App, error) { + if e.InvoicingApp != nil { + return e.InvoicingApp, nil + } else if e.loadedTypes[4] { + return nil, &NotFoundError{label: app.Label} + } + return nil, &NotLoadedError{edge: "invoicing_app"} +} + +// PaymentAppOrErr returns the PaymentApp value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e BillingProfileEdges) PaymentAppOrErr() (*App, error) { + if e.PaymentApp != nil { + return e.PaymentApp, nil + } else if e.loadedTypes[5] { + return nil, &NotFoundError{label: app.Label} + } + return nil, &NotLoadedError{edge: "payment_app"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*BillingProfile) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -118,7 +159,7 @@ func (*BillingProfile) scanValues(columns []string) ([]any, error) { values[i] = new([]byte) case billingprofile.FieldDefault: values[i] = new(sql.NullBool) - case billingprofile.FieldID, billingprofile.FieldNamespace, billingprofile.FieldName, billingprofile.FieldDescription, billingprofile.FieldSupplierAddressCountry, billingprofile.FieldSupplierAddressPostalCode, billingprofile.FieldSupplierAddressState, billingprofile.FieldSupplierAddressCity, billingprofile.FieldSupplierAddressLine1, billingprofile.FieldSupplierAddressLine2, billingprofile.FieldSupplierAddressPhoneNumber, billingprofile.FieldTaxProvider, billingprofile.FieldInvoicingProvider, billingprofile.FieldPaymentProvider, billingprofile.FieldWorkflowConfigID, billingprofile.FieldSupplierName: + case billingprofile.FieldID, billingprofile.FieldNamespace, billingprofile.FieldName, billingprofile.FieldDescription, billingprofile.FieldSupplierAddressCountry, billingprofile.FieldSupplierAddressPostalCode, billingprofile.FieldSupplierAddressState, billingprofile.FieldSupplierAddressCity, billingprofile.FieldSupplierAddressLine1, billingprofile.FieldSupplierAddressLine2, billingprofile.FieldSupplierAddressPhoneNumber, billingprofile.FieldTaxAppID, billingprofile.FieldInvoicingAppID, billingprofile.FieldPaymentAppID, billingprofile.FieldWorkflowConfigID, billingprofile.FieldSupplierName, billingprofile.FieldSupplierTaxCode: values[i] = new(sql.NullString) case billingprofile.FieldCreatedAt, billingprofile.FieldUpdatedAt, billingprofile.FieldDeletedAt: values[i] = new(sql.NullTime) @@ -238,23 +279,23 @@ func (bp *BillingProfile) assignValues(columns []string, values []any) error { bp.SupplierAddressPhoneNumber = new(string) *bp.SupplierAddressPhoneNumber = value.String } - case billingprofile.FieldTaxProvider: + case billingprofile.FieldTaxAppID: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field tax_provider", values[i]) + return fmt.Errorf("unexpected type %T for field tax_app_id", values[i]) } else if value.Valid { - bp.TaxProvider = provider.TaxProvider(value.String) + bp.TaxAppID = value.String } - case billingprofile.FieldInvoicingProvider: + case billingprofile.FieldInvoicingAppID: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field invoicing_provider", values[i]) + return fmt.Errorf("unexpected type %T for field invoicing_app_id", values[i]) } else if value.Valid { - bp.InvoicingProvider = provider.InvoicingProvider(value.String) + bp.InvoicingAppID = value.String } - case billingprofile.FieldPaymentProvider: + case billingprofile.FieldPaymentAppID: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field payment_provider", values[i]) + return fmt.Errorf("unexpected type %T for field payment_app_id", values[i]) } else if value.Valid { - bp.PaymentProvider = provider.PaymentProvider(value.String) + bp.PaymentAppID = value.String } case billingprofile.FieldWorkflowConfigID: if value, ok := values[i].(*sql.NullString); !ok { @@ -274,6 +315,13 @@ func (bp *BillingProfile) assignValues(columns []string, values []any) error { } else if value.Valid { bp.SupplierName = value.String } + case billingprofile.FieldSupplierTaxCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field supplier_tax_code", values[i]) + } else if value.Valid { + bp.SupplierTaxCode = new(string) + *bp.SupplierTaxCode = value.String + } default: bp.selectValues.Set(columns[i], values[i]) } @@ -302,6 +350,21 @@ func (bp *BillingProfile) QueryWorkflowConfig() *BillingWorkflowConfigQuery { return NewBillingProfileClient(bp.config).QueryWorkflowConfig(bp) } +// QueryTaxApp queries the "tax_app" edge of the BillingProfile entity. +func (bp *BillingProfile) QueryTaxApp() *AppQuery { + return NewBillingProfileClient(bp.config).QueryTaxApp(bp) +} + +// QueryInvoicingApp queries the "invoicing_app" edge of the BillingProfile entity. +func (bp *BillingProfile) QueryInvoicingApp() *AppQuery { + return NewBillingProfileClient(bp.config).QueryInvoicingApp(bp) +} + +// QueryPaymentApp queries the "payment_app" edge of the BillingProfile entity. +func (bp *BillingProfile) QueryPaymentApp() *AppQuery { + return NewBillingProfileClient(bp.config).QueryPaymentApp(bp) +} + // Update returns a builder for updating this BillingProfile. // Note that you need to call BillingProfile.Unwrap() before calling this method if this BillingProfile // was returned from a transaction, and the transaction was committed or rolled back. @@ -385,14 +448,14 @@ func (bp *BillingProfile) String() string { builder.WriteString(*v) } builder.WriteString(", ") - builder.WriteString("tax_provider=") - builder.WriteString(fmt.Sprintf("%v", bp.TaxProvider)) + builder.WriteString("tax_app_id=") + builder.WriteString(bp.TaxAppID) builder.WriteString(", ") - builder.WriteString("invoicing_provider=") - builder.WriteString(fmt.Sprintf("%v", bp.InvoicingProvider)) + builder.WriteString("invoicing_app_id=") + builder.WriteString(bp.InvoicingAppID) builder.WriteString(", ") - builder.WriteString("payment_provider=") - builder.WriteString(fmt.Sprintf("%v", bp.PaymentProvider)) + builder.WriteString("payment_app_id=") + builder.WriteString(bp.PaymentAppID) builder.WriteString(", ") builder.WriteString("workflow_config_id=") builder.WriteString(bp.WorkflowConfigID) @@ -402,6 +465,11 @@ func (bp *BillingProfile) String() string { builder.WriteString(", ") builder.WriteString("supplier_name=") builder.WriteString(bp.SupplierName) + builder.WriteString(", ") + if v := bp.SupplierTaxCode; v != nil { + builder.WriteString("supplier_tax_code=") + builder.WriteString(*v) + } builder.WriteByte(')') return builder.String() } diff --git a/openmeter/ent/db/billingprofile/billingprofile.go b/openmeter/ent/db/billingprofile/billingprofile.go index 8c0823a74..71bfc51e2 100644 --- a/openmeter/ent/db/billingprofile/billingprofile.go +++ b/openmeter/ent/db/billingprofile/billingprofile.go @@ -3,12 +3,10 @@ package billingprofile import ( - "fmt" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/openmeterio/openmeter/openmeter/billing/provider" ) const ( @@ -44,24 +42,32 @@ const ( FieldSupplierAddressLine2 = "supplier_address_line2" // FieldSupplierAddressPhoneNumber holds the string denoting the supplier_address_phone_number field in the database. FieldSupplierAddressPhoneNumber = "supplier_address_phone_number" - // FieldTaxProvider holds the string denoting the tax_provider field in the database. - FieldTaxProvider = "tax_provider" - // FieldInvoicingProvider holds the string denoting the invoicing_provider field in the database. - FieldInvoicingProvider = "invoicing_provider" - // FieldPaymentProvider holds the string denoting the payment_provider field in the database. - FieldPaymentProvider = "payment_provider" + // FieldTaxAppID holds the string denoting the tax_app_id field in the database. + FieldTaxAppID = "tax_app_id" + // FieldInvoicingAppID holds the string denoting the invoicing_app_id field in the database. + FieldInvoicingAppID = "invoicing_app_id" + // FieldPaymentAppID holds the string denoting the payment_app_id field in the database. + FieldPaymentAppID = "payment_app_id" // FieldWorkflowConfigID holds the string denoting the workflow_config_id field in the database. FieldWorkflowConfigID = "workflow_config_id" // FieldDefault holds the string denoting the default field in the database. FieldDefault = "default" // FieldSupplierName holds the string denoting the supplier_name field in the database. FieldSupplierName = "supplier_name" + // FieldSupplierTaxCode holds the string denoting the supplier_tax_code field in the database. + FieldSupplierTaxCode = "supplier_tax_code" // EdgeBillingInvoices holds the string denoting the billing_invoices edge name in mutations. EdgeBillingInvoices = "billing_invoices" // EdgeBillingCustomerOverride holds the string denoting the billing_customer_override edge name in mutations. EdgeBillingCustomerOverride = "billing_customer_override" // EdgeWorkflowConfig holds the string denoting the workflow_config edge name in mutations. EdgeWorkflowConfig = "workflow_config" + // EdgeTaxApp holds the string denoting the tax_app edge name in mutations. + EdgeTaxApp = "tax_app" + // EdgeInvoicingApp holds the string denoting the invoicing_app edge name in mutations. + EdgeInvoicingApp = "invoicing_app" + // EdgePaymentApp holds the string denoting the payment_app edge name in mutations. + EdgePaymentApp = "payment_app" // Table holds the table name of the billingprofile in the database. Table = "billing_profiles" // BillingInvoicesTable is the table that holds the billing_invoices relation/edge. @@ -85,6 +91,27 @@ const ( WorkflowConfigInverseTable = "billing_workflow_configs" // WorkflowConfigColumn is the table column denoting the workflow_config relation/edge. WorkflowConfigColumn = "workflow_config_id" + // TaxAppTable is the table that holds the tax_app relation/edge. + TaxAppTable = "billing_profiles" + // TaxAppInverseTable is the table name for the App entity. + // It exists in this package in order to avoid circular dependency with the "app" package. + TaxAppInverseTable = "apps" + // TaxAppColumn is the table column denoting the tax_app relation/edge. + TaxAppColumn = "tax_app_id" + // InvoicingAppTable is the table that holds the invoicing_app relation/edge. + InvoicingAppTable = "billing_profiles" + // InvoicingAppInverseTable is the table name for the App entity. + // It exists in this package in order to avoid circular dependency with the "app" package. + InvoicingAppInverseTable = "apps" + // InvoicingAppColumn is the table column denoting the invoicing_app relation/edge. + InvoicingAppColumn = "invoicing_app_id" + // PaymentAppTable is the table that holds the payment_app relation/edge. + PaymentAppTable = "billing_profiles" + // PaymentAppInverseTable is the table name for the App entity. + // It exists in this package in order to avoid circular dependency with the "app" package. + PaymentAppInverseTable = "apps" + // PaymentAppColumn is the table column denoting the payment_app relation/edge. + PaymentAppColumn = "payment_app_id" ) // Columns holds all SQL columns for billingprofile fields. @@ -104,12 +131,13 @@ var Columns = []string{ FieldSupplierAddressLine1, FieldSupplierAddressLine2, FieldSupplierAddressPhoneNumber, - FieldTaxProvider, - FieldInvoicingProvider, - FieldPaymentProvider, + FieldTaxAppID, + FieldInvoicingAppID, + FieldPaymentAppID, FieldWorkflowConfigID, FieldDefault, FieldSupplierName, + FieldSupplierTaxCode, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -143,36 +171,6 @@ var ( DefaultID func() string ) -// TaxProviderValidator is a validator for the "tax_provider" field enum values. It is called by the builders before save. -func TaxProviderValidator(tp provider.TaxProvider) error { - switch tp { - case "openmeter_sandbox", "stripe": - return nil - default: - return fmt.Errorf("billingprofile: invalid enum value for tax_provider field: %q", tp) - } -} - -// InvoicingProviderValidator is a validator for the "invoicing_provider" field enum values. It is called by the builders before save. -func InvoicingProviderValidator(ip provider.InvoicingProvider) error { - switch ip { - case "openmeter_sandbox", "stripe": - return nil - default: - return fmt.Errorf("billingprofile: invalid enum value for invoicing_provider field: %q", ip) - } -} - -// PaymentProviderValidator is a validator for the "payment_provider" field enum values. It is called by the builders before save. -func PaymentProviderValidator(pp provider.PaymentProvider) error { - switch pp { - case "openmeter_sandbox", "stripe_payments": - return nil - default: - return fmt.Errorf("billingprofile: invalid enum value for payment_provider field: %q", pp) - } -} - // OrderOption defines the ordering options for the BillingProfile queries. type OrderOption func(*sql.Selector) @@ -246,19 +244,19 @@ func BySupplierAddressPhoneNumber(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldSupplierAddressPhoneNumber, opts...).ToFunc() } -// ByTaxProvider orders the results by the tax_provider field. -func ByTaxProvider(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldTaxProvider, opts...).ToFunc() +// ByTaxAppID orders the results by the tax_app_id field. +func ByTaxAppID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTaxAppID, opts...).ToFunc() } -// ByInvoicingProvider orders the results by the invoicing_provider field. -func ByInvoicingProvider(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldInvoicingProvider, opts...).ToFunc() +// ByInvoicingAppID orders the results by the invoicing_app_id field. +func ByInvoicingAppID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldInvoicingAppID, opts...).ToFunc() } -// ByPaymentProvider orders the results by the payment_provider field. -func ByPaymentProvider(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPaymentProvider, opts...).ToFunc() +// ByPaymentAppID orders the results by the payment_app_id field. +func ByPaymentAppID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPaymentAppID, opts...).ToFunc() } // ByWorkflowConfigID orders the results by the workflow_config_id field. @@ -276,6 +274,11 @@ func BySupplierName(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldSupplierName, opts...).ToFunc() } +// BySupplierTaxCode orders the results by the supplier_tax_code field. +func BySupplierTaxCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSupplierTaxCode, opts...).ToFunc() +} + // ByBillingInvoicesCount orders the results by billing_invoices count. func ByBillingInvoicesCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -310,6 +313,27 @@ func ByWorkflowConfigField(field string, opts ...sql.OrderTermOption) OrderOptio sqlgraph.OrderByNeighborTerms(s, newWorkflowConfigStep(), sql.OrderByField(field, opts...)) } } + +// ByTaxAppField orders the results by tax_app field. +func ByTaxAppField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newTaxAppStep(), sql.OrderByField(field, opts...)) + } +} + +// ByInvoicingAppField orders the results by invoicing_app field. +func ByInvoicingAppField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newInvoicingAppStep(), sql.OrderByField(field, opts...)) + } +} + +// ByPaymentAppField orders the results by payment_app field. +func ByPaymentAppField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPaymentAppStep(), sql.OrderByField(field, opts...)) + } +} func newBillingInvoicesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -331,3 +355,24 @@ func newWorkflowConfigStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2O, true, WorkflowConfigTable, WorkflowConfigColumn), ) } +func newTaxAppStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TaxAppInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, TaxAppTable, TaxAppColumn), + ) +} +func newInvoicingAppStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(InvoicingAppInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, InvoicingAppTable, InvoicingAppColumn), + ) +} +func newPaymentAppStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PaymentAppInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, PaymentAppTable, PaymentAppColumn), + ) +} diff --git a/openmeter/ent/db/billingprofile/where.go b/openmeter/ent/db/billingprofile/where.go index 886916c61..b315f8def 100644 --- a/openmeter/ent/db/billingprofile/where.go +++ b/openmeter/ent/db/billingprofile/where.go @@ -7,7 +7,6 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/openmeterio/openmeter/openmeter/billing/provider" "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" "github.com/openmeterio/openmeter/pkg/models" ) @@ -133,6 +132,21 @@ func SupplierAddressPhoneNumber(v string) predicate.BillingProfile { return predicate.BillingProfile(sql.FieldEQ(FieldSupplierAddressPhoneNumber, v)) } +// TaxAppID applies equality check predicate on the "tax_app_id" field. It's identical to TaxAppIDEQ. +func TaxAppID(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldEQ(FieldTaxAppID, v)) +} + +// InvoicingAppID applies equality check predicate on the "invoicing_app_id" field. It's identical to InvoicingAppIDEQ. +func InvoicingAppID(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldEQ(FieldInvoicingAppID, v)) +} + +// PaymentAppID applies equality check predicate on the "payment_app_id" field. It's identical to PaymentAppIDEQ. +func PaymentAppID(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldEQ(FieldPaymentAppID, v)) +} + // WorkflowConfigID applies equality check predicate on the "workflow_config_id" field. It's identical to WorkflowConfigIDEQ. func WorkflowConfigID(v string) predicate.BillingProfile { return predicate.BillingProfile(sql.FieldEQ(FieldWorkflowConfigID, v)) @@ -148,6 +162,11 @@ func SupplierName(v string) predicate.BillingProfile { return predicate.BillingProfile(sql.FieldEQ(FieldSupplierName, v)) } +// SupplierTaxCode applies equality check predicate on the "supplier_tax_code" field. It's identical to SupplierTaxCodeEQ. +func SupplierTaxCode(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldEQ(FieldSupplierTaxCode, v)) +} + // NamespaceEQ applies the EQ predicate on the "namespace" field. func NamespaceEQ(v string) predicate.BillingProfile { return predicate.BillingProfile(sql.FieldEQ(FieldNamespace, v)) @@ -1037,94 +1056,199 @@ func SupplierAddressPhoneNumberContainsFold(v string) predicate.BillingProfile { return predicate.BillingProfile(sql.FieldContainsFold(FieldSupplierAddressPhoneNumber, v)) } -// TaxProviderEQ applies the EQ predicate on the "tax_provider" field. -func TaxProviderEQ(v provider.TaxProvider) predicate.BillingProfile { - vc := v - return predicate.BillingProfile(sql.FieldEQ(FieldTaxProvider, vc)) +// TaxAppIDEQ applies the EQ predicate on the "tax_app_id" field. +func TaxAppIDEQ(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldEQ(FieldTaxAppID, v)) } -// TaxProviderNEQ applies the NEQ predicate on the "tax_provider" field. -func TaxProviderNEQ(v provider.TaxProvider) predicate.BillingProfile { - vc := v - return predicate.BillingProfile(sql.FieldNEQ(FieldTaxProvider, vc)) +// TaxAppIDNEQ applies the NEQ predicate on the "tax_app_id" field. +func TaxAppIDNEQ(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldNEQ(FieldTaxAppID, v)) } -// TaxProviderIn applies the In predicate on the "tax_provider" field. -func TaxProviderIn(vs ...provider.TaxProvider) predicate.BillingProfile { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingProfile(sql.FieldIn(FieldTaxProvider, v...)) +// TaxAppIDIn applies the In predicate on the "tax_app_id" field. +func TaxAppIDIn(vs ...string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldIn(FieldTaxAppID, vs...)) } -// TaxProviderNotIn applies the NotIn predicate on the "tax_provider" field. -func TaxProviderNotIn(vs ...provider.TaxProvider) predicate.BillingProfile { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingProfile(sql.FieldNotIn(FieldTaxProvider, v...)) +// TaxAppIDNotIn applies the NotIn predicate on the "tax_app_id" field. +func TaxAppIDNotIn(vs ...string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldNotIn(FieldTaxAppID, vs...)) } -// InvoicingProviderEQ applies the EQ predicate on the "invoicing_provider" field. -func InvoicingProviderEQ(v provider.InvoicingProvider) predicate.BillingProfile { - vc := v - return predicate.BillingProfile(sql.FieldEQ(FieldInvoicingProvider, vc)) +// TaxAppIDGT applies the GT predicate on the "tax_app_id" field. +func TaxAppIDGT(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldGT(FieldTaxAppID, v)) } -// InvoicingProviderNEQ applies the NEQ predicate on the "invoicing_provider" field. -func InvoicingProviderNEQ(v provider.InvoicingProvider) predicate.BillingProfile { - vc := v - return predicate.BillingProfile(sql.FieldNEQ(FieldInvoicingProvider, vc)) +// TaxAppIDGTE applies the GTE predicate on the "tax_app_id" field. +func TaxAppIDGTE(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldGTE(FieldTaxAppID, v)) } -// InvoicingProviderIn applies the In predicate on the "invoicing_provider" field. -func InvoicingProviderIn(vs ...provider.InvoicingProvider) predicate.BillingProfile { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingProfile(sql.FieldIn(FieldInvoicingProvider, v...)) +// TaxAppIDLT applies the LT predicate on the "tax_app_id" field. +func TaxAppIDLT(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldLT(FieldTaxAppID, v)) } -// InvoicingProviderNotIn applies the NotIn predicate on the "invoicing_provider" field. -func InvoicingProviderNotIn(vs ...provider.InvoicingProvider) predicate.BillingProfile { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingProfile(sql.FieldNotIn(FieldInvoicingProvider, v...)) +// TaxAppIDLTE applies the LTE predicate on the "tax_app_id" field. +func TaxAppIDLTE(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldLTE(FieldTaxAppID, v)) } -// PaymentProviderEQ applies the EQ predicate on the "payment_provider" field. -func PaymentProviderEQ(v provider.PaymentProvider) predicate.BillingProfile { - vc := v - return predicate.BillingProfile(sql.FieldEQ(FieldPaymentProvider, vc)) +// TaxAppIDContains applies the Contains predicate on the "tax_app_id" field. +func TaxAppIDContains(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldContains(FieldTaxAppID, v)) } -// PaymentProviderNEQ applies the NEQ predicate on the "payment_provider" field. -func PaymentProviderNEQ(v provider.PaymentProvider) predicate.BillingProfile { - vc := v - return predicate.BillingProfile(sql.FieldNEQ(FieldPaymentProvider, vc)) +// TaxAppIDHasPrefix applies the HasPrefix predicate on the "tax_app_id" field. +func TaxAppIDHasPrefix(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldHasPrefix(FieldTaxAppID, v)) } -// PaymentProviderIn applies the In predicate on the "payment_provider" field. -func PaymentProviderIn(vs ...provider.PaymentProvider) predicate.BillingProfile { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingProfile(sql.FieldIn(FieldPaymentProvider, v...)) +// TaxAppIDHasSuffix applies the HasSuffix predicate on the "tax_app_id" field. +func TaxAppIDHasSuffix(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldHasSuffix(FieldTaxAppID, v)) } -// PaymentProviderNotIn applies the NotIn predicate on the "payment_provider" field. -func PaymentProviderNotIn(vs ...provider.PaymentProvider) predicate.BillingProfile { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingProfile(sql.FieldNotIn(FieldPaymentProvider, v...)) +// TaxAppIDEqualFold applies the EqualFold predicate on the "tax_app_id" field. +func TaxAppIDEqualFold(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldEqualFold(FieldTaxAppID, v)) +} + +// TaxAppIDContainsFold applies the ContainsFold predicate on the "tax_app_id" field. +func TaxAppIDContainsFold(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldContainsFold(FieldTaxAppID, v)) +} + +// InvoicingAppIDEQ applies the EQ predicate on the "invoicing_app_id" field. +func InvoicingAppIDEQ(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldEQ(FieldInvoicingAppID, v)) +} + +// InvoicingAppIDNEQ applies the NEQ predicate on the "invoicing_app_id" field. +func InvoicingAppIDNEQ(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldNEQ(FieldInvoicingAppID, v)) +} + +// InvoicingAppIDIn applies the In predicate on the "invoicing_app_id" field. +func InvoicingAppIDIn(vs ...string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldIn(FieldInvoicingAppID, vs...)) +} + +// InvoicingAppIDNotIn applies the NotIn predicate on the "invoicing_app_id" field. +func InvoicingAppIDNotIn(vs ...string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldNotIn(FieldInvoicingAppID, vs...)) +} + +// InvoicingAppIDGT applies the GT predicate on the "invoicing_app_id" field. +func InvoicingAppIDGT(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldGT(FieldInvoicingAppID, v)) +} + +// InvoicingAppIDGTE applies the GTE predicate on the "invoicing_app_id" field. +func InvoicingAppIDGTE(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldGTE(FieldInvoicingAppID, v)) +} + +// InvoicingAppIDLT applies the LT predicate on the "invoicing_app_id" field. +func InvoicingAppIDLT(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldLT(FieldInvoicingAppID, v)) +} + +// InvoicingAppIDLTE applies the LTE predicate on the "invoicing_app_id" field. +func InvoicingAppIDLTE(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldLTE(FieldInvoicingAppID, v)) +} + +// InvoicingAppIDContains applies the Contains predicate on the "invoicing_app_id" field. +func InvoicingAppIDContains(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldContains(FieldInvoicingAppID, v)) +} + +// InvoicingAppIDHasPrefix applies the HasPrefix predicate on the "invoicing_app_id" field. +func InvoicingAppIDHasPrefix(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldHasPrefix(FieldInvoicingAppID, v)) +} + +// InvoicingAppIDHasSuffix applies the HasSuffix predicate on the "invoicing_app_id" field. +func InvoicingAppIDHasSuffix(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldHasSuffix(FieldInvoicingAppID, v)) +} + +// InvoicingAppIDEqualFold applies the EqualFold predicate on the "invoicing_app_id" field. +func InvoicingAppIDEqualFold(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldEqualFold(FieldInvoicingAppID, v)) +} + +// InvoicingAppIDContainsFold applies the ContainsFold predicate on the "invoicing_app_id" field. +func InvoicingAppIDContainsFold(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldContainsFold(FieldInvoicingAppID, v)) +} + +// PaymentAppIDEQ applies the EQ predicate on the "payment_app_id" field. +func PaymentAppIDEQ(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldEQ(FieldPaymentAppID, v)) +} + +// PaymentAppIDNEQ applies the NEQ predicate on the "payment_app_id" field. +func PaymentAppIDNEQ(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldNEQ(FieldPaymentAppID, v)) +} + +// PaymentAppIDIn applies the In predicate on the "payment_app_id" field. +func PaymentAppIDIn(vs ...string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldIn(FieldPaymentAppID, vs...)) +} + +// PaymentAppIDNotIn applies the NotIn predicate on the "payment_app_id" field. +func PaymentAppIDNotIn(vs ...string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldNotIn(FieldPaymentAppID, vs...)) +} + +// PaymentAppIDGT applies the GT predicate on the "payment_app_id" field. +func PaymentAppIDGT(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldGT(FieldPaymentAppID, v)) +} + +// PaymentAppIDGTE applies the GTE predicate on the "payment_app_id" field. +func PaymentAppIDGTE(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldGTE(FieldPaymentAppID, v)) +} + +// PaymentAppIDLT applies the LT predicate on the "payment_app_id" field. +func PaymentAppIDLT(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldLT(FieldPaymentAppID, v)) +} + +// PaymentAppIDLTE applies the LTE predicate on the "payment_app_id" field. +func PaymentAppIDLTE(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldLTE(FieldPaymentAppID, v)) +} + +// PaymentAppIDContains applies the Contains predicate on the "payment_app_id" field. +func PaymentAppIDContains(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldContains(FieldPaymentAppID, v)) +} + +// PaymentAppIDHasPrefix applies the HasPrefix predicate on the "payment_app_id" field. +func PaymentAppIDHasPrefix(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldHasPrefix(FieldPaymentAppID, v)) +} + +// PaymentAppIDHasSuffix applies the HasSuffix predicate on the "payment_app_id" field. +func PaymentAppIDHasSuffix(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldHasSuffix(FieldPaymentAppID, v)) +} + +// PaymentAppIDEqualFold applies the EqualFold predicate on the "payment_app_id" field. +func PaymentAppIDEqualFold(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldEqualFold(FieldPaymentAppID, v)) +} + +// PaymentAppIDContainsFold applies the ContainsFold predicate on the "payment_app_id" field. +func PaymentAppIDContainsFold(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldContainsFold(FieldPaymentAppID, v)) } // WorkflowConfigIDEQ applies the EQ predicate on the "workflow_config_id" field. @@ -1267,6 +1391,81 @@ func SupplierNameContainsFold(v string) predicate.BillingProfile { return predicate.BillingProfile(sql.FieldContainsFold(FieldSupplierName, v)) } +// SupplierTaxCodeEQ applies the EQ predicate on the "supplier_tax_code" field. +func SupplierTaxCodeEQ(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldEQ(FieldSupplierTaxCode, v)) +} + +// SupplierTaxCodeNEQ applies the NEQ predicate on the "supplier_tax_code" field. +func SupplierTaxCodeNEQ(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldNEQ(FieldSupplierTaxCode, v)) +} + +// SupplierTaxCodeIn applies the In predicate on the "supplier_tax_code" field. +func SupplierTaxCodeIn(vs ...string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldIn(FieldSupplierTaxCode, vs...)) +} + +// SupplierTaxCodeNotIn applies the NotIn predicate on the "supplier_tax_code" field. +func SupplierTaxCodeNotIn(vs ...string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldNotIn(FieldSupplierTaxCode, vs...)) +} + +// SupplierTaxCodeGT applies the GT predicate on the "supplier_tax_code" field. +func SupplierTaxCodeGT(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldGT(FieldSupplierTaxCode, v)) +} + +// SupplierTaxCodeGTE applies the GTE predicate on the "supplier_tax_code" field. +func SupplierTaxCodeGTE(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldGTE(FieldSupplierTaxCode, v)) +} + +// SupplierTaxCodeLT applies the LT predicate on the "supplier_tax_code" field. +func SupplierTaxCodeLT(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldLT(FieldSupplierTaxCode, v)) +} + +// SupplierTaxCodeLTE applies the LTE predicate on the "supplier_tax_code" field. +func SupplierTaxCodeLTE(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldLTE(FieldSupplierTaxCode, v)) +} + +// SupplierTaxCodeContains applies the Contains predicate on the "supplier_tax_code" field. +func SupplierTaxCodeContains(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldContains(FieldSupplierTaxCode, v)) +} + +// SupplierTaxCodeHasPrefix applies the HasPrefix predicate on the "supplier_tax_code" field. +func SupplierTaxCodeHasPrefix(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldHasPrefix(FieldSupplierTaxCode, v)) +} + +// SupplierTaxCodeHasSuffix applies the HasSuffix predicate on the "supplier_tax_code" field. +func SupplierTaxCodeHasSuffix(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldHasSuffix(FieldSupplierTaxCode, v)) +} + +// SupplierTaxCodeIsNil applies the IsNil predicate on the "supplier_tax_code" field. +func SupplierTaxCodeIsNil() predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldIsNull(FieldSupplierTaxCode)) +} + +// SupplierTaxCodeNotNil applies the NotNil predicate on the "supplier_tax_code" field. +func SupplierTaxCodeNotNil() predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldNotNull(FieldSupplierTaxCode)) +} + +// SupplierTaxCodeEqualFold applies the EqualFold predicate on the "supplier_tax_code" field. +func SupplierTaxCodeEqualFold(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldEqualFold(FieldSupplierTaxCode, v)) +} + +// SupplierTaxCodeContainsFold applies the ContainsFold predicate on the "supplier_tax_code" field. +func SupplierTaxCodeContainsFold(v string) predicate.BillingProfile { + return predicate.BillingProfile(sql.FieldContainsFold(FieldSupplierTaxCode, v)) +} + // HasBillingInvoices applies the HasEdge predicate on the "billing_invoices" edge. func HasBillingInvoices() predicate.BillingProfile { return predicate.BillingProfile(func(s *sql.Selector) { @@ -1336,6 +1535,75 @@ func HasWorkflowConfigWith(preds ...predicate.BillingWorkflowConfig) predicate.B }) } +// HasTaxApp applies the HasEdge predicate on the "tax_app" edge. +func HasTaxApp() predicate.BillingProfile { + return predicate.BillingProfile(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, TaxAppTable, TaxAppColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTaxAppWith applies the HasEdge predicate on the "tax_app" edge with a given conditions (other predicates). +func HasTaxAppWith(preds ...predicate.App) predicate.BillingProfile { + return predicate.BillingProfile(func(s *sql.Selector) { + step := newTaxAppStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasInvoicingApp applies the HasEdge predicate on the "invoicing_app" edge. +func HasInvoicingApp() predicate.BillingProfile { + return predicate.BillingProfile(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, InvoicingAppTable, InvoicingAppColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasInvoicingAppWith applies the HasEdge predicate on the "invoicing_app" edge with a given conditions (other predicates). +func HasInvoicingAppWith(preds ...predicate.App) predicate.BillingProfile { + return predicate.BillingProfile(func(s *sql.Selector) { + step := newInvoicingAppStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPaymentApp applies the HasEdge predicate on the "payment_app" edge. +func HasPaymentApp() predicate.BillingProfile { + return predicate.BillingProfile(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, PaymentAppTable, PaymentAppColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPaymentAppWith applies the HasEdge predicate on the "payment_app" edge with a given conditions (other predicates). +func HasPaymentAppWith(preds ...predicate.App) predicate.BillingProfile { + return predicate.BillingProfile(func(s *sql.Selector) { + step := newPaymentAppStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.BillingProfile) predicate.BillingProfile { return predicate.BillingProfile(sql.AndPredicates(predicates...)) diff --git a/openmeter/ent/db/billingprofile_create.go b/openmeter/ent/db/billingprofile_create.go index a0872e505..cf730d10a 100644 --- a/openmeter/ent/db/billingprofile_create.go +++ b/openmeter/ent/db/billingprofile_create.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/openmeterio/openmeter/openmeter/billing/provider" + "github.com/openmeterio/openmeter/openmeter/ent/db/app" "github.com/openmeterio/openmeter/openmeter/ent/db/billingcustomeroverride" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoice" "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" @@ -200,21 +200,21 @@ func (bpc *BillingProfileCreate) SetNillableSupplierAddressPhoneNumber(s *string return bpc } -// SetTaxProvider sets the "tax_provider" field. -func (bpc *BillingProfileCreate) SetTaxProvider(pp provider.TaxProvider) *BillingProfileCreate { - bpc.mutation.SetTaxProvider(pp) +// SetTaxAppID sets the "tax_app_id" field. +func (bpc *BillingProfileCreate) SetTaxAppID(s string) *BillingProfileCreate { + bpc.mutation.SetTaxAppID(s) return bpc } -// SetInvoicingProvider sets the "invoicing_provider" field. -func (bpc *BillingProfileCreate) SetInvoicingProvider(pp provider.InvoicingProvider) *BillingProfileCreate { - bpc.mutation.SetInvoicingProvider(pp) +// SetInvoicingAppID sets the "invoicing_app_id" field. +func (bpc *BillingProfileCreate) SetInvoicingAppID(s string) *BillingProfileCreate { + bpc.mutation.SetInvoicingAppID(s) return bpc } -// SetPaymentProvider sets the "payment_provider" field. -func (bpc *BillingProfileCreate) SetPaymentProvider(pp provider.PaymentProvider) *BillingProfileCreate { - bpc.mutation.SetPaymentProvider(pp) +// SetPaymentAppID sets the "payment_app_id" field. +func (bpc *BillingProfileCreate) SetPaymentAppID(s string) *BillingProfileCreate { + bpc.mutation.SetPaymentAppID(s) return bpc } @@ -244,6 +244,20 @@ func (bpc *BillingProfileCreate) SetSupplierName(s string) *BillingProfileCreate return bpc } +// SetSupplierTaxCode sets the "supplier_tax_code" field. +func (bpc *BillingProfileCreate) SetSupplierTaxCode(s string) *BillingProfileCreate { + bpc.mutation.SetSupplierTaxCode(s) + return bpc +} + +// SetNillableSupplierTaxCode sets the "supplier_tax_code" field if the given value is not nil. +func (bpc *BillingProfileCreate) SetNillableSupplierTaxCode(s *string) *BillingProfileCreate { + if s != nil { + bpc.SetSupplierTaxCode(*s) + } + return bpc +} + // SetID sets the "id" field. func (bpc *BillingProfileCreate) SetID(s string) *BillingProfileCreate { bpc.mutation.SetID(s) @@ -293,6 +307,21 @@ func (bpc *BillingProfileCreate) SetWorkflowConfig(b *BillingWorkflowConfig) *Bi return bpc.SetWorkflowConfigID(b.ID) } +// SetTaxApp sets the "tax_app" edge to the App entity. +func (bpc *BillingProfileCreate) SetTaxApp(a *App) *BillingProfileCreate { + return bpc.SetTaxAppID(a.ID) +} + +// SetInvoicingApp sets the "invoicing_app" edge to the App entity. +func (bpc *BillingProfileCreate) SetInvoicingApp(a *App) *BillingProfileCreate { + return bpc.SetInvoicingAppID(a.ID) +} + +// SetPaymentApp sets the "payment_app" edge to the App entity. +func (bpc *BillingProfileCreate) SetPaymentApp(a *App) *BillingProfileCreate { + return bpc.SetPaymentAppID(a.ID) +} + // Mutation returns the BillingProfileMutation object of the builder. func (bpc *BillingProfileCreate) Mutation() *BillingProfileMutation { return bpc.mutation @@ -370,29 +399,14 @@ func (bpc *BillingProfileCreate) check() error { return &ValidationError{Name: "supplier_address_country", err: fmt.Errorf(`db: validator failed for field "BillingProfile.supplier_address_country": %w`, err)} } } - if _, ok := bpc.mutation.TaxProvider(); !ok { - return &ValidationError{Name: "tax_provider", err: errors.New(`db: missing required field "BillingProfile.tax_provider"`)} - } - if v, ok := bpc.mutation.TaxProvider(); ok { - if err := billingprofile.TaxProviderValidator(v); err != nil { - return &ValidationError{Name: "tax_provider", err: fmt.Errorf(`db: validator failed for field "BillingProfile.tax_provider": %w`, err)} - } - } - if _, ok := bpc.mutation.InvoicingProvider(); !ok { - return &ValidationError{Name: "invoicing_provider", err: errors.New(`db: missing required field "BillingProfile.invoicing_provider"`)} + if _, ok := bpc.mutation.TaxAppID(); !ok { + return &ValidationError{Name: "tax_app_id", err: errors.New(`db: missing required field "BillingProfile.tax_app_id"`)} } - if v, ok := bpc.mutation.InvoicingProvider(); ok { - if err := billingprofile.InvoicingProviderValidator(v); err != nil { - return &ValidationError{Name: "invoicing_provider", err: fmt.Errorf(`db: validator failed for field "BillingProfile.invoicing_provider": %w`, err)} - } + if _, ok := bpc.mutation.InvoicingAppID(); !ok { + return &ValidationError{Name: "invoicing_app_id", err: errors.New(`db: missing required field "BillingProfile.invoicing_app_id"`)} } - if _, ok := bpc.mutation.PaymentProvider(); !ok { - return &ValidationError{Name: "payment_provider", err: errors.New(`db: missing required field "BillingProfile.payment_provider"`)} - } - if v, ok := bpc.mutation.PaymentProvider(); ok { - if err := billingprofile.PaymentProviderValidator(v); err != nil { - return &ValidationError{Name: "payment_provider", err: fmt.Errorf(`db: validator failed for field "BillingProfile.payment_provider": %w`, err)} - } + if _, ok := bpc.mutation.PaymentAppID(); !ok { + return &ValidationError{Name: "payment_app_id", err: errors.New(`db: missing required field "BillingProfile.payment_app_id"`)} } if _, ok := bpc.mutation.WorkflowConfigID(); !ok { return &ValidationError{Name: "workflow_config_id", err: errors.New(`db: missing required field "BillingProfile.workflow_config_id"`)} @@ -416,6 +430,15 @@ func (bpc *BillingProfileCreate) check() error { if len(bpc.mutation.WorkflowConfigIDs()) == 0 { return &ValidationError{Name: "workflow_config", err: errors.New(`db: missing required edge "BillingProfile.workflow_config"`)} } + if len(bpc.mutation.TaxAppIDs()) == 0 { + return &ValidationError{Name: "tax_app", err: errors.New(`db: missing required edge "BillingProfile.tax_app"`)} + } + if len(bpc.mutation.InvoicingAppIDs()) == 0 { + return &ValidationError{Name: "invoicing_app", err: errors.New(`db: missing required edge "BillingProfile.invoicing_app"`)} + } + if len(bpc.mutation.PaymentAppIDs()) == 0 { + return &ValidationError{Name: "payment_app", err: errors.New(`db: missing required edge "BillingProfile.payment_app"`)} + } return nil } @@ -508,18 +531,6 @@ func (bpc *BillingProfileCreate) createSpec() (*BillingProfile, *sqlgraph.Create _spec.SetField(billingprofile.FieldSupplierAddressPhoneNumber, field.TypeString, value) _node.SupplierAddressPhoneNumber = &value } - if value, ok := bpc.mutation.TaxProvider(); ok { - _spec.SetField(billingprofile.FieldTaxProvider, field.TypeEnum, value) - _node.TaxProvider = value - } - if value, ok := bpc.mutation.InvoicingProvider(); ok { - _spec.SetField(billingprofile.FieldInvoicingProvider, field.TypeEnum, value) - _node.InvoicingProvider = value - } - if value, ok := bpc.mutation.PaymentProvider(); ok { - _spec.SetField(billingprofile.FieldPaymentProvider, field.TypeEnum, value) - _node.PaymentProvider = value - } if value, ok := bpc.mutation.Default(); ok { _spec.SetField(billingprofile.FieldDefault, field.TypeBool, value) _node.Default = value @@ -528,6 +539,10 @@ func (bpc *BillingProfileCreate) createSpec() (*BillingProfile, *sqlgraph.Create _spec.SetField(billingprofile.FieldSupplierName, field.TypeString, value) _node.SupplierName = value } + if value, ok := bpc.mutation.SupplierTaxCode(); ok { + _spec.SetField(billingprofile.FieldSupplierTaxCode, field.TypeString, value) + _node.SupplierTaxCode = &value + } if nodes := bpc.mutation.BillingInvoicesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -577,6 +592,57 @@ func (bpc *BillingProfileCreate) createSpec() (*BillingProfile, *sqlgraph.Create _node.WorkflowConfigID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } + if nodes := bpc.mutation.TaxAppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: billingprofile.TaxAppTable, + Columns: []string{billingprofile.TaxAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.TaxAppID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := bpc.mutation.InvoicingAppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: billingprofile.InvoicingAppTable, + Columns: []string{billingprofile.InvoicingAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.InvoicingAppID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := bpc.mutation.PaymentAppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: billingprofile.PaymentAppTable, + Columns: []string{billingprofile.PaymentAppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.PaymentAppID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } @@ -833,42 +899,6 @@ func (u *BillingProfileUpsert) ClearSupplierAddressPhoneNumber() *BillingProfile return u } -// SetTaxProvider sets the "tax_provider" field. -func (u *BillingProfileUpsert) SetTaxProvider(v provider.TaxProvider) *BillingProfileUpsert { - u.Set(billingprofile.FieldTaxProvider, v) - return u -} - -// UpdateTaxProvider sets the "tax_provider" field to the value that was provided on create. -func (u *BillingProfileUpsert) UpdateTaxProvider() *BillingProfileUpsert { - u.SetExcluded(billingprofile.FieldTaxProvider) - return u -} - -// SetInvoicingProvider sets the "invoicing_provider" field. -func (u *BillingProfileUpsert) SetInvoicingProvider(v provider.InvoicingProvider) *BillingProfileUpsert { - u.Set(billingprofile.FieldInvoicingProvider, v) - return u -} - -// UpdateInvoicingProvider sets the "invoicing_provider" field to the value that was provided on create. -func (u *BillingProfileUpsert) UpdateInvoicingProvider() *BillingProfileUpsert { - u.SetExcluded(billingprofile.FieldInvoicingProvider) - return u -} - -// SetPaymentProvider sets the "payment_provider" field. -func (u *BillingProfileUpsert) SetPaymentProvider(v provider.PaymentProvider) *BillingProfileUpsert { - u.Set(billingprofile.FieldPaymentProvider, v) - return u -} - -// UpdatePaymentProvider sets the "payment_provider" field to the value that was provided on create. -func (u *BillingProfileUpsert) UpdatePaymentProvider() *BillingProfileUpsert { - u.SetExcluded(billingprofile.FieldPaymentProvider) - return u -} - // SetWorkflowConfigID sets the "workflow_config_id" field. func (u *BillingProfileUpsert) SetWorkflowConfigID(v string) *BillingProfileUpsert { u.Set(billingprofile.FieldWorkflowConfigID, v) @@ -905,6 +935,24 @@ func (u *BillingProfileUpsert) UpdateSupplierName() *BillingProfileUpsert { return u } +// SetSupplierTaxCode sets the "supplier_tax_code" field. +func (u *BillingProfileUpsert) SetSupplierTaxCode(v string) *BillingProfileUpsert { + u.Set(billingprofile.FieldSupplierTaxCode, v) + return u +} + +// UpdateSupplierTaxCode sets the "supplier_tax_code" field to the value that was provided on create. +func (u *BillingProfileUpsert) UpdateSupplierTaxCode() *BillingProfileUpsert { + u.SetExcluded(billingprofile.FieldSupplierTaxCode) + return u +} + +// ClearSupplierTaxCode clears the value of the "supplier_tax_code" field. +func (u *BillingProfileUpsert) ClearSupplierTaxCode() *BillingProfileUpsert { + u.SetNull(billingprofile.FieldSupplierTaxCode) + return u +} + // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // @@ -928,6 +976,15 @@ func (u *BillingProfileUpsertOne) UpdateNewValues() *BillingProfileUpsertOne { if _, exists := u.create.mutation.CreatedAt(); exists { s.SetIgnore(billingprofile.FieldCreatedAt) } + if _, exists := u.create.mutation.TaxAppID(); exists { + s.SetIgnore(billingprofile.FieldTaxAppID) + } + if _, exists := u.create.mutation.InvoicingAppID(); exists { + s.SetIgnore(billingprofile.FieldInvoicingAppID) + } + if _, exists := u.create.mutation.PaymentAppID(); exists { + s.SetIgnore(billingprofile.FieldPaymentAppID) + } })) return u } @@ -1197,48 +1254,6 @@ func (u *BillingProfileUpsertOne) ClearSupplierAddressPhoneNumber() *BillingProf }) } -// SetTaxProvider sets the "tax_provider" field. -func (u *BillingProfileUpsertOne) SetTaxProvider(v provider.TaxProvider) *BillingProfileUpsertOne { - return u.Update(func(s *BillingProfileUpsert) { - s.SetTaxProvider(v) - }) -} - -// UpdateTaxProvider sets the "tax_provider" field to the value that was provided on create. -func (u *BillingProfileUpsertOne) UpdateTaxProvider() *BillingProfileUpsertOne { - return u.Update(func(s *BillingProfileUpsert) { - s.UpdateTaxProvider() - }) -} - -// SetInvoicingProvider sets the "invoicing_provider" field. -func (u *BillingProfileUpsertOne) SetInvoicingProvider(v provider.InvoicingProvider) *BillingProfileUpsertOne { - return u.Update(func(s *BillingProfileUpsert) { - s.SetInvoicingProvider(v) - }) -} - -// UpdateInvoicingProvider sets the "invoicing_provider" field to the value that was provided on create. -func (u *BillingProfileUpsertOne) UpdateInvoicingProvider() *BillingProfileUpsertOne { - return u.Update(func(s *BillingProfileUpsert) { - s.UpdateInvoicingProvider() - }) -} - -// SetPaymentProvider sets the "payment_provider" field. -func (u *BillingProfileUpsertOne) SetPaymentProvider(v provider.PaymentProvider) *BillingProfileUpsertOne { - return u.Update(func(s *BillingProfileUpsert) { - s.SetPaymentProvider(v) - }) -} - -// UpdatePaymentProvider sets the "payment_provider" field to the value that was provided on create. -func (u *BillingProfileUpsertOne) UpdatePaymentProvider() *BillingProfileUpsertOne { - return u.Update(func(s *BillingProfileUpsert) { - s.UpdatePaymentProvider() - }) -} - // SetWorkflowConfigID sets the "workflow_config_id" field. func (u *BillingProfileUpsertOne) SetWorkflowConfigID(v string) *BillingProfileUpsertOne { return u.Update(func(s *BillingProfileUpsert) { @@ -1281,6 +1296,27 @@ func (u *BillingProfileUpsertOne) UpdateSupplierName() *BillingProfileUpsertOne }) } +// SetSupplierTaxCode sets the "supplier_tax_code" field. +func (u *BillingProfileUpsertOne) SetSupplierTaxCode(v string) *BillingProfileUpsertOne { + return u.Update(func(s *BillingProfileUpsert) { + s.SetSupplierTaxCode(v) + }) +} + +// UpdateSupplierTaxCode sets the "supplier_tax_code" field to the value that was provided on create. +func (u *BillingProfileUpsertOne) UpdateSupplierTaxCode() *BillingProfileUpsertOne { + return u.Update(func(s *BillingProfileUpsert) { + s.UpdateSupplierTaxCode() + }) +} + +// ClearSupplierTaxCode clears the value of the "supplier_tax_code" field. +func (u *BillingProfileUpsertOne) ClearSupplierTaxCode() *BillingProfileUpsertOne { + return u.Update(func(s *BillingProfileUpsert) { + s.ClearSupplierTaxCode() + }) +} + // Exec executes the query. func (u *BillingProfileUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -1470,6 +1506,15 @@ func (u *BillingProfileUpsertBulk) UpdateNewValues() *BillingProfileUpsertBulk { if _, exists := b.mutation.CreatedAt(); exists { s.SetIgnore(billingprofile.FieldCreatedAt) } + if _, exists := b.mutation.TaxAppID(); exists { + s.SetIgnore(billingprofile.FieldTaxAppID) + } + if _, exists := b.mutation.InvoicingAppID(); exists { + s.SetIgnore(billingprofile.FieldInvoicingAppID) + } + if _, exists := b.mutation.PaymentAppID(); exists { + s.SetIgnore(billingprofile.FieldPaymentAppID) + } } })) return u @@ -1740,48 +1785,6 @@ func (u *BillingProfileUpsertBulk) ClearSupplierAddressPhoneNumber() *BillingPro }) } -// SetTaxProvider sets the "tax_provider" field. -func (u *BillingProfileUpsertBulk) SetTaxProvider(v provider.TaxProvider) *BillingProfileUpsertBulk { - return u.Update(func(s *BillingProfileUpsert) { - s.SetTaxProvider(v) - }) -} - -// UpdateTaxProvider sets the "tax_provider" field to the value that was provided on create. -func (u *BillingProfileUpsertBulk) UpdateTaxProvider() *BillingProfileUpsertBulk { - return u.Update(func(s *BillingProfileUpsert) { - s.UpdateTaxProvider() - }) -} - -// SetInvoicingProvider sets the "invoicing_provider" field. -func (u *BillingProfileUpsertBulk) SetInvoicingProvider(v provider.InvoicingProvider) *BillingProfileUpsertBulk { - return u.Update(func(s *BillingProfileUpsert) { - s.SetInvoicingProvider(v) - }) -} - -// UpdateInvoicingProvider sets the "invoicing_provider" field to the value that was provided on create. -func (u *BillingProfileUpsertBulk) UpdateInvoicingProvider() *BillingProfileUpsertBulk { - return u.Update(func(s *BillingProfileUpsert) { - s.UpdateInvoicingProvider() - }) -} - -// SetPaymentProvider sets the "payment_provider" field. -func (u *BillingProfileUpsertBulk) SetPaymentProvider(v provider.PaymentProvider) *BillingProfileUpsertBulk { - return u.Update(func(s *BillingProfileUpsert) { - s.SetPaymentProvider(v) - }) -} - -// UpdatePaymentProvider sets the "payment_provider" field to the value that was provided on create. -func (u *BillingProfileUpsertBulk) UpdatePaymentProvider() *BillingProfileUpsertBulk { - return u.Update(func(s *BillingProfileUpsert) { - s.UpdatePaymentProvider() - }) -} - // SetWorkflowConfigID sets the "workflow_config_id" field. func (u *BillingProfileUpsertBulk) SetWorkflowConfigID(v string) *BillingProfileUpsertBulk { return u.Update(func(s *BillingProfileUpsert) { @@ -1824,6 +1827,27 @@ func (u *BillingProfileUpsertBulk) UpdateSupplierName() *BillingProfileUpsertBul }) } +// SetSupplierTaxCode sets the "supplier_tax_code" field. +func (u *BillingProfileUpsertBulk) SetSupplierTaxCode(v string) *BillingProfileUpsertBulk { + return u.Update(func(s *BillingProfileUpsert) { + s.SetSupplierTaxCode(v) + }) +} + +// UpdateSupplierTaxCode sets the "supplier_tax_code" field to the value that was provided on create. +func (u *BillingProfileUpsertBulk) UpdateSupplierTaxCode() *BillingProfileUpsertBulk { + return u.Update(func(s *BillingProfileUpsert) { + s.UpdateSupplierTaxCode() + }) +} + +// ClearSupplierTaxCode clears the value of the "supplier_tax_code" field. +func (u *BillingProfileUpsertBulk) ClearSupplierTaxCode() *BillingProfileUpsertBulk { + return u.Update(func(s *BillingProfileUpsert) { + s.ClearSupplierTaxCode() + }) +} + // Exec executes the query. func (u *BillingProfileUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/openmeter/ent/db/billingprofile_query.go b/openmeter/ent/db/billingprofile_query.go index 67cfa52da..34656287d 100644 --- a/openmeter/ent/db/billingprofile_query.go +++ b/openmeter/ent/db/billingprofile_query.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/openmeterio/openmeter/openmeter/ent/db/app" "github.com/openmeterio/openmeter/openmeter/ent/db/billingcustomeroverride" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoice" "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" @@ -30,6 +31,9 @@ type BillingProfileQuery struct { withBillingInvoices *BillingInvoiceQuery withBillingCustomerOverride *BillingCustomerOverrideQuery withWorkflowConfig *BillingWorkflowConfigQuery + withTaxApp *AppQuery + withInvoicingApp *AppQuery + withPaymentApp *AppQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector @@ -133,6 +137,72 @@ func (bpq *BillingProfileQuery) QueryWorkflowConfig() *BillingWorkflowConfigQuer return query } +// QueryTaxApp chains the current query on the "tax_app" edge. +func (bpq *BillingProfileQuery) QueryTaxApp() *AppQuery { + query := (&AppClient{config: bpq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := bpq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := bpq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(billingprofile.Table, billingprofile.FieldID, selector), + sqlgraph.To(app.Table, app.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, billingprofile.TaxAppTable, billingprofile.TaxAppColumn), + ) + fromU = sqlgraph.SetNeighbors(bpq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryInvoicingApp chains the current query on the "invoicing_app" edge. +func (bpq *BillingProfileQuery) QueryInvoicingApp() *AppQuery { + query := (&AppClient{config: bpq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := bpq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := bpq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(billingprofile.Table, billingprofile.FieldID, selector), + sqlgraph.To(app.Table, app.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, billingprofile.InvoicingAppTable, billingprofile.InvoicingAppColumn), + ) + fromU = sqlgraph.SetNeighbors(bpq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryPaymentApp chains the current query on the "payment_app" edge. +func (bpq *BillingProfileQuery) QueryPaymentApp() *AppQuery { + query := (&AppClient{config: bpq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := bpq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := bpq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(billingprofile.Table, billingprofile.FieldID, selector), + sqlgraph.To(app.Table, app.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, billingprofile.PaymentAppTable, billingprofile.PaymentAppColumn), + ) + fromU = sqlgraph.SetNeighbors(bpq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first BillingProfile entity from the query. // Returns a *NotFoundError when no BillingProfile was found. func (bpq *BillingProfileQuery) First(ctx context.Context) (*BillingProfile, error) { @@ -328,6 +398,9 @@ func (bpq *BillingProfileQuery) Clone() *BillingProfileQuery { withBillingInvoices: bpq.withBillingInvoices.Clone(), withBillingCustomerOverride: bpq.withBillingCustomerOverride.Clone(), withWorkflowConfig: bpq.withWorkflowConfig.Clone(), + withTaxApp: bpq.withTaxApp.Clone(), + withInvoicingApp: bpq.withInvoicingApp.Clone(), + withPaymentApp: bpq.withPaymentApp.Clone(), // clone intermediate query. sql: bpq.sql.Clone(), path: bpq.path, @@ -367,6 +440,39 @@ func (bpq *BillingProfileQuery) WithWorkflowConfig(opts ...func(*BillingWorkflow return bpq } +// WithTaxApp tells the query-builder to eager-load the nodes that are connected to +// the "tax_app" edge. The optional arguments are used to configure the query builder of the edge. +func (bpq *BillingProfileQuery) WithTaxApp(opts ...func(*AppQuery)) *BillingProfileQuery { + query := (&AppClient{config: bpq.config}).Query() + for _, opt := range opts { + opt(query) + } + bpq.withTaxApp = query + return bpq +} + +// WithInvoicingApp tells the query-builder to eager-load the nodes that are connected to +// the "invoicing_app" edge. The optional arguments are used to configure the query builder of the edge. +func (bpq *BillingProfileQuery) WithInvoicingApp(opts ...func(*AppQuery)) *BillingProfileQuery { + query := (&AppClient{config: bpq.config}).Query() + for _, opt := range opts { + opt(query) + } + bpq.withInvoicingApp = query + return bpq +} + +// WithPaymentApp tells the query-builder to eager-load the nodes that are connected to +// the "payment_app" edge. The optional arguments are used to configure the query builder of the edge. +func (bpq *BillingProfileQuery) WithPaymentApp(opts ...func(*AppQuery)) *BillingProfileQuery { + query := (&AppClient{config: bpq.config}).Query() + for _, opt := range opts { + opt(query) + } + bpq.withPaymentApp = query + return bpq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -445,10 +551,13 @@ func (bpq *BillingProfileQuery) sqlAll(ctx context.Context, hooks ...queryHook) var ( nodes = []*BillingProfile{} _spec = bpq.querySpec() - loadedTypes = [3]bool{ + loadedTypes = [6]bool{ bpq.withBillingInvoices != nil, bpq.withBillingCustomerOverride != nil, bpq.withWorkflowConfig != nil, + bpq.withTaxApp != nil, + bpq.withInvoicingApp != nil, + bpq.withPaymentApp != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -496,6 +605,24 @@ func (bpq *BillingProfileQuery) sqlAll(ctx context.Context, hooks ...queryHook) return nil, err } } + if query := bpq.withTaxApp; query != nil { + if err := bpq.loadTaxApp(ctx, query, nodes, nil, + func(n *BillingProfile, e *App) { n.Edges.TaxApp = e }); err != nil { + return nil, err + } + } + if query := bpq.withInvoicingApp; query != nil { + if err := bpq.loadInvoicingApp(ctx, query, nodes, nil, + func(n *BillingProfile, e *App) { n.Edges.InvoicingApp = e }); err != nil { + return nil, err + } + } + if query := bpq.withPaymentApp; query != nil { + if err := bpq.loadPaymentApp(ctx, query, nodes, nil, + func(n *BillingProfile, e *App) { n.Edges.PaymentApp = e }); err != nil { + return nil, err + } + } return nodes, nil } @@ -591,6 +718,93 @@ func (bpq *BillingProfileQuery) loadWorkflowConfig(ctx context.Context, query *B } return nil } +func (bpq *BillingProfileQuery) loadTaxApp(ctx context.Context, query *AppQuery, nodes []*BillingProfile, init func(*BillingProfile), assign func(*BillingProfile, *App)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*BillingProfile) + for i := range nodes { + fk := nodes[i].TaxAppID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(app.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "tax_app_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (bpq *BillingProfileQuery) loadInvoicingApp(ctx context.Context, query *AppQuery, nodes []*BillingProfile, init func(*BillingProfile), assign func(*BillingProfile, *App)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*BillingProfile) + for i := range nodes { + fk := nodes[i].InvoicingAppID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(app.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "invoicing_app_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (bpq *BillingProfileQuery) loadPaymentApp(ctx context.Context, query *AppQuery, nodes []*BillingProfile, init func(*BillingProfile), assign func(*BillingProfile, *App)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*BillingProfile) + for i := range nodes { + fk := nodes[i].PaymentAppID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(app.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "payment_app_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} func (bpq *BillingProfileQuery) sqlCount(ctx context.Context) (int, error) { _spec := bpq.querySpec() @@ -623,6 +837,15 @@ func (bpq *BillingProfileQuery) querySpec() *sqlgraph.QuerySpec { if bpq.withWorkflowConfig != nil { _spec.Node.AddColumnOnce(billingprofile.FieldWorkflowConfigID) } + if bpq.withTaxApp != nil { + _spec.Node.AddColumnOnce(billingprofile.FieldTaxAppID) + } + if bpq.withInvoicingApp != nil { + _spec.Node.AddColumnOnce(billingprofile.FieldInvoicingAppID) + } + if bpq.withPaymentApp != nil { + _spec.Node.AddColumnOnce(billingprofile.FieldPaymentAppID) + } } if ps := bpq.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { diff --git a/openmeter/ent/db/billingprofile_update.go b/openmeter/ent/db/billingprofile_update.go index cd951e940..c15a09429 100644 --- a/openmeter/ent/db/billingprofile_update.go +++ b/openmeter/ent/db/billingprofile_update.go @@ -11,7 +11,6 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/openmeterio/openmeter/openmeter/billing/provider" "github.com/openmeterio/openmeter/openmeter/ent/db/billingcustomeroverride" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoice" "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" @@ -245,48 +244,6 @@ func (bpu *BillingProfileUpdate) ClearSupplierAddressPhoneNumber() *BillingProfi return bpu } -// SetTaxProvider sets the "tax_provider" field. -func (bpu *BillingProfileUpdate) SetTaxProvider(pp provider.TaxProvider) *BillingProfileUpdate { - bpu.mutation.SetTaxProvider(pp) - return bpu -} - -// SetNillableTaxProvider sets the "tax_provider" field if the given value is not nil. -func (bpu *BillingProfileUpdate) SetNillableTaxProvider(pp *provider.TaxProvider) *BillingProfileUpdate { - if pp != nil { - bpu.SetTaxProvider(*pp) - } - return bpu -} - -// SetInvoicingProvider sets the "invoicing_provider" field. -func (bpu *BillingProfileUpdate) SetInvoicingProvider(pp provider.InvoicingProvider) *BillingProfileUpdate { - bpu.mutation.SetInvoicingProvider(pp) - return bpu -} - -// SetNillableInvoicingProvider sets the "invoicing_provider" field if the given value is not nil. -func (bpu *BillingProfileUpdate) SetNillableInvoicingProvider(pp *provider.InvoicingProvider) *BillingProfileUpdate { - if pp != nil { - bpu.SetInvoicingProvider(*pp) - } - return bpu -} - -// SetPaymentProvider sets the "payment_provider" field. -func (bpu *BillingProfileUpdate) SetPaymentProvider(pp provider.PaymentProvider) *BillingProfileUpdate { - bpu.mutation.SetPaymentProvider(pp) - return bpu -} - -// SetNillablePaymentProvider sets the "payment_provider" field if the given value is not nil. -func (bpu *BillingProfileUpdate) SetNillablePaymentProvider(pp *provider.PaymentProvider) *BillingProfileUpdate { - if pp != nil { - bpu.SetPaymentProvider(*pp) - } - return bpu -} - // SetWorkflowConfigID sets the "workflow_config_id" field. func (bpu *BillingProfileUpdate) SetWorkflowConfigID(s string) *BillingProfileUpdate { bpu.mutation.SetWorkflowConfigID(s) @@ -329,6 +286,26 @@ func (bpu *BillingProfileUpdate) SetNillableSupplierName(s *string) *BillingProf return bpu } +// SetSupplierTaxCode sets the "supplier_tax_code" field. +func (bpu *BillingProfileUpdate) SetSupplierTaxCode(s string) *BillingProfileUpdate { + bpu.mutation.SetSupplierTaxCode(s) + return bpu +} + +// SetNillableSupplierTaxCode sets the "supplier_tax_code" field if the given value is not nil. +func (bpu *BillingProfileUpdate) SetNillableSupplierTaxCode(s *string) *BillingProfileUpdate { + if s != nil { + bpu.SetSupplierTaxCode(*s) + } + return bpu +} + +// ClearSupplierTaxCode clears the value of the "supplier_tax_code" field. +func (bpu *BillingProfileUpdate) ClearSupplierTaxCode() *BillingProfileUpdate { + bpu.mutation.ClearSupplierTaxCode() + return bpu +} + // AddBillingInvoiceIDs adds the "billing_invoices" edge to the BillingInvoice entity by IDs. func (bpu *BillingProfileUpdate) AddBillingInvoiceIDs(ids ...string) *BillingProfileUpdate { bpu.mutation.AddBillingInvoiceIDs(ids...) @@ -460,21 +437,6 @@ func (bpu *BillingProfileUpdate) check() error { return &ValidationError{Name: "supplier_address_country", err: fmt.Errorf(`db: validator failed for field "BillingProfile.supplier_address_country": %w`, err)} } } - if v, ok := bpu.mutation.TaxProvider(); ok { - if err := billingprofile.TaxProviderValidator(v); err != nil { - return &ValidationError{Name: "tax_provider", err: fmt.Errorf(`db: validator failed for field "BillingProfile.tax_provider": %w`, err)} - } - } - if v, ok := bpu.mutation.InvoicingProvider(); ok { - if err := billingprofile.InvoicingProviderValidator(v); err != nil { - return &ValidationError{Name: "invoicing_provider", err: fmt.Errorf(`db: validator failed for field "BillingProfile.invoicing_provider": %w`, err)} - } - } - if v, ok := bpu.mutation.PaymentProvider(); ok { - if err := billingprofile.PaymentProviderValidator(v); err != nil { - return &ValidationError{Name: "payment_provider", err: fmt.Errorf(`db: validator failed for field "BillingProfile.payment_provider": %w`, err)} - } - } if v, ok := bpu.mutation.WorkflowConfigID(); ok { if err := billingprofile.WorkflowConfigIDValidator(v); err != nil { return &ValidationError{Name: "workflow_config_id", err: fmt.Errorf(`db: validator failed for field "BillingProfile.workflow_config_id": %w`, err)} @@ -488,6 +450,15 @@ func (bpu *BillingProfileUpdate) check() error { if bpu.mutation.WorkflowConfigCleared() && len(bpu.mutation.WorkflowConfigIDs()) > 0 { return errors.New(`db: clearing a required unique edge "BillingProfile.workflow_config"`) } + if bpu.mutation.TaxAppCleared() && len(bpu.mutation.TaxAppIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "BillingProfile.tax_app"`) + } + if bpu.mutation.InvoicingAppCleared() && len(bpu.mutation.InvoicingAppIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "BillingProfile.invoicing_app"`) + } + if bpu.mutation.PaymentAppCleared() && len(bpu.mutation.PaymentAppIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "BillingProfile.payment_app"`) + } return nil } @@ -569,21 +540,18 @@ func (bpu *BillingProfileUpdate) sqlSave(ctx context.Context) (n int, err error) if bpu.mutation.SupplierAddressPhoneNumberCleared() { _spec.ClearField(billingprofile.FieldSupplierAddressPhoneNumber, field.TypeString) } - if value, ok := bpu.mutation.TaxProvider(); ok { - _spec.SetField(billingprofile.FieldTaxProvider, field.TypeEnum, value) - } - if value, ok := bpu.mutation.InvoicingProvider(); ok { - _spec.SetField(billingprofile.FieldInvoicingProvider, field.TypeEnum, value) - } - if value, ok := bpu.mutation.PaymentProvider(); ok { - _spec.SetField(billingprofile.FieldPaymentProvider, field.TypeEnum, value) - } if value, ok := bpu.mutation.Default(); ok { _spec.SetField(billingprofile.FieldDefault, field.TypeBool, value) } if value, ok := bpu.mutation.SupplierName(); ok { _spec.SetField(billingprofile.FieldSupplierName, field.TypeString, value) } + if value, ok := bpu.mutation.SupplierTaxCode(); ok { + _spec.SetField(billingprofile.FieldSupplierTaxCode, field.TypeString, value) + } + if bpu.mutation.SupplierTaxCodeCleared() { + _spec.ClearField(billingprofile.FieldSupplierTaxCode, field.TypeString) + } if bpu.mutation.BillingInvoicesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -935,48 +903,6 @@ func (bpuo *BillingProfileUpdateOne) ClearSupplierAddressPhoneNumber() *BillingP return bpuo } -// SetTaxProvider sets the "tax_provider" field. -func (bpuo *BillingProfileUpdateOne) SetTaxProvider(pp provider.TaxProvider) *BillingProfileUpdateOne { - bpuo.mutation.SetTaxProvider(pp) - return bpuo -} - -// SetNillableTaxProvider sets the "tax_provider" field if the given value is not nil. -func (bpuo *BillingProfileUpdateOne) SetNillableTaxProvider(pp *provider.TaxProvider) *BillingProfileUpdateOne { - if pp != nil { - bpuo.SetTaxProvider(*pp) - } - return bpuo -} - -// SetInvoicingProvider sets the "invoicing_provider" field. -func (bpuo *BillingProfileUpdateOne) SetInvoicingProvider(pp provider.InvoicingProvider) *BillingProfileUpdateOne { - bpuo.mutation.SetInvoicingProvider(pp) - return bpuo -} - -// SetNillableInvoicingProvider sets the "invoicing_provider" field if the given value is not nil. -func (bpuo *BillingProfileUpdateOne) SetNillableInvoicingProvider(pp *provider.InvoicingProvider) *BillingProfileUpdateOne { - if pp != nil { - bpuo.SetInvoicingProvider(*pp) - } - return bpuo -} - -// SetPaymentProvider sets the "payment_provider" field. -func (bpuo *BillingProfileUpdateOne) SetPaymentProvider(pp provider.PaymentProvider) *BillingProfileUpdateOne { - bpuo.mutation.SetPaymentProvider(pp) - return bpuo -} - -// SetNillablePaymentProvider sets the "payment_provider" field if the given value is not nil. -func (bpuo *BillingProfileUpdateOne) SetNillablePaymentProvider(pp *provider.PaymentProvider) *BillingProfileUpdateOne { - if pp != nil { - bpuo.SetPaymentProvider(*pp) - } - return bpuo -} - // SetWorkflowConfigID sets the "workflow_config_id" field. func (bpuo *BillingProfileUpdateOne) SetWorkflowConfigID(s string) *BillingProfileUpdateOne { bpuo.mutation.SetWorkflowConfigID(s) @@ -1019,6 +945,26 @@ func (bpuo *BillingProfileUpdateOne) SetNillableSupplierName(s *string) *Billing return bpuo } +// SetSupplierTaxCode sets the "supplier_tax_code" field. +func (bpuo *BillingProfileUpdateOne) SetSupplierTaxCode(s string) *BillingProfileUpdateOne { + bpuo.mutation.SetSupplierTaxCode(s) + return bpuo +} + +// SetNillableSupplierTaxCode sets the "supplier_tax_code" field if the given value is not nil. +func (bpuo *BillingProfileUpdateOne) SetNillableSupplierTaxCode(s *string) *BillingProfileUpdateOne { + if s != nil { + bpuo.SetSupplierTaxCode(*s) + } + return bpuo +} + +// ClearSupplierTaxCode clears the value of the "supplier_tax_code" field. +func (bpuo *BillingProfileUpdateOne) ClearSupplierTaxCode() *BillingProfileUpdateOne { + bpuo.mutation.ClearSupplierTaxCode() + return bpuo +} + // AddBillingInvoiceIDs adds the "billing_invoices" edge to the BillingInvoice entity by IDs. func (bpuo *BillingProfileUpdateOne) AddBillingInvoiceIDs(ids ...string) *BillingProfileUpdateOne { bpuo.mutation.AddBillingInvoiceIDs(ids...) @@ -1163,21 +1109,6 @@ func (bpuo *BillingProfileUpdateOne) check() error { return &ValidationError{Name: "supplier_address_country", err: fmt.Errorf(`db: validator failed for field "BillingProfile.supplier_address_country": %w`, err)} } } - if v, ok := bpuo.mutation.TaxProvider(); ok { - if err := billingprofile.TaxProviderValidator(v); err != nil { - return &ValidationError{Name: "tax_provider", err: fmt.Errorf(`db: validator failed for field "BillingProfile.tax_provider": %w`, err)} - } - } - if v, ok := bpuo.mutation.InvoicingProvider(); ok { - if err := billingprofile.InvoicingProviderValidator(v); err != nil { - return &ValidationError{Name: "invoicing_provider", err: fmt.Errorf(`db: validator failed for field "BillingProfile.invoicing_provider": %w`, err)} - } - } - if v, ok := bpuo.mutation.PaymentProvider(); ok { - if err := billingprofile.PaymentProviderValidator(v); err != nil { - return &ValidationError{Name: "payment_provider", err: fmt.Errorf(`db: validator failed for field "BillingProfile.payment_provider": %w`, err)} - } - } if v, ok := bpuo.mutation.WorkflowConfigID(); ok { if err := billingprofile.WorkflowConfigIDValidator(v); err != nil { return &ValidationError{Name: "workflow_config_id", err: fmt.Errorf(`db: validator failed for field "BillingProfile.workflow_config_id": %w`, err)} @@ -1191,6 +1122,15 @@ func (bpuo *BillingProfileUpdateOne) check() error { if bpuo.mutation.WorkflowConfigCleared() && len(bpuo.mutation.WorkflowConfigIDs()) > 0 { return errors.New(`db: clearing a required unique edge "BillingProfile.workflow_config"`) } + if bpuo.mutation.TaxAppCleared() && len(bpuo.mutation.TaxAppIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "BillingProfile.tax_app"`) + } + if bpuo.mutation.InvoicingAppCleared() && len(bpuo.mutation.InvoicingAppIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "BillingProfile.invoicing_app"`) + } + if bpuo.mutation.PaymentAppCleared() && len(bpuo.mutation.PaymentAppIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "BillingProfile.payment_app"`) + } return nil } @@ -1289,21 +1229,18 @@ func (bpuo *BillingProfileUpdateOne) sqlSave(ctx context.Context) (_node *Billin if bpuo.mutation.SupplierAddressPhoneNumberCleared() { _spec.ClearField(billingprofile.FieldSupplierAddressPhoneNumber, field.TypeString) } - if value, ok := bpuo.mutation.TaxProvider(); ok { - _spec.SetField(billingprofile.FieldTaxProvider, field.TypeEnum, value) - } - if value, ok := bpuo.mutation.InvoicingProvider(); ok { - _spec.SetField(billingprofile.FieldInvoicingProvider, field.TypeEnum, value) - } - if value, ok := bpuo.mutation.PaymentProvider(); ok { - _spec.SetField(billingprofile.FieldPaymentProvider, field.TypeEnum, value) - } if value, ok := bpuo.mutation.Default(); ok { _spec.SetField(billingprofile.FieldDefault, field.TypeBool, value) } if value, ok := bpuo.mutation.SupplierName(); ok { _spec.SetField(billingprofile.FieldSupplierName, field.TypeString, value) } + if value, ok := bpuo.mutation.SupplierTaxCode(); ok { + _spec.SetField(billingprofile.FieldSupplierTaxCode, field.TypeString, value) + } + if bpuo.mutation.SupplierTaxCodeCleared() { + _spec.ClearField(billingprofile.FieldSupplierTaxCode, field.TypeString) + } if bpuo.mutation.BillingInvoicesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/openmeter/ent/db/billingworkflowconfig.go b/openmeter/ent/db/billingworkflowconfig.go index 1641ffff1..0737a0ec9 100644 --- a/openmeter/ent/db/billingworkflowconfig.go +++ b/openmeter/ent/db/billingworkflowconfig.go @@ -9,11 +9,11 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoice" "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" "github.com/openmeterio/openmeter/openmeter/ent/db/billingworkflowconfig" - "github.com/openmeterio/openmeter/pkg/timezone" + "github.com/openmeterio/openmeter/pkg/datex" ) // BillingWorkflowConfig is the model entity for the BillingWorkflowConfig schema. @@ -29,24 +29,18 @@ type BillingWorkflowConfig struct { UpdatedAt time.Time `json:"updated_at,omitempty"` // DeletedAt holds the value of the "deleted_at" field. DeletedAt *time.Time `json:"deleted_at,omitempty"` - // Timezone holds the value of the "timezone" field. - Timezone *timezone.Timezone `json:"timezone,omitempty"` // CollectionAlignment holds the value of the "collection_alignment" field. - CollectionAlignment billing.AlignmentKind `json:"collection_alignment,omitempty"` - // ItemCollectionPeriodSeconds holds the value of the "item_collection_period_seconds" field. - ItemCollectionPeriodSeconds int64 `json:"item_collection_period_seconds,omitempty"` + CollectionAlignment billingentity.AlignmentKind `json:"collection_alignment,omitempty"` + // ItemCollectionPeriod holds the value of the "item_collection_period" field. + ItemCollectionPeriod datex.ISOString `json:"item_collection_period,omitempty"` // InvoiceAutoAdvance holds the value of the "invoice_auto_advance" field. InvoiceAutoAdvance bool `json:"invoice_auto_advance,omitempty"` - // InvoiceDraftPeriodSeconds holds the value of the "invoice_draft_period_seconds" field. - InvoiceDraftPeriodSeconds int64 `json:"invoice_draft_period_seconds,omitempty"` - // InvoiceDueAfterSeconds holds the value of the "invoice_due_after_seconds" field. - InvoiceDueAfterSeconds int64 `json:"invoice_due_after_seconds,omitempty"` + // InvoiceDraftPeriod holds the value of the "invoice_draft_period" field. + InvoiceDraftPeriod datex.ISOString `json:"invoice_draft_period,omitempty"` + // InvoiceDueAfter holds the value of the "invoice_due_after" field. + InvoiceDueAfter datex.ISOString `json:"invoice_due_after,omitempty"` // InvoiceCollectionMethod holds the value of the "invoice_collection_method" field. - InvoiceCollectionMethod billing.CollectionMethod `json:"invoice_collection_method,omitempty"` - // InvoiceItemResolution holds the value of the "invoice_item_resolution" field. - InvoiceItemResolution billing.GranularityResolution `json:"invoice_item_resolution,omitempty"` - // InvoiceItemPerSubject holds the value of the "invoice_item_per_subject" field. - InvoiceItemPerSubject bool `json:"invoice_item_per_subject,omitempty"` + InvoiceCollectionMethod billingentity.CollectionMethod `json:"invoice_collection_method,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the BillingWorkflowConfigQuery when eager-loading is set. Edges BillingWorkflowConfigEdges `json:"edges"` @@ -91,11 +85,9 @@ func (*BillingWorkflowConfig) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case billingworkflowconfig.FieldInvoiceAutoAdvance, billingworkflowconfig.FieldInvoiceItemPerSubject: + case billingworkflowconfig.FieldInvoiceAutoAdvance: values[i] = new(sql.NullBool) - case billingworkflowconfig.FieldItemCollectionPeriodSeconds, billingworkflowconfig.FieldInvoiceDraftPeriodSeconds, billingworkflowconfig.FieldInvoiceDueAfterSeconds: - values[i] = new(sql.NullInt64) - case billingworkflowconfig.FieldID, billingworkflowconfig.FieldNamespace, billingworkflowconfig.FieldTimezone, billingworkflowconfig.FieldCollectionAlignment, billingworkflowconfig.FieldInvoiceCollectionMethod, billingworkflowconfig.FieldInvoiceItemResolution: + case billingworkflowconfig.FieldID, billingworkflowconfig.FieldNamespace, billingworkflowconfig.FieldCollectionAlignment, billingworkflowconfig.FieldItemCollectionPeriod, billingworkflowconfig.FieldInvoiceDraftPeriod, billingworkflowconfig.FieldInvoiceDueAfter, billingworkflowconfig.FieldInvoiceCollectionMethod: values[i] = new(sql.NullString) case billingworkflowconfig.FieldCreatedAt, billingworkflowconfig.FieldUpdatedAt, billingworkflowconfig.FieldDeletedAt: values[i] = new(sql.NullTime) @@ -145,24 +137,17 @@ func (bwc *BillingWorkflowConfig) assignValues(columns []string, values []any) e bwc.DeletedAt = new(time.Time) *bwc.DeletedAt = value.Time } - case billingworkflowconfig.FieldTimezone: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field timezone", values[i]) - } else if value.Valid { - bwc.Timezone = new(timezone.Timezone) - *bwc.Timezone = timezone.Timezone(value.String) - } case billingworkflowconfig.FieldCollectionAlignment: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field collection_alignment", values[i]) } else if value.Valid { - bwc.CollectionAlignment = billing.AlignmentKind(value.String) + bwc.CollectionAlignment = billingentity.AlignmentKind(value.String) } - case billingworkflowconfig.FieldItemCollectionPeriodSeconds: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field item_collection_period_seconds", values[i]) + case billingworkflowconfig.FieldItemCollectionPeriod: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field item_collection_period", values[i]) } else if value.Valid { - bwc.ItemCollectionPeriodSeconds = value.Int64 + bwc.ItemCollectionPeriod = datex.ISOString(value.String) } case billingworkflowconfig.FieldInvoiceAutoAdvance: if value, ok := values[i].(*sql.NullBool); !ok { @@ -170,35 +155,23 @@ func (bwc *BillingWorkflowConfig) assignValues(columns []string, values []any) e } else if value.Valid { bwc.InvoiceAutoAdvance = value.Bool } - case billingworkflowconfig.FieldInvoiceDraftPeriodSeconds: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field invoice_draft_period_seconds", values[i]) + case billingworkflowconfig.FieldInvoiceDraftPeriod: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field invoice_draft_period", values[i]) } else if value.Valid { - bwc.InvoiceDraftPeriodSeconds = value.Int64 + bwc.InvoiceDraftPeriod = datex.ISOString(value.String) } - case billingworkflowconfig.FieldInvoiceDueAfterSeconds: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field invoice_due_after_seconds", values[i]) + case billingworkflowconfig.FieldInvoiceDueAfter: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field invoice_due_after", values[i]) } else if value.Valid { - bwc.InvoiceDueAfterSeconds = value.Int64 + bwc.InvoiceDueAfter = datex.ISOString(value.String) } case billingworkflowconfig.FieldInvoiceCollectionMethod: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field invoice_collection_method", values[i]) } else if value.Valid { - bwc.InvoiceCollectionMethod = billing.CollectionMethod(value.String) - } - case billingworkflowconfig.FieldInvoiceItemResolution: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field invoice_item_resolution", values[i]) - } else if value.Valid { - bwc.InvoiceItemResolution = billing.GranularityResolution(value.String) - } - case billingworkflowconfig.FieldInvoiceItemPerSubject: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field invoice_item_per_subject", values[i]) - } else if value.Valid { - bwc.InvoiceItemPerSubject = value.Bool + bwc.InvoiceCollectionMethod = billingentity.CollectionMethod(value.String) } default: bwc.selectValues.Set(columns[i], values[i]) @@ -260,34 +233,23 @@ func (bwc *BillingWorkflowConfig) String() string { builder.WriteString(v.Format(time.ANSIC)) } builder.WriteString(", ") - if v := bwc.Timezone; v != nil { - builder.WriteString("timezone=") - builder.WriteString(fmt.Sprintf("%v", *v)) - } - builder.WriteString(", ") builder.WriteString("collection_alignment=") builder.WriteString(fmt.Sprintf("%v", bwc.CollectionAlignment)) builder.WriteString(", ") - builder.WriteString("item_collection_period_seconds=") - builder.WriteString(fmt.Sprintf("%v", bwc.ItemCollectionPeriodSeconds)) + builder.WriteString("item_collection_period=") + builder.WriteString(fmt.Sprintf("%v", bwc.ItemCollectionPeriod)) builder.WriteString(", ") builder.WriteString("invoice_auto_advance=") builder.WriteString(fmt.Sprintf("%v", bwc.InvoiceAutoAdvance)) builder.WriteString(", ") - builder.WriteString("invoice_draft_period_seconds=") - builder.WriteString(fmt.Sprintf("%v", bwc.InvoiceDraftPeriodSeconds)) + builder.WriteString("invoice_draft_period=") + builder.WriteString(fmt.Sprintf("%v", bwc.InvoiceDraftPeriod)) builder.WriteString(", ") - builder.WriteString("invoice_due_after_seconds=") - builder.WriteString(fmt.Sprintf("%v", bwc.InvoiceDueAfterSeconds)) + builder.WriteString("invoice_due_after=") + builder.WriteString(fmt.Sprintf("%v", bwc.InvoiceDueAfter)) builder.WriteString(", ") builder.WriteString("invoice_collection_method=") builder.WriteString(fmt.Sprintf("%v", bwc.InvoiceCollectionMethod)) - builder.WriteString(", ") - builder.WriteString("invoice_item_resolution=") - builder.WriteString(fmt.Sprintf("%v", bwc.InvoiceItemResolution)) - builder.WriteString(", ") - builder.WriteString("invoice_item_per_subject=") - builder.WriteString(fmt.Sprintf("%v", bwc.InvoiceItemPerSubject)) builder.WriteByte(')') return builder.String() } diff --git a/openmeter/ent/db/billingworkflowconfig/billingworkflowconfig.go b/openmeter/ent/db/billingworkflowconfig/billingworkflowconfig.go index 1304e4799..7ce96804b 100644 --- a/openmeter/ent/db/billingworkflowconfig/billingworkflowconfig.go +++ b/openmeter/ent/db/billingworkflowconfig/billingworkflowconfig.go @@ -8,7 +8,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" ) const ( @@ -24,24 +24,18 @@ const ( FieldUpdatedAt = "updated_at" // FieldDeletedAt holds the string denoting the deleted_at field in the database. FieldDeletedAt = "deleted_at" - // FieldTimezone holds the string denoting the timezone field in the database. - FieldTimezone = "timezone" // FieldCollectionAlignment holds the string denoting the collection_alignment field in the database. FieldCollectionAlignment = "collection_alignment" - // FieldItemCollectionPeriodSeconds holds the string denoting the item_collection_period_seconds field in the database. - FieldItemCollectionPeriodSeconds = "item_collection_period_seconds" + // FieldItemCollectionPeriod holds the string denoting the item_collection_period field in the database. + FieldItemCollectionPeriod = "item_collection_period" // FieldInvoiceAutoAdvance holds the string denoting the invoice_auto_advance field in the database. FieldInvoiceAutoAdvance = "invoice_auto_advance" - // FieldInvoiceDraftPeriodSeconds holds the string denoting the invoice_draft_period_seconds field in the database. - FieldInvoiceDraftPeriodSeconds = "invoice_draft_period_seconds" - // FieldInvoiceDueAfterSeconds holds the string denoting the invoice_due_after_seconds field in the database. - FieldInvoiceDueAfterSeconds = "invoice_due_after_seconds" + // FieldInvoiceDraftPeriod holds the string denoting the invoice_draft_period field in the database. + FieldInvoiceDraftPeriod = "invoice_draft_period" + // FieldInvoiceDueAfter holds the string denoting the invoice_due_after field in the database. + FieldInvoiceDueAfter = "invoice_due_after" // FieldInvoiceCollectionMethod holds the string denoting the invoice_collection_method field in the database. FieldInvoiceCollectionMethod = "invoice_collection_method" - // FieldInvoiceItemResolution holds the string denoting the invoice_item_resolution field in the database. - FieldInvoiceItemResolution = "invoice_item_resolution" - // FieldInvoiceItemPerSubject holds the string denoting the invoice_item_per_subject field in the database. - FieldInvoiceItemPerSubject = "invoice_item_per_subject" // EdgeBillingInvoices holds the string denoting the billing_invoices edge name in mutations. EdgeBillingInvoices = "billing_invoices" // EdgeBillingProfile holds the string denoting the billing_profile edge name in mutations. @@ -71,15 +65,12 @@ var Columns = []string{ FieldCreatedAt, FieldUpdatedAt, FieldDeletedAt, - FieldTimezone, FieldCollectionAlignment, - FieldItemCollectionPeriodSeconds, + FieldItemCollectionPeriod, FieldInvoiceAutoAdvance, - FieldInvoiceDraftPeriodSeconds, - FieldInvoiceDueAfterSeconds, + FieldInvoiceDraftPeriod, + FieldInvoiceDueAfter, FieldInvoiceCollectionMethod, - FieldInvoiceItemResolution, - FieldInvoiceItemPerSubject, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -106,7 +97,7 @@ var ( ) // CollectionAlignmentValidator is a validator for the "collection_alignment" field enum values. It is called by the builders before save. -func CollectionAlignmentValidator(ca billing.AlignmentKind) error { +func CollectionAlignmentValidator(ca billingentity.AlignmentKind) error { switch ca { case "subscription": return nil @@ -116,7 +107,7 @@ func CollectionAlignmentValidator(ca billing.AlignmentKind) error { } // InvoiceCollectionMethodValidator is a validator for the "invoice_collection_method" field enum values. It is called by the builders before save. -func InvoiceCollectionMethodValidator(icm billing.CollectionMethod) error { +func InvoiceCollectionMethodValidator(icm billingentity.CollectionMethod) error { switch icm { case "charge_automatically", "send_invoice": return nil @@ -125,16 +116,6 @@ func InvoiceCollectionMethodValidator(icm billing.CollectionMethod) error { } } -// InvoiceItemResolutionValidator is a validator for the "invoice_item_resolution" field enum values. It is called by the builders before save. -func InvoiceItemResolutionValidator(iir billing.GranularityResolution) error { - switch iir { - case "day", "period": - return nil - default: - return fmt.Errorf("billingworkflowconfig: invalid enum value for invoice_item_resolution field: %q", iir) - } -} - // OrderOption defines the ordering options for the BillingWorkflowConfig queries. type OrderOption func(*sql.Selector) @@ -163,19 +144,14 @@ func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() } -// ByTimezone orders the results by the timezone field. -func ByTimezone(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldTimezone, opts...).ToFunc() -} - // ByCollectionAlignment orders the results by the collection_alignment field. func ByCollectionAlignment(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCollectionAlignment, opts...).ToFunc() } -// ByItemCollectionPeriodSeconds orders the results by the item_collection_period_seconds field. -func ByItemCollectionPeriodSeconds(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldItemCollectionPeriodSeconds, opts...).ToFunc() +// ByItemCollectionPeriod orders the results by the item_collection_period field. +func ByItemCollectionPeriod(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldItemCollectionPeriod, opts...).ToFunc() } // ByInvoiceAutoAdvance orders the results by the invoice_auto_advance field. @@ -183,14 +159,14 @@ func ByInvoiceAutoAdvance(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldInvoiceAutoAdvance, opts...).ToFunc() } -// ByInvoiceDraftPeriodSeconds orders the results by the invoice_draft_period_seconds field. -func ByInvoiceDraftPeriodSeconds(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldInvoiceDraftPeriodSeconds, opts...).ToFunc() +// ByInvoiceDraftPeriod orders the results by the invoice_draft_period field. +func ByInvoiceDraftPeriod(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldInvoiceDraftPeriod, opts...).ToFunc() } -// ByInvoiceDueAfterSeconds orders the results by the invoice_due_after_seconds field. -func ByInvoiceDueAfterSeconds(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldInvoiceDueAfterSeconds, opts...).ToFunc() +// ByInvoiceDueAfter orders the results by the invoice_due_after field. +func ByInvoiceDueAfter(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldInvoiceDueAfter, opts...).ToFunc() } // ByInvoiceCollectionMethod orders the results by the invoice_collection_method field. @@ -198,16 +174,6 @@ func ByInvoiceCollectionMethod(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldInvoiceCollectionMethod, opts...).ToFunc() } -// ByInvoiceItemResolution orders the results by the invoice_item_resolution field. -func ByInvoiceItemResolution(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldInvoiceItemResolution, opts...).ToFunc() -} - -// ByInvoiceItemPerSubject orders the results by the invoice_item_per_subject field. -func ByInvoiceItemPerSubject(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldInvoiceItemPerSubject, opts...).ToFunc() -} - // ByBillingInvoicesField orders the results by billing_invoices field. func ByBillingInvoicesField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/openmeter/ent/db/billingworkflowconfig/where.go b/openmeter/ent/db/billingworkflowconfig/where.go index eec0f33d7..9bbc56361 100644 --- a/openmeter/ent/db/billingworkflowconfig/where.go +++ b/openmeter/ent/db/billingworkflowconfig/where.go @@ -7,9 +7,9 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" - "github.com/openmeterio/openmeter/pkg/timezone" + "github.com/openmeterio/openmeter/pkg/datex" ) // ID filters vertices based on their ID field. @@ -87,15 +87,10 @@ func DeletedAt(v time.Time) predicate.BillingWorkflowConfig { return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldDeletedAt, v)) } -// Timezone applies equality check predicate on the "timezone" field. It's identical to TimezoneEQ. -func Timezone(v timezone.Timezone) predicate.BillingWorkflowConfig { +// ItemCollectionPeriod applies equality check predicate on the "item_collection_period" field. It's identical to ItemCollectionPeriodEQ. +func ItemCollectionPeriod(v datex.ISOString) predicate.BillingWorkflowConfig { vc := string(v) - return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldTimezone, vc)) -} - -// ItemCollectionPeriodSeconds applies equality check predicate on the "item_collection_period_seconds" field. It's identical to ItemCollectionPeriodSecondsEQ. -func ItemCollectionPeriodSeconds(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldItemCollectionPeriodSeconds, v)) + return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldItemCollectionPeriod, vc)) } // InvoiceAutoAdvance applies equality check predicate on the "invoice_auto_advance" field. It's identical to InvoiceAutoAdvanceEQ. @@ -103,19 +98,16 @@ func InvoiceAutoAdvance(v bool) predicate.BillingWorkflowConfig { return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceAutoAdvance, v)) } -// InvoiceDraftPeriodSeconds applies equality check predicate on the "invoice_draft_period_seconds" field. It's identical to InvoiceDraftPeriodSecondsEQ. -func InvoiceDraftPeriodSeconds(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceDraftPeriodSeconds, v)) -} - -// InvoiceDueAfterSeconds applies equality check predicate on the "invoice_due_after_seconds" field. It's identical to InvoiceDueAfterSecondsEQ. -func InvoiceDueAfterSeconds(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceDueAfterSeconds, v)) +// InvoiceDraftPeriod applies equality check predicate on the "invoice_draft_period" field. It's identical to InvoiceDraftPeriodEQ. +func InvoiceDraftPeriod(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceDraftPeriod, vc)) } -// InvoiceItemPerSubject applies equality check predicate on the "invoice_item_per_subject" field. It's identical to InvoiceItemPerSubjectEQ. -func InvoiceItemPerSubject(v bool) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceItemPerSubject, v)) +// InvoiceDueAfter applies equality check predicate on the "invoice_due_after" field. It's identical to InvoiceDueAfterEQ. +func InvoiceDueAfter(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceDueAfter, vc)) } // NamespaceEQ applies the EQ predicate on the "namespace" field. @@ -313,274 +305,312 @@ func DeletedAtNotNil() predicate.BillingWorkflowConfig { return predicate.BillingWorkflowConfig(sql.FieldNotNull(FieldDeletedAt)) } -// TimezoneEQ applies the EQ predicate on the "timezone" field. -func TimezoneEQ(v timezone.Timezone) predicate.BillingWorkflowConfig { +// CollectionAlignmentEQ applies the EQ predicate on the "collection_alignment" field. +func CollectionAlignmentEQ(v billingentity.AlignmentKind) predicate.BillingWorkflowConfig { + vc := v + return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldCollectionAlignment, vc)) +} + +// CollectionAlignmentNEQ applies the NEQ predicate on the "collection_alignment" field. +func CollectionAlignmentNEQ(v billingentity.AlignmentKind) predicate.BillingWorkflowConfig { + vc := v + return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldCollectionAlignment, vc)) +} + +// CollectionAlignmentIn applies the In predicate on the "collection_alignment" field. +func CollectionAlignmentIn(vs ...billingentity.AlignmentKind) predicate.BillingWorkflowConfig { + v := make([]any, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.BillingWorkflowConfig(sql.FieldIn(FieldCollectionAlignment, v...)) +} + +// CollectionAlignmentNotIn applies the NotIn predicate on the "collection_alignment" field. +func CollectionAlignmentNotIn(vs ...billingentity.AlignmentKind) predicate.BillingWorkflowConfig { + v := make([]any, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.BillingWorkflowConfig(sql.FieldNotIn(FieldCollectionAlignment, v...)) +} + +// ItemCollectionPeriodEQ applies the EQ predicate on the "item_collection_period" field. +func ItemCollectionPeriodEQ(v datex.ISOString) predicate.BillingWorkflowConfig { vc := string(v) - return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldTimezone, vc)) + return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldItemCollectionPeriod, vc)) } -// TimezoneNEQ applies the NEQ predicate on the "timezone" field. -func TimezoneNEQ(v timezone.Timezone) predicate.BillingWorkflowConfig { +// ItemCollectionPeriodNEQ applies the NEQ predicate on the "item_collection_period" field. +func ItemCollectionPeriodNEQ(v datex.ISOString) predicate.BillingWorkflowConfig { vc := string(v) - return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldTimezone, vc)) + return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldItemCollectionPeriod, vc)) } -// TimezoneIn applies the In predicate on the "timezone" field. -func TimezoneIn(vs ...timezone.Timezone) predicate.BillingWorkflowConfig { +// ItemCollectionPeriodIn applies the In predicate on the "item_collection_period" field. +func ItemCollectionPeriodIn(vs ...datex.ISOString) predicate.BillingWorkflowConfig { v := make([]any, len(vs)) for i := range v { v[i] = string(vs[i]) } - return predicate.BillingWorkflowConfig(sql.FieldIn(FieldTimezone, v...)) + return predicate.BillingWorkflowConfig(sql.FieldIn(FieldItemCollectionPeriod, v...)) } -// TimezoneNotIn applies the NotIn predicate on the "timezone" field. -func TimezoneNotIn(vs ...timezone.Timezone) predicate.BillingWorkflowConfig { +// ItemCollectionPeriodNotIn applies the NotIn predicate on the "item_collection_period" field. +func ItemCollectionPeriodNotIn(vs ...datex.ISOString) predicate.BillingWorkflowConfig { v := make([]any, len(vs)) for i := range v { v[i] = string(vs[i]) } - return predicate.BillingWorkflowConfig(sql.FieldNotIn(FieldTimezone, v...)) + return predicate.BillingWorkflowConfig(sql.FieldNotIn(FieldItemCollectionPeriod, v...)) } -// TimezoneGT applies the GT predicate on the "timezone" field. -func TimezoneGT(v timezone.Timezone) predicate.BillingWorkflowConfig { +// ItemCollectionPeriodGT applies the GT predicate on the "item_collection_period" field. +func ItemCollectionPeriodGT(v datex.ISOString) predicate.BillingWorkflowConfig { vc := string(v) - return predicate.BillingWorkflowConfig(sql.FieldGT(FieldTimezone, vc)) + return predicate.BillingWorkflowConfig(sql.FieldGT(FieldItemCollectionPeriod, vc)) } -// TimezoneGTE applies the GTE predicate on the "timezone" field. -func TimezoneGTE(v timezone.Timezone) predicate.BillingWorkflowConfig { +// ItemCollectionPeriodGTE applies the GTE predicate on the "item_collection_period" field. +func ItemCollectionPeriodGTE(v datex.ISOString) predicate.BillingWorkflowConfig { vc := string(v) - return predicate.BillingWorkflowConfig(sql.FieldGTE(FieldTimezone, vc)) + return predicate.BillingWorkflowConfig(sql.FieldGTE(FieldItemCollectionPeriod, vc)) } -// TimezoneLT applies the LT predicate on the "timezone" field. -func TimezoneLT(v timezone.Timezone) predicate.BillingWorkflowConfig { +// ItemCollectionPeriodLT applies the LT predicate on the "item_collection_period" field. +func ItemCollectionPeriodLT(v datex.ISOString) predicate.BillingWorkflowConfig { vc := string(v) - return predicate.BillingWorkflowConfig(sql.FieldLT(FieldTimezone, vc)) + return predicate.BillingWorkflowConfig(sql.FieldLT(FieldItemCollectionPeriod, vc)) } -// TimezoneLTE applies the LTE predicate on the "timezone" field. -func TimezoneLTE(v timezone.Timezone) predicate.BillingWorkflowConfig { +// ItemCollectionPeriodLTE applies the LTE predicate on the "item_collection_period" field. +func ItemCollectionPeriodLTE(v datex.ISOString) predicate.BillingWorkflowConfig { vc := string(v) - return predicate.BillingWorkflowConfig(sql.FieldLTE(FieldTimezone, vc)) + return predicate.BillingWorkflowConfig(sql.FieldLTE(FieldItemCollectionPeriod, vc)) } -// TimezoneContains applies the Contains predicate on the "timezone" field. -func TimezoneContains(v timezone.Timezone) predicate.BillingWorkflowConfig { +// ItemCollectionPeriodContains applies the Contains predicate on the "item_collection_period" field. +func ItemCollectionPeriodContains(v datex.ISOString) predicate.BillingWorkflowConfig { vc := string(v) - return predicate.BillingWorkflowConfig(sql.FieldContains(FieldTimezone, vc)) + return predicate.BillingWorkflowConfig(sql.FieldContains(FieldItemCollectionPeriod, vc)) } -// TimezoneHasPrefix applies the HasPrefix predicate on the "timezone" field. -func TimezoneHasPrefix(v timezone.Timezone) predicate.BillingWorkflowConfig { +// ItemCollectionPeriodHasPrefix applies the HasPrefix predicate on the "item_collection_period" field. +func ItemCollectionPeriodHasPrefix(v datex.ISOString) predicate.BillingWorkflowConfig { vc := string(v) - return predicate.BillingWorkflowConfig(sql.FieldHasPrefix(FieldTimezone, vc)) + return predicate.BillingWorkflowConfig(sql.FieldHasPrefix(FieldItemCollectionPeriod, vc)) } -// TimezoneHasSuffix applies the HasSuffix predicate on the "timezone" field. -func TimezoneHasSuffix(v timezone.Timezone) predicate.BillingWorkflowConfig { +// ItemCollectionPeriodHasSuffix applies the HasSuffix predicate on the "item_collection_period" field. +func ItemCollectionPeriodHasSuffix(v datex.ISOString) predicate.BillingWorkflowConfig { vc := string(v) - return predicate.BillingWorkflowConfig(sql.FieldHasSuffix(FieldTimezone, vc)) + return predicate.BillingWorkflowConfig(sql.FieldHasSuffix(FieldItemCollectionPeriod, vc)) } -// TimezoneIsNil applies the IsNil predicate on the "timezone" field. -func TimezoneIsNil() predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldIsNull(FieldTimezone)) +// ItemCollectionPeriodEqualFold applies the EqualFold predicate on the "item_collection_period" field. +func ItemCollectionPeriodEqualFold(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldEqualFold(FieldItemCollectionPeriod, vc)) } -// TimezoneNotNil applies the NotNil predicate on the "timezone" field. -func TimezoneNotNil() predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldNotNull(FieldTimezone)) +// ItemCollectionPeriodContainsFold applies the ContainsFold predicate on the "item_collection_period" field. +func ItemCollectionPeriodContainsFold(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldContainsFold(FieldItemCollectionPeriod, vc)) } -// TimezoneEqualFold applies the EqualFold predicate on the "timezone" field. -func TimezoneEqualFold(v timezone.Timezone) predicate.BillingWorkflowConfig { - vc := string(v) - return predicate.BillingWorkflowConfig(sql.FieldEqualFold(FieldTimezone, vc)) +// InvoiceAutoAdvanceEQ applies the EQ predicate on the "invoice_auto_advance" field. +func InvoiceAutoAdvanceEQ(v bool) predicate.BillingWorkflowConfig { + return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceAutoAdvance, v)) } -// TimezoneContainsFold applies the ContainsFold predicate on the "timezone" field. -func TimezoneContainsFold(v timezone.Timezone) predicate.BillingWorkflowConfig { - vc := string(v) - return predicate.BillingWorkflowConfig(sql.FieldContainsFold(FieldTimezone, vc)) +// InvoiceAutoAdvanceNEQ applies the NEQ predicate on the "invoice_auto_advance" field. +func InvoiceAutoAdvanceNEQ(v bool) predicate.BillingWorkflowConfig { + return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldInvoiceAutoAdvance, v)) } -// CollectionAlignmentEQ applies the EQ predicate on the "collection_alignment" field. -func CollectionAlignmentEQ(v billing.AlignmentKind) predicate.BillingWorkflowConfig { - vc := v - return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldCollectionAlignment, vc)) +// InvoiceDraftPeriodEQ applies the EQ predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodEQ(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceDraftPeriod, vc)) } -// CollectionAlignmentNEQ applies the NEQ predicate on the "collection_alignment" field. -func CollectionAlignmentNEQ(v billing.AlignmentKind) predicate.BillingWorkflowConfig { - vc := v - return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldCollectionAlignment, vc)) +// InvoiceDraftPeriodNEQ applies the NEQ predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodNEQ(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldInvoiceDraftPeriod, vc)) } -// CollectionAlignmentIn applies the In predicate on the "collection_alignment" field. -func CollectionAlignmentIn(vs ...billing.AlignmentKind) predicate.BillingWorkflowConfig { +// InvoiceDraftPeriodIn applies the In predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodIn(vs ...datex.ISOString) predicate.BillingWorkflowConfig { v := make([]any, len(vs)) for i := range v { - v[i] = vs[i] + v[i] = string(vs[i]) } - return predicate.BillingWorkflowConfig(sql.FieldIn(FieldCollectionAlignment, v...)) + return predicate.BillingWorkflowConfig(sql.FieldIn(FieldInvoiceDraftPeriod, v...)) } -// CollectionAlignmentNotIn applies the NotIn predicate on the "collection_alignment" field. -func CollectionAlignmentNotIn(vs ...billing.AlignmentKind) predicate.BillingWorkflowConfig { +// InvoiceDraftPeriodNotIn applies the NotIn predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodNotIn(vs ...datex.ISOString) predicate.BillingWorkflowConfig { v := make([]any, len(vs)) for i := range v { - v[i] = vs[i] + v[i] = string(vs[i]) } - return predicate.BillingWorkflowConfig(sql.FieldNotIn(FieldCollectionAlignment, v...)) -} - -// ItemCollectionPeriodSecondsEQ applies the EQ predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsEQ(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldItemCollectionPeriodSeconds, v)) -} - -// ItemCollectionPeriodSecondsNEQ applies the NEQ predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsNEQ(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldItemCollectionPeriodSeconds, v)) -} - -// ItemCollectionPeriodSecondsIn applies the In predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsIn(vs ...int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldIn(FieldItemCollectionPeriodSeconds, vs...)) -} - -// ItemCollectionPeriodSecondsNotIn applies the NotIn predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsNotIn(vs ...int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldNotIn(FieldItemCollectionPeriodSeconds, vs...)) + return predicate.BillingWorkflowConfig(sql.FieldNotIn(FieldInvoiceDraftPeriod, v...)) } -// ItemCollectionPeriodSecondsGT applies the GT predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsGT(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldGT(FieldItemCollectionPeriodSeconds, v)) +// InvoiceDraftPeriodGT applies the GT predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodGT(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldGT(FieldInvoiceDraftPeriod, vc)) } -// ItemCollectionPeriodSecondsGTE applies the GTE predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsGTE(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldGTE(FieldItemCollectionPeriodSeconds, v)) +// InvoiceDraftPeriodGTE applies the GTE predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodGTE(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldGTE(FieldInvoiceDraftPeriod, vc)) } -// ItemCollectionPeriodSecondsLT applies the LT predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsLT(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldLT(FieldItemCollectionPeriodSeconds, v)) +// InvoiceDraftPeriodLT applies the LT predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodLT(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldLT(FieldInvoiceDraftPeriod, vc)) } -// ItemCollectionPeriodSecondsLTE applies the LTE predicate on the "item_collection_period_seconds" field. -func ItemCollectionPeriodSecondsLTE(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldLTE(FieldItemCollectionPeriodSeconds, v)) +// InvoiceDraftPeriodLTE applies the LTE predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodLTE(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldLTE(FieldInvoiceDraftPeriod, vc)) } -// InvoiceAutoAdvanceEQ applies the EQ predicate on the "invoice_auto_advance" field. -func InvoiceAutoAdvanceEQ(v bool) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceAutoAdvance, v)) +// InvoiceDraftPeriodContains applies the Contains predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodContains(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldContains(FieldInvoiceDraftPeriod, vc)) } -// InvoiceAutoAdvanceNEQ applies the NEQ predicate on the "invoice_auto_advance" field. -func InvoiceAutoAdvanceNEQ(v bool) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldInvoiceAutoAdvance, v)) +// InvoiceDraftPeriodHasPrefix applies the HasPrefix predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodHasPrefix(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldHasPrefix(FieldInvoiceDraftPeriod, vc)) } -// InvoiceDraftPeriodSecondsEQ applies the EQ predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsEQ(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceDraftPeriodSeconds, v)) +// InvoiceDraftPeriodHasSuffix applies the HasSuffix predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodHasSuffix(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldHasSuffix(FieldInvoiceDraftPeriod, vc)) } -// InvoiceDraftPeriodSecondsNEQ applies the NEQ predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsNEQ(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldInvoiceDraftPeriodSeconds, v)) +// InvoiceDraftPeriodEqualFold applies the EqualFold predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodEqualFold(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldEqualFold(FieldInvoiceDraftPeriod, vc)) } -// InvoiceDraftPeriodSecondsIn applies the In predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsIn(vs ...int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldIn(FieldInvoiceDraftPeriodSeconds, vs...)) +// InvoiceDraftPeriodContainsFold applies the ContainsFold predicate on the "invoice_draft_period" field. +func InvoiceDraftPeriodContainsFold(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldContainsFold(FieldInvoiceDraftPeriod, vc)) } -// InvoiceDraftPeriodSecondsNotIn applies the NotIn predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsNotIn(vs ...int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldNotIn(FieldInvoiceDraftPeriodSeconds, vs...)) +// InvoiceDueAfterEQ applies the EQ predicate on the "invoice_due_after" field. +func InvoiceDueAfterEQ(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceDueAfter, vc)) } -// InvoiceDraftPeriodSecondsGT applies the GT predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsGT(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldGT(FieldInvoiceDraftPeriodSeconds, v)) +// InvoiceDueAfterNEQ applies the NEQ predicate on the "invoice_due_after" field. +func InvoiceDueAfterNEQ(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldInvoiceDueAfter, vc)) } -// InvoiceDraftPeriodSecondsGTE applies the GTE predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsGTE(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldGTE(FieldInvoiceDraftPeriodSeconds, v)) +// InvoiceDueAfterIn applies the In predicate on the "invoice_due_after" field. +func InvoiceDueAfterIn(vs ...datex.ISOString) predicate.BillingWorkflowConfig { + v := make([]any, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.BillingWorkflowConfig(sql.FieldIn(FieldInvoiceDueAfter, v...)) } -// InvoiceDraftPeriodSecondsLT applies the LT predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsLT(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldLT(FieldInvoiceDraftPeriodSeconds, v)) +// InvoiceDueAfterNotIn applies the NotIn predicate on the "invoice_due_after" field. +func InvoiceDueAfterNotIn(vs ...datex.ISOString) predicate.BillingWorkflowConfig { + v := make([]any, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.BillingWorkflowConfig(sql.FieldNotIn(FieldInvoiceDueAfter, v...)) } -// InvoiceDraftPeriodSecondsLTE applies the LTE predicate on the "invoice_draft_period_seconds" field. -func InvoiceDraftPeriodSecondsLTE(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldLTE(FieldInvoiceDraftPeriodSeconds, v)) +// InvoiceDueAfterGT applies the GT predicate on the "invoice_due_after" field. +func InvoiceDueAfterGT(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldGT(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsEQ applies the EQ predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsEQ(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceDueAfterSeconds, v)) +// InvoiceDueAfterGTE applies the GTE predicate on the "invoice_due_after" field. +func InvoiceDueAfterGTE(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldGTE(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsNEQ applies the NEQ predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsNEQ(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldInvoiceDueAfterSeconds, v)) +// InvoiceDueAfterLT applies the LT predicate on the "invoice_due_after" field. +func InvoiceDueAfterLT(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldLT(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsIn applies the In predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsIn(vs ...int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldIn(FieldInvoiceDueAfterSeconds, vs...)) +// InvoiceDueAfterLTE applies the LTE predicate on the "invoice_due_after" field. +func InvoiceDueAfterLTE(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldLTE(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsNotIn applies the NotIn predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsNotIn(vs ...int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldNotIn(FieldInvoiceDueAfterSeconds, vs...)) +// InvoiceDueAfterContains applies the Contains predicate on the "invoice_due_after" field. +func InvoiceDueAfterContains(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldContains(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsGT applies the GT predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsGT(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldGT(FieldInvoiceDueAfterSeconds, v)) +// InvoiceDueAfterHasPrefix applies the HasPrefix predicate on the "invoice_due_after" field. +func InvoiceDueAfterHasPrefix(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldHasPrefix(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsGTE applies the GTE predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsGTE(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldGTE(FieldInvoiceDueAfterSeconds, v)) +// InvoiceDueAfterHasSuffix applies the HasSuffix predicate on the "invoice_due_after" field. +func InvoiceDueAfterHasSuffix(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldHasSuffix(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsLT applies the LT predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsLT(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldLT(FieldInvoiceDueAfterSeconds, v)) +// InvoiceDueAfterEqualFold applies the EqualFold predicate on the "invoice_due_after" field. +func InvoiceDueAfterEqualFold(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldEqualFold(FieldInvoiceDueAfter, vc)) } -// InvoiceDueAfterSecondsLTE applies the LTE predicate on the "invoice_due_after_seconds" field. -func InvoiceDueAfterSecondsLTE(v int64) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldLTE(FieldInvoiceDueAfterSeconds, v)) +// InvoiceDueAfterContainsFold applies the ContainsFold predicate on the "invoice_due_after" field. +func InvoiceDueAfterContainsFold(v datex.ISOString) predicate.BillingWorkflowConfig { + vc := string(v) + return predicate.BillingWorkflowConfig(sql.FieldContainsFold(FieldInvoiceDueAfter, vc)) } // InvoiceCollectionMethodEQ applies the EQ predicate on the "invoice_collection_method" field. -func InvoiceCollectionMethodEQ(v billing.CollectionMethod) predicate.BillingWorkflowConfig { +func InvoiceCollectionMethodEQ(v billingentity.CollectionMethod) predicate.BillingWorkflowConfig { vc := v return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceCollectionMethod, vc)) } // InvoiceCollectionMethodNEQ applies the NEQ predicate on the "invoice_collection_method" field. -func InvoiceCollectionMethodNEQ(v billing.CollectionMethod) predicate.BillingWorkflowConfig { +func InvoiceCollectionMethodNEQ(v billingentity.CollectionMethod) predicate.BillingWorkflowConfig { vc := v return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldInvoiceCollectionMethod, vc)) } // InvoiceCollectionMethodIn applies the In predicate on the "invoice_collection_method" field. -func InvoiceCollectionMethodIn(vs ...billing.CollectionMethod) predicate.BillingWorkflowConfig { +func InvoiceCollectionMethodIn(vs ...billingentity.CollectionMethod) predicate.BillingWorkflowConfig { v := make([]any, len(vs)) for i := range v { v[i] = vs[i] @@ -589,7 +619,7 @@ func InvoiceCollectionMethodIn(vs ...billing.CollectionMethod) predicate.Billing } // InvoiceCollectionMethodNotIn applies the NotIn predicate on the "invoice_collection_method" field. -func InvoiceCollectionMethodNotIn(vs ...billing.CollectionMethod) predicate.BillingWorkflowConfig { +func InvoiceCollectionMethodNotIn(vs ...billingentity.CollectionMethod) predicate.BillingWorkflowConfig { v := make([]any, len(vs)) for i := range v { v[i] = vs[i] @@ -597,46 +627,6 @@ func InvoiceCollectionMethodNotIn(vs ...billing.CollectionMethod) predicate.Bill return predicate.BillingWorkflowConfig(sql.FieldNotIn(FieldInvoiceCollectionMethod, v...)) } -// InvoiceItemResolutionEQ applies the EQ predicate on the "invoice_item_resolution" field. -func InvoiceItemResolutionEQ(v billing.GranularityResolution) predicate.BillingWorkflowConfig { - vc := v - return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceItemResolution, vc)) -} - -// InvoiceItemResolutionNEQ applies the NEQ predicate on the "invoice_item_resolution" field. -func InvoiceItemResolutionNEQ(v billing.GranularityResolution) predicate.BillingWorkflowConfig { - vc := v - return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldInvoiceItemResolution, vc)) -} - -// InvoiceItemResolutionIn applies the In predicate on the "invoice_item_resolution" field. -func InvoiceItemResolutionIn(vs ...billing.GranularityResolution) predicate.BillingWorkflowConfig { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingWorkflowConfig(sql.FieldIn(FieldInvoiceItemResolution, v...)) -} - -// InvoiceItemResolutionNotIn applies the NotIn predicate on the "invoice_item_resolution" field. -func InvoiceItemResolutionNotIn(vs ...billing.GranularityResolution) predicate.BillingWorkflowConfig { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.BillingWorkflowConfig(sql.FieldNotIn(FieldInvoiceItemResolution, v...)) -} - -// InvoiceItemPerSubjectEQ applies the EQ predicate on the "invoice_item_per_subject" field. -func InvoiceItemPerSubjectEQ(v bool) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldEQ(FieldInvoiceItemPerSubject, v)) -} - -// InvoiceItemPerSubjectNEQ applies the NEQ predicate on the "invoice_item_per_subject" field. -func InvoiceItemPerSubjectNEQ(v bool) predicate.BillingWorkflowConfig { - return predicate.BillingWorkflowConfig(sql.FieldNEQ(FieldInvoiceItemPerSubject, v)) -} - // HasBillingInvoices applies the HasEdge predicate on the "billing_invoices" edge. func HasBillingInvoices() predicate.BillingWorkflowConfig { return predicate.BillingWorkflowConfig(func(s *sql.Selector) { diff --git a/openmeter/ent/db/billingworkflowconfig_create.go b/openmeter/ent/db/billingworkflowconfig_create.go index 73e13d59a..a17d7970b 100644 --- a/openmeter/ent/db/billingworkflowconfig_create.go +++ b/openmeter/ent/db/billingworkflowconfig_create.go @@ -12,11 +12,11 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoice" "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" "github.com/openmeterio/openmeter/openmeter/ent/db/billingworkflowconfig" - "github.com/openmeterio/openmeter/pkg/timezone" + "github.com/openmeterio/openmeter/pkg/datex" ) // BillingWorkflowConfigCreate is the builder for creating a BillingWorkflowConfig entity. @@ -75,29 +75,15 @@ func (bwcc *BillingWorkflowConfigCreate) SetNillableDeletedAt(t *time.Time) *Bil return bwcc } -// SetTimezone sets the "timezone" field. -func (bwcc *BillingWorkflowConfigCreate) SetTimezone(t timezone.Timezone) *BillingWorkflowConfigCreate { - bwcc.mutation.SetTimezone(t) - return bwcc -} - -// SetNillableTimezone sets the "timezone" field if the given value is not nil. -func (bwcc *BillingWorkflowConfigCreate) SetNillableTimezone(t *timezone.Timezone) *BillingWorkflowConfigCreate { - if t != nil { - bwcc.SetTimezone(*t) - } - return bwcc -} - // SetCollectionAlignment sets the "collection_alignment" field. -func (bwcc *BillingWorkflowConfigCreate) SetCollectionAlignment(bk billing.AlignmentKind) *BillingWorkflowConfigCreate { +func (bwcc *BillingWorkflowConfigCreate) SetCollectionAlignment(bk billingentity.AlignmentKind) *BillingWorkflowConfigCreate { bwcc.mutation.SetCollectionAlignment(bk) return bwcc } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (bwcc *BillingWorkflowConfigCreate) SetItemCollectionPeriodSeconds(i int64) *BillingWorkflowConfigCreate { - bwcc.mutation.SetItemCollectionPeriodSeconds(i) +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (bwcc *BillingWorkflowConfigCreate) SetItemCollectionPeriod(ds datex.ISOString) *BillingWorkflowConfigCreate { + bwcc.mutation.SetItemCollectionPeriod(ds) return bwcc } @@ -107,36 +93,24 @@ func (bwcc *BillingWorkflowConfigCreate) SetInvoiceAutoAdvance(b bool) *BillingW return bwcc } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (bwcc *BillingWorkflowConfigCreate) SetInvoiceDraftPeriodSeconds(i int64) *BillingWorkflowConfigCreate { - bwcc.mutation.SetInvoiceDraftPeriodSeconds(i) +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (bwcc *BillingWorkflowConfigCreate) SetInvoiceDraftPeriod(ds datex.ISOString) *BillingWorkflowConfigCreate { + bwcc.mutation.SetInvoiceDraftPeriod(ds) return bwcc } -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (bwcc *BillingWorkflowConfigCreate) SetInvoiceDueAfterSeconds(i int64) *BillingWorkflowConfigCreate { - bwcc.mutation.SetInvoiceDueAfterSeconds(i) +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (bwcc *BillingWorkflowConfigCreate) SetInvoiceDueAfter(ds datex.ISOString) *BillingWorkflowConfigCreate { + bwcc.mutation.SetInvoiceDueAfter(ds) return bwcc } // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (bwcc *BillingWorkflowConfigCreate) SetInvoiceCollectionMethod(bm billing.CollectionMethod) *BillingWorkflowConfigCreate { +func (bwcc *BillingWorkflowConfigCreate) SetInvoiceCollectionMethod(bm billingentity.CollectionMethod) *BillingWorkflowConfigCreate { bwcc.mutation.SetInvoiceCollectionMethod(bm) return bwcc } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (bwcc *BillingWorkflowConfigCreate) SetInvoiceItemResolution(br billing.GranularityResolution) *BillingWorkflowConfigCreate { - bwcc.mutation.SetInvoiceItemResolution(br) - return bwcc -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (bwcc *BillingWorkflowConfigCreate) SetInvoiceItemPerSubject(b bool) *BillingWorkflowConfigCreate { - bwcc.mutation.SetInvoiceItemPerSubject(b) - return bwcc -} - // SetID sets the "id" field. func (bwcc *BillingWorkflowConfigCreate) SetID(s string) *BillingWorkflowConfigCreate { bwcc.mutation.SetID(s) @@ -262,17 +236,17 @@ func (bwcc *BillingWorkflowConfigCreate) check() error { return &ValidationError{Name: "collection_alignment", err: fmt.Errorf(`db: validator failed for field "BillingWorkflowConfig.collection_alignment": %w`, err)} } } - if _, ok := bwcc.mutation.ItemCollectionPeriodSeconds(); !ok { - return &ValidationError{Name: "item_collection_period_seconds", err: errors.New(`db: missing required field "BillingWorkflowConfig.item_collection_period_seconds"`)} + if _, ok := bwcc.mutation.ItemCollectionPeriod(); !ok { + return &ValidationError{Name: "item_collection_period", err: errors.New(`db: missing required field "BillingWorkflowConfig.item_collection_period"`)} } if _, ok := bwcc.mutation.InvoiceAutoAdvance(); !ok { return &ValidationError{Name: "invoice_auto_advance", err: errors.New(`db: missing required field "BillingWorkflowConfig.invoice_auto_advance"`)} } - if _, ok := bwcc.mutation.InvoiceDraftPeriodSeconds(); !ok { - return &ValidationError{Name: "invoice_draft_period_seconds", err: errors.New(`db: missing required field "BillingWorkflowConfig.invoice_draft_period_seconds"`)} + if _, ok := bwcc.mutation.InvoiceDraftPeriod(); !ok { + return &ValidationError{Name: "invoice_draft_period", err: errors.New(`db: missing required field "BillingWorkflowConfig.invoice_draft_period"`)} } - if _, ok := bwcc.mutation.InvoiceDueAfterSeconds(); !ok { - return &ValidationError{Name: "invoice_due_after_seconds", err: errors.New(`db: missing required field "BillingWorkflowConfig.invoice_due_after_seconds"`)} + if _, ok := bwcc.mutation.InvoiceDueAfter(); !ok { + return &ValidationError{Name: "invoice_due_after", err: errors.New(`db: missing required field "BillingWorkflowConfig.invoice_due_after"`)} } if _, ok := bwcc.mutation.InvoiceCollectionMethod(); !ok { return &ValidationError{Name: "invoice_collection_method", err: errors.New(`db: missing required field "BillingWorkflowConfig.invoice_collection_method"`)} @@ -282,17 +256,6 @@ func (bwcc *BillingWorkflowConfigCreate) check() error { return &ValidationError{Name: "invoice_collection_method", err: fmt.Errorf(`db: validator failed for field "BillingWorkflowConfig.invoice_collection_method": %w`, err)} } } - if _, ok := bwcc.mutation.InvoiceItemResolution(); !ok { - return &ValidationError{Name: "invoice_item_resolution", err: errors.New(`db: missing required field "BillingWorkflowConfig.invoice_item_resolution"`)} - } - if v, ok := bwcc.mutation.InvoiceItemResolution(); ok { - if err := billingworkflowconfig.InvoiceItemResolutionValidator(v); err != nil { - return &ValidationError{Name: "invoice_item_resolution", err: fmt.Errorf(`db: validator failed for field "BillingWorkflowConfig.invoice_item_resolution": %w`, err)} - } - } - if _, ok := bwcc.mutation.InvoiceItemPerSubject(); !ok { - return &ValidationError{Name: "invoice_item_per_subject", err: errors.New(`db: missing required field "BillingWorkflowConfig.invoice_item_per_subject"`)} - } return nil } @@ -345,42 +308,30 @@ func (bwcc *BillingWorkflowConfigCreate) createSpec() (*BillingWorkflowConfig, * _spec.SetField(billingworkflowconfig.FieldDeletedAt, field.TypeTime, value) _node.DeletedAt = &value } - if value, ok := bwcc.mutation.Timezone(); ok { - _spec.SetField(billingworkflowconfig.FieldTimezone, field.TypeString, value) - _node.Timezone = &value - } if value, ok := bwcc.mutation.CollectionAlignment(); ok { _spec.SetField(billingworkflowconfig.FieldCollectionAlignment, field.TypeEnum, value) _node.CollectionAlignment = value } - if value, ok := bwcc.mutation.ItemCollectionPeriodSeconds(); ok { - _spec.SetField(billingworkflowconfig.FieldItemCollectionPeriodSeconds, field.TypeInt64, value) - _node.ItemCollectionPeriodSeconds = value + if value, ok := bwcc.mutation.ItemCollectionPeriod(); ok { + _spec.SetField(billingworkflowconfig.FieldItemCollectionPeriod, field.TypeString, value) + _node.ItemCollectionPeriod = value } if value, ok := bwcc.mutation.InvoiceAutoAdvance(); ok { _spec.SetField(billingworkflowconfig.FieldInvoiceAutoAdvance, field.TypeBool, value) _node.InvoiceAutoAdvance = value } - if value, ok := bwcc.mutation.InvoiceDraftPeriodSeconds(); ok { - _spec.SetField(billingworkflowconfig.FieldInvoiceDraftPeriodSeconds, field.TypeInt64, value) - _node.InvoiceDraftPeriodSeconds = value + if value, ok := bwcc.mutation.InvoiceDraftPeriod(); ok { + _spec.SetField(billingworkflowconfig.FieldInvoiceDraftPeriod, field.TypeString, value) + _node.InvoiceDraftPeriod = value } - if value, ok := bwcc.mutation.InvoiceDueAfterSeconds(); ok { - _spec.SetField(billingworkflowconfig.FieldInvoiceDueAfterSeconds, field.TypeInt64, value) - _node.InvoiceDueAfterSeconds = value + if value, ok := bwcc.mutation.InvoiceDueAfter(); ok { + _spec.SetField(billingworkflowconfig.FieldInvoiceDueAfter, field.TypeString, value) + _node.InvoiceDueAfter = value } if value, ok := bwcc.mutation.InvoiceCollectionMethod(); ok { _spec.SetField(billingworkflowconfig.FieldInvoiceCollectionMethod, field.TypeEnum, value) _node.InvoiceCollectionMethod = value } - if value, ok := bwcc.mutation.InvoiceItemResolution(); ok { - _spec.SetField(billingworkflowconfig.FieldInvoiceItemResolution, field.TypeEnum, value) - _node.InvoiceItemResolution = value - } - if value, ok := bwcc.mutation.InvoiceItemPerSubject(); ok { - _spec.SetField(billingworkflowconfig.FieldInvoiceItemPerSubject, field.TypeBool, value) - _node.InvoiceItemPerSubject = value - } if nodes := bwcc.mutation.BillingInvoicesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2O, @@ -495,26 +446,8 @@ func (u *BillingWorkflowConfigUpsert) ClearDeletedAt() *BillingWorkflowConfigUps return u } -// SetTimezone sets the "timezone" field. -func (u *BillingWorkflowConfigUpsert) SetTimezone(v timezone.Timezone) *BillingWorkflowConfigUpsert { - u.Set(billingworkflowconfig.FieldTimezone, v) - return u -} - -// UpdateTimezone sets the "timezone" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsert) UpdateTimezone() *BillingWorkflowConfigUpsert { - u.SetExcluded(billingworkflowconfig.FieldTimezone) - return u -} - -// ClearTimezone clears the value of the "timezone" field. -func (u *BillingWorkflowConfigUpsert) ClearTimezone() *BillingWorkflowConfigUpsert { - u.SetNull(billingworkflowconfig.FieldTimezone) - return u -} - // SetCollectionAlignment sets the "collection_alignment" field. -func (u *BillingWorkflowConfigUpsert) SetCollectionAlignment(v billing.AlignmentKind) *BillingWorkflowConfigUpsert { +func (u *BillingWorkflowConfigUpsert) SetCollectionAlignment(v billingentity.AlignmentKind) *BillingWorkflowConfigUpsert { u.Set(billingworkflowconfig.FieldCollectionAlignment, v) return u } @@ -525,21 +458,15 @@ func (u *BillingWorkflowConfigUpsert) UpdateCollectionAlignment() *BillingWorkfl return u } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (u *BillingWorkflowConfigUpsert) SetItemCollectionPeriodSeconds(v int64) *BillingWorkflowConfigUpsert { - u.Set(billingworkflowconfig.FieldItemCollectionPeriodSeconds, v) - return u -} - -// UpdateItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsert) UpdateItemCollectionPeriodSeconds() *BillingWorkflowConfigUpsert { - u.SetExcluded(billingworkflowconfig.FieldItemCollectionPeriodSeconds) +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (u *BillingWorkflowConfigUpsert) SetItemCollectionPeriod(v datex.ISOString) *BillingWorkflowConfigUpsert { + u.Set(billingworkflowconfig.FieldItemCollectionPeriod, v) return u } -// AddItemCollectionPeriodSeconds adds v to the "item_collection_period_seconds" field. -func (u *BillingWorkflowConfigUpsert) AddItemCollectionPeriodSeconds(v int64) *BillingWorkflowConfigUpsert { - u.Add(billingworkflowconfig.FieldItemCollectionPeriodSeconds, v) +// UpdateItemCollectionPeriod sets the "item_collection_period" field to the value that was provided on create. +func (u *BillingWorkflowConfigUpsert) UpdateItemCollectionPeriod() *BillingWorkflowConfigUpsert { + u.SetExcluded(billingworkflowconfig.FieldItemCollectionPeriod) return u } @@ -555,44 +482,32 @@ func (u *BillingWorkflowConfigUpsert) UpdateInvoiceAutoAdvance() *BillingWorkflo return u } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (u *BillingWorkflowConfigUpsert) SetInvoiceDraftPeriodSeconds(v int64) *BillingWorkflowConfigUpsert { - u.Set(billingworkflowconfig.FieldInvoiceDraftPeriodSeconds, v) +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (u *BillingWorkflowConfigUpsert) SetInvoiceDraftPeriod(v datex.ISOString) *BillingWorkflowConfigUpsert { + u.Set(billingworkflowconfig.FieldInvoiceDraftPeriod, v) return u } -// UpdateInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsert) UpdateInvoiceDraftPeriodSeconds() *BillingWorkflowConfigUpsert { - u.SetExcluded(billingworkflowconfig.FieldInvoiceDraftPeriodSeconds) +// UpdateInvoiceDraftPeriod sets the "invoice_draft_period" field to the value that was provided on create. +func (u *BillingWorkflowConfigUpsert) UpdateInvoiceDraftPeriod() *BillingWorkflowConfigUpsert { + u.SetExcluded(billingworkflowconfig.FieldInvoiceDraftPeriod) return u } -// AddInvoiceDraftPeriodSeconds adds v to the "invoice_draft_period_seconds" field. -func (u *BillingWorkflowConfigUpsert) AddInvoiceDraftPeriodSeconds(v int64) *BillingWorkflowConfigUpsert { - u.Add(billingworkflowconfig.FieldInvoiceDraftPeriodSeconds, v) +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (u *BillingWorkflowConfigUpsert) SetInvoiceDueAfter(v datex.ISOString) *BillingWorkflowConfigUpsert { + u.Set(billingworkflowconfig.FieldInvoiceDueAfter, v) return u } -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (u *BillingWorkflowConfigUpsert) SetInvoiceDueAfterSeconds(v int64) *BillingWorkflowConfigUpsert { - u.Set(billingworkflowconfig.FieldInvoiceDueAfterSeconds, v) - return u -} - -// UpdateInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsert) UpdateInvoiceDueAfterSeconds() *BillingWorkflowConfigUpsert { - u.SetExcluded(billingworkflowconfig.FieldInvoiceDueAfterSeconds) - return u -} - -// AddInvoiceDueAfterSeconds adds v to the "invoice_due_after_seconds" field. -func (u *BillingWorkflowConfigUpsert) AddInvoiceDueAfterSeconds(v int64) *BillingWorkflowConfigUpsert { - u.Add(billingworkflowconfig.FieldInvoiceDueAfterSeconds, v) +// UpdateInvoiceDueAfter sets the "invoice_due_after" field to the value that was provided on create. +func (u *BillingWorkflowConfigUpsert) UpdateInvoiceDueAfter() *BillingWorkflowConfigUpsert { + u.SetExcluded(billingworkflowconfig.FieldInvoiceDueAfter) return u } // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (u *BillingWorkflowConfigUpsert) SetInvoiceCollectionMethod(v billing.CollectionMethod) *BillingWorkflowConfigUpsert { +func (u *BillingWorkflowConfigUpsert) SetInvoiceCollectionMethod(v billingentity.CollectionMethod) *BillingWorkflowConfigUpsert { u.Set(billingworkflowconfig.FieldInvoiceCollectionMethod, v) return u } @@ -603,30 +518,6 @@ func (u *BillingWorkflowConfigUpsert) UpdateInvoiceCollectionMethod() *BillingWo return u } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (u *BillingWorkflowConfigUpsert) SetInvoiceItemResolution(v billing.GranularityResolution) *BillingWorkflowConfigUpsert { - u.Set(billingworkflowconfig.FieldInvoiceItemResolution, v) - return u -} - -// UpdateInvoiceItemResolution sets the "invoice_item_resolution" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsert) UpdateInvoiceItemResolution() *BillingWorkflowConfigUpsert { - u.SetExcluded(billingworkflowconfig.FieldInvoiceItemResolution) - return u -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (u *BillingWorkflowConfigUpsert) SetInvoiceItemPerSubject(v bool) *BillingWorkflowConfigUpsert { - u.Set(billingworkflowconfig.FieldInvoiceItemPerSubject, v) - return u -} - -// UpdateInvoiceItemPerSubject sets the "invoice_item_per_subject" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsert) UpdateInvoiceItemPerSubject() *BillingWorkflowConfigUpsert { - u.SetExcluded(billingworkflowconfig.FieldInvoiceItemPerSubject) - return u -} - // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // @@ -716,29 +607,8 @@ func (u *BillingWorkflowConfigUpsertOne) ClearDeletedAt() *BillingWorkflowConfig }) } -// SetTimezone sets the "timezone" field. -func (u *BillingWorkflowConfigUpsertOne) SetTimezone(v timezone.Timezone) *BillingWorkflowConfigUpsertOne { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.SetTimezone(v) - }) -} - -// UpdateTimezone sets the "timezone" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsertOne) UpdateTimezone() *BillingWorkflowConfigUpsertOne { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.UpdateTimezone() - }) -} - -// ClearTimezone clears the value of the "timezone" field. -func (u *BillingWorkflowConfigUpsertOne) ClearTimezone() *BillingWorkflowConfigUpsertOne { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.ClearTimezone() - }) -} - // SetCollectionAlignment sets the "collection_alignment" field. -func (u *BillingWorkflowConfigUpsertOne) SetCollectionAlignment(v billing.AlignmentKind) *BillingWorkflowConfigUpsertOne { +func (u *BillingWorkflowConfigUpsertOne) SetCollectionAlignment(v billingentity.AlignmentKind) *BillingWorkflowConfigUpsertOne { return u.Update(func(s *BillingWorkflowConfigUpsert) { s.SetCollectionAlignment(v) }) @@ -751,24 +621,17 @@ func (u *BillingWorkflowConfigUpsertOne) UpdateCollectionAlignment() *BillingWor }) } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (u *BillingWorkflowConfigUpsertOne) SetItemCollectionPeriodSeconds(v int64) *BillingWorkflowConfigUpsertOne { +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (u *BillingWorkflowConfigUpsertOne) SetItemCollectionPeriod(v datex.ISOString) *BillingWorkflowConfigUpsertOne { return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.SetItemCollectionPeriodSeconds(v) + s.SetItemCollectionPeriod(v) }) } -// AddItemCollectionPeriodSeconds adds v to the "item_collection_period_seconds" field. -func (u *BillingWorkflowConfigUpsertOne) AddItemCollectionPeriodSeconds(v int64) *BillingWorkflowConfigUpsertOne { +// UpdateItemCollectionPeriod sets the "item_collection_period" field to the value that was provided on create. +func (u *BillingWorkflowConfigUpsertOne) UpdateItemCollectionPeriod() *BillingWorkflowConfigUpsertOne { return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.AddItemCollectionPeriodSeconds(v) - }) -} - -// UpdateItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsertOne) UpdateItemCollectionPeriodSeconds() *BillingWorkflowConfigUpsertOne { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.UpdateItemCollectionPeriodSeconds() + s.UpdateItemCollectionPeriod() }) } @@ -786,50 +649,36 @@ func (u *BillingWorkflowConfigUpsertOne) UpdateInvoiceAutoAdvance() *BillingWork }) } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (u *BillingWorkflowConfigUpsertOne) SetInvoiceDraftPeriodSeconds(v int64) *BillingWorkflowConfigUpsertOne { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.SetInvoiceDraftPeriodSeconds(v) - }) -} - -// AddInvoiceDraftPeriodSeconds adds v to the "invoice_draft_period_seconds" field. -func (u *BillingWorkflowConfigUpsertOne) AddInvoiceDraftPeriodSeconds(v int64) *BillingWorkflowConfigUpsertOne { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.AddInvoiceDraftPeriodSeconds(v) - }) -} - -// UpdateInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsertOne) UpdateInvoiceDraftPeriodSeconds() *BillingWorkflowConfigUpsertOne { +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (u *BillingWorkflowConfigUpsertOne) SetInvoiceDraftPeriod(v datex.ISOString) *BillingWorkflowConfigUpsertOne { return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.UpdateInvoiceDraftPeriodSeconds() + s.SetInvoiceDraftPeriod(v) }) } -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (u *BillingWorkflowConfigUpsertOne) SetInvoiceDueAfterSeconds(v int64) *BillingWorkflowConfigUpsertOne { +// UpdateInvoiceDraftPeriod sets the "invoice_draft_period" field to the value that was provided on create. +func (u *BillingWorkflowConfigUpsertOne) UpdateInvoiceDraftPeriod() *BillingWorkflowConfigUpsertOne { return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.SetInvoiceDueAfterSeconds(v) + s.UpdateInvoiceDraftPeriod() }) } -// AddInvoiceDueAfterSeconds adds v to the "invoice_due_after_seconds" field. -func (u *BillingWorkflowConfigUpsertOne) AddInvoiceDueAfterSeconds(v int64) *BillingWorkflowConfigUpsertOne { +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (u *BillingWorkflowConfigUpsertOne) SetInvoiceDueAfter(v datex.ISOString) *BillingWorkflowConfigUpsertOne { return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.AddInvoiceDueAfterSeconds(v) + s.SetInvoiceDueAfter(v) }) } -// UpdateInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsertOne) UpdateInvoiceDueAfterSeconds() *BillingWorkflowConfigUpsertOne { +// UpdateInvoiceDueAfter sets the "invoice_due_after" field to the value that was provided on create. +func (u *BillingWorkflowConfigUpsertOne) UpdateInvoiceDueAfter() *BillingWorkflowConfigUpsertOne { return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.UpdateInvoiceDueAfterSeconds() + s.UpdateInvoiceDueAfter() }) } // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (u *BillingWorkflowConfigUpsertOne) SetInvoiceCollectionMethod(v billing.CollectionMethod) *BillingWorkflowConfigUpsertOne { +func (u *BillingWorkflowConfigUpsertOne) SetInvoiceCollectionMethod(v billingentity.CollectionMethod) *BillingWorkflowConfigUpsertOne { return u.Update(func(s *BillingWorkflowConfigUpsert) { s.SetInvoiceCollectionMethod(v) }) @@ -842,34 +691,6 @@ func (u *BillingWorkflowConfigUpsertOne) UpdateInvoiceCollectionMethod() *Billin }) } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (u *BillingWorkflowConfigUpsertOne) SetInvoiceItemResolution(v billing.GranularityResolution) *BillingWorkflowConfigUpsertOne { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.SetInvoiceItemResolution(v) - }) -} - -// UpdateInvoiceItemResolution sets the "invoice_item_resolution" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsertOne) UpdateInvoiceItemResolution() *BillingWorkflowConfigUpsertOne { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.UpdateInvoiceItemResolution() - }) -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (u *BillingWorkflowConfigUpsertOne) SetInvoiceItemPerSubject(v bool) *BillingWorkflowConfigUpsertOne { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.SetInvoiceItemPerSubject(v) - }) -} - -// UpdateInvoiceItemPerSubject sets the "invoice_item_per_subject" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsertOne) UpdateInvoiceItemPerSubject() *BillingWorkflowConfigUpsertOne { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.UpdateInvoiceItemPerSubject() - }) -} - // Exec executes the query. func (u *BillingWorkflowConfigUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -1126,29 +947,8 @@ func (u *BillingWorkflowConfigUpsertBulk) ClearDeletedAt() *BillingWorkflowConfi }) } -// SetTimezone sets the "timezone" field. -func (u *BillingWorkflowConfigUpsertBulk) SetTimezone(v timezone.Timezone) *BillingWorkflowConfigUpsertBulk { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.SetTimezone(v) - }) -} - -// UpdateTimezone sets the "timezone" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsertBulk) UpdateTimezone() *BillingWorkflowConfigUpsertBulk { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.UpdateTimezone() - }) -} - -// ClearTimezone clears the value of the "timezone" field. -func (u *BillingWorkflowConfigUpsertBulk) ClearTimezone() *BillingWorkflowConfigUpsertBulk { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.ClearTimezone() - }) -} - // SetCollectionAlignment sets the "collection_alignment" field. -func (u *BillingWorkflowConfigUpsertBulk) SetCollectionAlignment(v billing.AlignmentKind) *BillingWorkflowConfigUpsertBulk { +func (u *BillingWorkflowConfigUpsertBulk) SetCollectionAlignment(v billingentity.AlignmentKind) *BillingWorkflowConfigUpsertBulk { return u.Update(func(s *BillingWorkflowConfigUpsert) { s.SetCollectionAlignment(v) }) @@ -1161,24 +961,17 @@ func (u *BillingWorkflowConfigUpsertBulk) UpdateCollectionAlignment() *BillingWo }) } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (u *BillingWorkflowConfigUpsertBulk) SetItemCollectionPeriodSeconds(v int64) *BillingWorkflowConfigUpsertBulk { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.SetItemCollectionPeriodSeconds(v) - }) -} - -// AddItemCollectionPeriodSeconds adds v to the "item_collection_period_seconds" field. -func (u *BillingWorkflowConfigUpsertBulk) AddItemCollectionPeriodSeconds(v int64) *BillingWorkflowConfigUpsertBulk { +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (u *BillingWorkflowConfigUpsertBulk) SetItemCollectionPeriod(v datex.ISOString) *BillingWorkflowConfigUpsertBulk { return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.AddItemCollectionPeriodSeconds(v) + s.SetItemCollectionPeriod(v) }) } -// UpdateItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsertBulk) UpdateItemCollectionPeriodSeconds() *BillingWorkflowConfigUpsertBulk { +// UpdateItemCollectionPeriod sets the "item_collection_period" field to the value that was provided on create. +func (u *BillingWorkflowConfigUpsertBulk) UpdateItemCollectionPeriod() *BillingWorkflowConfigUpsertBulk { return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.UpdateItemCollectionPeriodSeconds() + s.UpdateItemCollectionPeriod() }) } @@ -1196,50 +989,36 @@ func (u *BillingWorkflowConfigUpsertBulk) UpdateInvoiceAutoAdvance() *BillingWor }) } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (u *BillingWorkflowConfigUpsertBulk) SetInvoiceDraftPeriodSeconds(v int64) *BillingWorkflowConfigUpsertBulk { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.SetInvoiceDraftPeriodSeconds(v) - }) -} - -// AddInvoiceDraftPeriodSeconds adds v to the "invoice_draft_period_seconds" field. -func (u *BillingWorkflowConfigUpsertBulk) AddInvoiceDraftPeriodSeconds(v int64) *BillingWorkflowConfigUpsertBulk { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.AddInvoiceDraftPeriodSeconds(v) - }) -} - -// UpdateInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsertBulk) UpdateInvoiceDraftPeriodSeconds() *BillingWorkflowConfigUpsertBulk { +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (u *BillingWorkflowConfigUpsertBulk) SetInvoiceDraftPeriod(v datex.ISOString) *BillingWorkflowConfigUpsertBulk { return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.UpdateInvoiceDraftPeriodSeconds() + s.SetInvoiceDraftPeriod(v) }) } -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (u *BillingWorkflowConfigUpsertBulk) SetInvoiceDueAfterSeconds(v int64) *BillingWorkflowConfigUpsertBulk { +// UpdateInvoiceDraftPeriod sets the "invoice_draft_period" field to the value that was provided on create. +func (u *BillingWorkflowConfigUpsertBulk) UpdateInvoiceDraftPeriod() *BillingWorkflowConfigUpsertBulk { return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.SetInvoiceDueAfterSeconds(v) + s.UpdateInvoiceDraftPeriod() }) } -// AddInvoiceDueAfterSeconds adds v to the "invoice_due_after_seconds" field. -func (u *BillingWorkflowConfigUpsertBulk) AddInvoiceDueAfterSeconds(v int64) *BillingWorkflowConfigUpsertBulk { +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (u *BillingWorkflowConfigUpsertBulk) SetInvoiceDueAfter(v datex.ISOString) *BillingWorkflowConfigUpsertBulk { return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.AddInvoiceDueAfterSeconds(v) + s.SetInvoiceDueAfter(v) }) } -// UpdateInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsertBulk) UpdateInvoiceDueAfterSeconds() *BillingWorkflowConfigUpsertBulk { +// UpdateInvoiceDueAfter sets the "invoice_due_after" field to the value that was provided on create. +func (u *BillingWorkflowConfigUpsertBulk) UpdateInvoiceDueAfter() *BillingWorkflowConfigUpsertBulk { return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.UpdateInvoiceDueAfterSeconds() + s.UpdateInvoiceDueAfter() }) } // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (u *BillingWorkflowConfigUpsertBulk) SetInvoiceCollectionMethod(v billing.CollectionMethod) *BillingWorkflowConfigUpsertBulk { +func (u *BillingWorkflowConfigUpsertBulk) SetInvoiceCollectionMethod(v billingentity.CollectionMethod) *BillingWorkflowConfigUpsertBulk { return u.Update(func(s *BillingWorkflowConfigUpsert) { s.SetInvoiceCollectionMethod(v) }) @@ -1252,34 +1031,6 @@ func (u *BillingWorkflowConfigUpsertBulk) UpdateInvoiceCollectionMethod() *Billi }) } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (u *BillingWorkflowConfigUpsertBulk) SetInvoiceItemResolution(v billing.GranularityResolution) *BillingWorkflowConfigUpsertBulk { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.SetInvoiceItemResolution(v) - }) -} - -// UpdateInvoiceItemResolution sets the "invoice_item_resolution" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsertBulk) UpdateInvoiceItemResolution() *BillingWorkflowConfigUpsertBulk { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.UpdateInvoiceItemResolution() - }) -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (u *BillingWorkflowConfigUpsertBulk) SetInvoiceItemPerSubject(v bool) *BillingWorkflowConfigUpsertBulk { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.SetInvoiceItemPerSubject(v) - }) -} - -// UpdateInvoiceItemPerSubject sets the "invoice_item_per_subject" field to the value that was provided on create. -func (u *BillingWorkflowConfigUpsertBulk) UpdateInvoiceItemPerSubject() *BillingWorkflowConfigUpsertBulk { - return u.Update(func(s *BillingWorkflowConfigUpsert) { - s.UpdateInvoiceItemPerSubject() - }) -} - // Exec executes the query. func (u *BillingWorkflowConfigUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/openmeter/ent/db/billingworkflowconfig_update.go b/openmeter/ent/db/billingworkflowconfig_update.go index aac27aca7..a1f0b04ef 100644 --- a/openmeter/ent/db/billingworkflowconfig_update.go +++ b/openmeter/ent/db/billingworkflowconfig_update.go @@ -11,12 +11,12 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/ent/db/billinginvoice" "github.com/openmeterio/openmeter/openmeter/ent/db/billingprofile" "github.com/openmeterio/openmeter/openmeter/ent/db/billingworkflowconfig" "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" - "github.com/openmeterio/openmeter/pkg/timezone" + "github.com/openmeterio/openmeter/pkg/datex" ) // BillingWorkflowConfigUpdate is the builder for updating BillingWorkflowConfig entities. @@ -58,61 +58,34 @@ func (bwcu *BillingWorkflowConfigUpdate) ClearDeletedAt() *BillingWorkflowConfig return bwcu } -// SetTimezone sets the "timezone" field. -func (bwcu *BillingWorkflowConfigUpdate) SetTimezone(t timezone.Timezone) *BillingWorkflowConfigUpdate { - bwcu.mutation.SetTimezone(t) - return bwcu -} - -// SetNillableTimezone sets the "timezone" field if the given value is not nil. -func (bwcu *BillingWorkflowConfigUpdate) SetNillableTimezone(t *timezone.Timezone) *BillingWorkflowConfigUpdate { - if t != nil { - bwcu.SetTimezone(*t) - } - return bwcu -} - -// ClearTimezone clears the value of the "timezone" field. -func (bwcu *BillingWorkflowConfigUpdate) ClearTimezone() *BillingWorkflowConfigUpdate { - bwcu.mutation.ClearTimezone() - return bwcu -} - // SetCollectionAlignment sets the "collection_alignment" field. -func (bwcu *BillingWorkflowConfigUpdate) SetCollectionAlignment(bk billing.AlignmentKind) *BillingWorkflowConfigUpdate { +func (bwcu *BillingWorkflowConfigUpdate) SetCollectionAlignment(bk billingentity.AlignmentKind) *BillingWorkflowConfigUpdate { bwcu.mutation.SetCollectionAlignment(bk) return bwcu } // SetNillableCollectionAlignment sets the "collection_alignment" field if the given value is not nil. -func (bwcu *BillingWorkflowConfigUpdate) SetNillableCollectionAlignment(bk *billing.AlignmentKind) *BillingWorkflowConfigUpdate { +func (bwcu *BillingWorkflowConfigUpdate) SetNillableCollectionAlignment(bk *billingentity.AlignmentKind) *BillingWorkflowConfigUpdate { if bk != nil { bwcu.SetCollectionAlignment(*bk) } return bwcu } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (bwcu *BillingWorkflowConfigUpdate) SetItemCollectionPeriodSeconds(i int64) *BillingWorkflowConfigUpdate { - bwcu.mutation.ResetItemCollectionPeriodSeconds() - bwcu.mutation.SetItemCollectionPeriodSeconds(i) +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (bwcu *BillingWorkflowConfigUpdate) SetItemCollectionPeriod(ds datex.ISOString) *BillingWorkflowConfigUpdate { + bwcu.mutation.SetItemCollectionPeriod(ds) return bwcu } -// SetNillableItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field if the given value is not nil. -func (bwcu *BillingWorkflowConfigUpdate) SetNillableItemCollectionPeriodSeconds(i *int64) *BillingWorkflowConfigUpdate { - if i != nil { - bwcu.SetItemCollectionPeriodSeconds(*i) +// SetNillableItemCollectionPeriod sets the "item_collection_period" field if the given value is not nil. +func (bwcu *BillingWorkflowConfigUpdate) SetNillableItemCollectionPeriod(ds *datex.ISOString) *BillingWorkflowConfigUpdate { + if ds != nil { + bwcu.SetItemCollectionPeriod(*ds) } return bwcu } -// AddItemCollectionPeriodSeconds adds i to the "item_collection_period_seconds" field. -func (bwcu *BillingWorkflowConfigUpdate) AddItemCollectionPeriodSeconds(i int64) *BillingWorkflowConfigUpdate { - bwcu.mutation.AddItemCollectionPeriodSeconds(i) - return bwcu -} - // SetInvoiceAutoAdvance sets the "invoice_auto_advance" field. func (bwcu *BillingWorkflowConfigUpdate) SetInvoiceAutoAdvance(b bool) *BillingWorkflowConfigUpdate { bwcu.mutation.SetInvoiceAutoAdvance(b) @@ -127,90 +100,48 @@ func (bwcu *BillingWorkflowConfigUpdate) SetNillableInvoiceAutoAdvance(b *bool) return bwcu } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (bwcu *BillingWorkflowConfigUpdate) SetInvoiceDraftPeriodSeconds(i int64) *BillingWorkflowConfigUpdate { - bwcu.mutation.ResetInvoiceDraftPeriodSeconds() - bwcu.mutation.SetInvoiceDraftPeriodSeconds(i) +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (bwcu *BillingWorkflowConfigUpdate) SetInvoiceDraftPeriod(ds datex.ISOString) *BillingWorkflowConfigUpdate { + bwcu.mutation.SetInvoiceDraftPeriod(ds) return bwcu } -// SetNillableInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field if the given value is not nil. -func (bwcu *BillingWorkflowConfigUpdate) SetNillableInvoiceDraftPeriodSeconds(i *int64) *BillingWorkflowConfigUpdate { - if i != nil { - bwcu.SetInvoiceDraftPeriodSeconds(*i) +// SetNillableInvoiceDraftPeriod sets the "invoice_draft_period" field if the given value is not nil. +func (bwcu *BillingWorkflowConfigUpdate) SetNillableInvoiceDraftPeriod(ds *datex.ISOString) *BillingWorkflowConfigUpdate { + if ds != nil { + bwcu.SetInvoiceDraftPeriod(*ds) } return bwcu } -// AddInvoiceDraftPeriodSeconds adds i to the "invoice_draft_period_seconds" field. -func (bwcu *BillingWorkflowConfigUpdate) AddInvoiceDraftPeriodSeconds(i int64) *BillingWorkflowConfigUpdate { - bwcu.mutation.AddInvoiceDraftPeriodSeconds(i) - return bwcu -} - -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (bwcu *BillingWorkflowConfigUpdate) SetInvoiceDueAfterSeconds(i int64) *BillingWorkflowConfigUpdate { - bwcu.mutation.ResetInvoiceDueAfterSeconds() - bwcu.mutation.SetInvoiceDueAfterSeconds(i) +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (bwcu *BillingWorkflowConfigUpdate) SetInvoiceDueAfter(ds datex.ISOString) *BillingWorkflowConfigUpdate { + bwcu.mutation.SetInvoiceDueAfter(ds) return bwcu } -// SetNillableInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field if the given value is not nil. -func (bwcu *BillingWorkflowConfigUpdate) SetNillableInvoiceDueAfterSeconds(i *int64) *BillingWorkflowConfigUpdate { - if i != nil { - bwcu.SetInvoiceDueAfterSeconds(*i) +// SetNillableInvoiceDueAfter sets the "invoice_due_after" field if the given value is not nil. +func (bwcu *BillingWorkflowConfigUpdate) SetNillableInvoiceDueAfter(ds *datex.ISOString) *BillingWorkflowConfigUpdate { + if ds != nil { + bwcu.SetInvoiceDueAfter(*ds) } return bwcu } -// AddInvoiceDueAfterSeconds adds i to the "invoice_due_after_seconds" field. -func (bwcu *BillingWorkflowConfigUpdate) AddInvoiceDueAfterSeconds(i int64) *BillingWorkflowConfigUpdate { - bwcu.mutation.AddInvoiceDueAfterSeconds(i) - return bwcu -} - // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (bwcu *BillingWorkflowConfigUpdate) SetInvoiceCollectionMethod(bm billing.CollectionMethod) *BillingWorkflowConfigUpdate { +func (bwcu *BillingWorkflowConfigUpdate) SetInvoiceCollectionMethod(bm billingentity.CollectionMethod) *BillingWorkflowConfigUpdate { bwcu.mutation.SetInvoiceCollectionMethod(bm) return bwcu } // SetNillableInvoiceCollectionMethod sets the "invoice_collection_method" field if the given value is not nil. -func (bwcu *BillingWorkflowConfigUpdate) SetNillableInvoiceCollectionMethod(bm *billing.CollectionMethod) *BillingWorkflowConfigUpdate { +func (bwcu *BillingWorkflowConfigUpdate) SetNillableInvoiceCollectionMethod(bm *billingentity.CollectionMethod) *BillingWorkflowConfigUpdate { if bm != nil { bwcu.SetInvoiceCollectionMethod(*bm) } return bwcu } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (bwcu *BillingWorkflowConfigUpdate) SetInvoiceItemResolution(br billing.GranularityResolution) *BillingWorkflowConfigUpdate { - bwcu.mutation.SetInvoiceItemResolution(br) - return bwcu -} - -// SetNillableInvoiceItemResolution sets the "invoice_item_resolution" field if the given value is not nil. -func (bwcu *BillingWorkflowConfigUpdate) SetNillableInvoiceItemResolution(br *billing.GranularityResolution) *BillingWorkflowConfigUpdate { - if br != nil { - bwcu.SetInvoiceItemResolution(*br) - } - return bwcu -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (bwcu *BillingWorkflowConfigUpdate) SetInvoiceItemPerSubject(b bool) *BillingWorkflowConfigUpdate { - bwcu.mutation.SetInvoiceItemPerSubject(b) - return bwcu -} - -// SetNillableInvoiceItemPerSubject sets the "invoice_item_per_subject" field if the given value is not nil. -func (bwcu *BillingWorkflowConfigUpdate) SetNillableInvoiceItemPerSubject(b *bool) *BillingWorkflowConfigUpdate { - if b != nil { - bwcu.SetInvoiceItemPerSubject(*b) - } - return bwcu -} - // SetBillingInvoicesID sets the "billing_invoices" edge to the BillingInvoice entity by ID. func (bwcu *BillingWorkflowConfigUpdate) SetBillingInvoicesID(id string) *BillingWorkflowConfigUpdate { bwcu.mutation.SetBillingInvoicesID(id) @@ -314,11 +245,6 @@ func (bwcu *BillingWorkflowConfigUpdate) check() error { return &ValidationError{Name: "invoice_collection_method", err: fmt.Errorf(`db: validator failed for field "BillingWorkflowConfig.invoice_collection_method": %w`, err)} } } - if v, ok := bwcu.mutation.InvoiceItemResolution(); ok { - if err := billingworkflowconfig.InvoiceItemResolutionValidator(v); err != nil { - return &ValidationError{Name: "invoice_item_resolution", err: fmt.Errorf(`db: validator failed for field "BillingWorkflowConfig.invoice_item_resolution": %w`, err)} - } - } return nil } @@ -343,45 +269,24 @@ func (bwcu *BillingWorkflowConfigUpdate) sqlSave(ctx context.Context) (n int, er if bwcu.mutation.DeletedAtCleared() { _spec.ClearField(billingworkflowconfig.FieldDeletedAt, field.TypeTime) } - if value, ok := bwcu.mutation.Timezone(); ok { - _spec.SetField(billingworkflowconfig.FieldTimezone, field.TypeString, value) - } - if bwcu.mutation.TimezoneCleared() { - _spec.ClearField(billingworkflowconfig.FieldTimezone, field.TypeString) - } if value, ok := bwcu.mutation.CollectionAlignment(); ok { _spec.SetField(billingworkflowconfig.FieldCollectionAlignment, field.TypeEnum, value) } - if value, ok := bwcu.mutation.ItemCollectionPeriodSeconds(); ok { - _spec.SetField(billingworkflowconfig.FieldItemCollectionPeriodSeconds, field.TypeInt64, value) - } - if value, ok := bwcu.mutation.AddedItemCollectionPeriodSeconds(); ok { - _spec.AddField(billingworkflowconfig.FieldItemCollectionPeriodSeconds, field.TypeInt64, value) + if value, ok := bwcu.mutation.ItemCollectionPeriod(); ok { + _spec.SetField(billingworkflowconfig.FieldItemCollectionPeriod, field.TypeString, value) } if value, ok := bwcu.mutation.InvoiceAutoAdvance(); ok { _spec.SetField(billingworkflowconfig.FieldInvoiceAutoAdvance, field.TypeBool, value) } - if value, ok := bwcu.mutation.InvoiceDraftPeriodSeconds(); ok { - _spec.SetField(billingworkflowconfig.FieldInvoiceDraftPeriodSeconds, field.TypeInt64, value) - } - if value, ok := bwcu.mutation.AddedInvoiceDraftPeriodSeconds(); ok { - _spec.AddField(billingworkflowconfig.FieldInvoiceDraftPeriodSeconds, field.TypeInt64, value) - } - if value, ok := bwcu.mutation.InvoiceDueAfterSeconds(); ok { - _spec.SetField(billingworkflowconfig.FieldInvoiceDueAfterSeconds, field.TypeInt64, value) + if value, ok := bwcu.mutation.InvoiceDraftPeriod(); ok { + _spec.SetField(billingworkflowconfig.FieldInvoiceDraftPeriod, field.TypeString, value) } - if value, ok := bwcu.mutation.AddedInvoiceDueAfterSeconds(); ok { - _spec.AddField(billingworkflowconfig.FieldInvoiceDueAfterSeconds, field.TypeInt64, value) + if value, ok := bwcu.mutation.InvoiceDueAfter(); ok { + _spec.SetField(billingworkflowconfig.FieldInvoiceDueAfter, field.TypeString, value) } if value, ok := bwcu.mutation.InvoiceCollectionMethod(); ok { _spec.SetField(billingworkflowconfig.FieldInvoiceCollectionMethod, field.TypeEnum, value) } - if value, ok := bwcu.mutation.InvoiceItemResolution(); ok { - _spec.SetField(billingworkflowconfig.FieldInvoiceItemResolution, field.TypeEnum, value) - } - if value, ok := bwcu.mutation.InvoiceItemPerSubject(); ok { - _spec.SetField(billingworkflowconfig.FieldInvoiceItemPerSubject, field.TypeBool, value) - } if bwcu.mutation.BillingInvoicesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2O, @@ -486,61 +391,34 @@ func (bwcuo *BillingWorkflowConfigUpdateOne) ClearDeletedAt() *BillingWorkflowCo return bwcuo } -// SetTimezone sets the "timezone" field. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetTimezone(t timezone.Timezone) *BillingWorkflowConfigUpdateOne { - bwcuo.mutation.SetTimezone(t) - return bwcuo -} - -// SetNillableTimezone sets the "timezone" field if the given value is not nil. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableTimezone(t *timezone.Timezone) *BillingWorkflowConfigUpdateOne { - if t != nil { - bwcuo.SetTimezone(*t) - } - return bwcuo -} - -// ClearTimezone clears the value of the "timezone" field. -func (bwcuo *BillingWorkflowConfigUpdateOne) ClearTimezone() *BillingWorkflowConfigUpdateOne { - bwcuo.mutation.ClearTimezone() - return bwcuo -} - // SetCollectionAlignment sets the "collection_alignment" field. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetCollectionAlignment(bk billing.AlignmentKind) *BillingWorkflowConfigUpdateOne { +func (bwcuo *BillingWorkflowConfigUpdateOne) SetCollectionAlignment(bk billingentity.AlignmentKind) *BillingWorkflowConfigUpdateOne { bwcuo.mutation.SetCollectionAlignment(bk) return bwcuo } // SetNillableCollectionAlignment sets the "collection_alignment" field if the given value is not nil. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableCollectionAlignment(bk *billing.AlignmentKind) *BillingWorkflowConfigUpdateOne { +func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableCollectionAlignment(bk *billingentity.AlignmentKind) *BillingWorkflowConfigUpdateOne { if bk != nil { bwcuo.SetCollectionAlignment(*bk) } return bwcuo } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetItemCollectionPeriodSeconds(i int64) *BillingWorkflowConfigUpdateOne { - bwcuo.mutation.ResetItemCollectionPeriodSeconds() - bwcuo.mutation.SetItemCollectionPeriodSeconds(i) +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (bwcuo *BillingWorkflowConfigUpdateOne) SetItemCollectionPeriod(ds datex.ISOString) *BillingWorkflowConfigUpdateOne { + bwcuo.mutation.SetItemCollectionPeriod(ds) return bwcuo } -// SetNillableItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field if the given value is not nil. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableItemCollectionPeriodSeconds(i *int64) *BillingWorkflowConfigUpdateOne { - if i != nil { - bwcuo.SetItemCollectionPeriodSeconds(*i) +// SetNillableItemCollectionPeriod sets the "item_collection_period" field if the given value is not nil. +func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableItemCollectionPeriod(ds *datex.ISOString) *BillingWorkflowConfigUpdateOne { + if ds != nil { + bwcuo.SetItemCollectionPeriod(*ds) } return bwcuo } -// AddItemCollectionPeriodSeconds adds i to the "item_collection_period_seconds" field. -func (bwcuo *BillingWorkflowConfigUpdateOne) AddItemCollectionPeriodSeconds(i int64) *BillingWorkflowConfigUpdateOne { - bwcuo.mutation.AddItemCollectionPeriodSeconds(i) - return bwcuo -} - // SetInvoiceAutoAdvance sets the "invoice_auto_advance" field. func (bwcuo *BillingWorkflowConfigUpdateOne) SetInvoiceAutoAdvance(b bool) *BillingWorkflowConfigUpdateOne { bwcuo.mutation.SetInvoiceAutoAdvance(b) @@ -555,90 +433,48 @@ func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableInvoiceAutoAdvance(b *bo return bwcuo } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetInvoiceDraftPeriodSeconds(i int64) *BillingWorkflowConfigUpdateOne { - bwcuo.mutation.ResetInvoiceDraftPeriodSeconds() - bwcuo.mutation.SetInvoiceDraftPeriodSeconds(i) +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (bwcuo *BillingWorkflowConfigUpdateOne) SetInvoiceDraftPeriod(ds datex.ISOString) *BillingWorkflowConfigUpdateOne { + bwcuo.mutation.SetInvoiceDraftPeriod(ds) return bwcuo } -// SetNillableInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field if the given value is not nil. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableInvoiceDraftPeriodSeconds(i *int64) *BillingWorkflowConfigUpdateOne { - if i != nil { - bwcuo.SetInvoiceDraftPeriodSeconds(*i) +// SetNillableInvoiceDraftPeriod sets the "invoice_draft_period" field if the given value is not nil. +func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableInvoiceDraftPeriod(ds *datex.ISOString) *BillingWorkflowConfigUpdateOne { + if ds != nil { + bwcuo.SetInvoiceDraftPeriod(*ds) } return bwcuo } -// AddInvoiceDraftPeriodSeconds adds i to the "invoice_draft_period_seconds" field. -func (bwcuo *BillingWorkflowConfigUpdateOne) AddInvoiceDraftPeriodSeconds(i int64) *BillingWorkflowConfigUpdateOne { - bwcuo.mutation.AddInvoiceDraftPeriodSeconds(i) - return bwcuo -} - -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetInvoiceDueAfterSeconds(i int64) *BillingWorkflowConfigUpdateOne { - bwcuo.mutation.ResetInvoiceDueAfterSeconds() - bwcuo.mutation.SetInvoiceDueAfterSeconds(i) +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (bwcuo *BillingWorkflowConfigUpdateOne) SetInvoiceDueAfter(ds datex.ISOString) *BillingWorkflowConfigUpdateOne { + bwcuo.mutation.SetInvoiceDueAfter(ds) return bwcuo } -// SetNillableInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field if the given value is not nil. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableInvoiceDueAfterSeconds(i *int64) *BillingWorkflowConfigUpdateOne { - if i != nil { - bwcuo.SetInvoiceDueAfterSeconds(*i) +// SetNillableInvoiceDueAfter sets the "invoice_due_after" field if the given value is not nil. +func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableInvoiceDueAfter(ds *datex.ISOString) *BillingWorkflowConfigUpdateOne { + if ds != nil { + bwcuo.SetInvoiceDueAfter(*ds) } return bwcuo } -// AddInvoiceDueAfterSeconds adds i to the "invoice_due_after_seconds" field. -func (bwcuo *BillingWorkflowConfigUpdateOne) AddInvoiceDueAfterSeconds(i int64) *BillingWorkflowConfigUpdateOne { - bwcuo.mutation.AddInvoiceDueAfterSeconds(i) - return bwcuo -} - // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetInvoiceCollectionMethod(bm billing.CollectionMethod) *BillingWorkflowConfigUpdateOne { +func (bwcuo *BillingWorkflowConfigUpdateOne) SetInvoiceCollectionMethod(bm billingentity.CollectionMethod) *BillingWorkflowConfigUpdateOne { bwcuo.mutation.SetInvoiceCollectionMethod(bm) return bwcuo } // SetNillableInvoiceCollectionMethod sets the "invoice_collection_method" field if the given value is not nil. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableInvoiceCollectionMethod(bm *billing.CollectionMethod) *BillingWorkflowConfigUpdateOne { +func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableInvoiceCollectionMethod(bm *billingentity.CollectionMethod) *BillingWorkflowConfigUpdateOne { if bm != nil { bwcuo.SetInvoiceCollectionMethod(*bm) } return bwcuo } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetInvoiceItemResolution(br billing.GranularityResolution) *BillingWorkflowConfigUpdateOne { - bwcuo.mutation.SetInvoiceItemResolution(br) - return bwcuo -} - -// SetNillableInvoiceItemResolution sets the "invoice_item_resolution" field if the given value is not nil. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableInvoiceItemResolution(br *billing.GranularityResolution) *BillingWorkflowConfigUpdateOne { - if br != nil { - bwcuo.SetInvoiceItemResolution(*br) - } - return bwcuo -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetInvoiceItemPerSubject(b bool) *BillingWorkflowConfigUpdateOne { - bwcuo.mutation.SetInvoiceItemPerSubject(b) - return bwcuo -} - -// SetNillableInvoiceItemPerSubject sets the "invoice_item_per_subject" field if the given value is not nil. -func (bwcuo *BillingWorkflowConfigUpdateOne) SetNillableInvoiceItemPerSubject(b *bool) *BillingWorkflowConfigUpdateOne { - if b != nil { - bwcuo.SetInvoiceItemPerSubject(*b) - } - return bwcuo -} - // SetBillingInvoicesID sets the "billing_invoices" edge to the BillingInvoice entity by ID. func (bwcuo *BillingWorkflowConfigUpdateOne) SetBillingInvoicesID(id string) *BillingWorkflowConfigUpdateOne { bwcuo.mutation.SetBillingInvoicesID(id) @@ -755,11 +591,6 @@ func (bwcuo *BillingWorkflowConfigUpdateOne) check() error { return &ValidationError{Name: "invoice_collection_method", err: fmt.Errorf(`db: validator failed for field "BillingWorkflowConfig.invoice_collection_method": %w`, err)} } } - if v, ok := bwcuo.mutation.InvoiceItemResolution(); ok { - if err := billingworkflowconfig.InvoiceItemResolutionValidator(v); err != nil { - return &ValidationError{Name: "invoice_item_resolution", err: fmt.Errorf(`db: validator failed for field "BillingWorkflowConfig.invoice_item_resolution": %w`, err)} - } - } return nil } @@ -801,45 +632,24 @@ func (bwcuo *BillingWorkflowConfigUpdateOne) sqlSave(ctx context.Context) (_node if bwcuo.mutation.DeletedAtCleared() { _spec.ClearField(billingworkflowconfig.FieldDeletedAt, field.TypeTime) } - if value, ok := bwcuo.mutation.Timezone(); ok { - _spec.SetField(billingworkflowconfig.FieldTimezone, field.TypeString, value) - } - if bwcuo.mutation.TimezoneCleared() { - _spec.ClearField(billingworkflowconfig.FieldTimezone, field.TypeString) - } if value, ok := bwcuo.mutation.CollectionAlignment(); ok { _spec.SetField(billingworkflowconfig.FieldCollectionAlignment, field.TypeEnum, value) } - if value, ok := bwcuo.mutation.ItemCollectionPeriodSeconds(); ok { - _spec.SetField(billingworkflowconfig.FieldItemCollectionPeriodSeconds, field.TypeInt64, value) - } - if value, ok := bwcuo.mutation.AddedItemCollectionPeriodSeconds(); ok { - _spec.AddField(billingworkflowconfig.FieldItemCollectionPeriodSeconds, field.TypeInt64, value) + if value, ok := bwcuo.mutation.ItemCollectionPeriod(); ok { + _spec.SetField(billingworkflowconfig.FieldItemCollectionPeriod, field.TypeString, value) } if value, ok := bwcuo.mutation.InvoiceAutoAdvance(); ok { _spec.SetField(billingworkflowconfig.FieldInvoiceAutoAdvance, field.TypeBool, value) } - if value, ok := bwcuo.mutation.InvoiceDraftPeriodSeconds(); ok { - _spec.SetField(billingworkflowconfig.FieldInvoiceDraftPeriodSeconds, field.TypeInt64, value) - } - if value, ok := bwcuo.mutation.AddedInvoiceDraftPeriodSeconds(); ok { - _spec.AddField(billingworkflowconfig.FieldInvoiceDraftPeriodSeconds, field.TypeInt64, value) - } - if value, ok := bwcuo.mutation.InvoiceDueAfterSeconds(); ok { - _spec.SetField(billingworkflowconfig.FieldInvoiceDueAfterSeconds, field.TypeInt64, value) + if value, ok := bwcuo.mutation.InvoiceDraftPeriod(); ok { + _spec.SetField(billingworkflowconfig.FieldInvoiceDraftPeriod, field.TypeString, value) } - if value, ok := bwcuo.mutation.AddedInvoiceDueAfterSeconds(); ok { - _spec.AddField(billingworkflowconfig.FieldInvoiceDueAfterSeconds, field.TypeInt64, value) + if value, ok := bwcuo.mutation.InvoiceDueAfter(); ok { + _spec.SetField(billingworkflowconfig.FieldInvoiceDueAfter, field.TypeString, value) } if value, ok := bwcuo.mutation.InvoiceCollectionMethod(); ok { _spec.SetField(billingworkflowconfig.FieldInvoiceCollectionMethod, field.TypeEnum, value) } - if value, ok := bwcuo.mutation.InvoiceItemResolution(); ok { - _spec.SetField(billingworkflowconfig.FieldInvoiceItemResolution, field.TypeEnum, value) - } - if value, ok := bwcuo.mutation.InvoiceItemPerSubject(); ok { - _spec.SetField(billingworkflowconfig.FieldInvoiceItemPerSubject, field.TypeBool, value) - } if bwcuo.mutation.BillingInvoicesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2O, diff --git a/openmeter/ent/db/client.go b/openmeter/ent/db/client.go index 70f48c415..95b5dbe69 100644 --- a/openmeter/ent/db/client.go +++ b/openmeter/ent/db/client.go @@ -491,6 +491,54 @@ func (c *AppClient) QueryCustomerApps(a *App) *AppCustomerQuery { return query } +// QueryTaxApp queries the tax_app edge of a App. +func (c *AppClient) QueryTaxApp(a *App) *BillingProfileQuery { + query := (&BillingProfileClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := a.ID + step := sqlgraph.NewStep( + sqlgraph.From(app.Table, app.FieldID, id), + sqlgraph.To(billingprofile.Table, billingprofile.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, app.TaxAppTable, app.TaxAppColumn), + ) + fromV = sqlgraph.Neighbors(a.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryInvoicingApp queries the invoicing_app edge of a App. +func (c *AppClient) QueryInvoicingApp(a *App) *BillingProfileQuery { + query := (&BillingProfileClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := a.ID + step := sqlgraph.NewStep( + sqlgraph.From(app.Table, app.FieldID, id), + sqlgraph.To(billingprofile.Table, billingprofile.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, app.InvoicingAppTable, app.InvoicingAppColumn), + ) + fromV = sqlgraph.Neighbors(a.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryPaymentApp queries the payment_app edge of a App. +func (c *AppClient) QueryPaymentApp(a *App) *BillingProfileQuery { + query := (&BillingProfileClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := a.ID + step := sqlgraph.NewStep( + sqlgraph.From(app.Table, app.FieldID, id), + sqlgraph.To(billingprofile.Table, billingprofile.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, app.PaymentAppTable, app.PaymentAppColumn), + ) + fromV = sqlgraph.Neighbors(a.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *AppClient) Hooks() []Hook { return c.hooks.App @@ -1811,6 +1859,54 @@ func (c *BillingProfileClient) QueryWorkflowConfig(bp *BillingProfile) *BillingW return query } +// QueryTaxApp queries the tax_app edge of a BillingProfile. +func (c *BillingProfileClient) QueryTaxApp(bp *BillingProfile) *AppQuery { + query := (&AppClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := bp.ID + step := sqlgraph.NewStep( + sqlgraph.From(billingprofile.Table, billingprofile.FieldID, id), + sqlgraph.To(app.Table, app.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, billingprofile.TaxAppTable, billingprofile.TaxAppColumn), + ) + fromV = sqlgraph.Neighbors(bp.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryInvoicingApp queries the invoicing_app edge of a BillingProfile. +func (c *BillingProfileClient) QueryInvoicingApp(bp *BillingProfile) *AppQuery { + query := (&AppClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := bp.ID + step := sqlgraph.NewStep( + sqlgraph.From(billingprofile.Table, billingprofile.FieldID, id), + sqlgraph.To(app.Table, app.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, billingprofile.InvoicingAppTable, billingprofile.InvoicingAppColumn), + ) + fromV = sqlgraph.Neighbors(bp.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryPaymentApp queries the payment_app edge of a BillingProfile. +func (c *BillingProfileClient) QueryPaymentApp(bp *BillingProfile) *AppQuery { + query := (&AppClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := bp.ID + step := sqlgraph.NewStep( + sqlgraph.From(billingprofile.Table, billingprofile.FieldID, id), + sqlgraph.To(app.Table, app.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, billingprofile.PaymentAppTable, billingprofile.PaymentAppColumn), + ) + fromV = sqlgraph.Neighbors(bp.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *BillingProfileClient) Hooks() []Hook { return c.hooks.BillingProfile diff --git a/openmeter/ent/db/migrate/schema.go b/openmeter/ent/db/migrate/schema.go index 81e49740c..5e9de34cf 100644 --- a/openmeter/ent/db/migrate/schema.go +++ b/openmeter/ent/db/migrate/schema.go @@ -246,13 +246,11 @@ var ( {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "collection_alignment", Type: field.TypeEnum, Nullable: true, Enums: []string{"subscription"}}, - {Name: "item_collection_period_seconds", Type: field.TypeInt64, Nullable: true}, + {Name: "item_collection_period", Type: field.TypeString, Nullable: true}, {Name: "invoice_auto_advance", Type: field.TypeBool, Nullable: true}, - {Name: "invoice_draft_period_seconds", Type: field.TypeInt64, Nullable: true}, - {Name: "invoice_due_after_seconds", Type: field.TypeInt64, Nullable: true}, + {Name: "invoice_draft_period", Type: field.TypeString, Nullable: true}, + {Name: "invoice_due_after", Type: field.TypeString, Nullable: true}, {Name: "invoice_collection_method", Type: field.TypeEnum, Nullable: true, Enums: []string{"charge_automatically", "send_invoice"}}, - {Name: "invoice_item_resolution", Type: field.TypeEnum, Nullable: true, Enums: []string{"day", "period"}}, - {Name: "invoice_item_per_subject", Type: field.TypeBool, Nullable: true}, {Name: "billing_profile_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "char(26)"}}, {Name: "customer_id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "char(26)"}}, } @@ -264,13 +262,13 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "billing_customer_overrides_billing_profiles_billing_customer_override", - Columns: []*schema.Column{BillingCustomerOverridesColumns[13]}, + Columns: []*schema.Column{BillingCustomerOverridesColumns[11]}, RefColumns: []*schema.Column{BillingProfilesColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "billing_customer_overrides_customers_billing_customer_override", - Columns: []*schema.Column{BillingCustomerOverridesColumns[14]}, + Columns: []*schema.Column{BillingCustomerOverridesColumns[12]}, RefColumns: []*schema.Column{CustomersColumns[0]}, OnDelete: schema.Cascade, }, @@ -294,7 +292,7 @@ var ( { Name: "billingcustomeroverride_namespace_customer_id", Unique: true, - Columns: []*schema.Column{BillingCustomerOverridesColumns[1], BillingCustomerOverridesColumns[14]}, + Columns: []*schema.Column{BillingCustomerOverridesColumns[1], BillingCustomerOverridesColumns[12]}, }, }, } @@ -313,9 +311,6 @@ var ( {Name: "currency", Type: field.TypeString, SchemaType: map[string]string{"postgres": "varchar(3)"}}, {Name: "due_date", Type: field.TypeTime}, {Name: "status", Type: field.TypeEnum, Enums: []string{"created", "draft", "draft_sync", "draft_sync_failed", "issuing", "issued", "issuing_failed", "manual_approval_needed"}}, - {Name: "tax_provider", Type: field.TypeEnum, Nullable: true, Enums: []string{"openmeter_sandbox", "stripe"}}, - {Name: "invoicing_provider", Type: field.TypeEnum, Nullable: true, Enums: []string{"openmeter_sandbox", "stripe"}}, - {Name: "payment_provider", Type: field.TypeEnum, Nullable: true, Enums: []string{"openmeter_sandbox", "stripe_payments"}}, {Name: "period_start", Type: field.TypeTime}, {Name: "period_end", Type: field.TypeTime}, {Name: "billing_profile_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "char(26)"}}, @@ -329,13 +324,13 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "billing_invoices_billing_profiles_billing_invoices", - Columns: []*schema.Column{BillingInvoicesColumns[18]}, + Columns: []*schema.Column{BillingInvoicesColumns[15]}, RefColumns: []*schema.Column{BillingProfilesColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "billing_invoices_billing_workflow_configs_billing_invoices", - Columns: []*schema.Column{BillingInvoicesColumns[19]}, + Columns: []*schema.Column{BillingInvoicesColumns[16]}, RefColumns: []*schema.Column{BillingWorkflowConfigsColumns[0]}, OnDelete: schema.NoAction, }, @@ -456,11 +451,12 @@ var ( {Name: "supplier_address_line1", Type: field.TypeString, Nullable: true}, {Name: "supplier_address_line2", Type: field.TypeString, Nullable: true}, {Name: "supplier_address_phone_number", Type: field.TypeString, Nullable: true}, - {Name: "tax_provider", Type: field.TypeEnum, Enums: []string{"openmeter_sandbox", "stripe"}}, - {Name: "invoicing_provider", Type: field.TypeEnum, Enums: []string{"openmeter_sandbox", "stripe"}}, - {Name: "payment_provider", Type: field.TypeEnum, Enums: []string{"openmeter_sandbox", "stripe_payments"}}, {Name: "default", Type: field.TypeBool, Default: false}, {Name: "supplier_name", Type: field.TypeString}, + {Name: "supplier_tax_code", Type: field.TypeString, Nullable: true}, + {Name: "tax_app_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "char(26)"}}, + {Name: "invoicing_app_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "char(26)"}}, + {Name: "payment_app_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "char(26)"}}, {Name: "workflow_config_id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "char(26)"}}, } // BillingProfilesTable holds the schema information for the "billing_profiles" table. @@ -470,8 +466,26 @@ var ( PrimaryKey: []*schema.Column{BillingProfilesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "billing_profiles_billing_workflow_configs_billing_profile", + Symbol: "billing_profiles_apps_tax_app", + Columns: []*schema.Column{BillingProfilesColumns[18]}, + RefColumns: []*schema.Column{AppsColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "billing_profiles_apps_invoicing_app", + Columns: []*schema.Column{BillingProfilesColumns[19]}, + RefColumns: []*schema.Column{AppsColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "billing_profiles_apps_payment_app", Columns: []*schema.Column{BillingProfilesColumns[20]}, + RefColumns: []*schema.Column{AppsColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "billing_profiles_billing_workflow_configs_billing_profile", + Columns: []*schema.Column{BillingProfilesColumns[21]}, RefColumns: []*schema.Column{BillingWorkflowConfigsColumns[0]}, OnDelete: schema.NoAction, }, @@ -495,7 +509,7 @@ var ( { Name: "billingprofile_namespace_default_deleted_at", Unique: true, - Columns: []*schema.Column{BillingProfilesColumns[1], BillingProfilesColumns[18], BillingProfilesColumns[5]}, + Columns: []*schema.Column{BillingProfilesColumns[1], BillingProfilesColumns[15], BillingProfilesColumns[5]}, }, }, } @@ -506,15 +520,12 @@ var ( {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, - {Name: "timezone", Type: field.TypeString, Nullable: true}, {Name: "collection_alignment", Type: field.TypeEnum, Enums: []string{"subscription"}}, - {Name: "item_collection_period_seconds", Type: field.TypeInt64}, + {Name: "item_collection_period", Type: field.TypeString}, {Name: "invoice_auto_advance", Type: field.TypeBool}, - {Name: "invoice_draft_period_seconds", Type: field.TypeInt64}, - {Name: "invoice_due_after_seconds", Type: field.TypeInt64}, + {Name: "invoice_draft_period", Type: field.TypeString}, + {Name: "invoice_due_after", Type: field.TypeString}, {Name: "invoice_collection_method", Type: field.TypeEnum, Enums: []string{"charge_automatically", "send_invoice"}}, - {Name: "invoice_item_resolution", Type: field.TypeEnum, Enums: []string{"day", "period"}}, - {Name: "invoice_item_per_subject", Type: field.TypeBool}, } // BillingWorkflowConfigsTable holds the schema information for the "billing_workflow_configs" table. BillingWorkflowConfigsTable = &schema.Table{ @@ -1106,7 +1117,10 @@ func init() { BillingInvoicesTable.ForeignKeys[0].RefTable = BillingProfilesTable BillingInvoicesTable.ForeignKeys[1].RefTable = BillingWorkflowConfigsTable BillingInvoiceItemsTable.ForeignKeys[0].RefTable = BillingInvoicesTable - BillingProfilesTable.ForeignKeys[0].RefTable = BillingWorkflowConfigsTable + BillingProfilesTable.ForeignKeys[0].RefTable = AppsTable + BillingProfilesTable.ForeignKeys[1].RefTable = AppsTable + BillingProfilesTable.ForeignKeys[2].RefTable = AppsTable + BillingProfilesTable.ForeignKeys[3].RefTable = BillingWorkflowConfigsTable CustomerSubjectsTable.ForeignKeys[0].RefTable = CustomersTable EntitlementsTable.ForeignKeys[0].RefTable = FeaturesTable GrantsTable.ForeignKeys[0].RefTable = EntitlementsTable diff --git a/openmeter/ent/db/mutation.go b/openmeter/ent/db/mutation.go index 744af8000..e4edb65e7 100644 --- a/openmeter/ent/db/mutation.go +++ b/openmeter/ent/db/mutation.go @@ -13,8 +13,7 @@ import ( "entgo.io/ent/dialect/sql" "github.com/alpacahq/alpacadecimal" appentitybase "github.com/openmeterio/openmeter/openmeter/app/entity/base" - "github.com/openmeterio/openmeter/openmeter/billing" - "github.com/openmeterio/openmeter/openmeter/billing/provider" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/credit/balance" "github.com/openmeterio/openmeter/openmeter/credit/grant" "github.com/openmeterio/openmeter/openmeter/ent/db/app" @@ -40,6 +39,7 @@ import ( "github.com/openmeterio/openmeter/openmeter/ent/db/usagereset" "github.com/openmeterio/openmeter/openmeter/notification" "github.com/openmeterio/openmeter/pkg/currencyx" + "github.com/openmeterio/openmeter/pkg/datex" "github.com/openmeterio/openmeter/pkg/models" "github.com/openmeterio/openmeter/pkg/recurrence" "github.com/openmeterio/openmeter/pkg/timezone" @@ -96,6 +96,15 @@ type AppMutation struct { customer_apps map[int]struct{} removedcustomer_apps map[int]struct{} clearedcustomer_apps bool + tax_app map[string]struct{} + removedtax_app map[string]struct{} + clearedtax_app bool + invoicing_app map[string]struct{} + removedinvoicing_app map[string]struct{} + clearedinvoicing_app bool + payment_app map[string]struct{} + removedpayment_app map[string]struct{} + clearedpayment_app bool done bool oldValue func(context.Context) (*App, error) predicates []predicate.App @@ -658,6 +667,168 @@ func (m *AppMutation) ResetCustomerApps() { m.removedcustomer_apps = nil } +// AddTaxAppIDs adds the "tax_app" edge to the BillingProfile entity by ids. +func (m *AppMutation) AddTaxAppIDs(ids ...string) { + if m.tax_app == nil { + m.tax_app = make(map[string]struct{}) + } + for i := range ids { + m.tax_app[ids[i]] = struct{}{} + } +} + +// ClearTaxApp clears the "tax_app" edge to the BillingProfile entity. +func (m *AppMutation) ClearTaxApp() { + m.clearedtax_app = true +} + +// TaxAppCleared reports if the "tax_app" edge to the BillingProfile entity was cleared. +func (m *AppMutation) TaxAppCleared() bool { + return m.clearedtax_app +} + +// RemoveTaxAppIDs removes the "tax_app" edge to the BillingProfile entity by IDs. +func (m *AppMutation) RemoveTaxAppIDs(ids ...string) { + if m.removedtax_app == nil { + m.removedtax_app = make(map[string]struct{}) + } + for i := range ids { + delete(m.tax_app, ids[i]) + m.removedtax_app[ids[i]] = struct{}{} + } +} + +// RemovedTaxApp returns the removed IDs of the "tax_app" edge to the BillingProfile entity. +func (m *AppMutation) RemovedTaxAppIDs() (ids []string) { + for id := range m.removedtax_app { + ids = append(ids, id) + } + return +} + +// TaxAppIDs returns the "tax_app" edge IDs in the mutation. +func (m *AppMutation) TaxAppIDs() (ids []string) { + for id := range m.tax_app { + ids = append(ids, id) + } + return +} + +// ResetTaxApp resets all changes to the "tax_app" edge. +func (m *AppMutation) ResetTaxApp() { + m.tax_app = nil + m.clearedtax_app = false + m.removedtax_app = nil +} + +// AddInvoicingAppIDs adds the "invoicing_app" edge to the BillingProfile entity by ids. +func (m *AppMutation) AddInvoicingAppIDs(ids ...string) { + if m.invoicing_app == nil { + m.invoicing_app = make(map[string]struct{}) + } + for i := range ids { + m.invoicing_app[ids[i]] = struct{}{} + } +} + +// ClearInvoicingApp clears the "invoicing_app" edge to the BillingProfile entity. +func (m *AppMutation) ClearInvoicingApp() { + m.clearedinvoicing_app = true +} + +// InvoicingAppCleared reports if the "invoicing_app" edge to the BillingProfile entity was cleared. +func (m *AppMutation) InvoicingAppCleared() bool { + return m.clearedinvoicing_app +} + +// RemoveInvoicingAppIDs removes the "invoicing_app" edge to the BillingProfile entity by IDs. +func (m *AppMutation) RemoveInvoicingAppIDs(ids ...string) { + if m.removedinvoicing_app == nil { + m.removedinvoicing_app = make(map[string]struct{}) + } + for i := range ids { + delete(m.invoicing_app, ids[i]) + m.removedinvoicing_app[ids[i]] = struct{}{} + } +} + +// RemovedInvoicingApp returns the removed IDs of the "invoicing_app" edge to the BillingProfile entity. +func (m *AppMutation) RemovedInvoicingAppIDs() (ids []string) { + for id := range m.removedinvoicing_app { + ids = append(ids, id) + } + return +} + +// InvoicingAppIDs returns the "invoicing_app" edge IDs in the mutation. +func (m *AppMutation) InvoicingAppIDs() (ids []string) { + for id := range m.invoicing_app { + ids = append(ids, id) + } + return +} + +// ResetInvoicingApp resets all changes to the "invoicing_app" edge. +func (m *AppMutation) ResetInvoicingApp() { + m.invoicing_app = nil + m.clearedinvoicing_app = false + m.removedinvoicing_app = nil +} + +// AddPaymentAppIDs adds the "payment_app" edge to the BillingProfile entity by ids. +func (m *AppMutation) AddPaymentAppIDs(ids ...string) { + if m.payment_app == nil { + m.payment_app = make(map[string]struct{}) + } + for i := range ids { + m.payment_app[ids[i]] = struct{}{} + } +} + +// ClearPaymentApp clears the "payment_app" edge to the BillingProfile entity. +func (m *AppMutation) ClearPaymentApp() { + m.clearedpayment_app = true +} + +// PaymentAppCleared reports if the "payment_app" edge to the BillingProfile entity was cleared. +func (m *AppMutation) PaymentAppCleared() bool { + return m.clearedpayment_app +} + +// RemovePaymentAppIDs removes the "payment_app" edge to the BillingProfile entity by IDs. +func (m *AppMutation) RemovePaymentAppIDs(ids ...string) { + if m.removedpayment_app == nil { + m.removedpayment_app = make(map[string]struct{}) + } + for i := range ids { + delete(m.payment_app, ids[i]) + m.removedpayment_app[ids[i]] = struct{}{} + } +} + +// RemovedPaymentApp returns the removed IDs of the "payment_app" edge to the BillingProfile entity. +func (m *AppMutation) RemovedPaymentAppIDs() (ids []string) { + for id := range m.removedpayment_app { + ids = append(ids, id) + } + return +} + +// PaymentAppIDs returns the "payment_app" edge IDs in the mutation. +func (m *AppMutation) PaymentAppIDs() (ids []string) { + for id := range m.payment_app { + ids = append(ids, id) + } + return +} + +// ResetPaymentApp resets all changes to the "payment_app" edge. +func (m *AppMutation) ResetPaymentApp() { + m.payment_app = nil + m.clearedpayment_app = false + m.removedpayment_app = nil +} + // Where appends a list predicates to the AppMutation builder. func (m *AppMutation) Where(ps ...predicate.App) { m.predicates = append(m.predicates, ps...) @@ -965,10 +1136,19 @@ func (m *AppMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *AppMutation) AddedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 4) if m.customer_apps != nil { edges = append(edges, app.EdgeCustomerApps) } + if m.tax_app != nil { + edges = append(edges, app.EdgeTaxApp) + } + if m.invoicing_app != nil { + edges = append(edges, app.EdgeInvoicingApp) + } + if m.payment_app != nil { + edges = append(edges, app.EdgePaymentApp) + } return edges } @@ -982,16 +1162,43 @@ func (m *AppMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case app.EdgeTaxApp: + ids := make([]ent.Value, 0, len(m.tax_app)) + for id := range m.tax_app { + ids = append(ids, id) + } + return ids + case app.EdgeInvoicingApp: + ids := make([]ent.Value, 0, len(m.invoicing_app)) + for id := range m.invoicing_app { + ids = append(ids, id) + } + return ids + case app.EdgePaymentApp: + ids := make([]ent.Value, 0, len(m.payment_app)) + for id := range m.payment_app { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *AppMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 4) if m.removedcustomer_apps != nil { edges = append(edges, app.EdgeCustomerApps) } + if m.removedtax_app != nil { + edges = append(edges, app.EdgeTaxApp) + } + if m.removedinvoicing_app != nil { + edges = append(edges, app.EdgeInvoicingApp) + } + if m.removedpayment_app != nil { + edges = append(edges, app.EdgePaymentApp) + } return edges } @@ -1005,16 +1212,43 @@ func (m *AppMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case app.EdgeTaxApp: + ids := make([]ent.Value, 0, len(m.removedtax_app)) + for id := range m.removedtax_app { + ids = append(ids, id) + } + return ids + case app.EdgeInvoicingApp: + ids := make([]ent.Value, 0, len(m.removedinvoicing_app)) + for id := range m.removedinvoicing_app { + ids = append(ids, id) + } + return ids + case app.EdgePaymentApp: + ids := make([]ent.Value, 0, len(m.removedpayment_app)) + for id := range m.removedpayment_app { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *AppMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 4) if m.clearedcustomer_apps { edges = append(edges, app.EdgeCustomerApps) } + if m.clearedtax_app { + edges = append(edges, app.EdgeTaxApp) + } + if m.clearedinvoicing_app { + edges = append(edges, app.EdgeInvoicingApp) + } + if m.clearedpayment_app { + edges = append(edges, app.EdgePaymentApp) + } return edges } @@ -1024,6 +1258,12 @@ func (m *AppMutation) EdgeCleared(name string) bool { switch name { case app.EdgeCustomerApps: return m.clearedcustomer_apps + case app.EdgeTaxApp: + return m.clearedtax_app + case app.EdgeInvoicingApp: + return m.clearedinvoicing_app + case app.EdgePaymentApp: + return m.clearedpayment_app } return false } @@ -1043,6 +1283,15 @@ func (m *AppMutation) ResetEdge(name string) error { case app.EdgeCustomerApps: m.ResetCustomerApps() return nil + case app.EdgeTaxApp: + m.ResetTaxApp() + return nil + case app.EdgeInvoicingApp: + m.ResetInvoicingApp() + return nil + case app.EdgePaymentApp: + m.ResetPaymentApp() + return nil } return fmt.Errorf("unknown App edge %s", name) } @@ -4480,32 +4729,27 @@ func (m *BalanceSnapshotMutation) ResetEdge(name string) error { // BillingCustomerOverrideMutation represents an operation that mutates the BillingCustomerOverride nodes in the graph. type BillingCustomerOverrideMutation struct { config - op Op - typ string - id *string - namespace *string - created_at *time.Time - updated_at *time.Time - deleted_at *time.Time - collection_alignment *billing.AlignmentKind - item_collection_period_seconds *int64 - additem_collection_period_seconds *int64 - invoice_auto_advance *bool - invoice_draft_period_seconds *int64 - addinvoice_draft_period_seconds *int64 - invoice_due_after_seconds *int64 - addinvoice_due_after_seconds *int64 - invoice_collection_method *billing.CollectionMethod - invoice_item_resolution *billing.GranularityResolution - invoice_item_per_subject *bool - clearedFields map[string]struct{} - customer *string - clearedcustomer bool - billing_profile *string - clearedbilling_profile bool - done bool - oldValue func(context.Context) (*BillingCustomerOverride, error) - predicates []predicate.BillingCustomerOverride + op Op + typ string + id *string + namespace *string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + collection_alignment *billingentity.AlignmentKind + item_collection_period *datex.ISOString + invoice_auto_advance *bool + invoice_draft_period *datex.ISOString + invoice_due_after *datex.ISOString + invoice_collection_method *billingentity.CollectionMethod + clearedFields map[string]struct{} + customer *string + clearedcustomer bool + billing_profile *string + clearedbilling_profile bool + done bool + oldValue func(context.Context) (*BillingCustomerOverride, error) + predicates []predicate.BillingCustomerOverride } var _ ent.Mutation = (*BillingCustomerOverrideMutation)(nil) @@ -4855,12 +5099,12 @@ func (m *BillingCustomerOverrideMutation) ResetBillingProfileID() { } // SetCollectionAlignment sets the "collection_alignment" field. -func (m *BillingCustomerOverrideMutation) SetCollectionAlignment(bk billing.AlignmentKind) { +func (m *BillingCustomerOverrideMutation) SetCollectionAlignment(bk billingentity.AlignmentKind) { m.collection_alignment = &bk } // CollectionAlignment returns the value of the "collection_alignment" field in the mutation. -func (m *BillingCustomerOverrideMutation) CollectionAlignment() (r billing.AlignmentKind, exists bool) { +func (m *BillingCustomerOverrideMutation) CollectionAlignment() (r billingentity.AlignmentKind, exists bool) { v := m.collection_alignment if v == nil { return @@ -4871,7 +5115,7 @@ func (m *BillingCustomerOverrideMutation) CollectionAlignment() (r billing.Align // OldCollectionAlignment returns the old "collection_alignment" field's value of the BillingCustomerOverride entity. // If the BillingCustomerOverride object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingCustomerOverrideMutation) OldCollectionAlignment(ctx context.Context) (v *billing.AlignmentKind, err error) { +func (m *BillingCustomerOverrideMutation) OldCollectionAlignment(ctx context.Context) (v *billingentity.AlignmentKind, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCollectionAlignment is only allowed on UpdateOne operations") } @@ -4903,74 +5147,53 @@ func (m *BillingCustomerOverrideMutation) ResetCollectionAlignment() { delete(m.clearedFields, billingcustomeroverride.FieldCollectionAlignment) } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (m *BillingCustomerOverrideMutation) SetItemCollectionPeriodSeconds(i int64) { - m.item_collection_period_seconds = &i - m.additem_collection_period_seconds = nil +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (m *BillingCustomerOverrideMutation) SetItemCollectionPeriod(ds datex.ISOString) { + m.item_collection_period = &ds } -// ItemCollectionPeriodSeconds returns the value of the "item_collection_period_seconds" field in the mutation. -func (m *BillingCustomerOverrideMutation) ItemCollectionPeriodSeconds() (r int64, exists bool) { - v := m.item_collection_period_seconds +// ItemCollectionPeriod returns the value of the "item_collection_period" field in the mutation. +func (m *BillingCustomerOverrideMutation) ItemCollectionPeriod() (r datex.ISOString, exists bool) { + v := m.item_collection_period if v == nil { return } return *v, true } -// OldItemCollectionPeriodSeconds returns the old "item_collection_period_seconds" field's value of the BillingCustomerOverride entity. +// OldItemCollectionPeriod returns the old "item_collection_period" field's value of the BillingCustomerOverride entity. // If the BillingCustomerOverride object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingCustomerOverrideMutation) OldItemCollectionPeriodSeconds(ctx context.Context) (v *int64, err error) { +func (m *BillingCustomerOverrideMutation) OldItemCollectionPeriod(ctx context.Context) (v *datex.ISOString, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldItemCollectionPeriodSeconds is only allowed on UpdateOne operations") + return v, errors.New("OldItemCollectionPeriod is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldItemCollectionPeriodSeconds requires an ID field in the mutation") + return v, errors.New("OldItemCollectionPeriod requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldItemCollectionPeriodSeconds: %w", err) - } - return oldValue.ItemCollectionPeriodSeconds, nil -} - -// AddItemCollectionPeriodSeconds adds i to the "item_collection_period_seconds" field. -func (m *BillingCustomerOverrideMutation) AddItemCollectionPeriodSeconds(i int64) { - if m.additem_collection_period_seconds != nil { - *m.additem_collection_period_seconds += i - } else { - m.additem_collection_period_seconds = &i - } -} - -// AddedItemCollectionPeriodSeconds returns the value that was added to the "item_collection_period_seconds" field in this mutation. -func (m *BillingCustomerOverrideMutation) AddedItemCollectionPeriodSeconds() (r int64, exists bool) { - v := m.additem_collection_period_seconds - if v == nil { - return + return v, fmt.Errorf("querying old value for OldItemCollectionPeriod: %w", err) } - return *v, true + return oldValue.ItemCollectionPeriod, nil } -// ClearItemCollectionPeriodSeconds clears the value of the "item_collection_period_seconds" field. -func (m *BillingCustomerOverrideMutation) ClearItemCollectionPeriodSeconds() { - m.item_collection_period_seconds = nil - m.additem_collection_period_seconds = nil - m.clearedFields[billingcustomeroverride.FieldItemCollectionPeriodSeconds] = struct{}{} +// ClearItemCollectionPeriod clears the value of the "item_collection_period" field. +func (m *BillingCustomerOverrideMutation) ClearItemCollectionPeriod() { + m.item_collection_period = nil + m.clearedFields[billingcustomeroverride.FieldItemCollectionPeriod] = struct{}{} } -// ItemCollectionPeriodSecondsCleared returns if the "item_collection_period_seconds" field was cleared in this mutation. -func (m *BillingCustomerOverrideMutation) ItemCollectionPeriodSecondsCleared() bool { - _, ok := m.clearedFields[billingcustomeroverride.FieldItemCollectionPeriodSeconds] +// ItemCollectionPeriodCleared returns if the "item_collection_period" field was cleared in this mutation. +func (m *BillingCustomerOverrideMutation) ItemCollectionPeriodCleared() bool { + _, ok := m.clearedFields[billingcustomeroverride.FieldItemCollectionPeriod] return ok } -// ResetItemCollectionPeriodSeconds resets all changes to the "item_collection_period_seconds" field. -func (m *BillingCustomerOverrideMutation) ResetItemCollectionPeriodSeconds() { - m.item_collection_period_seconds = nil - m.additem_collection_period_seconds = nil - delete(m.clearedFields, billingcustomeroverride.FieldItemCollectionPeriodSeconds) +// ResetItemCollectionPeriod resets all changes to the "item_collection_period" field. +func (m *BillingCustomerOverrideMutation) ResetItemCollectionPeriod() { + m.item_collection_period = nil + delete(m.clearedFields, billingcustomeroverride.FieldItemCollectionPeriod) } // SetInvoiceAutoAdvance sets the "invoice_auto_advance" field. @@ -5022,153 +5245,111 @@ func (m *BillingCustomerOverrideMutation) ResetInvoiceAutoAdvance() { delete(m.clearedFields, billingcustomeroverride.FieldInvoiceAutoAdvance) } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (m *BillingCustomerOverrideMutation) SetInvoiceDraftPeriodSeconds(i int64) { - m.invoice_draft_period_seconds = &i - m.addinvoice_draft_period_seconds = nil +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (m *BillingCustomerOverrideMutation) SetInvoiceDraftPeriod(ds datex.ISOString) { + m.invoice_draft_period = &ds } -// InvoiceDraftPeriodSeconds returns the value of the "invoice_draft_period_seconds" field in the mutation. -func (m *BillingCustomerOverrideMutation) InvoiceDraftPeriodSeconds() (r int64, exists bool) { - v := m.invoice_draft_period_seconds +// InvoiceDraftPeriod returns the value of the "invoice_draft_period" field in the mutation. +func (m *BillingCustomerOverrideMutation) InvoiceDraftPeriod() (r datex.ISOString, exists bool) { + v := m.invoice_draft_period if v == nil { return } return *v, true } -// OldInvoiceDraftPeriodSeconds returns the old "invoice_draft_period_seconds" field's value of the BillingCustomerOverride entity. +// OldInvoiceDraftPeriod returns the old "invoice_draft_period" field's value of the BillingCustomerOverride entity. // If the BillingCustomerOverride object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingCustomerOverrideMutation) OldInvoiceDraftPeriodSeconds(ctx context.Context) (v *int64, err error) { +func (m *BillingCustomerOverrideMutation) OldInvoiceDraftPeriod(ctx context.Context) (v *datex.ISOString, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInvoiceDraftPeriodSeconds is only allowed on UpdateOne operations") + return v, errors.New("OldInvoiceDraftPeriod is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInvoiceDraftPeriodSeconds requires an ID field in the mutation") + return v, errors.New("OldInvoiceDraftPeriod requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldInvoiceDraftPeriodSeconds: %w", err) - } - return oldValue.InvoiceDraftPeriodSeconds, nil -} - -// AddInvoiceDraftPeriodSeconds adds i to the "invoice_draft_period_seconds" field. -func (m *BillingCustomerOverrideMutation) AddInvoiceDraftPeriodSeconds(i int64) { - if m.addinvoice_draft_period_seconds != nil { - *m.addinvoice_draft_period_seconds += i - } else { - m.addinvoice_draft_period_seconds = &i + return v, fmt.Errorf("querying old value for OldInvoiceDraftPeriod: %w", err) } + return oldValue.InvoiceDraftPeriod, nil } -// AddedInvoiceDraftPeriodSeconds returns the value that was added to the "invoice_draft_period_seconds" field in this mutation. -func (m *BillingCustomerOverrideMutation) AddedInvoiceDraftPeriodSeconds() (r int64, exists bool) { - v := m.addinvoice_draft_period_seconds - if v == nil { - return - } - return *v, true +// ClearInvoiceDraftPeriod clears the value of the "invoice_draft_period" field. +func (m *BillingCustomerOverrideMutation) ClearInvoiceDraftPeriod() { + m.invoice_draft_period = nil + m.clearedFields[billingcustomeroverride.FieldInvoiceDraftPeriod] = struct{}{} } -// ClearInvoiceDraftPeriodSeconds clears the value of the "invoice_draft_period_seconds" field. -func (m *BillingCustomerOverrideMutation) ClearInvoiceDraftPeriodSeconds() { - m.invoice_draft_period_seconds = nil - m.addinvoice_draft_period_seconds = nil - m.clearedFields[billingcustomeroverride.FieldInvoiceDraftPeriodSeconds] = struct{}{} -} - -// InvoiceDraftPeriodSecondsCleared returns if the "invoice_draft_period_seconds" field was cleared in this mutation. -func (m *BillingCustomerOverrideMutation) InvoiceDraftPeriodSecondsCleared() bool { - _, ok := m.clearedFields[billingcustomeroverride.FieldInvoiceDraftPeriodSeconds] +// InvoiceDraftPeriodCleared returns if the "invoice_draft_period" field was cleared in this mutation. +func (m *BillingCustomerOverrideMutation) InvoiceDraftPeriodCleared() bool { + _, ok := m.clearedFields[billingcustomeroverride.FieldInvoiceDraftPeriod] return ok } -// ResetInvoiceDraftPeriodSeconds resets all changes to the "invoice_draft_period_seconds" field. -func (m *BillingCustomerOverrideMutation) ResetInvoiceDraftPeriodSeconds() { - m.invoice_draft_period_seconds = nil - m.addinvoice_draft_period_seconds = nil - delete(m.clearedFields, billingcustomeroverride.FieldInvoiceDraftPeriodSeconds) +// ResetInvoiceDraftPeriod resets all changes to the "invoice_draft_period" field. +func (m *BillingCustomerOverrideMutation) ResetInvoiceDraftPeriod() { + m.invoice_draft_period = nil + delete(m.clearedFields, billingcustomeroverride.FieldInvoiceDraftPeriod) } -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (m *BillingCustomerOverrideMutation) SetInvoiceDueAfterSeconds(i int64) { - m.invoice_due_after_seconds = &i - m.addinvoice_due_after_seconds = nil +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (m *BillingCustomerOverrideMutation) SetInvoiceDueAfter(ds datex.ISOString) { + m.invoice_due_after = &ds } -// InvoiceDueAfterSeconds returns the value of the "invoice_due_after_seconds" field in the mutation. -func (m *BillingCustomerOverrideMutation) InvoiceDueAfterSeconds() (r int64, exists bool) { - v := m.invoice_due_after_seconds +// InvoiceDueAfter returns the value of the "invoice_due_after" field in the mutation. +func (m *BillingCustomerOverrideMutation) InvoiceDueAfter() (r datex.ISOString, exists bool) { + v := m.invoice_due_after if v == nil { return } return *v, true } -// OldInvoiceDueAfterSeconds returns the old "invoice_due_after_seconds" field's value of the BillingCustomerOverride entity. +// OldInvoiceDueAfter returns the old "invoice_due_after" field's value of the BillingCustomerOverride entity. // If the BillingCustomerOverride object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingCustomerOverrideMutation) OldInvoiceDueAfterSeconds(ctx context.Context) (v *int64, err error) { +func (m *BillingCustomerOverrideMutation) OldInvoiceDueAfter(ctx context.Context) (v *datex.ISOString, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInvoiceDueAfterSeconds is only allowed on UpdateOne operations") + return v, errors.New("OldInvoiceDueAfter is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInvoiceDueAfterSeconds requires an ID field in the mutation") + return v, errors.New("OldInvoiceDueAfter requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldInvoiceDueAfterSeconds: %w", err) - } - return oldValue.InvoiceDueAfterSeconds, nil -} - -// AddInvoiceDueAfterSeconds adds i to the "invoice_due_after_seconds" field. -func (m *BillingCustomerOverrideMutation) AddInvoiceDueAfterSeconds(i int64) { - if m.addinvoice_due_after_seconds != nil { - *m.addinvoice_due_after_seconds += i - } else { - m.addinvoice_due_after_seconds = &i - } -} - -// AddedInvoiceDueAfterSeconds returns the value that was added to the "invoice_due_after_seconds" field in this mutation. -func (m *BillingCustomerOverrideMutation) AddedInvoiceDueAfterSeconds() (r int64, exists bool) { - v := m.addinvoice_due_after_seconds - if v == nil { - return + return v, fmt.Errorf("querying old value for OldInvoiceDueAfter: %w", err) } - return *v, true + return oldValue.InvoiceDueAfter, nil } -// ClearInvoiceDueAfterSeconds clears the value of the "invoice_due_after_seconds" field. -func (m *BillingCustomerOverrideMutation) ClearInvoiceDueAfterSeconds() { - m.invoice_due_after_seconds = nil - m.addinvoice_due_after_seconds = nil - m.clearedFields[billingcustomeroverride.FieldInvoiceDueAfterSeconds] = struct{}{} +// ClearInvoiceDueAfter clears the value of the "invoice_due_after" field. +func (m *BillingCustomerOverrideMutation) ClearInvoiceDueAfter() { + m.invoice_due_after = nil + m.clearedFields[billingcustomeroverride.FieldInvoiceDueAfter] = struct{}{} } -// InvoiceDueAfterSecondsCleared returns if the "invoice_due_after_seconds" field was cleared in this mutation. -func (m *BillingCustomerOverrideMutation) InvoiceDueAfterSecondsCleared() bool { - _, ok := m.clearedFields[billingcustomeroverride.FieldInvoiceDueAfterSeconds] +// InvoiceDueAfterCleared returns if the "invoice_due_after" field was cleared in this mutation. +func (m *BillingCustomerOverrideMutation) InvoiceDueAfterCleared() bool { + _, ok := m.clearedFields[billingcustomeroverride.FieldInvoiceDueAfter] return ok } -// ResetInvoiceDueAfterSeconds resets all changes to the "invoice_due_after_seconds" field. -func (m *BillingCustomerOverrideMutation) ResetInvoiceDueAfterSeconds() { - m.invoice_due_after_seconds = nil - m.addinvoice_due_after_seconds = nil - delete(m.clearedFields, billingcustomeroverride.FieldInvoiceDueAfterSeconds) +// ResetInvoiceDueAfter resets all changes to the "invoice_due_after" field. +func (m *BillingCustomerOverrideMutation) ResetInvoiceDueAfter() { + m.invoice_due_after = nil + delete(m.clearedFields, billingcustomeroverride.FieldInvoiceDueAfter) } // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (m *BillingCustomerOverrideMutation) SetInvoiceCollectionMethod(bm billing.CollectionMethod) { +func (m *BillingCustomerOverrideMutation) SetInvoiceCollectionMethod(bm billingentity.CollectionMethod) { m.invoice_collection_method = &bm } // InvoiceCollectionMethod returns the value of the "invoice_collection_method" field in the mutation. -func (m *BillingCustomerOverrideMutation) InvoiceCollectionMethod() (r billing.CollectionMethod, exists bool) { +func (m *BillingCustomerOverrideMutation) InvoiceCollectionMethod() (r billingentity.CollectionMethod, exists bool) { v := m.invoice_collection_method if v == nil { return @@ -5179,7 +5360,7 @@ func (m *BillingCustomerOverrideMutation) InvoiceCollectionMethod() (r billing.C // OldInvoiceCollectionMethod returns the old "invoice_collection_method" field's value of the BillingCustomerOverride entity. // If the BillingCustomerOverride object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingCustomerOverrideMutation) OldInvoiceCollectionMethod(ctx context.Context) (v *billing.CollectionMethod, err error) { +func (m *BillingCustomerOverrideMutation) OldInvoiceCollectionMethod(ctx context.Context) (v *billingentity.CollectionMethod, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldInvoiceCollectionMethod is only allowed on UpdateOne operations") } @@ -5211,104 +5392,6 @@ func (m *BillingCustomerOverrideMutation) ResetInvoiceCollectionMethod() { delete(m.clearedFields, billingcustomeroverride.FieldInvoiceCollectionMethod) } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (m *BillingCustomerOverrideMutation) SetInvoiceItemResolution(br billing.GranularityResolution) { - m.invoice_item_resolution = &br -} - -// InvoiceItemResolution returns the value of the "invoice_item_resolution" field in the mutation. -func (m *BillingCustomerOverrideMutation) InvoiceItemResolution() (r billing.GranularityResolution, exists bool) { - v := m.invoice_item_resolution - if v == nil { - return - } - return *v, true -} - -// OldInvoiceItemResolution returns the old "invoice_item_resolution" field's value of the BillingCustomerOverride entity. -// If the BillingCustomerOverride object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingCustomerOverrideMutation) OldInvoiceItemResolution(ctx context.Context) (v *billing.GranularityResolution, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInvoiceItemResolution is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInvoiceItemResolution requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldInvoiceItemResolution: %w", err) - } - return oldValue.InvoiceItemResolution, nil -} - -// ClearInvoiceItemResolution clears the value of the "invoice_item_resolution" field. -func (m *BillingCustomerOverrideMutation) ClearInvoiceItemResolution() { - m.invoice_item_resolution = nil - m.clearedFields[billingcustomeroverride.FieldInvoiceItemResolution] = struct{}{} -} - -// InvoiceItemResolutionCleared returns if the "invoice_item_resolution" field was cleared in this mutation. -func (m *BillingCustomerOverrideMutation) InvoiceItemResolutionCleared() bool { - _, ok := m.clearedFields[billingcustomeroverride.FieldInvoiceItemResolution] - return ok -} - -// ResetInvoiceItemResolution resets all changes to the "invoice_item_resolution" field. -func (m *BillingCustomerOverrideMutation) ResetInvoiceItemResolution() { - m.invoice_item_resolution = nil - delete(m.clearedFields, billingcustomeroverride.FieldInvoiceItemResolution) -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (m *BillingCustomerOverrideMutation) SetInvoiceItemPerSubject(b bool) { - m.invoice_item_per_subject = &b -} - -// InvoiceItemPerSubject returns the value of the "invoice_item_per_subject" field in the mutation. -func (m *BillingCustomerOverrideMutation) InvoiceItemPerSubject() (r bool, exists bool) { - v := m.invoice_item_per_subject - if v == nil { - return - } - return *v, true -} - -// OldInvoiceItemPerSubject returns the old "invoice_item_per_subject" field's value of the BillingCustomerOverride entity. -// If the BillingCustomerOverride object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingCustomerOverrideMutation) OldInvoiceItemPerSubject(ctx context.Context) (v *bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInvoiceItemPerSubject is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInvoiceItemPerSubject requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldInvoiceItemPerSubject: %w", err) - } - return oldValue.InvoiceItemPerSubject, nil -} - -// ClearInvoiceItemPerSubject clears the value of the "invoice_item_per_subject" field. -func (m *BillingCustomerOverrideMutation) ClearInvoiceItemPerSubject() { - m.invoice_item_per_subject = nil - m.clearedFields[billingcustomeroverride.FieldInvoiceItemPerSubject] = struct{}{} -} - -// InvoiceItemPerSubjectCleared returns if the "invoice_item_per_subject" field was cleared in this mutation. -func (m *BillingCustomerOverrideMutation) InvoiceItemPerSubjectCleared() bool { - _, ok := m.clearedFields[billingcustomeroverride.FieldInvoiceItemPerSubject] - return ok -} - -// ResetInvoiceItemPerSubject resets all changes to the "invoice_item_per_subject" field. -func (m *BillingCustomerOverrideMutation) ResetInvoiceItemPerSubject() { - m.invoice_item_per_subject = nil - delete(m.clearedFields, billingcustomeroverride.FieldInvoiceItemPerSubject) -} - // ClearCustomer clears the "customer" edge to the Customer entity. func (m *BillingCustomerOverrideMutation) ClearCustomer() { m.clearedcustomer = true @@ -5397,7 +5480,7 @@ func (m *BillingCustomerOverrideMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BillingCustomerOverrideMutation) Fields() []string { - fields := make([]string, 0, 14) + fields := make([]string, 0, 12) if m.namespace != nil { fields = append(fields, billingcustomeroverride.FieldNamespace) } @@ -5419,27 +5502,21 @@ func (m *BillingCustomerOverrideMutation) Fields() []string { if m.collection_alignment != nil { fields = append(fields, billingcustomeroverride.FieldCollectionAlignment) } - if m.item_collection_period_seconds != nil { - fields = append(fields, billingcustomeroverride.FieldItemCollectionPeriodSeconds) + if m.item_collection_period != nil { + fields = append(fields, billingcustomeroverride.FieldItemCollectionPeriod) } if m.invoice_auto_advance != nil { fields = append(fields, billingcustomeroverride.FieldInvoiceAutoAdvance) } - if m.invoice_draft_period_seconds != nil { - fields = append(fields, billingcustomeroverride.FieldInvoiceDraftPeriodSeconds) + if m.invoice_draft_period != nil { + fields = append(fields, billingcustomeroverride.FieldInvoiceDraftPeriod) } - if m.invoice_due_after_seconds != nil { - fields = append(fields, billingcustomeroverride.FieldInvoiceDueAfterSeconds) + if m.invoice_due_after != nil { + fields = append(fields, billingcustomeroverride.FieldInvoiceDueAfter) } if m.invoice_collection_method != nil { fields = append(fields, billingcustomeroverride.FieldInvoiceCollectionMethod) } - if m.invoice_item_resolution != nil { - fields = append(fields, billingcustomeroverride.FieldInvoiceItemResolution) - } - if m.invoice_item_per_subject != nil { - fields = append(fields, billingcustomeroverride.FieldInvoiceItemPerSubject) - } return fields } @@ -5462,20 +5539,16 @@ func (m *BillingCustomerOverrideMutation) Field(name string) (ent.Value, bool) { return m.BillingProfileID() case billingcustomeroverride.FieldCollectionAlignment: return m.CollectionAlignment() - case billingcustomeroverride.FieldItemCollectionPeriodSeconds: - return m.ItemCollectionPeriodSeconds() + case billingcustomeroverride.FieldItemCollectionPeriod: + return m.ItemCollectionPeriod() case billingcustomeroverride.FieldInvoiceAutoAdvance: return m.InvoiceAutoAdvance() - case billingcustomeroverride.FieldInvoiceDraftPeriodSeconds: - return m.InvoiceDraftPeriodSeconds() - case billingcustomeroverride.FieldInvoiceDueAfterSeconds: - return m.InvoiceDueAfterSeconds() + case billingcustomeroverride.FieldInvoiceDraftPeriod: + return m.InvoiceDraftPeriod() + case billingcustomeroverride.FieldInvoiceDueAfter: + return m.InvoiceDueAfter() case billingcustomeroverride.FieldInvoiceCollectionMethod: return m.InvoiceCollectionMethod() - case billingcustomeroverride.FieldInvoiceItemResolution: - return m.InvoiceItemResolution() - case billingcustomeroverride.FieldInvoiceItemPerSubject: - return m.InvoiceItemPerSubject() } return nil, false } @@ -5499,20 +5572,16 @@ func (m *BillingCustomerOverrideMutation) OldField(ctx context.Context, name str return m.OldBillingProfileID(ctx) case billingcustomeroverride.FieldCollectionAlignment: return m.OldCollectionAlignment(ctx) - case billingcustomeroverride.FieldItemCollectionPeriodSeconds: - return m.OldItemCollectionPeriodSeconds(ctx) + case billingcustomeroverride.FieldItemCollectionPeriod: + return m.OldItemCollectionPeriod(ctx) case billingcustomeroverride.FieldInvoiceAutoAdvance: return m.OldInvoiceAutoAdvance(ctx) - case billingcustomeroverride.FieldInvoiceDraftPeriodSeconds: - return m.OldInvoiceDraftPeriodSeconds(ctx) - case billingcustomeroverride.FieldInvoiceDueAfterSeconds: - return m.OldInvoiceDueAfterSeconds(ctx) + case billingcustomeroverride.FieldInvoiceDraftPeriod: + return m.OldInvoiceDraftPeriod(ctx) + case billingcustomeroverride.FieldInvoiceDueAfter: + return m.OldInvoiceDueAfter(ctx) case billingcustomeroverride.FieldInvoiceCollectionMethod: return m.OldInvoiceCollectionMethod(ctx) - case billingcustomeroverride.FieldInvoiceItemResolution: - return m.OldInvoiceItemResolution(ctx) - case billingcustomeroverride.FieldInvoiceItemPerSubject: - return m.OldInvoiceItemPerSubject(ctx) } return nil, fmt.Errorf("unknown BillingCustomerOverride field %s", name) } @@ -5565,18 +5634,18 @@ func (m *BillingCustomerOverrideMutation) SetField(name string, value ent.Value) m.SetBillingProfileID(v) return nil case billingcustomeroverride.FieldCollectionAlignment: - v, ok := value.(billing.AlignmentKind) + v, ok := value.(billingentity.AlignmentKind) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCollectionAlignment(v) return nil - case billingcustomeroverride.FieldItemCollectionPeriodSeconds: - v, ok := value.(int64) + case billingcustomeroverride.FieldItemCollectionPeriod: + v, ok := value.(datex.ISOString) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetItemCollectionPeriodSeconds(v) + m.SetItemCollectionPeriod(v) return nil case billingcustomeroverride.FieldInvoiceAutoAdvance: v, ok := value.(bool) @@ -5585,41 +5654,27 @@ func (m *BillingCustomerOverrideMutation) SetField(name string, value ent.Value) } m.SetInvoiceAutoAdvance(v) return nil - case billingcustomeroverride.FieldInvoiceDraftPeriodSeconds: - v, ok := value.(int64) + case billingcustomeroverride.FieldInvoiceDraftPeriod: + v, ok := value.(datex.ISOString) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetInvoiceDraftPeriodSeconds(v) + m.SetInvoiceDraftPeriod(v) return nil - case billingcustomeroverride.FieldInvoiceDueAfterSeconds: - v, ok := value.(int64) + case billingcustomeroverride.FieldInvoiceDueAfter: + v, ok := value.(datex.ISOString) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetInvoiceDueAfterSeconds(v) + m.SetInvoiceDueAfter(v) return nil case billingcustomeroverride.FieldInvoiceCollectionMethod: - v, ok := value.(billing.CollectionMethod) + v, ok := value.(billingentity.CollectionMethod) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetInvoiceCollectionMethod(v) return nil - case billingcustomeroverride.FieldInvoiceItemResolution: - v, ok := value.(billing.GranularityResolution) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetInvoiceItemResolution(v) - return nil - case billingcustomeroverride.FieldInvoiceItemPerSubject: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetInvoiceItemPerSubject(v) - return nil } return fmt.Errorf("unknown BillingCustomerOverride field %s", name) } @@ -5627,31 +5682,13 @@ func (m *BillingCustomerOverrideMutation) SetField(name string, value ent.Value) // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *BillingCustomerOverrideMutation) AddedFields() []string { - var fields []string - if m.additem_collection_period_seconds != nil { - fields = append(fields, billingcustomeroverride.FieldItemCollectionPeriodSeconds) - } - if m.addinvoice_draft_period_seconds != nil { - fields = append(fields, billingcustomeroverride.FieldInvoiceDraftPeriodSeconds) - } - if m.addinvoice_due_after_seconds != nil { - fields = append(fields, billingcustomeroverride.FieldInvoiceDueAfterSeconds) - } - return fields + return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. func (m *BillingCustomerOverrideMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case billingcustomeroverride.FieldItemCollectionPeriodSeconds: - return m.AddedItemCollectionPeriodSeconds() - case billingcustomeroverride.FieldInvoiceDraftPeriodSeconds: - return m.AddedInvoiceDraftPeriodSeconds() - case billingcustomeroverride.FieldInvoiceDueAfterSeconds: - return m.AddedInvoiceDueAfterSeconds() - } return nil, false } @@ -5660,27 +5697,6 @@ func (m *BillingCustomerOverrideMutation) AddedField(name string) (ent.Value, bo // type. func (m *BillingCustomerOverrideMutation) AddField(name string, value ent.Value) error { switch name { - case billingcustomeroverride.FieldItemCollectionPeriodSeconds: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddItemCollectionPeriodSeconds(v) - return nil - case billingcustomeroverride.FieldInvoiceDraftPeriodSeconds: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddInvoiceDraftPeriodSeconds(v) - return nil - case billingcustomeroverride.FieldInvoiceDueAfterSeconds: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddInvoiceDueAfterSeconds(v) - return nil } return fmt.Errorf("unknown BillingCustomerOverride numeric field %s", name) } @@ -5698,27 +5714,21 @@ func (m *BillingCustomerOverrideMutation) ClearedFields() []string { if m.FieldCleared(billingcustomeroverride.FieldCollectionAlignment) { fields = append(fields, billingcustomeroverride.FieldCollectionAlignment) } - if m.FieldCleared(billingcustomeroverride.FieldItemCollectionPeriodSeconds) { - fields = append(fields, billingcustomeroverride.FieldItemCollectionPeriodSeconds) + if m.FieldCleared(billingcustomeroverride.FieldItemCollectionPeriod) { + fields = append(fields, billingcustomeroverride.FieldItemCollectionPeriod) } if m.FieldCleared(billingcustomeroverride.FieldInvoiceAutoAdvance) { fields = append(fields, billingcustomeroverride.FieldInvoiceAutoAdvance) } - if m.FieldCleared(billingcustomeroverride.FieldInvoiceDraftPeriodSeconds) { - fields = append(fields, billingcustomeroverride.FieldInvoiceDraftPeriodSeconds) + if m.FieldCleared(billingcustomeroverride.FieldInvoiceDraftPeriod) { + fields = append(fields, billingcustomeroverride.FieldInvoiceDraftPeriod) } - if m.FieldCleared(billingcustomeroverride.FieldInvoiceDueAfterSeconds) { - fields = append(fields, billingcustomeroverride.FieldInvoiceDueAfterSeconds) + if m.FieldCleared(billingcustomeroverride.FieldInvoiceDueAfter) { + fields = append(fields, billingcustomeroverride.FieldInvoiceDueAfter) } if m.FieldCleared(billingcustomeroverride.FieldInvoiceCollectionMethod) { fields = append(fields, billingcustomeroverride.FieldInvoiceCollectionMethod) } - if m.FieldCleared(billingcustomeroverride.FieldInvoiceItemResolution) { - fields = append(fields, billingcustomeroverride.FieldInvoiceItemResolution) - } - if m.FieldCleared(billingcustomeroverride.FieldInvoiceItemPerSubject) { - fields = append(fields, billingcustomeroverride.FieldInvoiceItemPerSubject) - } return fields } @@ -5742,27 +5752,21 @@ func (m *BillingCustomerOverrideMutation) ClearField(name string) error { case billingcustomeroverride.FieldCollectionAlignment: m.ClearCollectionAlignment() return nil - case billingcustomeroverride.FieldItemCollectionPeriodSeconds: - m.ClearItemCollectionPeriodSeconds() + case billingcustomeroverride.FieldItemCollectionPeriod: + m.ClearItemCollectionPeriod() return nil case billingcustomeroverride.FieldInvoiceAutoAdvance: m.ClearInvoiceAutoAdvance() return nil - case billingcustomeroverride.FieldInvoiceDraftPeriodSeconds: - m.ClearInvoiceDraftPeriodSeconds() + case billingcustomeroverride.FieldInvoiceDraftPeriod: + m.ClearInvoiceDraftPeriod() return nil - case billingcustomeroverride.FieldInvoiceDueAfterSeconds: - m.ClearInvoiceDueAfterSeconds() + case billingcustomeroverride.FieldInvoiceDueAfter: + m.ClearInvoiceDueAfter() return nil case billingcustomeroverride.FieldInvoiceCollectionMethod: m.ClearInvoiceCollectionMethod() return nil - case billingcustomeroverride.FieldInvoiceItemResolution: - m.ClearInvoiceItemResolution() - return nil - case billingcustomeroverride.FieldInvoiceItemPerSubject: - m.ClearInvoiceItemPerSubject() - return nil } return fmt.Errorf("unknown BillingCustomerOverride nullable field %s", name) } @@ -5792,27 +5796,21 @@ func (m *BillingCustomerOverrideMutation) ResetField(name string) error { case billingcustomeroverride.FieldCollectionAlignment: m.ResetCollectionAlignment() return nil - case billingcustomeroverride.FieldItemCollectionPeriodSeconds: - m.ResetItemCollectionPeriodSeconds() + case billingcustomeroverride.FieldItemCollectionPeriod: + m.ResetItemCollectionPeriod() return nil case billingcustomeroverride.FieldInvoiceAutoAdvance: m.ResetInvoiceAutoAdvance() return nil - case billingcustomeroverride.FieldInvoiceDraftPeriodSeconds: - m.ResetInvoiceDraftPeriodSeconds() + case billingcustomeroverride.FieldInvoiceDraftPeriod: + m.ResetInvoiceDraftPeriod() return nil - case billingcustomeroverride.FieldInvoiceDueAfterSeconds: - m.ResetInvoiceDueAfterSeconds() + case billingcustomeroverride.FieldInvoiceDueAfter: + m.ResetInvoiceDueAfter() return nil case billingcustomeroverride.FieldInvoiceCollectionMethod: m.ResetInvoiceCollectionMethod() return nil - case billingcustomeroverride.FieldInvoiceItemResolution: - m.ResetInvoiceItemResolution() - return nil - case billingcustomeroverride.FieldInvoiceItemPerSubject: - m.ResetInvoiceItemPerSubject() - return nil } return fmt.Errorf("unknown BillingCustomerOverride field %s", name) } @@ -5926,10 +5924,7 @@ type BillingInvoiceMutation struct { voided_at *time.Time currency *string due_date *time.Time - status *billing.InvoiceStatus - tax_provider *provider.TaxProvider - invoicing_provider *provider.InvoicingProvider - payment_provider *provider.PaymentProvider + status *billingentity.InvoiceStatus period_start *time.Time period_end *time.Time clearedFields map[string]struct{} @@ -6547,12 +6542,12 @@ func (m *BillingInvoiceMutation) ResetDueDate() { } // SetStatus sets the "status" field. -func (m *BillingInvoiceMutation) SetStatus(bs billing.InvoiceStatus) { +func (m *BillingInvoiceMutation) SetStatus(bs billingentity.InvoiceStatus) { m.status = &bs } // Status returns the value of the "status" field in the mutation. -func (m *BillingInvoiceMutation) Status() (r billing.InvoiceStatus, exists bool) { +func (m *BillingInvoiceMutation) Status() (r billingentity.InvoiceStatus, exists bool) { v := m.status if v == nil { return @@ -6563,7 +6558,7 @@ func (m *BillingInvoiceMutation) Status() (r billing.InvoiceStatus, exists bool) // OldStatus returns the old "status" field's value of the BillingInvoice entity. // If the BillingInvoice object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingInvoiceMutation) OldStatus(ctx context.Context) (v billing.InvoiceStatus, err error) { +func (m *BillingInvoiceMutation) OldStatus(ctx context.Context) (v billingentity.InvoiceStatus, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldStatus is only allowed on UpdateOne operations") } @@ -6582,192 +6577,45 @@ func (m *BillingInvoiceMutation) ResetStatus() { m.status = nil } -// SetTaxProvider sets the "tax_provider" field. -func (m *BillingInvoiceMutation) SetTaxProvider(pp provider.TaxProvider) { - m.tax_provider = &pp +// SetWorkflowConfigID sets the "workflow_config_id" field. +func (m *BillingInvoiceMutation) SetWorkflowConfigID(s string) { + m.billing_workflow_config = &s } -// TaxProvider returns the value of the "tax_provider" field in the mutation. -func (m *BillingInvoiceMutation) TaxProvider() (r provider.TaxProvider, exists bool) { - v := m.tax_provider +// WorkflowConfigID returns the value of the "workflow_config_id" field in the mutation. +func (m *BillingInvoiceMutation) WorkflowConfigID() (r string, exists bool) { + v := m.billing_workflow_config if v == nil { return } return *v, true } -// OldTaxProvider returns the old "tax_provider" field's value of the BillingInvoice entity. +// OldWorkflowConfigID returns the old "workflow_config_id" field's value of the BillingInvoice entity. // If the BillingInvoice object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingInvoiceMutation) OldTaxProvider(ctx context.Context) (v *provider.TaxProvider, err error) { +func (m *BillingInvoiceMutation) OldWorkflowConfigID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTaxProvider is only allowed on UpdateOne operations") + return v, errors.New("OldWorkflowConfigID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTaxProvider requires an ID field in the mutation") + return v, errors.New("OldWorkflowConfigID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTaxProvider: %w", err) + return v, fmt.Errorf("querying old value for OldWorkflowConfigID: %w", err) } - return oldValue.TaxProvider, nil -} - -// ClearTaxProvider clears the value of the "tax_provider" field. -func (m *BillingInvoiceMutation) ClearTaxProvider() { - m.tax_provider = nil - m.clearedFields[billinginvoice.FieldTaxProvider] = struct{}{} -} - -// TaxProviderCleared returns if the "tax_provider" field was cleared in this mutation. -func (m *BillingInvoiceMutation) TaxProviderCleared() bool { - _, ok := m.clearedFields[billinginvoice.FieldTaxProvider] - return ok + return oldValue.WorkflowConfigID, nil } -// ResetTaxProvider resets all changes to the "tax_provider" field. -func (m *BillingInvoiceMutation) ResetTaxProvider() { - m.tax_provider = nil - delete(m.clearedFields, billinginvoice.FieldTaxProvider) +// ResetWorkflowConfigID resets all changes to the "workflow_config_id" field. +func (m *BillingInvoiceMutation) ResetWorkflowConfigID() { + m.billing_workflow_config = nil } -// SetInvoicingProvider sets the "invoicing_provider" field. -func (m *BillingInvoiceMutation) SetInvoicingProvider(pp provider.InvoicingProvider) { - m.invoicing_provider = &pp -} - -// InvoicingProvider returns the value of the "invoicing_provider" field in the mutation. -func (m *BillingInvoiceMutation) InvoicingProvider() (r provider.InvoicingProvider, exists bool) { - v := m.invoicing_provider - if v == nil { - return - } - return *v, true -} - -// OldInvoicingProvider returns the old "invoicing_provider" field's value of the BillingInvoice entity. -// If the BillingInvoice object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingInvoiceMutation) OldInvoicingProvider(ctx context.Context) (v *provider.InvoicingProvider, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInvoicingProvider is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInvoicingProvider requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldInvoicingProvider: %w", err) - } - return oldValue.InvoicingProvider, nil -} - -// ClearInvoicingProvider clears the value of the "invoicing_provider" field. -func (m *BillingInvoiceMutation) ClearInvoicingProvider() { - m.invoicing_provider = nil - m.clearedFields[billinginvoice.FieldInvoicingProvider] = struct{}{} -} - -// InvoicingProviderCleared returns if the "invoicing_provider" field was cleared in this mutation. -func (m *BillingInvoiceMutation) InvoicingProviderCleared() bool { - _, ok := m.clearedFields[billinginvoice.FieldInvoicingProvider] - return ok -} - -// ResetInvoicingProvider resets all changes to the "invoicing_provider" field. -func (m *BillingInvoiceMutation) ResetInvoicingProvider() { - m.invoicing_provider = nil - delete(m.clearedFields, billinginvoice.FieldInvoicingProvider) -} - -// SetPaymentProvider sets the "payment_provider" field. -func (m *BillingInvoiceMutation) SetPaymentProvider(pp provider.PaymentProvider) { - m.payment_provider = &pp -} - -// PaymentProvider returns the value of the "payment_provider" field in the mutation. -func (m *BillingInvoiceMutation) PaymentProvider() (r provider.PaymentProvider, exists bool) { - v := m.payment_provider - if v == nil { - return - } - return *v, true -} - -// OldPaymentProvider returns the old "payment_provider" field's value of the BillingInvoice entity. -// If the BillingInvoice object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingInvoiceMutation) OldPaymentProvider(ctx context.Context) (v *provider.PaymentProvider, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPaymentProvider is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPaymentProvider requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPaymentProvider: %w", err) - } - return oldValue.PaymentProvider, nil -} - -// ClearPaymentProvider clears the value of the "payment_provider" field. -func (m *BillingInvoiceMutation) ClearPaymentProvider() { - m.payment_provider = nil - m.clearedFields[billinginvoice.FieldPaymentProvider] = struct{}{} -} - -// PaymentProviderCleared returns if the "payment_provider" field was cleared in this mutation. -func (m *BillingInvoiceMutation) PaymentProviderCleared() bool { - _, ok := m.clearedFields[billinginvoice.FieldPaymentProvider] - return ok -} - -// ResetPaymentProvider resets all changes to the "payment_provider" field. -func (m *BillingInvoiceMutation) ResetPaymentProvider() { - m.payment_provider = nil - delete(m.clearedFields, billinginvoice.FieldPaymentProvider) -} - -// SetWorkflowConfigID sets the "workflow_config_id" field. -func (m *BillingInvoiceMutation) SetWorkflowConfigID(s string) { - m.billing_workflow_config = &s -} - -// WorkflowConfigID returns the value of the "workflow_config_id" field in the mutation. -func (m *BillingInvoiceMutation) WorkflowConfigID() (r string, exists bool) { - v := m.billing_workflow_config - if v == nil { - return - } - return *v, true -} - -// OldWorkflowConfigID returns the old "workflow_config_id" field's value of the BillingInvoice entity. -// If the BillingInvoice object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingInvoiceMutation) OldWorkflowConfigID(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWorkflowConfigID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWorkflowConfigID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldWorkflowConfigID: %w", err) - } - return oldValue.WorkflowConfigID, nil -} - -// ResetWorkflowConfigID resets all changes to the "workflow_config_id" field. -func (m *BillingInvoiceMutation) ResetWorkflowConfigID() { - m.billing_workflow_config = nil -} - -// SetPeriodStart sets the "period_start" field. -func (m *BillingInvoiceMutation) SetPeriodStart(t time.Time) { - m.period_start = &t +// SetPeriodStart sets the "period_start" field. +func (m *BillingInvoiceMutation) SetPeriodStart(t time.Time) { + m.period_start = &t } // PeriodStart returns the value of the "period_start" field in the mutation. @@ -6992,7 +6840,7 @@ func (m *BillingInvoiceMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BillingInvoiceMutation) Fields() []string { - fields := make([]string, 0, 19) + fields := make([]string, 0, 16) if m.namespace != nil { fields = append(fields, billinginvoice.FieldNamespace) } @@ -7032,15 +6880,6 @@ func (m *BillingInvoiceMutation) Fields() []string { if m.status != nil { fields = append(fields, billinginvoice.FieldStatus) } - if m.tax_provider != nil { - fields = append(fields, billinginvoice.FieldTaxProvider) - } - if m.invoicing_provider != nil { - fields = append(fields, billinginvoice.FieldInvoicingProvider) - } - if m.payment_provider != nil { - fields = append(fields, billinginvoice.FieldPaymentProvider) - } if m.billing_workflow_config != nil { fields = append(fields, billinginvoice.FieldWorkflowConfigID) } @@ -7084,12 +6923,6 @@ func (m *BillingInvoiceMutation) Field(name string) (ent.Value, bool) { return m.DueDate() case billinginvoice.FieldStatus: return m.Status() - case billinginvoice.FieldTaxProvider: - return m.TaxProvider() - case billinginvoice.FieldInvoicingProvider: - return m.InvoicingProvider() - case billinginvoice.FieldPaymentProvider: - return m.PaymentProvider() case billinginvoice.FieldWorkflowConfigID: return m.WorkflowConfigID() case billinginvoice.FieldPeriodStart: @@ -7131,12 +6964,6 @@ func (m *BillingInvoiceMutation) OldField(ctx context.Context, name string) (ent return m.OldDueDate(ctx) case billinginvoice.FieldStatus: return m.OldStatus(ctx) - case billinginvoice.FieldTaxProvider: - return m.OldTaxProvider(ctx) - case billinginvoice.FieldInvoicingProvider: - return m.OldInvoicingProvider(ctx) - case billinginvoice.FieldPaymentProvider: - return m.OldPaymentProvider(ctx) case billinginvoice.FieldWorkflowConfigID: return m.OldWorkflowConfigID(ctx) case billinginvoice.FieldPeriodStart: @@ -7237,33 +7064,12 @@ func (m *BillingInvoiceMutation) SetField(name string, value ent.Value) error { m.SetDueDate(v) return nil case billinginvoice.FieldStatus: - v, ok := value.(billing.InvoiceStatus) + v, ok := value.(billingentity.InvoiceStatus) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetStatus(v) return nil - case billinginvoice.FieldTaxProvider: - v, ok := value.(provider.TaxProvider) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTaxProvider(v) - return nil - case billinginvoice.FieldInvoicingProvider: - v, ok := value.(provider.InvoicingProvider) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetInvoicingProvider(v) - return nil - case billinginvoice.FieldPaymentProvider: - v, ok := value.(provider.PaymentProvider) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPaymentProvider(v) - return nil case billinginvoice.FieldWorkflowConfigID: v, ok := value.(string) if !ok { @@ -7330,15 +7136,6 @@ func (m *BillingInvoiceMutation) ClearedFields() []string { if m.FieldCleared(billinginvoice.FieldVoidedAt) { fields = append(fields, billinginvoice.FieldVoidedAt) } - if m.FieldCleared(billinginvoice.FieldTaxProvider) { - fields = append(fields, billinginvoice.FieldTaxProvider) - } - if m.FieldCleared(billinginvoice.FieldInvoicingProvider) { - fields = append(fields, billinginvoice.FieldInvoicingProvider) - } - if m.FieldCleared(billinginvoice.FieldPaymentProvider) { - fields = append(fields, billinginvoice.FieldPaymentProvider) - } return fields } @@ -7368,15 +7165,6 @@ func (m *BillingInvoiceMutation) ClearField(name string) error { case billinginvoice.FieldVoidedAt: m.ClearVoidedAt() return nil - case billinginvoice.FieldTaxProvider: - m.ClearTaxProvider() - return nil - case billinginvoice.FieldInvoicingProvider: - m.ClearInvoicingProvider() - return nil - case billinginvoice.FieldPaymentProvider: - m.ClearPaymentProvider() - return nil } return fmt.Errorf("unknown BillingInvoice nullable field %s", name) } @@ -7424,15 +7212,6 @@ func (m *BillingInvoiceMutation) ResetField(name string) error { case billinginvoice.FieldStatus: m.ResetStatus() return nil - case billinginvoice.FieldTaxProvider: - m.ResetTaxProvider() - return nil - case billinginvoice.FieldInvoicingProvider: - m.ResetInvoicingProvider() - return nil - case billinginvoice.FieldPaymentProvider: - m.ResetPaymentProvider() - return nil case billinginvoice.FieldWorkflowConfigID: m.ResetWorkflowConfigID() return nil @@ -7581,12 +7360,12 @@ type BillingInvoiceItemMutation struct { period_start *time.Time period_end *time.Time invoice_at *time.Time - _type *billing.InvoiceItemType + _type *billingentity.InvoiceItemType name *string quantity *alpacadecimal.Decimal unit_price *alpacadecimal.Decimal currency *currencyx.Code - tax_code_override *billing.TaxOverrides + tax_code_override *billingentity.TaxOverrides clearedFields map[string]struct{} billing_invoice *string clearedbilling_invoice bool @@ -8099,12 +7878,12 @@ func (m *BillingInvoiceItemMutation) ResetInvoiceAt() { } // SetType sets the "type" field. -func (m *BillingInvoiceItemMutation) SetType(bit billing.InvoiceItemType) { +func (m *BillingInvoiceItemMutation) SetType(bit billingentity.InvoiceItemType) { m._type = &bit } // GetType returns the value of the "type" field in the mutation. -func (m *BillingInvoiceItemMutation) GetType() (r billing.InvoiceItemType, exists bool) { +func (m *BillingInvoiceItemMutation) GetType() (r billingentity.InvoiceItemType, exists bool) { v := m._type if v == nil { return @@ -8115,7 +7894,7 @@ func (m *BillingInvoiceItemMutation) GetType() (r billing.InvoiceItemType, exist // OldType returns the old "type" field's value of the BillingInvoiceItem entity. // If the BillingInvoiceItem object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingInvoiceItemMutation) OldType(ctx context.Context) (v billing.InvoiceItemType, err error) { +func (m *BillingInvoiceItemMutation) OldType(ctx context.Context) (v billingentity.InvoiceItemType, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldType is only allowed on UpdateOne operations") } @@ -8292,12 +8071,12 @@ func (m *BillingInvoiceItemMutation) ResetCurrency() { } // SetTaxCodeOverride sets the "tax_code_override" field. -func (m *BillingInvoiceItemMutation) SetTaxCodeOverride(bo billing.TaxOverrides) { +func (m *BillingInvoiceItemMutation) SetTaxCodeOverride(bo billingentity.TaxOverrides) { m.tax_code_override = &bo } // TaxCodeOverride returns the value of the "tax_code_override" field in the mutation. -func (m *BillingInvoiceItemMutation) TaxCodeOverride() (r billing.TaxOverrides, exists bool) { +func (m *BillingInvoiceItemMutation) TaxCodeOverride() (r billingentity.TaxOverrides, exists bool) { v := m.tax_code_override if v == nil { return @@ -8308,7 +8087,7 @@ func (m *BillingInvoiceItemMutation) TaxCodeOverride() (r billing.TaxOverrides, // OldTaxCodeOverride returns the old "tax_code_override" field's value of the BillingInvoiceItem entity. // If the BillingInvoiceItem object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingInvoiceItemMutation) OldTaxCodeOverride(ctx context.Context) (v billing.TaxOverrides, err error) { +func (m *BillingInvoiceItemMutation) OldTaxCodeOverride(ctx context.Context) (v billingentity.TaxOverrides, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldTaxCodeOverride is only allowed on UpdateOne operations") } @@ -8611,7 +8390,7 @@ func (m *BillingInvoiceItemMutation) SetField(name string, value ent.Value) erro m.SetInvoiceAt(v) return nil case billinginvoiceitem.FieldType: - v, ok := value.(billing.InvoiceItemType) + v, ok := value.(billingentity.InvoiceItemType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -8646,7 +8425,7 @@ func (m *BillingInvoiceItemMutation) SetField(name string, value ent.Value) erro m.SetCurrency(v) return nil case billinginvoiceitem.FieldTaxCodeOverride: - v, ok := value.(billing.TaxOverrides) + v, ok := value.(billingentity.TaxOverrides) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -8874,11 +8653,9 @@ type BillingProfileMutation struct { supplier_address_line1 *string supplier_address_line2 *string supplier_address_phone_number *string - tax_provider *provider.TaxProvider - invoicing_provider *provider.InvoicingProvider - payment_provider *provider.PaymentProvider _default *bool supplier_name *string + supplier_tax_code *string clearedFields map[string]struct{} billing_invoices map[string]struct{} removedbilling_invoices map[string]struct{} @@ -8888,6 +8665,12 @@ type BillingProfileMutation struct { clearedbilling_customer_override bool workflow_config *string clearedworkflow_config bool + tax_app *string + clearedtax_app bool + invoicing_app *string + clearedinvoicing_app bool + payment_app *string + clearedpayment_app bool done bool oldValue func(context.Context) (*BillingProfile, error) predicates []predicate.BillingProfile @@ -9631,112 +9414,112 @@ func (m *BillingProfileMutation) ResetSupplierAddressPhoneNumber() { delete(m.clearedFields, billingprofile.FieldSupplierAddressPhoneNumber) } -// SetTaxProvider sets the "tax_provider" field. -func (m *BillingProfileMutation) SetTaxProvider(pp provider.TaxProvider) { - m.tax_provider = &pp +// SetTaxAppID sets the "tax_app_id" field. +func (m *BillingProfileMutation) SetTaxAppID(s string) { + m.tax_app = &s } -// TaxProvider returns the value of the "tax_provider" field in the mutation. -func (m *BillingProfileMutation) TaxProvider() (r provider.TaxProvider, exists bool) { - v := m.tax_provider +// TaxAppID returns the value of the "tax_app_id" field in the mutation. +func (m *BillingProfileMutation) TaxAppID() (r string, exists bool) { + v := m.tax_app if v == nil { return } return *v, true } -// OldTaxProvider returns the old "tax_provider" field's value of the BillingProfile entity. +// OldTaxAppID returns the old "tax_app_id" field's value of the BillingProfile entity. // If the BillingProfile object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingProfileMutation) OldTaxProvider(ctx context.Context) (v provider.TaxProvider, err error) { +func (m *BillingProfileMutation) OldTaxAppID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTaxProvider is only allowed on UpdateOne operations") + return v, errors.New("OldTaxAppID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTaxProvider requires an ID field in the mutation") + return v, errors.New("OldTaxAppID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTaxProvider: %w", err) + return v, fmt.Errorf("querying old value for OldTaxAppID: %w", err) } - return oldValue.TaxProvider, nil + return oldValue.TaxAppID, nil } -// ResetTaxProvider resets all changes to the "tax_provider" field. -func (m *BillingProfileMutation) ResetTaxProvider() { - m.tax_provider = nil +// ResetTaxAppID resets all changes to the "tax_app_id" field. +func (m *BillingProfileMutation) ResetTaxAppID() { + m.tax_app = nil } -// SetInvoicingProvider sets the "invoicing_provider" field. -func (m *BillingProfileMutation) SetInvoicingProvider(pp provider.InvoicingProvider) { - m.invoicing_provider = &pp +// SetInvoicingAppID sets the "invoicing_app_id" field. +func (m *BillingProfileMutation) SetInvoicingAppID(s string) { + m.invoicing_app = &s } -// InvoicingProvider returns the value of the "invoicing_provider" field in the mutation. -func (m *BillingProfileMutation) InvoicingProvider() (r provider.InvoicingProvider, exists bool) { - v := m.invoicing_provider +// InvoicingAppID returns the value of the "invoicing_app_id" field in the mutation. +func (m *BillingProfileMutation) InvoicingAppID() (r string, exists bool) { + v := m.invoicing_app if v == nil { return } return *v, true } -// OldInvoicingProvider returns the old "invoicing_provider" field's value of the BillingProfile entity. +// OldInvoicingAppID returns the old "invoicing_app_id" field's value of the BillingProfile entity. // If the BillingProfile object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingProfileMutation) OldInvoicingProvider(ctx context.Context) (v provider.InvoicingProvider, err error) { +func (m *BillingProfileMutation) OldInvoicingAppID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInvoicingProvider is only allowed on UpdateOne operations") + return v, errors.New("OldInvoicingAppID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInvoicingProvider requires an ID field in the mutation") + return v, errors.New("OldInvoicingAppID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldInvoicingProvider: %w", err) + return v, fmt.Errorf("querying old value for OldInvoicingAppID: %w", err) } - return oldValue.InvoicingProvider, nil + return oldValue.InvoicingAppID, nil } -// ResetInvoicingProvider resets all changes to the "invoicing_provider" field. -func (m *BillingProfileMutation) ResetInvoicingProvider() { - m.invoicing_provider = nil +// ResetInvoicingAppID resets all changes to the "invoicing_app_id" field. +func (m *BillingProfileMutation) ResetInvoicingAppID() { + m.invoicing_app = nil } -// SetPaymentProvider sets the "payment_provider" field. -func (m *BillingProfileMutation) SetPaymentProvider(pp provider.PaymentProvider) { - m.payment_provider = &pp +// SetPaymentAppID sets the "payment_app_id" field. +func (m *BillingProfileMutation) SetPaymentAppID(s string) { + m.payment_app = &s } -// PaymentProvider returns the value of the "payment_provider" field in the mutation. -func (m *BillingProfileMutation) PaymentProvider() (r provider.PaymentProvider, exists bool) { - v := m.payment_provider +// PaymentAppID returns the value of the "payment_app_id" field in the mutation. +func (m *BillingProfileMutation) PaymentAppID() (r string, exists bool) { + v := m.payment_app if v == nil { return } return *v, true } -// OldPaymentProvider returns the old "payment_provider" field's value of the BillingProfile entity. +// OldPaymentAppID returns the old "payment_app_id" field's value of the BillingProfile entity. // If the BillingProfile object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingProfileMutation) OldPaymentProvider(ctx context.Context) (v provider.PaymentProvider, err error) { +func (m *BillingProfileMutation) OldPaymentAppID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPaymentProvider is only allowed on UpdateOne operations") + return v, errors.New("OldPaymentAppID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPaymentProvider requires an ID field in the mutation") + return v, errors.New("OldPaymentAppID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPaymentProvider: %w", err) + return v, fmt.Errorf("querying old value for OldPaymentAppID: %w", err) } - return oldValue.PaymentProvider, nil + return oldValue.PaymentAppID, nil } -// ResetPaymentProvider resets all changes to the "payment_provider" field. -func (m *BillingProfileMutation) ResetPaymentProvider() { - m.payment_provider = nil +// ResetPaymentAppID resets all changes to the "payment_app_id" field. +func (m *BillingProfileMutation) ResetPaymentAppID() { + m.payment_app = nil } // SetWorkflowConfigID sets the "workflow_config_id" field. @@ -9847,6 +9630,55 @@ func (m *BillingProfileMutation) ResetSupplierName() { m.supplier_name = nil } +// SetSupplierTaxCode sets the "supplier_tax_code" field. +func (m *BillingProfileMutation) SetSupplierTaxCode(s string) { + m.supplier_tax_code = &s +} + +// SupplierTaxCode returns the value of the "supplier_tax_code" field in the mutation. +func (m *BillingProfileMutation) SupplierTaxCode() (r string, exists bool) { + v := m.supplier_tax_code + if v == nil { + return + } + return *v, true +} + +// OldSupplierTaxCode returns the old "supplier_tax_code" field's value of the BillingProfile entity. +// If the BillingProfile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BillingProfileMutation) OldSupplierTaxCode(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSupplierTaxCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSupplierTaxCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSupplierTaxCode: %w", err) + } + return oldValue.SupplierTaxCode, nil +} + +// ClearSupplierTaxCode clears the value of the "supplier_tax_code" field. +func (m *BillingProfileMutation) ClearSupplierTaxCode() { + m.supplier_tax_code = nil + m.clearedFields[billingprofile.FieldSupplierTaxCode] = struct{}{} +} + +// SupplierTaxCodeCleared returns if the "supplier_tax_code" field was cleared in this mutation. +func (m *BillingProfileMutation) SupplierTaxCodeCleared() bool { + _, ok := m.clearedFields[billingprofile.FieldSupplierTaxCode] + return ok +} + +// ResetSupplierTaxCode resets all changes to the "supplier_tax_code" field. +func (m *BillingProfileMutation) ResetSupplierTaxCode() { + m.supplier_tax_code = nil + delete(m.clearedFields, billingprofile.FieldSupplierTaxCode) +} + // AddBillingInvoiceIDs adds the "billing_invoices" edge to the BillingInvoice entity by ids. func (m *BillingProfileMutation) AddBillingInvoiceIDs(ids ...string) { if m.billing_invoices == nil { @@ -9982,6 +9814,87 @@ func (m *BillingProfileMutation) ResetWorkflowConfig() { m.clearedworkflow_config = false } +// ClearTaxApp clears the "tax_app" edge to the App entity. +func (m *BillingProfileMutation) ClearTaxApp() { + m.clearedtax_app = true + m.clearedFields[billingprofile.FieldTaxAppID] = struct{}{} +} + +// TaxAppCleared reports if the "tax_app" edge to the App entity was cleared. +func (m *BillingProfileMutation) TaxAppCleared() bool { + return m.clearedtax_app +} + +// TaxAppIDs returns the "tax_app" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TaxAppID instead. It exists only for internal usage by the builders. +func (m *BillingProfileMutation) TaxAppIDs() (ids []string) { + if id := m.tax_app; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetTaxApp resets all changes to the "tax_app" edge. +func (m *BillingProfileMutation) ResetTaxApp() { + m.tax_app = nil + m.clearedtax_app = false +} + +// ClearInvoicingApp clears the "invoicing_app" edge to the App entity. +func (m *BillingProfileMutation) ClearInvoicingApp() { + m.clearedinvoicing_app = true + m.clearedFields[billingprofile.FieldInvoicingAppID] = struct{}{} +} + +// InvoicingAppCleared reports if the "invoicing_app" edge to the App entity was cleared. +func (m *BillingProfileMutation) InvoicingAppCleared() bool { + return m.clearedinvoicing_app +} + +// InvoicingAppIDs returns the "invoicing_app" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// InvoicingAppID instead. It exists only for internal usage by the builders. +func (m *BillingProfileMutation) InvoicingAppIDs() (ids []string) { + if id := m.invoicing_app; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetInvoicingApp resets all changes to the "invoicing_app" edge. +func (m *BillingProfileMutation) ResetInvoicingApp() { + m.invoicing_app = nil + m.clearedinvoicing_app = false +} + +// ClearPaymentApp clears the "payment_app" edge to the App entity. +func (m *BillingProfileMutation) ClearPaymentApp() { + m.clearedpayment_app = true + m.clearedFields[billingprofile.FieldPaymentAppID] = struct{}{} +} + +// PaymentAppCleared reports if the "payment_app" edge to the App entity was cleared. +func (m *BillingProfileMutation) PaymentAppCleared() bool { + return m.clearedpayment_app +} + +// PaymentAppIDs returns the "payment_app" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// PaymentAppID instead. It exists only for internal usage by the builders. +func (m *BillingProfileMutation) PaymentAppIDs() (ids []string) { + if id := m.payment_app; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetPaymentApp resets all changes to the "payment_app" edge. +func (m *BillingProfileMutation) ResetPaymentApp() { + m.payment_app = nil + m.clearedpayment_app = false +} + // Where appends a list predicates to the BillingProfileMutation builder. func (m *BillingProfileMutation) Where(ps ...predicate.BillingProfile) { m.predicates = append(m.predicates, ps...) @@ -10016,7 +9929,7 @@ func (m *BillingProfileMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BillingProfileMutation) Fields() []string { - fields := make([]string, 0, 20) + fields := make([]string, 0, 21) if m.namespace != nil { fields = append(fields, billingprofile.FieldNamespace) } @@ -10059,14 +9972,14 @@ func (m *BillingProfileMutation) Fields() []string { if m.supplier_address_phone_number != nil { fields = append(fields, billingprofile.FieldSupplierAddressPhoneNumber) } - if m.tax_provider != nil { - fields = append(fields, billingprofile.FieldTaxProvider) + if m.tax_app != nil { + fields = append(fields, billingprofile.FieldTaxAppID) } - if m.invoicing_provider != nil { - fields = append(fields, billingprofile.FieldInvoicingProvider) + if m.invoicing_app != nil { + fields = append(fields, billingprofile.FieldInvoicingAppID) } - if m.payment_provider != nil { - fields = append(fields, billingprofile.FieldPaymentProvider) + if m.payment_app != nil { + fields = append(fields, billingprofile.FieldPaymentAppID) } if m.workflow_config != nil { fields = append(fields, billingprofile.FieldWorkflowConfigID) @@ -10077,6 +9990,9 @@ func (m *BillingProfileMutation) Fields() []string { if m.supplier_name != nil { fields = append(fields, billingprofile.FieldSupplierName) } + if m.supplier_tax_code != nil { + fields = append(fields, billingprofile.FieldSupplierTaxCode) + } return fields } @@ -10113,18 +10029,20 @@ func (m *BillingProfileMutation) Field(name string) (ent.Value, bool) { return m.SupplierAddressLine2() case billingprofile.FieldSupplierAddressPhoneNumber: return m.SupplierAddressPhoneNumber() - case billingprofile.FieldTaxProvider: - return m.TaxProvider() - case billingprofile.FieldInvoicingProvider: - return m.InvoicingProvider() - case billingprofile.FieldPaymentProvider: - return m.PaymentProvider() + case billingprofile.FieldTaxAppID: + return m.TaxAppID() + case billingprofile.FieldInvoicingAppID: + return m.InvoicingAppID() + case billingprofile.FieldPaymentAppID: + return m.PaymentAppID() case billingprofile.FieldWorkflowConfigID: return m.WorkflowConfigID() case billingprofile.FieldDefault: return m.Default() case billingprofile.FieldSupplierName: return m.SupplierName() + case billingprofile.FieldSupplierTaxCode: + return m.SupplierTaxCode() } return nil, false } @@ -10162,18 +10080,20 @@ func (m *BillingProfileMutation) OldField(ctx context.Context, name string) (ent return m.OldSupplierAddressLine2(ctx) case billingprofile.FieldSupplierAddressPhoneNumber: return m.OldSupplierAddressPhoneNumber(ctx) - case billingprofile.FieldTaxProvider: - return m.OldTaxProvider(ctx) - case billingprofile.FieldInvoicingProvider: - return m.OldInvoicingProvider(ctx) - case billingprofile.FieldPaymentProvider: - return m.OldPaymentProvider(ctx) + case billingprofile.FieldTaxAppID: + return m.OldTaxAppID(ctx) + case billingprofile.FieldInvoicingAppID: + return m.OldInvoicingAppID(ctx) + case billingprofile.FieldPaymentAppID: + return m.OldPaymentAppID(ctx) case billingprofile.FieldWorkflowConfigID: return m.OldWorkflowConfigID(ctx) case billingprofile.FieldDefault: return m.OldDefault(ctx) case billingprofile.FieldSupplierName: return m.OldSupplierName(ctx) + case billingprofile.FieldSupplierTaxCode: + return m.OldSupplierTaxCode(ctx) } return nil, fmt.Errorf("unknown BillingProfile field %s", name) } @@ -10281,26 +10201,26 @@ func (m *BillingProfileMutation) SetField(name string, value ent.Value) error { } m.SetSupplierAddressPhoneNumber(v) return nil - case billingprofile.FieldTaxProvider: - v, ok := value.(provider.TaxProvider) + case billingprofile.FieldTaxAppID: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetTaxProvider(v) + m.SetTaxAppID(v) return nil - case billingprofile.FieldInvoicingProvider: - v, ok := value.(provider.InvoicingProvider) + case billingprofile.FieldInvoicingAppID: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetInvoicingProvider(v) + m.SetInvoicingAppID(v) return nil - case billingprofile.FieldPaymentProvider: - v, ok := value.(provider.PaymentProvider) + case billingprofile.FieldPaymentAppID: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPaymentProvider(v) + m.SetPaymentAppID(v) return nil case billingprofile.FieldWorkflowConfigID: v, ok := value.(string) @@ -10323,6 +10243,13 @@ func (m *BillingProfileMutation) SetField(name string, value ent.Value) error { } m.SetSupplierName(v) return nil + case billingprofile.FieldSupplierTaxCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSupplierTaxCode(v) + return nil } return fmt.Errorf("unknown BillingProfile field %s", name) } @@ -10383,6 +10310,9 @@ func (m *BillingProfileMutation) ClearedFields() []string { if m.FieldCleared(billingprofile.FieldSupplierAddressPhoneNumber) { fields = append(fields, billingprofile.FieldSupplierAddressPhoneNumber) } + if m.FieldCleared(billingprofile.FieldSupplierTaxCode) { + fields = append(fields, billingprofile.FieldSupplierTaxCode) + } return fields } @@ -10427,6 +10357,9 @@ func (m *BillingProfileMutation) ClearField(name string) error { case billingprofile.FieldSupplierAddressPhoneNumber: m.ClearSupplierAddressPhoneNumber() return nil + case billingprofile.FieldSupplierTaxCode: + m.ClearSupplierTaxCode() + return nil } return fmt.Errorf("unknown BillingProfile nullable field %s", name) } @@ -10477,14 +10410,14 @@ func (m *BillingProfileMutation) ResetField(name string) error { case billingprofile.FieldSupplierAddressPhoneNumber: m.ResetSupplierAddressPhoneNumber() return nil - case billingprofile.FieldTaxProvider: - m.ResetTaxProvider() + case billingprofile.FieldTaxAppID: + m.ResetTaxAppID() return nil - case billingprofile.FieldInvoicingProvider: - m.ResetInvoicingProvider() + case billingprofile.FieldInvoicingAppID: + m.ResetInvoicingAppID() return nil - case billingprofile.FieldPaymentProvider: - m.ResetPaymentProvider() + case billingprofile.FieldPaymentAppID: + m.ResetPaymentAppID() return nil case billingprofile.FieldWorkflowConfigID: m.ResetWorkflowConfigID() @@ -10495,13 +10428,16 @@ func (m *BillingProfileMutation) ResetField(name string) error { case billingprofile.FieldSupplierName: m.ResetSupplierName() return nil + case billingprofile.FieldSupplierTaxCode: + m.ResetSupplierTaxCode() + return nil } return fmt.Errorf("unknown BillingProfile field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. func (m *BillingProfileMutation) AddedEdges() []string { - edges := make([]string, 0, 3) + edges := make([]string, 0, 6) if m.billing_invoices != nil { edges = append(edges, billingprofile.EdgeBillingInvoices) } @@ -10511,6 +10447,15 @@ func (m *BillingProfileMutation) AddedEdges() []string { if m.workflow_config != nil { edges = append(edges, billingprofile.EdgeWorkflowConfig) } + if m.tax_app != nil { + edges = append(edges, billingprofile.EdgeTaxApp) + } + if m.invoicing_app != nil { + edges = append(edges, billingprofile.EdgeInvoicingApp) + } + if m.payment_app != nil { + edges = append(edges, billingprofile.EdgePaymentApp) + } return edges } @@ -10534,13 +10479,25 @@ func (m *BillingProfileMutation) AddedIDs(name string) []ent.Value { if id := m.workflow_config; id != nil { return []ent.Value{*id} } + case billingprofile.EdgeTaxApp: + if id := m.tax_app; id != nil { + return []ent.Value{*id} + } + case billingprofile.EdgeInvoicingApp: + if id := m.invoicing_app; id != nil { + return []ent.Value{*id} + } + case billingprofile.EdgePaymentApp: + if id := m.payment_app; id != nil { + return []ent.Value{*id} + } } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *BillingProfileMutation) RemovedEdges() []string { - edges := make([]string, 0, 3) + edges := make([]string, 0, 6) if m.removedbilling_invoices != nil { edges = append(edges, billingprofile.EdgeBillingInvoices) } @@ -10572,7 +10529,7 @@ func (m *BillingProfileMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *BillingProfileMutation) ClearedEdges() []string { - edges := make([]string, 0, 3) + edges := make([]string, 0, 6) if m.clearedbilling_invoices { edges = append(edges, billingprofile.EdgeBillingInvoices) } @@ -10582,6 +10539,15 @@ func (m *BillingProfileMutation) ClearedEdges() []string { if m.clearedworkflow_config { edges = append(edges, billingprofile.EdgeWorkflowConfig) } + if m.clearedtax_app { + edges = append(edges, billingprofile.EdgeTaxApp) + } + if m.clearedinvoicing_app { + edges = append(edges, billingprofile.EdgeInvoicingApp) + } + if m.clearedpayment_app { + edges = append(edges, billingprofile.EdgePaymentApp) + } return edges } @@ -10595,6 +10561,12 @@ func (m *BillingProfileMutation) EdgeCleared(name string) bool { return m.clearedbilling_customer_override case billingprofile.EdgeWorkflowConfig: return m.clearedworkflow_config + case billingprofile.EdgeTaxApp: + return m.clearedtax_app + case billingprofile.EdgeInvoicingApp: + return m.clearedinvoicing_app + case billingprofile.EdgePaymentApp: + return m.clearedpayment_app } return false } @@ -10606,6 +10578,15 @@ func (m *BillingProfileMutation) ClearEdge(name string) error { case billingprofile.EdgeWorkflowConfig: m.ClearWorkflowConfig() return nil + case billingprofile.EdgeTaxApp: + m.ClearTaxApp() + return nil + case billingprofile.EdgeInvoicingApp: + m.ClearInvoicingApp() + return nil + case billingprofile.EdgePaymentApp: + m.ClearPaymentApp() + return nil } return fmt.Errorf("unknown BillingProfile unique edge %s", name) } @@ -10623,6 +10604,15 @@ func (m *BillingProfileMutation) ResetEdge(name string) error { case billingprofile.EdgeWorkflowConfig: m.ResetWorkflowConfig() return nil + case billingprofile.EdgeTaxApp: + m.ResetTaxApp() + return nil + case billingprofile.EdgeInvoicingApp: + m.ResetInvoicingApp() + return nil + case billingprofile.EdgePaymentApp: + m.ResetPaymentApp() + return nil } return fmt.Errorf("unknown BillingProfile edge %s", name) } @@ -10630,33 +10620,27 @@ func (m *BillingProfileMutation) ResetEdge(name string) error { // BillingWorkflowConfigMutation represents an operation that mutates the BillingWorkflowConfig nodes in the graph. type BillingWorkflowConfigMutation struct { config - op Op - typ string - id *string - namespace *string - created_at *time.Time - updated_at *time.Time - deleted_at *time.Time - timezone *timezone.Timezone - collection_alignment *billing.AlignmentKind - item_collection_period_seconds *int64 - additem_collection_period_seconds *int64 - invoice_auto_advance *bool - invoice_draft_period_seconds *int64 - addinvoice_draft_period_seconds *int64 - invoice_due_after_seconds *int64 - addinvoice_due_after_seconds *int64 - invoice_collection_method *billing.CollectionMethod - invoice_item_resolution *billing.GranularityResolution - invoice_item_per_subject *bool - clearedFields map[string]struct{} - billing_invoices *string - clearedbilling_invoices bool - billing_profile *string - clearedbilling_profile bool - done bool - oldValue func(context.Context) (*BillingWorkflowConfig, error) - predicates []predicate.BillingWorkflowConfig + op Op + typ string + id *string + namespace *string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + collection_alignment *billingentity.AlignmentKind + item_collection_period *datex.ISOString + invoice_auto_advance *bool + invoice_draft_period *datex.ISOString + invoice_due_after *datex.ISOString + invoice_collection_method *billingentity.CollectionMethod + clearedFields map[string]struct{} + billing_invoices *string + clearedbilling_invoices bool + billing_profile *string + clearedbilling_profile bool + done bool + oldValue func(context.Context) (*BillingWorkflowConfig, error) + predicates []predicate.BillingWorkflowConfig } var _ ent.Mutation = (*BillingWorkflowConfigMutation)(nil) @@ -10920,62 +10904,13 @@ func (m *BillingWorkflowConfigMutation) ResetDeletedAt() { delete(m.clearedFields, billingworkflowconfig.FieldDeletedAt) } -// SetTimezone sets the "timezone" field. -func (m *BillingWorkflowConfigMutation) SetTimezone(t timezone.Timezone) { - m.timezone = &t -} - -// Timezone returns the value of the "timezone" field in the mutation. -func (m *BillingWorkflowConfigMutation) Timezone() (r timezone.Timezone, exists bool) { - v := m.timezone - if v == nil { - return - } - return *v, true -} - -// OldTimezone returns the old "timezone" field's value of the BillingWorkflowConfig entity. -// If the BillingWorkflowConfig object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingWorkflowConfigMutation) OldTimezone(ctx context.Context) (v *timezone.Timezone, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTimezone is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTimezone requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTimezone: %w", err) - } - return oldValue.Timezone, nil -} - -// ClearTimezone clears the value of the "timezone" field. -func (m *BillingWorkflowConfigMutation) ClearTimezone() { - m.timezone = nil - m.clearedFields[billingworkflowconfig.FieldTimezone] = struct{}{} -} - -// TimezoneCleared returns if the "timezone" field was cleared in this mutation. -func (m *BillingWorkflowConfigMutation) TimezoneCleared() bool { - _, ok := m.clearedFields[billingworkflowconfig.FieldTimezone] - return ok -} - -// ResetTimezone resets all changes to the "timezone" field. -func (m *BillingWorkflowConfigMutation) ResetTimezone() { - m.timezone = nil - delete(m.clearedFields, billingworkflowconfig.FieldTimezone) -} - // SetCollectionAlignment sets the "collection_alignment" field. -func (m *BillingWorkflowConfigMutation) SetCollectionAlignment(bk billing.AlignmentKind) { +func (m *BillingWorkflowConfigMutation) SetCollectionAlignment(bk billingentity.AlignmentKind) { m.collection_alignment = &bk } // CollectionAlignment returns the value of the "collection_alignment" field in the mutation. -func (m *BillingWorkflowConfigMutation) CollectionAlignment() (r billing.AlignmentKind, exists bool) { +func (m *BillingWorkflowConfigMutation) CollectionAlignment() (r billingentity.AlignmentKind, exists bool) { v := m.collection_alignment if v == nil { return @@ -10986,7 +10921,7 @@ func (m *BillingWorkflowConfigMutation) CollectionAlignment() (r billing.Alignme // OldCollectionAlignment returns the old "collection_alignment" field's value of the BillingWorkflowConfig entity. // If the BillingWorkflowConfig object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingWorkflowConfigMutation) OldCollectionAlignment(ctx context.Context) (v billing.AlignmentKind, err error) { +func (m *BillingWorkflowConfigMutation) OldCollectionAlignment(ctx context.Context) (v billingentity.AlignmentKind, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCollectionAlignment is only allowed on UpdateOne operations") } @@ -11005,60 +10940,40 @@ func (m *BillingWorkflowConfigMutation) ResetCollectionAlignment() { m.collection_alignment = nil } -// SetItemCollectionPeriodSeconds sets the "item_collection_period_seconds" field. -func (m *BillingWorkflowConfigMutation) SetItemCollectionPeriodSeconds(i int64) { - m.item_collection_period_seconds = &i - m.additem_collection_period_seconds = nil +// SetItemCollectionPeriod sets the "item_collection_period" field. +func (m *BillingWorkflowConfigMutation) SetItemCollectionPeriod(ds datex.ISOString) { + m.item_collection_period = &ds } -// ItemCollectionPeriodSeconds returns the value of the "item_collection_period_seconds" field in the mutation. -func (m *BillingWorkflowConfigMutation) ItemCollectionPeriodSeconds() (r int64, exists bool) { - v := m.item_collection_period_seconds +// ItemCollectionPeriod returns the value of the "item_collection_period" field in the mutation. +func (m *BillingWorkflowConfigMutation) ItemCollectionPeriod() (r datex.ISOString, exists bool) { + v := m.item_collection_period if v == nil { return } return *v, true } -// OldItemCollectionPeriodSeconds returns the old "item_collection_period_seconds" field's value of the BillingWorkflowConfig entity. +// OldItemCollectionPeriod returns the old "item_collection_period" field's value of the BillingWorkflowConfig entity. // If the BillingWorkflowConfig object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingWorkflowConfigMutation) OldItemCollectionPeriodSeconds(ctx context.Context) (v int64, err error) { +func (m *BillingWorkflowConfigMutation) OldItemCollectionPeriod(ctx context.Context) (v datex.ISOString, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldItemCollectionPeriodSeconds is only allowed on UpdateOne operations") + return v, errors.New("OldItemCollectionPeriod is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldItemCollectionPeriodSeconds requires an ID field in the mutation") + return v, errors.New("OldItemCollectionPeriod requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldItemCollectionPeriodSeconds: %w", err) - } - return oldValue.ItemCollectionPeriodSeconds, nil -} - -// AddItemCollectionPeriodSeconds adds i to the "item_collection_period_seconds" field. -func (m *BillingWorkflowConfigMutation) AddItemCollectionPeriodSeconds(i int64) { - if m.additem_collection_period_seconds != nil { - *m.additem_collection_period_seconds += i - } else { - m.additem_collection_period_seconds = &i - } -} - -// AddedItemCollectionPeriodSeconds returns the value that was added to the "item_collection_period_seconds" field in this mutation. -func (m *BillingWorkflowConfigMutation) AddedItemCollectionPeriodSeconds() (r int64, exists bool) { - v := m.additem_collection_period_seconds - if v == nil { - return + return v, fmt.Errorf("querying old value for OldItemCollectionPeriod: %w", err) } - return *v, true + return oldValue.ItemCollectionPeriod, nil } -// ResetItemCollectionPeriodSeconds resets all changes to the "item_collection_period_seconds" field. -func (m *BillingWorkflowConfigMutation) ResetItemCollectionPeriodSeconds() { - m.item_collection_period_seconds = nil - m.additem_collection_period_seconds = nil +// ResetItemCollectionPeriod resets all changes to the "item_collection_period" field. +func (m *BillingWorkflowConfigMutation) ResetItemCollectionPeriod() { + m.item_collection_period = nil } // SetInvoiceAutoAdvance sets the "invoice_auto_advance" field. @@ -11097,125 +11012,85 @@ func (m *BillingWorkflowConfigMutation) ResetInvoiceAutoAdvance() { m.invoice_auto_advance = nil } -// SetInvoiceDraftPeriodSeconds sets the "invoice_draft_period_seconds" field. -func (m *BillingWorkflowConfigMutation) SetInvoiceDraftPeriodSeconds(i int64) { - m.invoice_draft_period_seconds = &i - m.addinvoice_draft_period_seconds = nil +// SetInvoiceDraftPeriod sets the "invoice_draft_period" field. +func (m *BillingWorkflowConfigMutation) SetInvoiceDraftPeriod(ds datex.ISOString) { + m.invoice_draft_period = &ds } -// InvoiceDraftPeriodSeconds returns the value of the "invoice_draft_period_seconds" field in the mutation. -func (m *BillingWorkflowConfigMutation) InvoiceDraftPeriodSeconds() (r int64, exists bool) { - v := m.invoice_draft_period_seconds +// InvoiceDraftPeriod returns the value of the "invoice_draft_period" field in the mutation. +func (m *BillingWorkflowConfigMutation) InvoiceDraftPeriod() (r datex.ISOString, exists bool) { + v := m.invoice_draft_period if v == nil { return } return *v, true } -// OldInvoiceDraftPeriodSeconds returns the old "invoice_draft_period_seconds" field's value of the BillingWorkflowConfig entity. +// OldInvoiceDraftPeriod returns the old "invoice_draft_period" field's value of the BillingWorkflowConfig entity. // If the BillingWorkflowConfig object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingWorkflowConfigMutation) OldInvoiceDraftPeriodSeconds(ctx context.Context) (v int64, err error) { +func (m *BillingWorkflowConfigMutation) OldInvoiceDraftPeriod(ctx context.Context) (v datex.ISOString, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInvoiceDraftPeriodSeconds is only allowed on UpdateOne operations") + return v, errors.New("OldInvoiceDraftPeriod is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInvoiceDraftPeriodSeconds requires an ID field in the mutation") + return v, errors.New("OldInvoiceDraftPeriod requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldInvoiceDraftPeriodSeconds: %w", err) + return v, fmt.Errorf("querying old value for OldInvoiceDraftPeriod: %w", err) } - return oldValue.InvoiceDraftPeriodSeconds, nil + return oldValue.InvoiceDraftPeriod, nil } -// AddInvoiceDraftPeriodSeconds adds i to the "invoice_draft_period_seconds" field. -func (m *BillingWorkflowConfigMutation) AddInvoiceDraftPeriodSeconds(i int64) { - if m.addinvoice_draft_period_seconds != nil { - *m.addinvoice_draft_period_seconds += i - } else { - m.addinvoice_draft_period_seconds = &i - } +// ResetInvoiceDraftPeriod resets all changes to the "invoice_draft_period" field. +func (m *BillingWorkflowConfigMutation) ResetInvoiceDraftPeriod() { + m.invoice_draft_period = nil } -// AddedInvoiceDraftPeriodSeconds returns the value that was added to the "invoice_draft_period_seconds" field in this mutation. -func (m *BillingWorkflowConfigMutation) AddedInvoiceDraftPeriodSeconds() (r int64, exists bool) { - v := m.addinvoice_draft_period_seconds - if v == nil { - return - } - return *v, true +// SetInvoiceDueAfter sets the "invoice_due_after" field. +func (m *BillingWorkflowConfigMutation) SetInvoiceDueAfter(ds datex.ISOString) { + m.invoice_due_after = &ds } -// ResetInvoiceDraftPeriodSeconds resets all changes to the "invoice_draft_period_seconds" field. -func (m *BillingWorkflowConfigMutation) ResetInvoiceDraftPeriodSeconds() { - m.invoice_draft_period_seconds = nil - m.addinvoice_draft_period_seconds = nil -} - -// SetInvoiceDueAfterSeconds sets the "invoice_due_after_seconds" field. -func (m *BillingWorkflowConfigMutation) SetInvoiceDueAfterSeconds(i int64) { - m.invoice_due_after_seconds = &i - m.addinvoice_due_after_seconds = nil -} - -// InvoiceDueAfterSeconds returns the value of the "invoice_due_after_seconds" field in the mutation. -func (m *BillingWorkflowConfigMutation) InvoiceDueAfterSeconds() (r int64, exists bool) { - v := m.invoice_due_after_seconds +// InvoiceDueAfter returns the value of the "invoice_due_after" field in the mutation. +func (m *BillingWorkflowConfigMutation) InvoiceDueAfter() (r datex.ISOString, exists bool) { + v := m.invoice_due_after if v == nil { return } return *v, true } -// OldInvoiceDueAfterSeconds returns the old "invoice_due_after_seconds" field's value of the BillingWorkflowConfig entity. +// OldInvoiceDueAfter returns the old "invoice_due_after" field's value of the BillingWorkflowConfig entity. // If the BillingWorkflowConfig object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingWorkflowConfigMutation) OldInvoiceDueAfterSeconds(ctx context.Context) (v int64, err error) { +func (m *BillingWorkflowConfigMutation) OldInvoiceDueAfter(ctx context.Context) (v datex.ISOString, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInvoiceDueAfterSeconds is only allowed on UpdateOne operations") + return v, errors.New("OldInvoiceDueAfter is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInvoiceDueAfterSeconds requires an ID field in the mutation") + return v, errors.New("OldInvoiceDueAfter requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldInvoiceDueAfterSeconds: %w", err) - } - return oldValue.InvoiceDueAfterSeconds, nil -} - -// AddInvoiceDueAfterSeconds adds i to the "invoice_due_after_seconds" field. -func (m *BillingWorkflowConfigMutation) AddInvoiceDueAfterSeconds(i int64) { - if m.addinvoice_due_after_seconds != nil { - *m.addinvoice_due_after_seconds += i - } else { - m.addinvoice_due_after_seconds = &i - } -} - -// AddedInvoiceDueAfterSeconds returns the value that was added to the "invoice_due_after_seconds" field in this mutation. -func (m *BillingWorkflowConfigMutation) AddedInvoiceDueAfterSeconds() (r int64, exists bool) { - v := m.addinvoice_due_after_seconds - if v == nil { - return + return v, fmt.Errorf("querying old value for OldInvoiceDueAfter: %w", err) } - return *v, true + return oldValue.InvoiceDueAfter, nil } -// ResetInvoiceDueAfterSeconds resets all changes to the "invoice_due_after_seconds" field. -func (m *BillingWorkflowConfigMutation) ResetInvoiceDueAfterSeconds() { - m.invoice_due_after_seconds = nil - m.addinvoice_due_after_seconds = nil +// ResetInvoiceDueAfter resets all changes to the "invoice_due_after" field. +func (m *BillingWorkflowConfigMutation) ResetInvoiceDueAfter() { + m.invoice_due_after = nil } // SetInvoiceCollectionMethod sets the "invoice_collection_method" field. -func (m *BillingWorkflowConfigMutation) SetInvoiceCollectionMethod(bm billing.CollectionMethod) { +func (m *BillingWorkflowConfigMutation) SetInvoiceCollectionMethod(bm billingentity.CollectionMethod) { m.invoice_collection_method = &bm } // InvoiceCollectionMethod returns the value of the "invoice_collection_method" field in the mutation. -func (m *BillingWorkflowConfigMutation) InvoiceCollectionMethod() (r billing.CollectionMethod, exists bool) { +func (m *BillingWorkflowConfigMutation) InvoiceCollectionMethod() (r billingentity.CollectionMethod, exists bool) { v := m.invoice_collection_method if v == nil { return @@ -11226,7 +11101,7 @@ func (m *BillingWorkflowConfigMutation) InvoiceCollectionMethod() (r billing.Col // OldInvoiceCollectionMethod returns the old "invoice_collection_method" field's value of the BillingWorkflowConfig entity. // If the BillingWorkflowConfig object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingWorkflowConfigMutation) OldInvoiceCollectionMethod(ctx context.Context) (v billing.CollectionMethod, err error) { +func (m *BillingWorkflowConfigMutation) OldInvoiceCollectionMethod(ctx context.Context) (v billingentity.CollectionMethod, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldInvoiceCollectionMethod is only allowed on UpdateOne operations") } @@ -11245,78 +11120,6 @@ func (m *BillingWorkflowConfigMutation) ResetInvoiceCollectionMethod() { m.invoice_collection_method = nil } -// SetInvoiceItemResolution sets the "invoice_item_resolution" field. -func (m *BillingWorkflowConfigMutation) SetInvoiceItemResolution(br billing.GranularityResolution) { - m.invoice_item_resolution = &br -} - -// InvoiceItemResolution returns the value of the "invoice_item_resolution" field in the mutation. -func (m *BillingWorkflowConfigMutation) InvoiceItemResolution() (r billing.GranularityResolution, exists bool) { - v := m.invoice_item_resolution - if v == nil { - return - } - return *v, true -} - -// OldInvoiceItemResolution returns the old "invoice_item_resolution" field's value of the BillingWorkflowConfig entity. -// If the BillingWorkflowConfig object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingWorkflowConfigMutation) OldInvoiceItemResolution(ctx context.Context) (v billing.GranularityResolution, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInvoiceItemResolution is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInvoiceItemResolution requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldInvoiceItemResolution: %w", err) - } - return oldValue.InvoiceItemResolution, nil -} - -// ResetInvoiceItemResolution resets all changes to the "invoice_item_resolution" field. -func (m *BillingWorkflowConfigMutation) ResetInvoiceItemResolution() { - m.invoice_item_resolution = nil -} - -// SetInvoiceItemPerSubject sets the "invoice_item_per_subject" field. -func (m *BillingWorkflowConfigMutation) SetInvoiceItemPerSubject(b bool) { - m.invoice_item_per_subject = &b -} - -// InvoiceItemPerSubject returns the value of the "invoice_item_per_subject" field in the mutation. -func (m *BillingWorkflowConfigMutation) InvoiceItemPerSubject() (r bool, exists bool) { - v := m.invoice_item_per_subject - if v == nil { - return - } - return *v, true -} - -// OldInvoiceItemPerSubject returns the old "invoice_item_per_subject" field's value of the BillingWorkflowConfig entity. -// If the BillingWorkflowConfig object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *BillingWorkflowConfigMutation) OldInvoiceItemPerSubject(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInvoiceItemPerSubject is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInvoiceItemPerSubject requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldInvoiceItemPerSubject: %w", err) - } - return oldValue.InvoiceItemPerSubject, nil -} - -// ResetInvoiceItemPerSubject resets all changes to the "invoice_item_per_subject" field. -func (m *BillingWorkflowConfigMutation) ResetInvoiceItemPerSubject() { - m.invoice_item_per_subject = nil -} - // SetBillingInvoicesID sets the "billing_invoices" edge to the BillingInvoice entity by id. func (m *BillingWorkflowConfigMutation) SetBillingInvoicesID(id string) { m.billing_invoices = &id @@ -11429,7 +11232,7 @@ func (m *BillingWorkflowConfigMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BillingWorkflowConfigMutation) Fields() []string { - fields := make([]string, 0, 13) + fields := make([]string, 0, 10) if m.namespace != nil { fields = append(fields, billingworkflowconfig.FieldNamespace) } @@ -11442,33 +11245,24 @@ func (m *BillingWorkflowConfigMutation) Fields() []string { if m.deleted_at != nil { fields = append(fields, billingworkflowconfig.FieldDeletedAt) } - if m.timezone != nil { - fields = append(fields, billingworkflowconfig.FieldTimezone) - } if m.collection_alignment != nil { fields = append(fields, billingworkflowconfig.FieldCollectionAlignment) } - if m.item_collection_period_seconds != nil { - fields = append(fields, billingworkflowconfig.FieldItemCollectionPeriodSeconds) + if m.item_collection_period != nil { + fields = append(fields, billingworkflowconfig.FieldItemCollectionPeriod) } if m.invoice_auto_advance != nil { fields = append(fields, billingworkflowconfig.FieldInvoiceAutoAdvance) } - if m.invoice_draft_period_seconds != nil { - fields = append(fields, billingworkflowconfig.FieldInvoiceDraftPeriodSeconds) + if m.invoice_draft_period != nil { + fields = append(fields, billingworkflowconfig.FieldInvoiceDraftPeriod) } - if m.invoice_due_after_seconds != nil { - fields = append(fields, billingworkflowconfig.FieldInvoiceDueAfterSeconds) + if m.invoice_due_after != nil { + fields = append(fields, billingworkflowconfig.FieldInvoiceDueAfter) } if m.invoice_collection_method != nil { fields = append(fields, billingworkflowconfig.FieldInvoiceCollectionMethod) } - if m.invoice_item_resolution != nil { - fields = append(fields, billingworkflowconfig.FieldInvoiceItemResolution) - } - if m.invoice_item_per_subject != nil { - fields = append(fields, billingworkflowconfig.FieldInvoiceItemPerSubject) - } return fields } @@ -11485,24 +11279,18 @@ func (m *BillingWorkflowConfigMutation) Field(name string) (ent.Value, bool) { return m.UpdatedAt() case billingworkflowconfig.FieldDeletedAt: return m.DeletedAt() - case billingworkflowconfig.FieldTimezone: - return m.Timezone() case billingworkflowconfig.FieldCollectionAlignment: return m.CollectionAlignment() - case billingworkflowconfig.FieldItemCollectionPeriodSeconds: - return m.ItemCollectionPeriodSeconds() + case billingworkflowconfig.FieldItemCollectionPeriod: + return m.ItemCollectionPeriod() case billingworkflowconfig.FieldInvoiceAutoAdvance: return m.InvoiceAutoAdvance() - case billingworkflowconfig.FieldInvoiceDraftPeriodSeconds: - return m.InvoiceDraftPeriodSeconds() - case billingworkflowconfig.FieldInvoiceDueAfterSeconds: - return m.InvoiceDueAfterSeconds() + case billingworkflowconfig.FieldInvoiceDraftPeriod: + return m.InvoiceDraftPeriod() + case billingworkflowconfig.FieldInvoiceDueAfter: + return m.InvoiceDueAfter() case billingworkflowconfig.FieldInvoiceCollectionMethod: return m.InvoiceCollectionMethod() - case billingworkflowconfig.FieldInvoiceItemResolution: - return m.InvoiceItemResolution() - case billingworkflowconfig.FieldInvoiceItemPerSubject: - return m.InvoiceItemPerSubject() } return nil, false } @@ -11520,24 +11308,18 @@ func (m *BillingWorkflowConfigMutation) OldField(ctx context.Context, name strin return m.OldUpdatedAt(ctx) case billingworkflowconfig.FieldDeletedAt: return m.OldDeletedAt(ctx) - case billingworkflowconfig.FieldTimezone: - return m.OldTimezone(ctx) case billingworkflowconfig.FieldCollectionAlignment: return m.OldCollectionAlignment(ctx) - case billingworkflowconfig.FieldItemCollectionPeriodSeconds: - return m.OldItemCollectionPeriodSeconds(ctx) + case billingworkflowconfig.FieldItemCollectionPeriod: + return m.OldItemCollectionPeriod(ctx) case billingworkflowconfig.FieldInvoiceAutoAdvance: return m.OldInvoiceAutoAdvance(ctx) - case billingworkflowconfig.FieldInvoiceDraftPeriodSeconds: - return m.OldInvoiceDraftPeriodSeconds(ctx) - case billingworkflowconfig.FieldInvoiceDueAfterSeconds: - return m.OldInvoiceDueAfterSeconds(ctx) + case billingworkflowconfig.FieldInvoiceDraftPeriod: + return m.OldInvoiceDraftPeriod(ctx) + case billingworkflowconfig.FieldInvoiceDueAfter: + return m.OldInvoiceDueAfter(ctx) case billingworkflowconfig.FieldInvoiceCollectionMethod: return m.OldInvoiceCollectionMethod(ctx) - case billingworkflowconfig.FieldInvoiceItemResolution: - return m.OldInvoiceItemResolution(ctx) - case billingworkflowconfig.FieldInvoiceItemPerSubject: - return m.OldInvoiceItemPerSubject(ctx) } return nil, fmt.Errorf("unknown BillingWorkflowConfig field %s", name) } @@ -11575,26 +11357,19 @@ func (m *BillingWorkflowConfigMutation) SetField(name string, value ent.Value) e } m.SetDeletedAt(v) return nil - case billingworkflowconfig.FieldTimezone: - v, ok := value.(timezone.Timezone) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTimezone(v) - return nil case billingworkflowconfig.FieldCollectionAlignment: - v, ok := value.(billing.AlignmentKind) + v, ok := value.(billingentity.AlignmentKind) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCollectionAlignment(v) return nil - case billingworkflowconfig.FieldItemCollectionPeriodSeconds: - v, ok := value.(int64) + case billingworkflowconfig.FieldItemCollectionPeriod: + v, ok := value.(datex.ISOString) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetItemCollectionPeriodSeconds(v) + m.SetItemCollectionPeriod(v) return nil case billingworkflowconfig.FieldInvoiceAutoAdvance: v, ok := value.(bool) @@ -11603,41 +11378,27 @@ func (m *BillingWorkflowConfigMutation) SetField(name string, value ent.Value) e } m.SetInvoiceAutoAdvance(v) return nil - case billingworkflowconfig.FieldInvoiceDraftPeriodSeconds: - v, ok := value.(int64) + case billingworkflowconfig.FieldInvoiceDraftPeriod: + v, ok := value.(datex.ISOString) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetInvoiceDraftPeriodSeconds(v) + m.SetInvoiceDraftPeriod(v) return nil - case billingworkflowconfig.FieldInvoiceDueAfterSeconds: - v, ok := value.(int64) + case billingworkflowconfig.FieldInvoiceDueAfter: + v, ok := value.(datex.ISOString) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetInvoiceDueAfterSeconds(v) + m.SetInvoiceDueAfter(v) return nil case billingworkflowconfig.FieldInvoiceCollectionMethod: - v, ok := value.(billing.CollectionMethod) + v, ok := value.(billingentity.CollectionMethod) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetInvoiceCollectionMethod(v) return nil - case billingworkflowconfig.FieldInvoiceItemResolution: - v, ok := value.(billing.GranularityResolution) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetInvoiceItemResolution(v) - return nil - case billingworkflowconfig.FieldInvoiceItemPerSubject: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetInvoiceItemPerSubject(v) - return nil } return fmt.Errorf("unknown BillingWorkflowConfig field %s", name) } @@ -11645,31 +11406,13 @@ func (m *BillingWorkflowConfigMutation) SetField(name string, value ent.Value) e // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *BillingWorkflowConfigMutation) AddedFields() []string { - var fields []string - if m.additem_collection_period_seconds != nil { - fields = append(fields, billingworkflowconfig.FieldItemCollectionPeriodSeconds) - } - if m.addinvoice_draft_period_seconds != nil { - fields = append(fields, billingworkflowconfig.FieldInvoiceDraftPeriodSeconds) - } - if m.addinvoice_due_after_seconds != nil { - fields = append(fields, billingworkflowconfig.FieldInvoiceDueAfterSeconds) - } - return fields + return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. func (m *BillingWorkflowConfigMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case billingworkflowconfig.FieldItemCollectionPeriodSeconds: - return m.AddedItemCollectionPeriodSeconds() - case billingworkflowconfig.FieldInvoiceDraftPeriodSeconds: - return m.AddedInvoiceDraftPeriodSeconds() - case billingworkflowconfig.FieldInvoiceDueAfterSeconds: - return m.AddedInvoiceDueAfterSeconds() - } return nil, false } @@ -11678,27 +11421,6 @@ func (m *BillingWorkflowConfigMutation) AddedField(name string) (ent.Value, bool // type. func (m *BillingWorkflowConfigMutation) AddField(name string, value ent.Value) error { switch name { - case billingworkflowconfig.FieldItemCollectionPeriodSeconds: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddItemCollectionPeriodSeconds(v) - return nil - case billingworkflowconfig.FieldInvoiceDraftPeriodSeconds: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddInvoiceDraftPeriodSeconds(v) - return nil - case billingworkflowconfig.FieldInvoiceDueAfterSeconds: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddInvoiceDueAfterSeconds(v) - return nil } return fmt.Errorf("unknown BillingWorkflowConfig numeric field %s", name) } @@ -11710,9 +11432,6 @@ func (m *BillingWorkflowConfigMutation) ClearedFields() []string { if m.FieldCleared(billingworkflowconfig.FieldDeletedAt) { fields = append(fields, billingworkflowconfig.FieldDeletedAt) } - if m.FieldCleared(billingworkflowconfig.FieldTimezone) { - fields = append(fields, billingworkflowconfig.FieldTimezone) - } return fields } @@ -11730,9 +11449,6 @@ func (m *BillingWorkflowConfigMutation) ClearField(name string) error { case billingworkflowconfig.FieldDeletedAt: m.ClearDeletedAt() return nil - case billingworkflowconfig.FieldTimezone: - m.ClearTimezone() - return nil } return fmt.Errorf("unknown BillingWorkflowConfig nullable field %s", name) } @@ -11753,33 +11469,24 @@ func (m *BillingWorkflowConfigMutation) ResetField(name string) error { case billingworkflowconfig.FieldDeletedAt: m.ResetDeletedAt() return nil - case billingworkflowconfig.FieldTimezone: - m.ResetTimezone() - return nil case billingworkflowconfig.FieldCollectionAlignment: m.ResetCollectionAlignment() return nil - case billingworkflowconfig.FieldItemCollectionPeriodSeconds: - m.ResetItemCollectionPeriodSeconds() + case billingworkflowconfig.FieldItemCollectionPeriod: + m.ResetItemCollectionPeriod() return nil case billingworkflowconfig.FieldInvoiceAutoAdvance: m.ResetInvoiceAutoAdvance() return nil - case billingworkflowconfig.FieldInvoiceDraftPeriodSeconds: - m.ResetInvoiceDraftPeriodSeconds() + case billingworkflowconfig.FieldInvoiceDraftPeriod: + m.ResetInvoiceDraftPeriod() return nil - case billingworkflowconfig.FieldInvoiceDueAfterSeconds: - m.ResetInvoiceDueAfterSeconds() + case billingworkflowconfig.FieldInvoiceDueAfter: + m.ResetInvoiceDueAfter() return nil case billingworkflowconfig.FieldInvoiceCollectionMethod: m.ResetInvoiceCollectionMethod() return nil - case billingworkflowconfig.FieldInvoiceItemResolution: - m.ResetInvoiceItemResolution() - return nil - case billingworkflowconfig.FieldInvoiceItemPerSubject: - m.ResetInvoiceItemPerSubject() - return nil } return fmt.Errorf("unknown BillingWorkflowConfig field %s", name) } diff --git a/openmeter/ent/db/setorclear.go b/openmeter/ent/db/setorclear.go index b8312dc4a..8a67dfb0f 100644 --- a/openmeter/ent/db/setorclear.go +++ b/openmeter/ent/db/setorclear.go @@ -6,9 +6,9 @@ import ( "time" "github.com/alpacahq/alpacadecimal" - "github.com/openmeterio/openmeter/openmeter/billing" - "github.com/openmeterio/openmeter/openmeter/billing/provider" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/pkg/currencyx" + "github.com/openmeterio/openmeter/pkg/datex" "github.com/openmeterio/openmeter/pkg/models" "github.com/openmeterio/openmeter/pkg/timezone" ) @@ -153,32 +153,32 @@ func (u *BillingCustomerOverrideUpdateOne) SetOrClearBillingProfileID(value *str return u.SetBillingProfileID(*value) } -func (u *BillingCustomerOverrideUpdate) SetOrClearCollectionAlignment(value *billing.AlignmentKind) *BillingCustomerOverrideUpdate { +func (u *BillingCustomerOverrideUpdate) SetOrClearCollectionAlignment(value *billingentity.AlignmentKind) *BillingCustomerOverrideUpdate { if value == nil { return u.ClearCollectionAlignment() } return u.SetCollectionAlignment(*value) } -func (u *BillingCustomerOverrideUpdateOne) SetOrClearCollectionAlignment(value *billing.AlignmentKind) *BillingCustomerOverrideUpdateOne { +func (u *BillingCustomerOverrideUpdateOne) SetOrClearCollectionAlignment(value *billingentity.AlignmentKind) *BillingCustomerOverrideUpdateOne { if value == nil { return u.ClearCollectionAlignment() } return u.SetCollectionAlignment(*value) } -func (u *BillingCustomerOverrideUpdate) SetOrClearItemCollectionPeriodSeconds(value *int64) *BillingCustomerOverrideUpdate { +func (u *BillingCustomerOverrideUpdate) SetOrClearItemCollectionPeriod(value *datex.ISOString) *BillingCustomerOverrideUpdate { if value == nil { - return u.ClearItemCollectionPeriodSeconds() + return u.ClearItemCollectionPeriod() } - return u.SetItemCollectionPeriodSeconds(*value) + return u.SetItemCollectionPeriod(*value) } -func (u *BillingCustomerOverrideUpdateOne) SetOrClearItemCollectionPeriodSeconds(value *int64) *BillingCustomerOverrideUpdateOne { +func (u *BillingCustomerOverrideUpdateOne) SetOrClearItemCollectionPeriod(value *datex.ISOString) *BillingCustomerOverrideUpdateOne { if value == nil { - return u.ClearItemCollectionPeriodSeconds() + return u.ClearItemCollectionPeriod() } - return u.SetItemCollectionPeriodSeconds(*value) + return u.SetItemCollectionPeriod(*value) } func (u *BillingCustomerOverrideUpdate) SetOrClearInvoiceAutoAdvance(value *bool) *BillingCustomerOverrideUpdate { @@ -195,76 +195,48 @@ func (u *BillingCustomerOverrideUpdateOne) SetOrClearInvoiceAutoAdvance(value *b return u.SetInvoiceAutoAdvance(*value) } -func (u *BillingCustomerOverrideUpdate) SetOrClearInvoiceDraftPeriodSeconds(value *int64) *BillingCustomerOverrideUpdate { +func (u *BillingCustomerOverrideUpdate) SetOrClearInvoiceDraftPeriod(value *datex.ISOString) *BillingCustomerOverrideUpdate { if value == nil { - return u.ClearInvoiceDraftPeriodSeconds() + return u.ClearInvoiceDraftPeriod() } - return u.SetInvoiceDraftPeriodSeconds(*value) + return u.SetInvoiceDraftPeriod(*value) } -func (u *BillingCustomerOverrideUpdateOne) SetOrClearInvoiceDraftPeriodSeconds(value *int64) *BillingCustomerOverrideUpdateOne { +func (u *BillingCustomerOverrideUpdateOne) SetOrClearInvoiceDraftPeriod(value *datex.ISOString) *BillingCustomerOverrideUpdateOne { if value == nil { - return u.ClearInvoiceDraftPeriodSeconds() + return u.ClearInvoiceDraftPeriod() } - return u.SetInvoiceDraftPeriodSeconds(*value) + return u.SetInvoiceDraftPeriod(*value) } -func (u *BillingCustomerOverrideUpdate) SetOrClearInvoiceDueAfterSeconds(value *int64) *BillingCustomerOverrideUpdate { +func (u *BillingCustomerOverrideUpdate) SetOrClearInvoiceDueAfter(value *datex.ISOString) *BillingCustomerOverrideUpdate { if value == nil { - return u.ClearInvoiceDueAfterSeconds() + return u.ClearInvoiceDueAfter() } - return u.SetInvoiceDueAfterSeconds(*value) + return u.SetInvoiceDueAfter(*value) } -func (u *BillingCustomerOverrideUpdateOne) SetOrClearInvoiceDueAfterSeconds(value *int64) *BillingCustomerOverrideUpdateOne { +func (u *BillingCustomerOverrideUpdateOne) SetOrClearInvoiceDueAfter(value *datex.ISOString) *BillingCustomerOverrideUpdateOne { if value == nil { - return u.ClearInvoiceDueAfterSeconds() + return u.ClearInvoiceDueAfter() } - return u.SetInvoiceDueAfterSeconds(*value) + return u.SetInvoiceDueAfter(*value) } -func (u *BillingCustomerOverrideUpdate) SetOrClearInvoiceCollectionMethod(value *billing.CollectionMethod) *BillingCustomerOverrideUpdate { +func (u *BillingCustomerOverrideUpdate) SetOrClearInvoiceCollectionMethod(value *billingentity.CollectionMethod) *BillingCustomerOverrideUpdate { if value == nil { return u.ClearInvoiceCollectionMethod() } return u.SetInvoiceCollectionMethod(*value) } -func (u *BillingCustomerOverrideUpdateOne) SetOrClearInvoiceCollectionMethod(value *billing.CollectionMethod) *BillingCustomerOverrideUpdateOne { +func (u *BillingCustomerOverrideUpdateOne) SetOrClearInvoiceCollectionMethod(value *billingentity.CollectionMethod) *BillingCustomerOverrideUpdateOne { if value == nil { return u.ClearInvoiceCollectionMethod() } return u.SetInvoiceCollectionMethod(*value) } -func (u *BillingCustomerOverrideUpdate) SetOrClearInvoiceItemResolution(value *billing.GranularityResolution) *BillingCustomerOverrideUpdate { - if value == nil { - return u.ClearInvoiceItemResolution() - } - return u.SetInvoiceItemResolution(*value) -} - -func (u *BillingCustomerOverrideUpdateOne) SetOrClearInvoiceItemResolution(value *billing.GranularityResolution) *BillingCustomerOverrideUpdateOne { - if value == nil { - return u.ClearInvoiceItemResolution() - } - return u.SetInvoiceItemResolution(*value) -} - -func (u *BillingCustomerOverrideUpdate) SetOrClearInvoiceItemPerSubject(value *bool) *BillingCustomerOverrideUpdate { - if value == nil { - return u.ClearInvoiceItemPerSubject() - } - return u.SetInvoiceItemPerSubject(*value) -} - -func (u *BillingCustomerOverrideUpdateOne) SetOrClearInvoiceItemPerSubject(value *bool) *BillingCustomerOverrideUpdateOne { - if value == nil { - return u.ClearInvoiceItemPerSubject() - } - return u.SetInvoiceItemPerSubject(*value) -} - func (u *BillingInvoiceUpdate) SetOrClearDeletedAt(value *time.Time) *BillingInvoiceUpdate { if value == nil { return u.ClearDeletedAt() @@ -335,48 +307,6 @@ func (u *BillingInvoiceUpdateOne) SetOrClearVoidedAt(value *time.Time) *BillingI return u.SetVoidedAt(*value) } -func (u *BillingInvoiceUpdate) SetOrClearTaxProvider(value *provider.TaxProvider) *BillingInvoiceUpdate { - if value == nil { - return u.ClearTaxProvider() - } - return u.SetTaxProvider(*value) -} - -func (u *BillingInvoiceUpdateOne) SetOrClearTaxProvider(value *provider.TaxProvider) *BillingInvoiceUpdateOne { - if value == nil { - return u.ClearTaxProvider() - } - return u.SetTaxProvider(*value) -} - -func (u *BillingInvoiceUpdate) SetOrClearInvoicingProvider(value *provider.InvoicingProvider) *BillingInvoiceUpdate { - if value == nil { - return u.ClearInvoicingProvider() - } - return u.SetInvoicingProvider(*value) -} - -func (u *BillingInvoiceUpdateOne) SetOrClearInvoicingProvider(value *provider.InvoicingProvider) *BillingInvoiceUpdateOne { - if value == nil { - return u.ClearInvoicingProvider() - } - return u.SetInvoicingProvider(*value) -} - -func (u *BillingInvoiceUpdate) SetOrClearPaymentProvider(value *provider.PaymentProvider) *BillingInvoiceUpdate { - if value == nil { - return u.ClearPaymentProvider() - } - return u.SetPaymentProvider(*value) -} - -func (u *BillingInvoiceUpdateOne) SetOrClearPaymentProvider(value *provider.PaymentProvider) *BillingInvoiceUpdateOne { - if value == nil { - return u.ClearPaymentProvider() - } - return u.SetPaymentProvider(*value) -} - func (u *BillingInvoiceItemUpdate) SetOrClearDeletedAt(value *time.Time) *BillingInvoiceItemUpdate { if value == nil { return u.ClearDeletedAt() @@ -573,32 +503,32 @@ func (u *BillingProfileUpdateOne) SetOrClearSupplierAddressPhoneNumber(value *st return u.SetSupplierAddressPhoneNumber(*value) } -func (u *BillingWorkflowConfigUpdate) SetOrClearDeletedAt(value *time.Time) *BillingWorkflowConfigUpdate { +func (u *BillingProfileUpdate) SetOrClearSupplierTaxCode(value *string) *BillingProfileUpdate { if value == nil { - return u.ClearDeletedAt() + return u.ClearSupplierTaxCode() } - return u.SetDeletedAt(*value) + return u.SetSupplierTaxCode(*value) } -func (u *BillingWorkflowConfigUpdateOne) SetOrClearDeletedAt(value *time.Time) *BillingWorkflowConfigUpdateOne { +func (u *BillingProfileUpdateOne) SetOrClearSupplierTaxCode(value *string) *BillingProfileUpdateOne { if value == nil { - return u.ClearDeletedAt() + return u.ClearSupplierTaxCode() } - return u.SetDeletedAt(*value) + return u.SetSupplierTaxCode(*value) } -func (u *BillingWorkflowConfigUpdate) SetOrClearTimezone(value *timezone.Timezone) *BillingWorkflowConfigUpdate { +func (u *BillingWorkflowConfigUpdate) SetOrClearDeletedAt(value *time.Time) *BillingWorkflowConfigUpdate { if value == nil { - return u.ClearTimezone() + return u.ClearDeletedAt() } - return u.SetTimezone(*value) + return u.SetDeletedAt(*value) } -func (u *BillingWorkflowConfigUpdateOne) SetOrClearTimezone(value *timezone.Timezone) *BillingWorkflowConfigUpdateOne { +func (u *BillingWorkflowConfigUpdateOne) SetOrClearDeletedAt(value *time.Time) *BillingWorkflowConfigUpdateOne { if value == nil { - return u.ClearTimezone() + return u.ClearDeletedAt() } - return u.SetTimezone(*value) + return u.SetDeletedAt(*value) } func (u *CustomerUpdate) SetOrClearMetadata(value *map[string]string) *CustomerUpdate { diff --git a/openmeter/ent/schema/app.go b/openmeter/ent/schema/app.go index c89fa3272..ab675dbe4 100644 --- a/openmeter/ent/schema/app.go +++ b/openmeter/ent/schema/app.go @@ -46,6 +46,9 @@ func (App) Edges() []ent.Edge { return []ent.Edge{ edge.To("customer_apps", AppCustomer.Type). Annotations(entsql.OnDelete(entsql.Cascade)), + edge.To("tax_app", BillingProfile.Type), + edge.To("invoicing_app", BillingProfile.Type), + edge.To("payment_app", BillingProfile.Type), } } diff --git a/openmeter/ent/schema/billing.go b/openmeter/ent/schema/billing.go index 84a0ecc32..58dd5b14d 100644 --- a/openmeter/ent/schema/billing.go +++ b/openmeter/ent/schema/billing.go @@ -8,11 +8,10 @@ import ( "entgo.io/ent/schema/index" "github.com/alpacahq/alpacadecimal" - "github.com/openmeterio/openmeter/openmeter/billing" - "github.com/openmeterio/openmeter/openmeter/billing/provider" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/pkg/currencyx" + "github.com/openmeterio/openmeter/pkg/datex" "github.com/openmeterio/openmeter/pkg/framework/entutils" - "github.com/openmeterio/openmeter/pkg/timezone" ) type BillingProfile struct { @@ -30,15 +29,30 @@ func (BillingProfile) Mixin() []ent.Mixin { func (BillingProfile) Fields() []ent.Field { return []ent.Field{ - field.Enum("tax_provider").GoType(provider.TaxProvider("")), - field.Enum("invoicing_provider").GoType(provider.InvoicingProvider("")), - field.Enum("payment_provider").GoType(provider.PaymentProvider("")), + field.String("tax_app_id"). + Immutable(). + SchemaType(map[string]string{ + dialect.Postgres: "char(26)", + }), + field.String("invoicing_app_id"). + Immutable(). + SchemaType(map[string]string{ + dialect.Postgres: "char(26)", + }), + field.String("payment_app_id"). + Immutable(). + SchemaType(map[string]string{ + dialect.Postgres: "char(26)", + }), field.String("workflow_config_id"). NotEmpty(), field.Bool("default"). Default(false), field.String("supplier_name"). NotEmpty(), + field.String("supplier_tax_code"). + Optional(). + Nillable(), } } @@ -51,12 +65,31 @@ func (BillingProfile) Edges() []ent.Edge { Field("workflow_config_id"). Unique(). Required(), + edge.From("tax_app", App.Type). + Ref("tax_app"). + Field("tax_app_id"). + Unique(). + Immutable(). + Required(), + edge.From("invoicing_app", App.Type). + Ref("invoicing_app"). + Field("invoicing_app_id"). + Unique(). + Immutable(). + Required(), + edge.From("payment_app", App.Type). + Ref("payment_app"). + Field("payment_app_id"). + Unique(). + Immutable(). + Required(), } } func (BillingProfile) Indexes() []ent.Index { return []ent.Index{ - index.Fields("namespace", "default", "deleted_at").Unique(), + index.Fields("namespace", "default", "deleted_at"). + Unique(), } } @@ -74,28 +107,20 @@ func (BillingWorkflowConfig) Mixin() []ent.Mixin { func (BillingWorkflowConfig) Fields() []ent.Field { return []ent.Field{ - // Defaults to UTC if not specified, customer TZ overrides this - field.String("timezone").GoType(timezone.Timezone("")).Optional().Nillable(), - // TODO: later we will add more alignment details here (e.g. monthly, yearly, etc.) field.Enum("collection_alignment"). - GoType(billing.AlignmentKind("")), + GoType(billingentity.AlignmentKind("")), - field.Int64("item_collection_period_seconds"), + field.String("item_collection_period").GoType(datex.ISOString("")), field.Bool("invoice_auto_advance"), - field.Int64("invoice_draft_period_seconds"), + field.String("invoice_draft_period").GoType(datex.ISOString("")), - field.Int64("invoice_due_after_seconds"), + field.String("invoice_due_after").GoType(datex.ISOString("")), field.Enum("invoice_collection_method"). - GoType(billing.CollectionMethod("")), - - field.Enum("invoice_item_resolution"). - GoType(billing.GranularityResolution("")), - - field.Bool("invoice_item_per_subject"), + GoType(billingentity.CollectionMethod("")), } } @@ -148,11 +173,12 @@ func (BillingCustomerOverride) Fields() []ent.Field { // Workflow config overrides // TODO: later we will add more alignment details here (e.g. monthly, yearly, etc.) field.Enum("collection_alignment"). - GoType(billing.AlignmentKind("")). + GoType(billingentity.AlignmentKind("")). Optional(). Nillable(), - field.Int64("item_collection_period_seconds"). + field.String("item_collection_period"). + GoType(datex.ISOString("")). Optional(). Nillable(), @@ -160,25 +186,18 @@ func (BillingCustomerOverride) Fields() []ent.Field { Optional(). Nillable(), - field.Int64("invoice_draft_period_seconds"). + field.String("invoice_draft_period"). + GoType(datex.ISOString("")). Optional(). Nillable(), - field.Int64("invoice_due_after_seconds"). + field.String("invoice_due_after"). + GoType(datex.ISOString("")). Optional(). Nillable(), field.Enum("invoice_collection_method"). - GoType(billing.CollectionMethod("")). - Optional(). - Nillable(), - - field.Enum("invoice_item_resolution"). - GoType(billing.GranularityResolution("")). - Optional(). - Nillable(), - - field.Bool("invoice_item_per_subject"). + GoType(billingentity.CollectionMethod("")). Optional(). Nillable(), } @@ -241,7 +260,7 @@ func (BillingInvoiceItem) Fields() []ent.Field { // TODO[dependency]: overrides (as soon as plan override entities are ready) field.Enum("type"). - GoType(billing.InvoiceItemType("")), + GoType(billingentity.InvoiceItemType("")), field.String("name"). NotEmpty(), @@ -264,7 +283,7 @@ func (BillingInvoiceItem) Fields() []ent.Field { SchemaType(map[string]string{ "postgres": "varchar(3)", }), - field.JSON("tax_code_override", billing.TaxOverrides{}). + field.JSON("tax_code_override", billingentity.TaxOverrides{}). SchemaType(map[string]string{ "postgres": "jsonb", }), @@ -336,11 +355,7 @@ func (BillingInvoice) Fields() []ent.Field { field.Time("due_date"), field.Enum("status"). - GoType(billing.InvoiceStatus("")), - - field.Enum("tax_provider").GoType(provider.TaxProvider("")).Optional().Nillable(), - field.Enum("invoicing_provider").GoType(provider.InvoicingProvider("")).Optional().Nillable(), - field.Enum("payment_provider").GoType(provider.PaymentProvider("")).Optional().Nillable(), + GoType(billingentity.InvoiceStatus("")), field.String("workflow_config_id"). SchemaType(map[string]string{ diff --git a/openmeter/server/router/app.go b/openmeter/server/router/app.go index e90ce6ca1..afd6c5956 100644 --- a/openmeter/server/router/app.go +++ b/openmeter/server/router/app.go @@ -9,17 +9,29 @@ import ( // Handle to get app by id // (GET /api/v1/apps/{appId}) func (a *Router) GetApp(w http.ResponseWriter, r *http.Request, appID string) { + if !a.config.AppsEnabled { + unimplemented.GetApp(w, r, appID) + return + } a.appHandler.GetApp().With(appID).ServeHTTP(w, r) } // Handle to list apps // (GET /api/v1/apps) func (a *Router) ListApps(w http.ResponseWriter, r *http.Request, params api.ListAppsParams) { + if !a.config.AppsEnabled { + unimplemented.ListApps(w, r, params) + return + } a.appHandler.ListApps().With(params).ServeHTTP(w, r) } // Uninstall an app by id // (DELETE /api/v1/apps/{id}) func (a *Router) UninstallApp(w http.ResponseWriter, r *http.Request, appID string) { + if !a.config.AppsEnabled { + unimplemented.UninstallApp(w, r, appID) + return + } a.appHandler.UninstallApp().With(appID).ServeHTTP(w, r) } diff --git a/openmeter/server/router/appstripe.go b/openmeter/server/router/appstripe.go index 1a4ab63d0..8177e92ce 100644 --- a/openmeter/server/router/appstripe.go +++ b/openmeter/server/router/appstripe.go @@ -12,6 +12,10 @@ import ( // Handle app stripe webhook // (POST /api/v1/apps/{appId}/stripe/webhook) func (a *Router) AppStripeWebhook(w http.ResponseWriter, r *http.Request, appID string) { + if !a.config.AppsEnabled { + models.NewStatusProblem(r.Context(), fmt.Errorf("apps are disabled"), http.StatusNotImplemented).Respond(w) + return + } const MaxBodyBytes = int64(65536) r.Body = http.MaxBytesReader(w, r.Body, MaxBodyBytes) payload, err := io.ReadAll(r.Body) @@ -32,5 +36,10 @@ func (a *Router) AppStripeWebhook(w http.ResponseWriter, r *http.Request, appID // Handle create app stripe checkout session // (POST /api/v1/integration/stripe/checkout/sessions) func (a *Router) CreateStripeCheckoutSession(w http.ResponseWriter, r *http.Request) { + if !a.config.AppsEnabled { + unimplemented.CreateStripeCheckoutSession(w, r) + return + } + a.appStripeHandler.CreateAppStripeCheckoutSession().ServeHTTP(w, r) } diff --git a/openmeter/server/router/billing.go b/openmeter/server/router/billing.go index 34785f047..e99423883 100644 --- a/openmeter/server/router/billing.go +++ b/openmeter/server/router/billing.go @@ -104,29 +104,54 @@ func (a *Router) BillingCreatePendingItemByCustomer(w http.ResponseWriter, r *ht // (GET /api/v1/billing/profile) func (a *Router) BillingListProfiles(w http.ResponseWriter, r *http.Request, params api.BillingListProfilesParams) { - w.WriteHeader(http.StatusNotImplemented) + if !a.config.BillingEnabled { + unimplemented.BillingListProfiles(w, r, params) + return + } + + a.billingHandler.ListProfiles().With(params).ServeHTTP(w, r) } // Create a new billing profile // (POST /api/v1/billing/profile) func (a *Router) BillingCreateProfile(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusNotImplemented) + if !a.config.BillingEnabled { + unimplemented.BillingCreateProfile(w, r) + return + } + + a.billingHandler.CreateProfile().ServeHTTP(w, r) } // Archive a billing profile // (DELETE /api/v1/billing/profile/{id}) func (a *Router) BillingArchiveProfile(w http.ResponseWriter, r *http.Request, id string) { - w.WriteHeader(http.StatusNotImplemented) + if !a.config.BillingEnabled { + unimplemented.BillingArchiveProfile(w, r, id) + return + } + + a.billingHandler.ArchiveProfile().With(id).ServeHTTP(w, r) } // Get a billing profile by ID // (GET /api/v1/billing/profile/{id}) func (a *Router) BillingGetProfile(w http.ResponseWriter, r *http.Request, id string) { - w.WriteHeader(http.StatusNotImplemented) + if !a.config.BillingEnabled { + unimplemented.BillingGetProfile(w, r, id) + return + } + + a.billingHandler.GetProfile().With(id).ServeHTTP(w, r) } // Update a billing profile // (PUT /api/v1/billing/profile/{id}) func (a *Router) BillingUpdateProfile(w http.ResponseWriter, r *http.Request, id string) { - w.WriteHeader(http.StatusNotImplemented) + if !a.config.BillingEnabled { + unimplemented.BillingUpdateProfile(w, r, id) + return + } + + a.billingHandler.UpdateProfile().With(id).ServeHTTP(w, r) } diff --git a/openmeter/server/router/router.go b/openmeter/server/router/router.go index b5a91564c..2ed87db31 100644 --- a/openmeter/server/router/router.go +++ b/openmeter/server/router/router.go @@ -15,6 +15,8 @@ import ( apphttpdriver "github.com/openmeterio/openmeter/openmeter/app/httpdriver" appstripe "github.com/openmeterio/openmeter/openmeter/app/stripe" appstripehttpdriver "github.com/openmeterio/openmeter/openmeter/app/stripe/httpdriver" + "github.com/openmeterio/openmeter/openmeter/billing" + billinghttpdriver "github.com/openmeterio/openmeter/openmeter/billing/httpdriver" "github.com/openmeterio/openmeter/openmeter/credit" creditdriver "github.com/openmeterio/openmeter/openmeter/credit/driver" "github.com/openmeterio/openmeter/openmeter/credit/grant" @@ -69,6 +71,7 @@ type Config struct { App app.Service AppStripe appstripe.Service Customer customer.Service + Billing billing.Service DebugConnector debug.DebugConnector FeatureConnector feature.FeatureConnector EntitlementConnector entitlement.Connector @@ -80,6 +83,8 @@ type Config struct { // FIXME: implement generic module management, loading, etc... EntitlementsEnabled bool NotificationEnabled bool + BillingEnabled bool + AppsEnabled bool } func (c Config) Validate() error { @@ -133,16 +138,24 @@ func (c Config) Validate() error { } } - if c.App == nil { - return errors.New("app service is required") + if c.AppsEnabled { + if c.App == nil { + return errors.New("app service is required") + } + + if c.AppStripe == nil { + return errors.New("app stripe service is required") + } } - if c.AppStripe == nil { - return errors.New("app stripe service is required") + if c.BillingEnabled || c.AppsEnabled { + if c.Customer == nil { + return errors.New("customer service is required") + } } - if c.Customer == nil { - return errors.New("customer service is required") + if c.BillingEnabled && c.Billing == nil { + return errors.New("billing service is required") } return nil @@ -153,6 +166,7 @@ type Router struct { appHandler apphttpdriver.Handler appStripeHandler appstripehttpdriver.AppStripeHandler + billingHandler billinghttpdriver.Handler featureHandler productcatalog_httpdriver.FeatureHandler creditHandler creditdriver.GrantHandler debugHandler debug_httpdriver.DebugHandler @@ -239,5 +253,13 @@ func NewRouter(config Config) (*Router, error) { httptransport.WithErrorHandler(config.ErrorHandler), ) + if config.BillingEnabled { + router.billingHandler = billinghttpdriver.New( + staticNamespaceDecoder, + config.Billing, + httptransport.WithErrorHandler(config.ErrorHandler), + ) + } + return router, nil } diff --git a/pkg/datex/date.go b/pkg/datex/date.go new file mode 100644 index 000000000..414364912 --- /dev/null +++ b/pkg/datex/date.go @@ -0,0 +1,64 @@ +// Package datex is a wrapper around github.com/rickb777/date/v2 and github.com/rickb777/period +// so we don't depend on it directly. +package datex + +import ( + "testing" + "time" + + "github.com/rickb777/period" + "github.com/samber/lo" +) + +type ISOString period.ISOString + +func (i ISOString) Parse() (Period, error) { + res, err := period.Parse(string(i)) + return Period{res}, err +} + +// ParsePtrOrNil parses the ISO8601 string representation of the period or if ISOString is nil, returns nil +func (i *ISOString) ParsePtrOrNil() (*Period, error) { + if i == nil { + return nil, nil + } + + d, err := i.Parse() + if err != nil { + return nil, err + } + + return lo.ToPtr(d), nil +} + +type Period struct { + period.Period +} + +// FromDuration creates a Period from a time.Duration +func FromDuration(d time.Duration) Period { + return Period{period.NewOf(d).Normalise(false)} +} + +// ISOString() returns the ISO8601 string representation of the period +func (p Period) ISOString() ISOString { + return ISOString(p.Period.String()) +} + +// ISOStringPtrOrNil() returns the ISO8601 string representation of the period or if Period is nil, returns nil +func (d *Period) ISOStringPtrOrNil() *ISOString { + if d == nil { + return nil + } + + return lo.ToPtr(d.ISOString()) +} + +func MustParse(t *testing.T, s string) Period { + res, err := period.Parse(s) + if err != nil { + t.Fatalf("failed to parse period: %v", err) + } + + return Period{res} +} diff --git a/pkg/framework/entutils/transaction.go b/pkg/framework/entutils/transaction.go index 84e18ad3a..2654997d3 100644 --- a/pkg/framework/entutils/transaction.go +++ b/pkg/framework/entutils/transaction.go @@ -213,6 +213,21 @@ func TransactingRepo[R, T any]( }) } +// TransactingRepoWithNoValue is a helper that can be used inside repository methods. +func TransactingRepoWithNoValue[T any]( + ctx context.Context, + repo interface { + TxUser[T] + TxCreator + }, + cb func(ctx context.Context, rep T) error, +) error { + _, err := TransactingRepo(ctx, repo, func(ctx context.Context, rep T) (interface{}, error) { + return nil, cb(ctx, rep) + }) + return err +} + // Only use for direct interacton with the Ent driver implementation func GetDriverFromContext(ctx context.Context) (*TxDriver, error) { driver, err := transaction.GetDriverFromContext(ctx) diff --git a/test/billing/customeroverride_test.go b/test/billing/customeroverride_test.go index 627d1ac3b..423442b4c 100644 --- a/test/billing/customeroverride_test.go +++ b/test/billing/customeroverride_test.go @@ -3,14 +3,15 @@ package billing_test import ( "context" "testing" - "time" "github.com/samber/lo" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" customerentity "github.com/openmeterio/openmeter/openmeter/customer/entity" + "github.com/openmeterio/openmeter/pkg/datex" "github.com/openmeterio/openmeter/pkg/models" "github.com/openmeterio/openmeter/pkg/timezone" ) @@ -43,6 +44,8 @@ func (s *CustomerOverrideTestSuite) TestDefaultProfileHandling() { ns := "test-ns-default-profile-handling" ctx := context.Background() + _ = s.installSandboxApp(s.T(), ns) + // Given we have an existing customer customer, err := s.CustomerService.CreateCustomer(ctx, customerentity.CreateCustomerInput{ Namespace: ns, @@ -69,7 +72,7 @@ func (s *CustomerOverrideTestSuite) TestDefaultProfileHandling() { require.Nil(t, profileWithOverride) }) - var defaultProfile *billing.Profile + var defaultProfile *billingentity.Profile s.T().Run("customer with default profile, no override", func(t *testing.T) { // Given having a default profile @@ -104,19 +107,16 @@ func (s *CustomerOverrideTestSuite) TestDefaultProfileHandling() { Namespace: ns, CustomerID: customerID, - Collection: billing.CollectionOverrideConfig{ - ItemCollectionPeriod: lo.ToPtr(time.Hour), + Collection: billingentity.CollectionOverrideConfig{ + Interval: lo.ToPtr(datex.MustParse(s.T(), "PT1H")), }, - Invoicing: billing.InvoicingOverrideConfig{ + Invoicing: billingentity.InvoicingOverrideConfig{ AutoAdvance: lo.ToPtr(false), - DraftPeriod: lo.ToPtr(2 * time.Hour), - DueAfter: lo.ToPtr(3 * time.Hour), - - ItemResolution: lo.ToPtr(billing.GranularityResolutionDay), - ItemPerSubject: lo.ToPtr(true), + DraftPeriod: lo.ToPtr(datex.MustParse(s.T(), "PT2H")), + DueAfter: lo.ToPtr(datex.MustParse(s.T(), "PT3H")), }, - Payment: billing.PaymentOverrideConfig{ - CollectionMethod: lo.ToPtr(billing.CollectionMethodSendInvoice), + Payment: billingentity.PaymentOverrideConfig{ + CollectionMethod: lo.ToPtr(billingentity.CollectionMethodSendInvoice), }, }) @@ -134,13 +134,11 @@ func (s *CustomerOverrideTestSuite) TestDefaultProfileHandling() { wfConfig := customerProfile.Profile.WorkflowConfig - require.Equal(t, wfConfig.Collection.ItemCollectionPeriod, time.Hour) - require.Equal(t, wfConfig.Invoicing.AutoAdvance, false) - require.Equal(t, wfConfig.Invoicing.DraftPeriod, 2*time.Hour) - require.Equal(t, wfConfig.Invoicing.DueAfter, 3*time.Hour) - require.Equal(t, wfConfig.Invoicing.ItemResolution, billing.GranularityResolutionDay) - require.Equal(t, wfConfig.Invoicing.ItemPerSubject, true) - require.Equal(t, wfConfig.Payment.CollectionMethod, billing.CollectionMethodSendInvoice) + require.Equal(t, wfConfig.Collection.Interval, datex.MustParse(t, "PT1H")) + require.Equal(t, *wfConfig.Invoicing.AutoAdvance, false) + require.Equal(t, wfConfig.Invoicing.DraftPeriod, datex.MustParse(t, "PT2H")) + require.Equal(t, wfConfig.Invoicing.DueAfter, datex.MustParse(t, "PT3H")) + require.Equal(t, wfConfig.Payment.CollectionMethod, billingentity.CollectionMethodSendInvoice) }) } @@ -148,6 +146,8 @@ func (s *CustomerOverrideTestSuite) TestPinnedProfileHandling() { ns := "test-ns-pinned-profile-handling" ctx := context.Background() + _ = s.installSandboxApp(s.T(), ns) + // Given we have an existing customer customer, err := s.CustomerService.CreateCustomer(ctx, customerentity.CreateCustomerInput{ Namespace: ns, @@ -190,8 +190,8 @@ func (s *CustomerOverrideTestSuite) TestPinnedProfileHandling() { CustomerID: customerID, ProfileID: pinnedProfile.ID, - Collection: billing.CollectionOverrideConfig{ - ItemCollectionPeriod: lo.ToPtr(time.Hour), + Collection: billingentity.CollectionOverrideConfig{ + Interval: lo.ToPtr(datex.MustParse(s.T(), "PT1H")), }, }) @@ -209,13 +209,11 @@ func (s *CustomerOverrideTestSuite) TestPinnedProfileHandling() { wfConfig := customerProfile.Profile.WorkflowConfig - require.Equal(t, wfConfig.Collection.ItemCollectionPeriod, time.Hour) - require.Equal(t, wfConfig.Invoicing.AutoAdvance, false) - require.Equal(t, wfConfig.Invoicing.DraftPeriod, 24*time.Hour) - require.Equal(t, wfConfig.Invoicing.DueAfter, 30*24*time.Hour) - require.Equal(t, wfConfig.Invoicing.ItemResolution, billing.GranularityResolutionPeriod) - require.Equal(t, wfConfig.Invoicing.ItemPerSubject, false) - require.Equal(t, wfConfig.Payment.CollectionMethod, billing.CollectionMethodChargeAutomatically) + require.Equal(t, wfConfig.Collection.Interval, datex.MustParse(s.T(), "PT1H")) + require.Equal(t, *wfConfig.Invoicing.AutoAdvance, true) + require.Equal(t, wfConfig.Invoicing.DraftPeriod, billingentity.DefaultWorkflowConfig.Invoicing.DraftPeriod) + require.Equal(t, wfConfig.Invoicing.DueAfter, billingentity.DefaultWorkflowConfig.Invoicing.DueAfter) + require.Equal(t, wfConfig.Payment.CollectionMethod, billingentity.CollectionMethodChargeAutomatically) }) } @@ -224,6 +222,8 @@ func (s *CustomerOverrideTestSuite) TestSanityOverrideOperations() { ns := "test-sanity-override-operations" ctx := context.Background() + s.installSandboxApp(s.T(), ns) + customer, err := s.CustomerService.CreateCustomer(ctx, customerentity.CreateCustomerInput{ Namespace: ns, Customer: customerentity.Customer{ @@ -246,14 +246,21 @@ func (s *CustomerOverrideTestSuite) TestSanityOverrideOperations() { require.ErrorAs(t, err, &billing.NotFoundError{}) }) + profileInput := minimalCreateProfileInputTemplate + profileInput.Namespace = ns + + defaultProfile, err := s.BillingService.CreateProfile(ctx, profileInput) + require.NoError(s.T(), err) + require.NotNil(s.T(), defaultProfile) + s.T().Run("create, delete, create override", func(t *testing.T) { // Given we have an override for the customer createdCustomerOverride, err := s.BillingService.CreateCustomerOverride(ctx, billing.CreateCustomerOverrideInput{ Namespace: ns, CustomerID: customer.ID, - Collection: billing.CollectionOverrideConfig{ - ItemCollectionPeriod: lo.ToPtr(time.Hour), + Collection: billingentity.CollectionOverrideConfig{ + Interval: lo.ToPtr(datex.MustParse(s.T(), "PT1234H")), }, }) @@ -276,8 +283,9 @@ func (s *CustomerOverrideTestSuite) TestSanityOverrideOperations() { }) // Then we get a NotFoundError - require.ErrorAs(t, err, &billing.NotFoundError{}) - require.Nil(t, customerProfile) + require.NoError(t, err) + require.NotNil(t, customerProfile) + require.Equal(t, defaultProfile.WorkflowConfig.Collection.Interval, customerProfile.Profile.WorkflowConfig.Collection.Interval) // When fetching the override _, err = s.BillingService.GetCustomerOverride(ctx, billing.GetCustomerOverrideInput{ @@ -294,15 +302,15 @@ func (s *CustomerOverrideTestSuite) TestSanityOverrideOperations() { Namespace: ns, CustomerID: customer.ID, - Collection: billing.CollectionOverrideConfig{ - ItemCollectionPeriod: lo.ToPtr(48 * time.Hour), + Collection: billingentity.CollectionOverrideConfig{ + Interval: lo.ToPtr(datex.MustParse(s.T(), "PT48H")), }, }) // Then the override is created require.NoError(t, err) require.NotNil(t, createdCustomerOverride) - require.Equal(t, *createdCustomerOverride.Collection.ItemCollectionPeriod, 48*time.Hour) + require.Equal(t, *createdCustomerOverride.Collection.Interval, datex.MustParse(s.T(), "PT48H")) }) } @@ -311,6 +319,8 @@ func (s *CustomerOverrideTestSuite) TestCustomerIntegration() { ns := "test-customer-integration" ctx := context.Background() + _ = s.installSandboxApp(s.T(), ns) + customer, err := s.CustomerService.CreateCustomer(ctx, customerentity.CreateCustomerInput{ Namespace: ns, @@ -357,6 +367,8 @@ func (s *CustomerOverrideTestSuite) TestNullSetting() { ns := "test-null-setting" ctx := context.Background() + _ = s.installSandboxApp(s.T(), ns) + customer, err := s.CustomerService.CreateCustomer(ctx, customerentity.CreateCustomerInput{ Namespace: ns, @@ -381,8 +393,8 @@ func (s *CustomerOverrideTestSuite) TestNullSetting() { Namespace: ns, CustomerID: customer.ID, - Collection: billing.CollectionOverrideConfig{ - ItemCollectionPeriod: lo.ToPtr(time.Hour), + Collection: billingentity.CollectionOverrideConfig{ + Interval: lo.ToPtr(datex.MustParse(s.T(), "PT1H")), }, }) require.NoError(s.T(), err) @@ -394,8 +406,8 @@ func (s *CustomerOverrideTestSuite) TestNullSetting() { CustomerID: customer.ID, UpdatedAt: createdCustomerOverride.UpdatedAt, - Collection: billing.CollectionOverrideConfig{ - ItemCollectionPeriod: nil, + Collection: billingentity.CollectionOverrideConfig{ + Interval: nil, }, }) @@ -410,5 +422,5 @@ func (s *CustomerOverrideTestSuite) TestNullSetting() { require.NoError(s.T(), err) require.NotNil(s.T(), customerProfile) - require.Nil(s.T(), customerProfile.Collection.ItemCollectionPeriod) + require.Nil(s.T(), customerProfile.Collection.Interval) } diff --git a/test/billing/invoice_test.go b/test/billing/invoice_test.go index 6527813d8..711e56434 100644 --- a/test/billing/invoice_test.go +++ b/test/billing/invoice_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/openmeterio/openmeter/openmeter/billing" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" "github.com/openmeterio/openmeter/openmeter/billing/gobldriver" customerentity "github.com/openmeterio/openmeter/openmeter/customer/entity" "github.com/openmeterio/openmeter/pkg/currencyx" @@ -35,6 +36,8 @@ func (s *InvoicingTestSuite) TestPendingInvoiceValidation() { periodStart := periodEnd.Add(-time.Hour * 24 * 30) issueAt := now.Add(-time.Minute) + _ = s.installSandboxApp(s.T(), namespace) + ctx := context.Background() // Given we have a test customer @@ -75,8 +78,8 @@ func (s *InvoicingTestSuite) TestPendingInvoiceValidation() { require.NotNil(t, profile) }) - var items []billing.InvoiceItem - var HUFItem billing.InvoiceItem + var items []billingentity.InvoiceItem + var HUFItem billingentity.InvoiceItem s.T().Run("CreateInvoiceItems", func(t *testing.T) { // When we create invoice items @@ -85,7 +88,7 @@ func (s *InvoicingTestSuite) TestPendingInvoiceValidation() { billing.CreateInvoiceItemsInput{ InvoiceID: nil, Namespace: namespace, - Items: []billing.InvoiceItem{ + Items: []billingentity.InvoiceItem{ { Namespace: namespace, CustomerID: customerEntity.ID, @@ -94,7 +97,7 @@ func (s *InvoicingTestSuite) TestPendingInvoiceValidation() { InvoiceAt: issueAt, - Type: billing.InvoiceItemTypeStatic, + Type: billingentity.InvoiceItemTypeStatic, Name: "Test item - USD", Quantity: lo.ToPtr(alpacadecimal.NewFromFloat(1)), @@ -113,7 +116,7 @@ func (s *InvoicingTestSuite) TestPendingInvoiceValidation() { InvoiceAt: issueAt, - Type: billing.InvoiceItemTypeStatic, + Type: billingentity.InvoiceItemTypeStatic, Name: "Test item - HUF", Quantity: lo.ToPtr(alpacadecimal.NewFromFloat(3)), @@ -126,7 +129,7 @@ func (s *InvoicingTestSuite) TestPendingInvoiceValidation() { // Then we should have the items created require.NoError(s.T(), err) require.Len(s.T(), items, 2) - require.Equal(s.T(), items[0], billing.InvoiceItem{ + require.Equal(s.T(), items[0], billingentity.InvoiceItem{ ID: items[0].ID, Namespace: namespace, CustomerID: customerEntity.ID, @@ -136,7 +139,7 @@ func (s *InvoicingTestSuite) TestPendingInvoiceValidation() { InvoiceAt: issueAt, - Type: billing.InvoiceItemTypeStatic, + Type: billingentity.InvoiceItemTypeStatic, Name: "Test item - USD", Quantity: lo.ToPtr(alpacadecimal.NewFromFloat(1)), @@ -155,8 +158,8 @@ func (s *InvoicingTestSuite) TestPendingInvoiceValidation() { HUFItem = items[1] }) - var pendingInvoices []billing.InvoiceWithValidation - var USDInvoice billing.InvoiceWithValidation + var pendingInvoices []billingentity.InvoiceWithValidation + var USDInvoice billingentity.InvoiceWithValidation s.T().Run("Pending invoices", func(t *testing.T) { // When we get the pending invoices @@ -178,7 +181,7 @@ func (s *InvoicingTestSuite) TestPendingInvoiceValidation() { pendingInvoice.Invoice.Customer.CreatedAt = customerEntity.CreatedAt pendingInvoice.Invoice.Customer.UpdatedAt = customerEntity.UpdatedAt - require.EqualValues(t, billing.InvoiceCustomer(*customerEntity), pendingInvoice.Invoice.Customer) + require.EqualValues(t, billingentity.InvoiceCustomer(*customerEntity), pendingInvoice.Invoice.Customer) } require.EqualValues(t, HUFItem.ID, pendingInvoices[0].Invoice.Items[0].ID) diff --git a/test/billing/profile_test.go b/test/billing/profile_test.go index 6c469dfae..370d63ed0 100644 --- a/test/billing/profile_test.go +++ b/test/billing/profile_test.go @@ -9,8 +9,10 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + appentitybase "github.com/openmeterio/openmeter/openmeter/app/entity/base" "github.com/openmeterio/openmeter/openmeter/billing" - "github.com/openmeterio/openmeter/openmeter/billing/provider" + billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" + "github.com/openmeterio/openmeter/pkg/datex" "github.com/openmeterio/openmeter/pkg/models" ) @@ -18,30 +20,30 @@ var minimalCreateProfileInputTemplate = billing.CreateProfileInput{ Name: "Awesome Profile", Default: true, - TaxConfiguration: provider.TaxConfiguration{ - Type: provider.TaxProviderOpenMeterSandbox, - }, - - InvoicingConfiguration: provider.InvoicingConfiguration{ - Type: provider.InvoicingProviderOpenMeterSandbox, - }, - - PaymentConfiguration: provider.PaymentConfiguration{ - Type: provider.PaymentProviderOpenMeterSandbox, - }, - - WorkflowConfig: billing.WorkflowConfig{ - Collection: billing.CollectionConfig{ - Alignment: billing.AlignmentKindSubscription, + WorkflowConfig: billingentity.WorkflowConfig{ + Collection: billingentity.CollectionConfig{ + Alignment: billingentity.AlignmentKindSubscription, }, }, - Supplier: billing.SupplierContact{ + Supplier: billingentity.SupplierContact{ Name: "Awesome Supplier", Address: models.Address{ Country: lo.ToPtr(models.CountryCode("US")), }, }, + + Apps: billing.CreateProfileAppsInput{ + Invoicing: billingentity.AppReference{ + Type: appentitybase.AppTypeSandbox, + }, + Payment: billingentity.AppReference{ + Type: appentitybase.AppTypeSandbox, + }, + Tax: billingentity.AppReference{ + Type: appentitybase.AppTypeSandbox, + }, + }, } type ProfileTestSuite struct { @@ -56,6 +58,8 @@ func (s *ProfileTestSuite) TestProfileLifecycle() { ctx := context.Background() ns := "test_create_billing_profile" + _ = s.installSandboxApp(s.T(), ns) + s.T().Run("missing default profile", func(t *testing.T) { defaultProfile, err := s.BillingService.GetDefaultProfile(ctx, billing.GetDefaultProfileInput{ Namespace: ns, @@ -64,7 +68,7 @@ func (s *ProfileTestSuite) TestProfileLifecycle() { require.Nil(t, defaultProfile) }) - var profile *billing.Profile + var profile *billingentity.Profile var err error minimalCreateProfileInput := minimalCreateProfileInputTemplate @@ -141,44 +145,36 @@ func (s *ProfileTestSuite) TestProfileLifecycle() { func (s *ProfileTestSuite) TestProfileFieldSetting() { ctx := context.Background() + t := s.T() ns := "test_profile_field_setting" + app := s.installSandboxApp(s.T(), ns) + input := billing.CreateProfileInput{ Namespace: ns, Default: true, Name: "Awesome Default Profile", - TaxConfiguration: provider.TaxConfiguration{ - Type: provider.TaxProviderOpenMeterSandbox, + Metadata: map[string]string{ + "key": "value", }, - InvoicingConfiguration: provider.InvoicingConfiguration{ - Type: provider.InvoicingProviderOpenMeterSandbox, - }, - - PaymentConfiguration: provider.PaymentConfiguration{ - Type: provider.PaymentProviderOpenMeterSandbox, - }, - - WorkflowConfig: billing.WorkflowConfig{ - Collection: billing.CollectionConfig{ - Alignment: billing.AlignmentKindSubscription, - ItemCollectionPeriod: 30 * time.Minute, + WorkflowConfig: billingentity.WorkflowConfig{ + Collection: billingentity.CollectionConfig{ + Alignment: billingentity.AlignmentKindSubscription, + Interval: datex.MustParse(t, "PT30M"), }, - Invoicing: billing.InvoicingConfig{ - AutoAdvance: true, - DraftPeriod: 1 * time.Hour, - DueAfter: 24 * time.Hour, - - ItemResolution: billing.GranularityResolutionDay, - ItemPerSubject: true, + Invoicing: billingentity.InvoicingConfig{ + AutoAdvance: lo.ToPtr(true), + DraftPeriod: datex.MustParse(t, "PT1H"), + DueAfter: datex.MustParse(t, "PT24H"), }, - Payment: billing.PaymentConfig{ - CollectionMethod: billing.CollectionMethodSendInvoice, + Payment: billingentity.PaymentConfig{ + CollectionMethod: billingentity.CollectionMethodSendInvoice, }, }, - Supplier: billing.SupplierContact{ + Supplier: billingentity.SupplierContact{ Name: "Awesome Supplier", Address: models.Address{ Country: lo.ToPtr(models.CountryCode("US")), @@ -190,6 +186,18 @@ func (s *ProfileTestSuite) TestProfileFieldSetting() { PhoneNumber: lo.ToPtr("1234567890"), }, }, + + Apps: billing.CreateProfileAppsInput{ + Invoicing: billingentity.AppReference{ + Type: appentitybase.AppTypeSandbox, + }, + Payment: billingentity.AppReference{ + Type: appentitybase.AppTypeSandbox, + }, + Tax: billingentity.AppReference{ + Type: appentitybase.AppTypeSandbox, + }, + }, } profile, err := s.BillingService.CreateProfile(ctx, input) @@ -212,17 +220,38 @@ func (s *ProfileTestSuite) TestProfileFieldSetting() { require.Equal(s.T(), profile, fetchedProfile) // let's add the db derived fields to the input - input.ID = profile.ID - input.CreatedAt = fetchedProfile.CreatedAt - input.UpdatedAt = fetchedProfile.UpdatedAt - input.DeletedAt = fetchedProfile.DeletedAt - input.WorkflowConfig.ID = fetchedProfile.WorkflowConfig.ID - input.WorkflowConfig.CreatedAt = fetchedProfile.WorkflowConfig.CreatedAt - input.WorkflowConfig.UpdatedAt = fetchedProfile.WorkflowConfig.UpdatedAt - input.WorkflowConfig.DeletedAt = fetchedProfile.WorkflowConfig.DeletedAt + expectedProfile := billingentity.Profile{ + BaseProfile: billingentity.BaseProfile{ + ID: profile.ID, + + Namespace: input.Namespace, + Name: input.Name, + Description: input.Description, + Default: input.Default, + + CreatedAt: fetchedProfile.CreatedAt, + UpdatedAt: fetchedProfile.UpdatedAt, + DeletedAt: fetchedProfile.DeletedAt, + + WorkflowConfig: input.WorkflowConfig, + Supplier: input.Supplier, + + Metadata: input.Metadata, + AppReferences: fetchedProfile.AppReferences, + }, + Apps: fetchedProfile.Apps, + } + + expectedProfile.WorkflowConfig.ID = fetchedProfile.WorkflowConfig.ID + expectedProfile.WorkflowConfig.CreatedAt = fetchedProfile.WorkflowConfig.CreatedAt + expectedProfile.WorkflowConfig.UpdatedAt = fetchedProfile.WorkflowConfig.UpdatedAt + expectedProfile.WorkflowConfig.DeletedAt = fetchedProfile.WorkflowConfig.DeletedAt // Let's check if the fields are set correctly - require.Equal(s.T(), billing.Profile(input), *fetchedProfile) + require.Equal(s.T(), expectedProfile, *fetchedProfile) + require.Equal(s.T(), app.GetID(), fetchedProfile.Apps.Tax.GetID()) + require.Equal(s.T(), app.GetID(), fetchedProfile.Apps.Invoicing.GetID()) + require.Equal(s.T(), app.GetID(), fetchedProfile.Apps.Payment.GetID()) } func (s *ProfileTestSuite) TestProfileUpdates() { @@ -230,43 +259,32 @@ func (s *ProfileTestSuite) TestProfileUpdates() { ctx := context.Background() ns := "test_profile_updates" + _ = s.installSandboxApp(s.T(), ns) + input := billing.CreateProfileInput{ Namespace: ns, Default: true, Name: "Awesome Default Profile", - TaxConfiguration: provider.TaxConfiguration{ - Type: provider.TaxProviderOpenMeterSandbox, - }, + Apps: minimalCreateProfileInputTemplate.Apps, - InvoicingConfiguration: provider.InvoicingConfiguration{ - Type: provider.InvoicingProviderOpenMeterSandbox, - }, - - PaymentConfiguration: provider.PaymentConfiguration{ - Type: provider.PaymentProviderOpenMeterSandbox, - }, - - WorkflowConfig: billing.WorkflowConfig{ - Collection: billing.CollectionConfig{ - Alignment: billing.AlignmentKindSubscription, - ItemCollectionPeriod: 30 * time.Minute, + WorkflowConfig: billingentity.WorkflowConfig{ + Collection: billingentity.CollectionConfig{ + Alignment: billingentity.AlignmentKindSubscription, + Interval: datex.MustParse(s.T(), "PT30M"), }, - Invoicing: billing.InvoicingConfig{ - AutoAdvance: true, - DraftPeriod: 1 * time.Hour, - DueAfter: 24 * time.Hour, - - ItemResolution: billing.GranularityResolutionDay, - ItemPerSubject: true, + Invoicing: billingentity.InvoicingConfig{ + AutoAdvance: lo.ToPtr(true), + DraftPeriod: datex.MustParse(s.T(), "PT1H"), + DueAfter: datex.MustParse(s.T(), "PT24H"), }, - Payment: billing.PaymentConfig{ - CollectionMethod: billing.CollectionMethodSendInvoice, + Payment: billingentity.PaymentConfig{ + CollectionMethod: billingentity.CollectionMethodSendInvoice, }, }, - Supplier: billing.SupplierContact{ + Supplier: billingentity.SupplierContact{ Name: "Awesome Supplier", Address: models.Address{ Country: lo.ToPtr(models.CountryCode("US")), @@ -311,38 +329,23 @@ func (s *ProfileTestSuite) TestProfileUpdates() { UpdatedAt: profile.UpdatedAt, - TaxConfiguration: provider.TaxConfiguration{ - Type: provider.TaxProviderOpenMeterSandbox, - }, - - InvoicingConfiguration: provider.InvoicingConfiguration{ - Type: provider.InvoicingProviderOpenMeterSandbox, - }, - - PaymentConfiguration: provider.PaymentConfiguration{ - Type: provider.PaymentProviderOpenMeterSandbox, - }, - - WorkflowConfig: billing.WorkflowConfig{ + WorkflowConfig: billingentity.WorkflowConfig{ CreatedAt: profile.WorkflowConfig.CreatedAt, - Collection: billing.CollectionConfig{ - Alignment: billing.AlignmentKindSubscription, - ItemCollectionPeriod: 60 * time.Minute, + Collection: billingentity.CollectionConfig{ + Alignment: billingentity.AlignmentKindSubscription, + Interval: datex.MustParse(s.T(), "PT30M"), }, - Invoicing: billing.InvoicingConfig{ - AutoAdvance: false, - DraftPeriod: 2 * time.Hour, - DueAfter: 48 * time.Hour, - - ItemResolution: billing.GranularityResolutionPeriod, - ItemPerSubject: false, + Invoicing: billingentity.InvoicingConfig{ + AutoAdvance: lo.ToPtr(false), + DraftPeriod: datex.MustParse(s.T(), "PT2H"), + DueAfter: datex.MustParse(s.T(), "PT48H"), }, - Payment: billing.PaymentConfig{ - CollectionMethod: billing.CollectionMethodChargeAutomatically, + Payment: billingentity.PaymentConfig{ + CollectionMethod: billingentity.CollectionMethodChargeAutomatically, }, }, - Supplier: billing.SupplierContact{ + Supplier: billingentity.SupplierContact{ Name: "Awesome Supplier [update]", Address: models.Address{ Country: lo.ToPtr(models.CountryCode("HU")), @@ -366,12 +369,27 @@ func (s *ProfileTestSuite) TestProfileUpdates() { require.NotEqual(t, fetchedProfile.UpdatedAt, updatedProfile.UpdatedAt, "the new updated at is returned") // Set up DB only fields - expecedOutput := billing.Profile(updateInput) - expecedOutput.WorkflowConfig.ID = fetchedProfile.WorkflowConfig.ID - expecedOutput.UpdatedAt = updatedProfile.UpdatedAt // This is checked by the previous assertion - expecedOutput.WorkflowConfig.UpdatedAt = updatedProfile.WorkflowConfig.UpdatedAt // This is checked by the previous assertion + expectedOutput := billingentity.Profile{ + BaseProfile: billingentity.BaseProfile{ + ID: updateInput.ID, + Namespace: updateInput.Namespace, + CreatedAt: fetchedProfile.CreatedAt, + Name: updateInput.Name, + Description: updateInput.Description, + Metadata: updateInput.Metadata, + Supplier: updateInput.Supplier, + Default: updateInput.Default, + + WorkflowConfig: updateInput.WorkflowConfig, + AppReferences: fetchedProfile.AppReferences, + }, + } + expectedOutput.WorkflowConfig.ID = fetchedProfile.WorkflowConfig.ID + expectedOutput.UpdatedAt = updatedProfile.UpdatedAt // This is checked by the previous assertion + expectedOutput.WorkflowConfig.UpdatedAt = updatedProfile.WorkflowConfig.UpdatedAt // This is checked by the previous assertion + expectedOutput.Apps = fetchedProfile.Apps - require.Equal(t, expecedOutput, *updatedProfile) + require.Equal(t, expectedOutput, *updatedProfile) }) s.T().Run("update profile, out of date input", func(t *testing.T) { @@ -386,38 +404,23 @@ func (s *ProfileTestSuite) TestProfileUpdates() { UpdatedAt: profile.UpdatedAt, - TaxConfiguration: provider.TaxConfiguration{ - Type: provider.TaxProviderStripeTax, - }, - - InvoicingConfiguration: provider.InvoicingConfiguration{ - Type: provider.InvoicingProviderStripeInvoicing, - }, - - PaymentConfiguration: provider.PaymentConfiguration{ - Type: provider.PaymentProviderStripePayments, - }, - - WorkflowConfig: billing.WorkflowConfig{ + WorkflowConfig: billingentity.WorkflowConfig{ CreatedAt: profile.WorkflowConfig.CreatedAt, - Collection: billing.CollectionConfig{ - Alignment: billing.AlignmentKindSubscription, - ItemCollectionPeriod: 60 * time.Minute, + Collection: billingentity.CollectionConfig{ + Alignment: billingentity.AlignmentKindSubscription, + Interval: datex.MustParse(t, "PT30M"), }, - Invoicing: billing.InvoicingConfig{ - AutoAdvance: false, - DraftPeriod: 2 * time.Hour, - DueAfter: 48 * time.Hour, - - ItemResolution: billing.GranularityResolutionPeriod, - ItemPerSubject: false, + Invoicing: billingentity.InvoicingConfig{ + AutoAdvance: lo.ToPtr(false), + DraftPeriod: datex.MustParse(t, "PT2H"), + DueAfter: datex.MustParse(t, "PT48H"), }, - Payment: billing.PaymentConfig{ - CollectionMethod: billing.CollectionMethodChargeAutomatically, + Payment: billingentity.PaymentConfig{ + CollectionMethod: billingentity.CollectionMethodChargeAutomatically, }, }, - Supplier: billing.SupplierContact{ + Supplier: billingentity.SupplierContact{ Name: "Awesome Supplier [update]", Address: models.Address{ Country: lo.ToPtr(models.CountryCode("HU")), @@ -437,75 +440,4 @@ func (s *ProfileTestSuite) TestProfileUpdates() { require.ErrorIs(t, err, billing.ErrProfileConflict) require.ErrorAs(t, err, &billing.UpdateAfterDeleteError{}) }) - - s.T().Run("update profile, provider change => fails", func(t *testing.T) { - // When updating the profile with new providers (which is not allowed) - profile, err = s.BillingService.GetProfile(ctx, billing.GetProfileInput{ - Namespace: ns, - ID: profile.ID, - }) - - require.NoError(t, err) - - updateInput := billing.UpdateProfileInput{ - ID: profile.ID, - Namespace: ns, - Default: true, - CreatedAt: profile.CreatedAt, - - Name: "Awesome Default Profile [update]", - - UpdatedAt: profile.UpdatedAt, - - TaxConfiguration: provider.TaxConfiguration{ - Type: provider.TaxProviderStripeTax, - }, - - InvoicingConfiguration: provider.InvoicingConfiguration{ - Type: provider.InvoicingProviderStripeInvoicing, - }, - - PaymentConfiguration: provider.PaymentConfiguration{ - Type: provider.PaymentProviderStripePayments, - }, - - WorkflowConfig: billing.WorkflowConfig{ - CreatedAt: profile.WorkflowConfig.CreatedAt, - Collection: billing.CollectionConfig{ - Alignment: billing.AlignmentKindSubscription, - ItemCollectionPeriod: 60 * time.Minute, - }, - Invoicing: billing.InvoicingConfig{ - AutoAdvance: false, - DraftPeriod: 2 * time.Hour, - DueAfter: 48 * time.Hour, - - ItemResolution: billing.GranularityResolutionPeriod, - ItemPerSubject: false, - }, - Payment: billing.PaymentConfig{ - CollectionMethod: billing.CollectionMethodChargeAutomatically, - }, - }, - - Supplier: billing.SupplierContact{ - Name: "Awesome Supplier [update]", - Address: models.Address{ - Country: lo.ToPtr(models.CountryCode("HU")), - PostalCode: lo.ToPtr("12345 [update]"), - City: lo.ToPtr("City [update]"), - State: lo.ToPtr("State [update]"), - Line1: lo.ToPtr("Line 1 [update]"), - Line2: lo.ToPtr("Line 2 [update]"), - PhoneNumber: lo.ToPtr("1234567890 [update]"), - }, - }, - } - - _, err := s.BillingService.UpdateProfile(ctx, updateInput) - - // Then the profile update is rejected - require.ErrorIs(t, err, billing.ErrProfileTaxTypeChange) - require.ErrorAs(t, err, &billing.ValidationError{}) - }) } diff --git a/test/billing/suite_test.go b/test/billing/suite_test.go index e47802649..c256d1577 100644 --- a/test/billing/suite_test.go +++ b/test/billing/suite_test.go @@ -4,10 +4,17 @@ import ( "context" "log/slog" "os" + "testing" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/openmeterio/openmeter/openmeter/app" + appadapter "github.com/openmeterio/openmeter/openmeter/app/adapter" + appentity "github.com/openmeterio/openmeter/openmeter/app/entity" + appentitybase "github.com/openmeterio/openmeter/openmeter/app/entity/base" + appsandbox "github.com/openmeterio/openmeter/openmeter/app/sandbox" + appservice "github.com/openmeterio/openmeter/openmeter/app/service" "github.com/openmeterio/openmeter/openmeter/billing" billingadapter "github.com/openmeterio/openmeter/openmeter/billing/adapter" billingservice "github.com/openmeterio/openmeter/openmeter/billing/service" @@ -29,6 +36,8 @@ type BaseSuite struct { BillingService billing.Service CustomerService customer.Service + + AppService app.Service } func (s *BaseSuite) SetupSuite() { @@ -61,8 +70,29 @@ func (s *BaseSuite) SetupSuite() { require.NoError(t, err) s.CustomerService = customerService + // App + appAdapter, err := appadapter.New(appadapter.Config{ + Client: dbClient, + BaseURL: "http://localhost:8888", + }) + require.NoError(t, err) + + appService, err := appservice.New(appservice.Config{ + Adapter: appAdapter, + }) + require.NoError(t, err) + s.AppService = appService + + // OpenMeter sandbox (registration as side-effect) + _, err = appsandbox.NewFactory(appsandbox.Config{ + AppService: appService, + }) + require.NoError(t, err) + + // Billing billingAdapter, err := billingadapter.New(billingadapter.Config{ Client: dbClient, + Logger: slog.Default(), }) require.NoError(t, err) s.BillingAdapter = billingAdapter @@ -70,11 +100,26 @@ func (s *BaseSuite) SetupSuite() { billingService, err := billingservice.New(billingservice.Config{ Adapter: billingAdapter, CustomerService: s.CustomerService, + AppService: s.AppService, }) require.NoError(t, err) s.BillingService = billingService } +func (s *BaseSuite) installSandboxApp(t *testing.T, ns string) appentity.App { + ctx := context.Background() + defaultApp, err := s.AppService.CreateApp(ctx, + appentity.CreateAppInput{ + Name: "Sandbox", + Description: "Sandbox app", + Type: appentitybase.AppTypeSandbox, + Namespace: ns, + }) + + require.NoError(t, err) + return defaultApp +} + func (s *BaseSuite) TearDownSuite() { s.TestDB.EntDriver.Close() s.TestDB.PGDriver.Close() diff --git a/test/customer/customer.go b/test/customer/customer.go index d6d023789..a26de08a6 100644 --- a/test/customer/customer.go +++ b/test/customer/customer.go @@ -7,7 +7,6 @@ import ( "github.com/oklog/ulid/v2" "github.com/stretchr/testify/require" - "github.com/openmeterio/openmeter/openmeter/billing/provider" customerentity "github.com/openmeterio/openmeter/openmeter/customer/entity" "github.com/openmeterio/openmeter/pkg/currencyx" "github.com/openmeterio/openmeter/pkg/models" @@ -35,10 +34,7 @@ var ( PostalCode: &TestAddressPostalCode, PhoneNumber: &TestAddressPhoneNumber, } - TestSubjectKeys = []string{"subject-0"} - TestTaxProvider = provider.TaxProviderOpenMeterSandbox - TestInvoicingProvider = provider.InvoicingProviderOpenMeterSandbox - TestPaymentProvider = provider.PaymentProviderOpenMeterSandbox + TestSubjectKeys = []string{"subject-0"} ) type CustomerHandlerTestSuite struct { diff --git a/tools/migrate/migrations/20241021124045_billing-profile.down.sql b/tools/migrate/migrations/20241021124045_billing-profile.down.sql new file mode 100644 index 000000000..8ce005b66 --- /dev/null +++ b/tools/migrate/migrations/20241021124045_billing-profile.down.sql @@ -0,0 +1,8 @@ +-- reverse: modify "billing_profiles" table +ALTER TABLE "billing_profiles" DROP CONSTRAINT "billing_profiles_apps_tax_app", DROP CONSTRAINT "billing_profiles_apps_payment_app", DROP CONSTRAINT "billing_profiles_apps_invoicing_app", DROP COLUMN "payment_app_id", DROP COLUMN "invoicing_app_id", DROP COLUMN "tax_app_id", DROP COLUMN "supplier_tax_code", ADD COLUMN "payment_provider" character varying NOT NULL, ADD COLUMN "invoicing_provider" character varying NOT NULL, ADD COLUMN "tax_provider" character varying NOT NULL; +-- reverse: modify "billing_workflow_configs" table +ALTER TABLE "billing_workflow_configs" DROP COLUMN "invoice_due_after", DROP COLUMN "invoice_draft_period", DROP COLUMN "item_collection_period", ADD COLUMN "invoice_item_per_subject" boolean NOT NULL, ADD COLUMN "timezone" character varying NULL, ADD COLUMN "invoice_item_resolution" character varying NOT NULL, ADD COLUMN "invoice_due_after_seconds" bigint NOT NULL, ADD COLUMN "invoice_draft_period_seconds" bigint NOT NULL, ADD COLUMN "item_collection_period_seconds" bigint NOT NULL; +-- reverse: modify "billing_invoices" table +ALTER TABLE "billing_invoices" ADD COLUMN "payment_provider" character varying NULL, ADD COLUMN "invoicing_provider" character varying NULL, ADD COLUMN "tax_provider" character varying NULL; +-- reverse: modify "billing_customer_overrides" table +ALTER TABLE "billing_customer_overrides" DROP COLUMN "invoice_due_after", DROP COLUMN "invoice_draft_period", DROP COLUMN "item_collection_period", ADD COLUMN "invoice_item_per_subject" boolean NULL, ADD COLUMN "invoice_item_resolution" character varying NULL, ADD COLUMN "invoice_due_after_seconds" bigint NULL, ADD COLUMN "invoice_draft_period_seconds" bigint NULL, ADD COLUMN "item_collection_period_seconds" bigint NULL; diff --git a/tools/migrate/migrations/20241021124045_billing-profile.up.sql b/tools/migrate/migrations/20241021124045_billing-profile.up.sql new file mode 100644 index 000000000..58f235367 --- /dev/null +++ b/tools/migrate/migrations/20241021124045_billing-profile.up.sql @@ -0,0 +1,15 @@ +-- modify "billing_customer_overrides" table +-- atlas:nolint DS103 +ALTER TABLE "billing_customer_overrides" DROP COLUMN "item_collection_period_seconds", DROP COLUMN "invoice_draft_period_seconds", DROP COLUMN "invoice_due_after_seconds", DROP COLUMN "invoice_item_resolution", DROP COLUMN "invoice_item_per_subject", ADD COLUMN "item_collection_period" character varying NULL, ADD COLUMN "invoice_draft_period" character varying NULL, ADD COLUMN "invoice_due_after" character varying NULL; +-- modify "billing_invoices" table +-- atlas:nolint DS103 +ALTER TABLE "billing_invoices" DROP COLUMN "tax_provider", DROP COLUMN "invoicing_provider", DROP COLUMN "payment_provider"; +-- modify "billing_workflow_configs" table +-- atlas:nolint DS103 MF103 +ALTER TABLE "billing_workflow_configs" DROP COLUMN "item_collection_period_seconds", DROP COLUMN "invoice_draft_period_seconds", DROP COLUMN "invoice_due_after_seconds", DROP COLUMN "invoice_item_resolution", DROP COLUMN "timezone", DROP COLUMN "invoice_item_per_subject", ADD COLUMN "item_collection_period" character varying NOT NULL, ADD COLUMN "invoice_draft_period" character varying NOT NULL, ADD COLUMN "invoice_due_after" character varying NOT NULL; +-- modify "billing_profiles" table +-- atlas:nolint DS103 MF103 +ALTER TABLE "billing_profiles" DROP COLUMN "tax_provider", DROP COLUMN "invoicing_provider", DROP COLUMN "payment_provider", ADD COLUMN "supplier_tax_code" character varying NULL, ADD COLUMN "tax_app_id" character(26) NOT NULL, ADD COLUMN "invoicing_app_id" character(26) NOT NULL, ADD COLUMN "payment_app_id" character(26) NOT NULL, ADD + CONSTRAINT "billing_profiles_apps_invoicing_app" FOREIGN KEY ("invoicing_app_id") REFERENCES "apps" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD + CONSTRAINT "billing_profiles_apps_payment_app" FOREIGN KEY ("payment_app_id") REFERENCES "apps" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD + CONSTRAINT "billing_profiles_apps_tax_app" FOREIGN KEY ("tax_app_id") REFERENCES "apps" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION; diff --git a/tools/migrate/migrations/atlas.sum b/tools/migrate/migrations/atlas.sum index 033eb651c..19a88bbde 100644 --- a/tools/migrate/migrations/atlas.sum +++ b/tools/migrate/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:2ygNE43wugkY8SDdHqGAMJdM45focljx6GKyPjYFIXw= +h1:4cBUGpRhyp4V7GFCH3Q2Tf6uKH45Yhth5Z3M+J85Z+g= 20240826120919_init.down.sql h1:AIbgwwngjkJEYa3yRZsIXQyBa2+qoZttwMXHxXEbHLI= 20240826120919_init.up.sql h1:/hYHWF3Z3dab8SMKnw99ixVktCuJe2bAw5wstCZIEN8= 20240903155435_entitlement-expired-index.down.sql h1:np2xgYs3KQ2z7qPBcobtGNhqWQ3V8NwEP9E5U3TmpSA= @@ -27,3 +27,5 @@ h1:2ygNE43wugkY8SDdHqGAMJdM45focljx6GKyPjYFIXw= 20241017090045_unify-resource-def.up.sql h1:YSRP6iyb60Q2Zscc1MatXb+r6BTDXRYxDXmKvfwOOj8= 20241017135535_entitlement_scheduling.down.sql h1:Km2FQ5euyZfFas/85ESuLQSWJk8ZboMCtm7OXLDkdpk= 20241017135535_entitlement_scheduling.up.sql h1:ODE4LqknutPUtgjWF/DyvCLVJYjv1oSRsLAx1f5goYI= +20241021124045_billing-profile.down.sql h1:Irb1QA8YGH2e59OHjnwRcusPvykLbCzYxpCLIVsSiZU= +20241021124045_billing-profile.up.sql h1:KHLsYk7IcMxJhUZBK9ArQbtJKDxyxUwzf18LsjLlvik=