| |
|
|
| package chargeusagebasedruns |
|
|
| import ( |
| "fmt" |
| "time" |
|
|
| "entgo.io/ent/dialect/sql" |
| "entgo.io/ent/dialect/sql/sqlgraph" |
| "github.com/openmeterio/openmeter/openmeter/billing/charges/usagebased" |
| ) |
|
|
| const ( |
| |
| Label = "charge_usage_based_runs" |
| |
| FieldID = "id" |
| |
| FieldNamespace = "namespace" |
| |
| FieldCreatedAt = "created_at" |
| |
| FieldUpdatedAt = "updated_at" |
| |
| FieldDeletedAt = "deleted_at" |
| |
| FieldAmount = "amount" |
| |
| FieldTaxesTotal = "taxes_total" |
| |
| FieldTaxesInclusiveTotal = "taxes_inclusive_total" |
| |
| FieldTaxesExclusiveTotal = "taxes_exclusive_total" |
| |
| FieldChargesTotal = "charges_total" |
| |
| FieldDiscountsTotal = "discounts_total" |
| |
| FieldCreditsTotal = "credits_total" |
| |
| FieldTotal = "total" |
| |
| FieldChargeID = "charge_id" |
| |
| FieldFeatureID = "feature_id" |
| |
| FieldType = "type" |
| |
| FieldInitialType = "initial_type" |
| |
| FieldStoredAtLt = "stored_at_lt" |
| |
| FieldServicePeriodTo = "service_period_to" |
| |
| FieldDetailedLinesPresent = "detailed_lines_present" |
| |
| FieldLineID = "line_id" |
| |
| FieldInvoiceID = "invoice_id" |
| |
| FieldMeteredQuantity = "metered_quantity" |
| |
| FieldNoFiatTransactionRequired = "no_fiat_transaction_required" |
| |
| EdgeUsageBased = "usage_based" |
| |
| EdgeFeature = "feature" |
| |
| EdgeBillingInvoiceLine = "billing_invoice_line" |
| |
| EdgeBillingInvoice = "billing_invoice" |
| |
| EdgeCreditAllocations = "credit_allocations" |
| |
| EdgeDetailedLines = "detailed_lines" |
| |
| EdgeCorrectedDetailedLines = "corrected_detailed_lines" |
| |
| EdgeInvoicedUsage = "invoiced_usage" |
| |
| EdgePayment = "payment" |
| |
| Table = "charge_usage_based_runs" |
| |
| UsageBasedTable = "charge_usage_based_runs" |
| |
| |
| UsageBasedInverseTable = "charge_usage_based" |
| |
| UsageBasedColumn = "charge_id" |
| |
| FeatureTable = "charge_usage_based_runs" |
| |
| |
| FeatureInverseTable = "features" |
| |
| FeatureColumn = "feature_id" |
| |
| BillingInvoiceLineTable = "charge_usage_based_runs" |
| |
| |
| BillingInvoiceLineInverseTable = "billing_invoice_lines" |
| |
| BillingInvoiceLineColumn = "line_id" |
| |
| BillingInvoiceTable = "charge_usage_based_runs" |
| |
| |
| BillingInvoiceInverseTable = "billing_invoices" |
| |
| BillingInvoiceColumn = "invoice_id" |
| |
| CreditAllocationsTable = "charge_usage_based_run_credit_allocations" |
| |
| |
| CreditAllocationsInverseTable = "charge_usage_based_run_credit_allocations" |
| |
| CreditAllocationsColumn = "run_id" |
| |
| DetailedLinesTable = "charge_usage_based_run_detailed_line" |
| |
| |
| DetailedLinesInverseTable = "charge_usage_based_run_detailed_line" |
| |
| DetailedLinesColumn = "run_id" |
| |
| CorrectedDetailedLinesTable = "charge_usage_based_run_detailed_line" |
| |
| |
| CorrectedDetailedLinesInverseTable = "charge_usage_based_run_detailed_line" |
| |
| CorrectedDetailedLinesColumn = "corrects_run_id" |
| |
| InvoicedUsageTable = "charge_usage_based_run_invoiced_usages" |
| |
| |
| InvoicedUsageInverseTable = "charge_usage_based_run_invoiced_usages" |
| |
| InvoicedUsageColumn = "run_id" |
| |
| PaymentTable = "charge_usage_based_run_payments" |
| |
| |
| PaymentInverseTable = "charge_usage_based_run_payments" |
| |
| PaymentColumn = "run_id" |
| ) |
|
|
| |
| var Columns = []string{ |
| FieldID, |
| FieldNamespace, |
| FieldCreatedAt, |
| FieldUpdatedAt, |
| FieldDeletedAt, |
| FieldAmount, |
| FieldTaxesTotal, |
| FieldTaxesInclusiveTotal, |
| FieldTaxesExclusiveTotal, |
| FieldChargesTotal, |
| FieldDiscountsTotal, |
| FieldCreditsTotal, |
| FieldTotal, |
| FieldChargeID, |
| FieldFeatureID, |
| FieldType, |
| FieldInitialType, |
| FieldStoredAtLt, |
| FieldServicePeriodTo, |
| FieldDetailedLinesPresent, |
| FieldLineID, |
| FieldInvoiceID, |
| FieldMeteredQuantity, |
| FieldNoFiatTransactionRequired, |
| } |
|
|
| |
| func ValidColumn(column string) bool { |
| for i := range Columns { |
| if column == Columns[i] { |
| return true |
| } |
| } |
| return false |
| } |
|
|
| var ( |
| |
| NamespaceValidator func(string) error |
| |
| DefaultCreatedAt func() time.Time |
| |
| DefaultUpdatedAt func() time.Time |
| |
| UpdateDefaultUpdatedAt func() time.Time |
| |
| FeatureIDValidator func(string) error |
| |
| LineIDValidator func(string) error |
| |
| InvoiceIDValidator func(string) error |
| |
| DefaultID func() string |
| ) |
|
|
| |
| func TypeValidator(_type usagebased.RealizationRunType) error { |
| switch _type { |
| case "final_realization", "partial_invoice", "invalid_due_to_unsupported_credit_note": |
| return nil |
| default: |
| return fmt.Errorf("chargeusagebasedruns: invalid enum value for type field: %q", _type) |
| } |
| } |
|
|
| |
| func InitialTypeValidator(it usagebased.RealizationRunType) error { |
| switch it { |
| case "final_realization", "partial_invoice", "invalid_due_to_unsupported_credit_note": |
| return nil |
| default: |
| return fmt.Errorf("chargeusagebasedruns: invalid enum value for initial_type field: %q", it) |
| } |
| } |
|
|
| |
| type OrderOption func(*sql.Selector) |
|
|
| |
| func ByID(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldID, opts...).ToFunc() |
| } |
|
|
| |
| func ByNamespace(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldNamespace, opts...).ToFunc() |
| } |
|
|
| |
| func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() |
| } |
|
|
| |
| func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() |
| } |
|
|
| |
| func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() |
| } |
|
|
| |
| func ByAmount(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldAmount, opts...).ToFunc() |
| } |
|
|
| |
| func ByTaxesTotal(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldTaxesTotal, opts...).ToFunc() |
| } |
|
|
| |
| func ByTaxesInclusiveTotal(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldTaxesInclusiveTotal, opts...).ToFunc() |
| } |
|
|
| |
| func ByTaxesExclusiveTotal(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldTaxesExclusiveTotal, opts...).ToFunc() |
| } |
|
|
| |
| func ByChargesTotal(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldChargesTotal, opts...).ToFunc() |
| } |
|
|
| |
| func ByDiscountsTotal(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldDiscountsTotal, opts...).ToFunc() |
| } |
|
|
| |
| func ByCreditsTotal(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldCreditsTotal, opts...).ToFunc() |
| } |
|
|
| |
| func ByTotal(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldTotal, opts...).ToFunc() |
| } |
|
|
| |
| func ByChargeID(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldChargeID, opts...).ToFunc() |
| } |
|
|
| |
| func ByFeatureID(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldFeatureID, opts...).ToFunc() |
| } |
|
|
| |
| func ByType(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldType, opts...).ToFunc() |
| } |
|
|
| |
| func ByInitialType(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldInitialType, opts...).ToFunc() |
| } |
|
|
| |
| func ByStoredAtLt(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldStoredAtLt, opts...).ToFunc() |
| } |
|
|
| |
| func ByServicePeriodTo(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldServicePeriodTo, opts...).ToFunc() |
| } |
|
|
| |
| func ByDetailedLinesPresent(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldDetailedLinesPresent, opts...).ToFunc() |
| } |
|
|
| |
| func ByLineID(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldLineID, opts...).ToFunc() |
| } |
|
|
| |
| func ByInvoiceID(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldInvoiceID, opts...).ToFunc() |
| } |
|
|
| |
| func ByMeteredQuantity(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldMeteredQuantity, opts...).ToFunc() |
| } |
|
|
| |
| func ByNoFiatTransactionRequired(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldNoFiatTransactionRequired, opts...).ToFunc() |
| } |
|
|
| |
| func ByUsageBasedField(field string, opts ...sql.OrderTermOption) OrderOption { |
| return func(s *sql.Selector) { |
| sqlgraph.OrderByNeighborTerms(s, newUsageBasedStep(), sql.OrderByField(field, opts...)) |
| } |
| } |
|
|
| |
| func ByFeatureField(field string, opts ...sql.OrderTermOption) OrderOption { |
| return func(s *sql.Selector) { |
| sqlgraph.OrderByNeighborTerms(s, newFeatureStep(), sql.OrderByField(field, opts...)) |
| } |
| } |
|
|
| |
| func ByBillingInvoiceLineField(field string, opts ...sql.OrderTermOption) OrderOption { |
| return func(s *sql.Selector) { |
| sqlgraph.OrderByNeighborTerms(s, newBillingInvoiceLineStep(), sql.OrderByField(field, opts...)) |
| } |
| } |
|
|
| |
| func ByBillingInvoiceField(field string, opts ...sql.OrderTermOption) OrderOption { |
| return func(s *sql.Selector) { |
| sqlgraph.OrderByNeighborTerms(s, newBillingInvoiceStep(), sql.OrderByField(field, opts...)) |
| } |
| } |
|
|
| |
| func ByCreditAllocationsCount(opts ...sql.OrderTermOption) OrderOption { |
| return func(s *sql.Selector) { |
| sqlgraph.OrderByNeighborsCount(s, newCreditAllocationsStep(), opts...) |
| } |
| } |
|
|
| |
| func ByCreditAllocations(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { |
| return func(s *sql.Selector) { |
| sqlgraph.OrderByNeighborTerms(s, newCreditAllocationsStep(), append([]sql.OrderTerm{term}, terms...)...) |
| } |
| } |
|
|
| |
| func ByDetailedLinesCount(opts ...sql.OrderTermOption) OrderOption { |
| return func(s *sql.Selector) { |
| sqlgraph.OrderByNeighborsCount(s, newDetailedLinesStep(), opts...) |
| } |
| } |
|
|
| |
| func ByDetailedLines(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { |
| return func(s *sql.Selector) { |
| sqlgraph.OrderByNeighborTerms(s, newDetailedLinesStep(), append([]sql.OrderTerm{term}, terms...)...) |
| } |
| } |
|
|
| |
| func ByCorrectedDetailedLinesCount(opts ...sql.OrderTermOption) OrderOption { |
| return func(s *sql.Selector) { |
| sqlgraph.OrderByNeighborsCount(s, newCorrectedDetailedLinesStep(), opts...) |
| } |
| } |
|
|
| |
| func ByCorrectedDetailedLines(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { |
| return func(s *sql.Selector) { |
| sqlgraph.OrderByNeighborTerms(s, newCorrectedDetailedLinesStep(), append([]sql.OrderTerm{term}, terms...)...) |
| } |
| } |
|
|
| |
| func ByInvoicedUsageField(field string, opts ...sql.OrderTermOption) OrderOption { |
| return func(s *sql.Selector) { |
| sqlgraph.OrderByNeighborTerms(s, newInvoicedUsageStep(), sql.OrderByField(field, opts...)) |
| } |
| } |
|
|
| |
| func ByPaymentField(field string, opts ...sql.OrderTermOption) OrderOption { |
| return func(s *sql.Selector) { |
| sqlgraph.OrderByNeighborTerms(s, newPaymentStep(), sql.OrderByField(field, opts...)) |
| } |
| } |
| func newUsageBasedStep() *sqlgraph.Step { |
| return sqlgraph.NewStep( |
| sqlgraph.From(Table, FieldID), |
| sqlgraph.To(UsageBasedInverseTable, FieldID), |
| sqlgraph.Edge(sqlgraph.M2O, true, UsageBasedTable, UsageBasedColumn), |
| ) |
| } |
| func newFeatureStep() *sqlgraph.Step { |
| return sqlgraph.NewStep( |
| sqlgraph.From(Table, FieldID), |
| sqlgraph.To(FeatureInverseTable, FieldID), |
| sqlgraph.Edge(sqlgraph.M2O, true, FeatureTable, FeatureColumn), |
| ) |
| } |
| func newBillingInvoiceLineStep() *sqlgraph.Step { |
| return sqlgraph.NewStep( |
| sqlgraph.From(Table, FieldID), |
| sqlgraph.To(BillingInvoiceLineInverseTable, FieldID), |
| sqlgraph.Edge(sqlgraph.O2O, true, BillingInvoiceLineTable, BillingInvoiceLineColumn), |
| ) |
| } |
| func newBillingInvoiceStep() *sqlgraph.Step { |
| return sqlgraph.NewStep( |
| sqlgraph.From(Table, FieldID), |
| sqlgraph.To(BillingInvoiceInverseTable, FieldID), |
| sqlgraph.Edge(sqlgraph.M2O, true, BillingInvoiceTable, BillingInvoiceColumn), |
| ) |
| } |
| func newCreditAllocationsStep() *sqlgraph.Step { |
| return sqlgraph.NewStep( |
| sqlgraph.From(Table, FieldID), |
| sqlgraph.To(CreditAllocationsInverseTable, FieldID), |
| sqlgraph.Edge(sqlgraph.O2M, false, CreditAllocationsTable, CreditAllocationsColumn), |
| ) |
| } |
| func newDetailedLinesStep() *sqlgraph.Step { |
| return sqlgraph.NewStep( |
| sqlgraph.From(Table, FieldID), |
| sqlgraph.To(DetailedLinesInverseTable, FieldID), |
| sqlgraph.Edge(sqlgraph.O2M, false, DetailedLinesTable, DetailedLinesColumn), |
| ) |
| } |
| func newCorrectedDetailedLinesStep() *sqlgraph.Step { |
| return sqlgraph.NewStep( |
| sqlgraph.From(Table, FieldID), |
| sqlgraph.To(CorrectedDetailedLinesInverseTable, FieldID), |
| sqlgraph.Edge(sqlgraph.O2M, false, CorrectedDetailedLinesTable, CorrectedDetailedLinesColumn), |
| ) |
| } |
| func newInvoicedUsageStep() *sqlgraph.Step { |
| return sqlgraph.NewStep( |
| sqlgraph.From(Table, FieldID), |
| sqlgraph.To(InvoicedUsageInverseTable, FieldID), |
| sqlgraph.Edge(sqlgraph.O2O, false, InvoicedUsageTable, InvoicedUsageColumn), |
| ) |
| } |
| func newPaymentStep() *sqlgraph.Step { |
| return sqlgraph.NewStep( |
| sqlgraph.From(Table, FieldID), |
| sqlgraph.To(PaymentInverseTable, FieldID), |
| sqlgraph.Edge(sqlgraph.O2O, false, PaymentTable, PaymentColumn), |
| ) |
| } |
|
|