collect

package
v1.0.0-beta.193 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllCmd = func() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "all",
		Short: "Advance all eligible invoices",
		RunE: func(cmd *cobra.Command, args []string) error {
			return internal.App.BillingCollector.All(cmd.Context(), namespaces, customerIDs, batchSize)
		},
	}

	cmd.PersistentFlags().StringSliceVar(&namespaces, "n", nil, "filter by namespaces")
	cmd.PersistentFlags().StringSliceVar(&customerIDs, "c", nil, "filter by customer ids")
	cmd.PersistentFlags().IntVar(&batchSize, "batch", 0, "operation batch size")

	return cmd
}
View Source
var Cmd = &cobra.Command{
	Use:   "collect",
	Short: "Invoice collection operations",
}
View Source
var InvoiceCmd = func() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "invoice [CUSTOMER_ID]",
		Short: "Create new invoice(s) for customer(s)",
		Args:  cobra.MinimumNArgs(1),
		RunE: func(cmd *cobra.Command, args []string) error {
			for _, customerID := range args {
				_, err := internal.App.BillingCollector.CollectCustomerInvoice(cmd.Context(),
					billingworkercollect.CollectCustomerInvoiceInput{
						CustomerID: customerID,
						AsOf:       nil,
					},
				)
				if err != nil {
					return fmt.Errorf("failed to advance invoice %s: %w", customerID, err)
				}
			}

			return nil
		},
	}

	return cmd
}
View Source
var ListCmd = func() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "list",
		Short: "List gathering invoices which can be collected",
		RunE: func(cmd *cobra.Command, args []string) error {
			invoices, err := internal.App.BillingCollector.ListCollectableInvoices(cmd.Context(),
				billingworkercollect.ListCollectableInvoicesInput{
					Namespaces:   namespaces,
					InvoiceIDs:   invoiceIDs,
					Customers:    customerIDs,
					CollectionAt: time.Now(),
				})
			if err != nil {
				return err
			}

			for _, invoice := range invoices {
				fmt.Printf("Namespace: %s ID: %s CollectAt: %s\n", invoice.Namespace, invoice.ID, invoice.CollectionAt)
			}

			return nil
		},
	}

	cmd.PersistentFlags().StringSliceVar(&namespaces, "n", nil, "filter by namespaces")
	cmd.PersistentFlags().StringSliceVar(&customerIDs, "c", nil, "filter by customer ids")
	cmd.PersistentFlags().StringSliceVar(&invoiceIDs, "i", nil, "filter by invoice ids")

	return cmd
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL