advance

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: 4 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 {
			var ns []string
			if namespace != "" {
				ns = append(ns, namespace)
			}

			return internal.App.BillingAutoAdvancer.All(cmd.Context(), ns, batchSize)
		},
	}

	cmd.PersistentFlags().IntVar(&batchSize, "batch", 0, "operation batch size")

	return cmd
}
View Source
var Cmd = &cobra.Command{
	Use:   "advance",
	Short: "Invoice advance operations",
}
View Source
var InvoiceCmd = func() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "invoice [INVOICE_ID]",
		Short: "Advance invoice(s)",
		Args:  cobra.MinimumNArgs(1),
		RunE: func(cmd *cobra.Command, args []string) error {
			if namespace == "" {
				return fmt.Errorf("invoice namespace is required")
			}

			for _, invoiceID := range args {
				_, err := internal.App.BillingAutoAdvancer.AdvanceInvoice(cmd.Context(), billing.InvoiceID{
					Namespace: namespace,
					ID:        invoiceID,
				})
				if err != nil {
					return fmt.Errorf("failed to advance invoice %s: %w", invoiceID, err)
				}
			}

			return nil
		},
	}

	return cmd
}
View Source
var ListCmd = func() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "list",
		Short: "List invoices which can be advanced",
		RunE: func(cmd *cobra.Command, args []string) error {
			var ns []string
			if namespace != "" {
				ns = append(ns, namespace)
			}

			invoices, err := internal.App.BillingAutoAdvancer.ListInvoicesToAdvance(cmd.Context(), ns, nil)
			if err != nil {
				return err
			}

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

			return nil
		},
	}

	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