SaveBudgetData - accountsIQ/API-Wiki GitHub Wiki
The SaveBudgetData function saves the provided budget data into the company.
public WSResult2OfWSBudgetHeader SaveBudgetData(string token, WSBudgetHeader header)
Public Function SaveBudgetData(ByVal token As String, ByVal options as WSBudgetHeader ) As WSResult2OfWSBudgetHeader
Parameter | Type | Description |
---|---|---|
token | String | The session token retrieved during authentication. |
header | WSBudgetHeader | The budget data you wish to save. |
The following example retrieves the budget template data for all accounts for the year 2019. The budget values are increased by 10% and then saved as 2020 budget.
Integration ws = new Integration();
String auth = ws.Login(entityID, partnerKey, userKey);
if( auth != null )
{
//Get 2019 Budget data
var options = new WSBudgetOptions();
options.Year = 2019;
options.AccountSelection = AccuontSelection.All;
options.ValueSelection = ValueSelection.Budget;
options.IncludeZeroMovement = true;
options.IncludeBiCode = false;
WSResult2OfWSBudgetHeader initialResult = this.ws.GetBudgetData(this.auth, options);
//Update the values by 10% and store as 2020 budget
initialResult.Result.Year = 2020;
initialResult.Result.DataType = BudgetDataType.Budget;
initialResult.result.Entries.ForEach(entry=>
entry.Data.Value *= 1.10;
);
var updateResult = ws.SaveBudgetData(auth, initialResult.Result);
if (updateResult.Status != OperationStatus.Success)
{
if (updateResult.ErrorCode == VisorExceptionCodes.WS_INVALIDTOKEN)
{
Console.WriteLine("Your login token is invalid or expired. Please login again.");
}
else if (updateResult.ErrorCode == VisorExceptionCodes.BUDGET_DATA_ERROR)
{
// BUDGET_DATA_ERROR - there is an data error - examine the data
var dataErrors = updateResult.Result.Entries.Where(entry=>entry.HasErrors);
var headerErrors = updateResult.Result.ValidationErrors;
dataErrors.ForEach(entry=>entry.ValidationErrors.ForEach(error=>Console.WriteLine("GL: {0} Error: {1}", entry.GlAccountCode, error);
headerErrors.ForEach(error=>Console.WriteLine("Budget Error: {0}", error);
}
else if (updateResult.ErrorCode == VisorExceptionCodes.BUDGET_FAILED_TO_SAVE)
{
// The operation failed
var errorMessages = hello.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries);
errorMessages.ForEach(message=>Console.WriteLine(message));
}
else
{
Console.WriteLine("2020 budget data saved.");
}
}