The following sample creates an account record. In the sample, required fields are commented. During account creation, it is optional to set posting criteria or definitions on which types of financial records can post to the account (for example, tasks, expenses, invoices).
Date date = new Date();
protected AccountRepository accountRepository;
AccountCreate account = createAccount();
String accountUniqueKey = accountRepository.insertAccount(account);
private String createAccount() throws Exception {
AccountCreate account = new AccountCreate();
//name is a required field
account.setName("2009-Q1");
//startOn date is a required field
account.setStartOn(01-JAN-09);
//endOn date is a required field
account.setEndOn(31-MAR-09);
//allocationLimit is a required field
account.setAllocationLimit(25000.00);
//(optional) set the account type as BUDGET or RESERVE
account.setType(AccountType.BUDGET);
//(optional) set the account overdraft type
account.setAccountOverdraftType(AccountOverdraftType.ALLOW_NEGATIVE);
//(optional) if this is a child account, set the parent account
account.setParentAccountUniqueKey("ACCT_4141");
returns account;
}
//the following sample code would be used as an excerpt from the above sample for creating an account; it is presented separately just to simplify the process for setting account posting criteria
//the following section sets posting criteria that allows tasks of a certain category to post to this account
account.setAllowTask(true);
account.setTaskCategoryUniqueKey(taskCategoryUniqueKey);
account.setTaskPercent(100);
//the following section sets posting criteria that allows expenses of a certain category to post to this account
account.setAllowExpense(true);
account.setExpenseCategoryUniqueKey(expenseCategoryUniqueKey);
account.setExpensePercent(100);
//the following section sets posting criteria that allows invoice expense line items of a certain category to post to this account
account.setAllowInvoiceExpense(true);
account.setInvoiceExpenseCategoryUniqueKey(invoiceExpCategoryUniqueKey);
account.setInvoiceExpensePercent(100);
//the following section sets posting criteria that allows invoice fee line items of a certain category to post to this account
account.setAllowInvoiceTask(true);
account.setInvoiceTaskCategoryUniqueKey(invoiceTaskCategoryUniqueKey);
account.setInvoiceTaskPercent(100);