Submit Documentation FeedbackJoin Developer CommunityLog In

Budget pipelines

This topic provides an overview of Budget pipelines.


100GetSettingsGets BudgetsFromOnlineOnly setting. If Currency parameter is not null, then sets ConversionRate into result (if CurrencyRate for currency is null or ConversionRate is equal 0, then use 1, otherwise value from CurrencyRate.ConversionRate).
200CreateOrderHistoryQuerySets OrderHistoryQuery by whole OrderHistory table
300FilterOrderHistoryQueryFilter OrderHistoryQuery with BillTo.CustomerNumber, PeriodStartDate and PeriodEndDate parameters.

If ShipTo parameter is set, UserProfile parameter is null and BudgetsFromOnlineOnly setting is false, then filter also by ShipTo.CustomerSequence parameter.
400FilterForOnlineOnlyIfNeededIf BudgetsFromOnlineOnly is false, then exit pipe.

If OrderHistoryQuery is null, then throw ArgumentNullException

Join CustomerOrder table by orderHistory.WebOrderNumber and cart.OrderNumber. If UserProfile parameter exists, filter cart.InitiatedByUserProfile.UserName also by UserProfile.UserName parameter. And update OrderHistoryQuery result by all filtering with selecting order history.
500CalculateBudgetActualAmountIf OrderHistoryQuery is null, then throw ArgumentNullException

Calculate BudgetActualAmount by summarizing all OrderHistoryQuery results.

Code Example:

`orderHistory.OrderTotal / (orderHistory.ConversionRate == 0


100GetCurrencyGet BillTo currency or default website currency (if customer currency is not set).
200GetBudgetCalendarGet first BudgetCalendar filtered by BillTo.Id and FiscalYear parameters.
300GetCustomerBudgetsIf UserProfile parameter is not null, filter CustomerBudget by BillTo.Id and UserProfile.Id parameters

If ShipTo parameter is not null, filter CustomerBudget by BillTo.Id and ShipTo.Id parameters

Else filter CustomerBudget by BillTo.Id parameter and ShipToCustomerId, UserProfileId equal null.

CurrentCustomerBudget and PreviousCustomerBudget are being set by filtering collection.
400CalculateVarianceIf BudgetCalendar is null, exit pipe.

Fill CustomerBudgetReviewDtos with 13 periods by using data from previous pipes (BudgetCalendar, CurrentCustomerBudget, PreviousCustomerBudget).
500GetBudgetActualAmountsIf GetBudgetActualAmounts is false, exit pipe.

Iterate over CustomerBudgetReviewDtos and calculate CurrentFiscalYearActual and LastFiscalYearActual using GetBudgetActualAmount budget pipeline. Based on previous iteration, calculate CurrentFiscalYearVariance and LastFiscalYearVariance per each CustomerBudgetReviewDto.


100ValidateBudgetEnforcementLevelRetrieves BillTo by BillToId parameter, can return not found error. If BudgetsFromOnlineOnly setting is false and customer BudgetEnforcementLevel is BudgetEnforcementLevel.User, then set BudgetEnforcementLevel to BudgetEnforcementLevel.None. If customer BudgetEnforcementLevel is BudgetEnforcementLevel.None, then exit the handler chain.
200GetFilterForBudgetEnforcementLevelIf customer BudgetEnforcementLevel is BudgetEnforcementLevel.ShipTo, then retrieve ShipTo by ShipToId parameter, can return not found error.

If customer BudgetEnforcementLevel is BudgetEnforcementLevel.User, then retrieve UserProfile by UserProfileId parameter, can return not found error.
300CalculateAvailableBudgetBalanceCall GetCustomerBudgetReview budget pipeline for current year, with retrieved BillTo, ShipTo or UserProfile. Calculate FiscalYearBudget based on retrieved data.

If customer budget review records exists. then set result Currency from BillTo or website default currency (if BillTo Currency property is not set). Call GetBudgetActualAmount budget pipeline and set FiscalYearActual with pipeline result.

AvailableBudgetBalance value will be.calculated as FiscalYearBudget minus FiscalYearActual.

What’s Next
Did this page help you?