| |
|
|
| package chargeusagebasedrunpayment |
|
|
| import ( |
| "fmt" |
| "time" |
|
|
| "entgo.io/ent/dialect/sql" |
| "entgo.io/ent/dialect/sql/sqlgraph" |
| "github.com/openmeterio/openmeter/openmeter/billing/charges/models/payment" |
| ) |
|
|
| const ( |
| |
| Label = "charge_usage_based_run_payment" |
| |
| FieldID = "id" |
| |
| FieldLineID = "line_id" |
| |
| FieldInvoiceID = "invoice_id" |
| |
| FieldServicePeriodFrom = "service_period_from" |
| |
| FieldServicePeriodTo = "service_period_to" |
| |
| FieldStatus = "status" |
| |
| FieldAmount = "amount" |
| |
| FieldAuthorizedTransactionGroupID = "authorized_transaction_group_id" |
| |
| FieldAuthorizedAt = "authorized_at" |
| |
| FieldSettledTransactionGroupID = "settled_transaction_group_id" |
| |
| FieldSettledAt = "settled_at" |
| |
| FieldNamespace = "namespace" |
| |
| FieldCreatedAt = "created_at" |
| |
| FieldUpdatedAt = "updated_at" |
| |
| FieldDeletedAt = "deleted_at" |
| |
| FieldAnnotations = "annotations" |
| |
| FieldRunID = "run_id" |
| |
| EdgeRun = "run" |
| |
| Table = "charge_usage_based_run_payments" |
| |
| RunTable = "charge_usage_based_run_payments" |
| |
| |
| RunInverseTable = "charge_usage_based_runs" |
| |
| RunColumn = "run_id" |
| ) |
|
|
| |
| var Columns = []string{ |
| FieldID, |
| FieldLineID, |
| FieldInvoiceID, |
| FieldServicePeriodFrom, |
| FieldServicePeriodTo, |
| FieldStatus, |
| FieldAmount, |
| FieldAuthorizedTransactionGroupID, |
| FieldAuthorizedAt, |
| FieldSettledTransactionGroupID, |
| FieldSettledAt, |
| FieldNamespace, |
| FieldCreatedAt, |
| FieldUpdatedAt, |
| FieldDeletedAt, |
| FieldAnnotations, |
| FieldRunID, |
| } |
|
|
| |
| func ValidColumn(column string) bool { |
| for i := range Columns { |
| if column == Columns[i] { |
| return true |
| } |
| } |
| return false |
| } |
|
|
| var ( |
| |
| AuthorizedTransactionGroupIDValidator func(string) error |
| |
| SettledTransactionGroupIDValidator func(string) error |
| |
| NamespaceValidator func(string) error |
| |
| DefaultCreatedAt func() time.Time |
| |
| DefaultUpdatedAt func() time.Time |
| |
| UpdateDefaultUpdatedAt func() time.Time |
| |
| DefaultID func() string |
| ) |
|
|
| |
| func StatusValidator(s payment.Status) error { |
| switch s { |
| case "authorized", "settled": |
| return nil |
| default: |
| return fmt.Errorf("chargeusagebasedrunpayment: invalid enum value for status field: %q", s) |
| } |
| } |
|
|
| |
| type OrderOption func(*sql.Selector) |
|
|
| |
| func ByID(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldID, 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 ByServicePeriodFrom(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldServicePeriodFrom, opts...).ToFunc() |
| } |
|
|
| |
| func ByServicePeriodTo(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldServicePeriodTo, opts...).ToFunc() |
| } |
|
|
| |
| func ByStatus(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldStatus, opts...).ToFunc() |
| } |
|
|
| |
| func ByAmount(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldAmount, opts...).ToFunc() |
| } |
|
|
| |
| func ByAuthorizedTransactionGroupID(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldAuthorizedTransactionGroupID, opts...).ToFunc() |
| } |
|
|
| |
| func ByAuthorizedAt(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldAuthorizedAt, opts...).ToFunc() |
| } |
|
|
| |
| func BySettledTransactionGroupID(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldSettledTransactionGroupID, opts...).ToFunc() |
| } |
|
|
| |
| func BySettledAt(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldSettledAt, 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 ByRunID(opts ...sql.OrderTermOption) OrderOption { |
| return sql.OrderByField(FieldRunID, opts...).ToFunc() |
| } |
|
|
| |
| func ByRunField(field string, opts ...sql.OrderTermOption) OrderOption { |
| return func(s *sql.Selector) { |
| sqlgraph.OrderByNeighborTerms(s, newRunStep(), sql.OrderByField(field, opts...)) |
| } |
| } |
| func newRunStep() *sqlgraph.Step { |
| return sqlgraph.NewStep( |
| sqlgraph.From(Table, FieldID), |
| sqlgraph.To(RunInverseTable, FieldID), |
| sqlgraph.Edge(sqlgraph.O2O, true, RunTable, RunColumn), |
| ) |
| } |
|
|