Interface representing the operations related to budgets within the MegaScript context.

interface Budgets {
    AddBudget: ((customerId: number, amount: Number, expiresOnUtc?: object, sendEmail?: boolean, associatedOpvId?: object) => Budget);
    BulkAddBudget: ((customerIds: number[], amount: Number, expiresOnUtc?: object, sendEmail?: boolean) => number[]);
    ClearBudget: ((budgetId: number) => void);
    GetAvailableBudgets: ((customerObj: object, validOnly?: boolean) => Budget[]);
    GetAvailableBudgetTotal: ((customerObj: object) => number);
}

Properties

AddBudget: ((customerId: number, amount: Number, expiresOnUtc?: object, sendEmail?: boolean, associatedOpvId?: object) => Budget)

Adds a new budget for a specific customer.

Type declaration

    • (customerId, amount, expiresOnUtc?, sendEmail?, associatedOpvId?): Budget
    • Parameters

      • customerId: number

        The ID of the customer.

      • amount: Number

        The amount to allocate to the budget.

      • OptionalexpiresOnUtc: object

        Optional. The expiration date of the budget. Defaults to null.

      • OptionalsendEmail: boolean

        Optional. Indicates whether to send an email notification. Defaults to false.

      • OptionalassociatedOpvId: object

        Optional. The associated Order Product Variant ID. Defaults to null.

      Returns Budget

      The newly created budget as a BudgetObject.

Exception if the customer is not found or if the amount is invalid.

BulkAddBudget: ((customerIds: number[], amount: Number, expiresOnUtc?: object, sendEmail?: boolean) => number[])

Adds budgets in bulk for multiple customers.

Type declaration

    • (customerIds, amount, expiresOnUtc?, sendEmail?): number[]
    • Parameters

      • customerIds: number[]

        An array of customer IDs.

      • amount: Number

        The amount to allocate to each budget.

      • OptionalexpiresOnUtc: object

        Optional. The expiration date of the budgets. Defaults to null.

      • OptionalsendEmail: boolean

        Optional. Indicates whether to send email notifications. Defaults to false.

      Returns number[]

      An array of budget IDs as ArrayInstance.

Exception if the amount is invalid or if any customer ID is invalid.

ClearBudget: ((budgetId: number) => void)

Clears a specific budget by ID.

Type declaration

    • (budgetId): void
    • Parameters

      • budgetId: number

        The ID of the budget to clear.

      Returns void

Exception if the budget is not found.

GetAvailableBudgets: ((customerObj: object, validOnly?: boolean) => Budget[])

Retrieves the available budgets for a specific customer.

Type declaration

    • (customerObj, validOnly?): Budget[]
    • Parameters

      • customerObj: object

        The customer object to retrieve budgets for.

      • OptionalvalidOnly: boolean

        Optional. Indicates whether to return only valid budgets. Defaults to true.

      Returns Budget[]

      An array of available budgets as ArrayInstance.

Exception if the customer is not found.

GetAvailableBudgetTotal: ((customerObj: object) => number)

Retrieves the total available budget for a specific customer.

Type declaration

    • (customerObj): number
    • Parameters

      • customerObj: object

        The customer object to retrieve the budget for.

      Returns number

      The available budget total as a NumberInstance.

Exception if the customer is not found.