use of org.kuali.kfs.coa.businessobject.Chart in project cu-kfs by CU-CommunityApps.
the class ScrubberValidatorImpl method validateChart.
/**
* Validates the chart of the origin entry
*
* @param originEntry the origin entry being scrubbed
* @param workingEntry the scrubbed version of the origin entry
* @return a Message if an error was encountered, otherwise null
*/
protected Message validateChart(OriginEntryInformation originEntry, OriginEntryInformation workingEntry, AccountingCycleCachingService accountingCycleCachingService) {
LOG.debug("validateChart() started");
Chart originEntryChart = accountingCycleCachingService.getChart(originEntry.getChartOfAccountsCode());
if (originEntryChart == null) {
return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_CHART_NOT_FOUND, originEntry.getChartOfAccountsCode(), Message.TYPE_FATAL);
}
if (!originEntryChart.isActive()) {
return MessageBuilder.buildMessage(KFSKeyConstants.ERROR_CHART_NOT_ACTIVE, originEntry.getChartOfAccountsCode(), Message.TYPE_FATAL);
}
workingEntry.setChartOfAccountsCode(originEntry.getChartOfAccountsCode());
return null;
}
use of org.kuali.kfs.coa.businessobject.Chart in project cu-kfs by CU-CommunityApps.
the class AmazonWebServicesBillingServiceImpl method updateTansactionDTOChart.
private void updateTansactionDTOChart(AmazonBillingDistributionOfIncomeTransactionDTO transactionDTO, AmazonBillingCostCenterDTO costCenterDTO, Account account) {
if (StringUtils.isNotBlank(costCenterDTO.getChartCode())) {
Chart chart = getChartService().getByPrimaryId(costCenterDTO.getChartCode());
if (ObjectUtils.isNotNull(chart) && chart.isActive()) {
transactionDTO.setChartCode(chart.getChartOfAccountsCode());
} else {
LOG.info("updateTansactionDTOChart() Invalid Chart.");
transactionDTO.setTransactionInputError(true);
}
} else {
transactionDTO.setChartCode(account.getChartOfAccountsCode());
}
}
use of org.kuali.kfs.coa.businessobject.Chart in project cu-kfs by CU-CommunityApps.
the class AwsAccountingXmlDocumentAccountingLineServiceImplTest method buildMockChartService.
private ChartService buildMockChartService() {
ChartService chartService = mock(ChartService.class);
Chart expectedChart = createMockChart(ChartFixture.CHART_IT);
when(chartService.getByPrimaryId(CuFPTestConstants.TEST_AWS_BILLING_DEFAULT_CHART_CODE)).thenReturn(expectedChart);
expectedChart = createMockChart(ChartFixture.CHART_CS);
when(chartService.getByPrimaryId(CuFPTestConstants.TEST_AWS_BILLING_CHART_CODE_CS)).thenReturn(expectedChart);
return chartService;
}
use of org.kuali.kfs.coa.businessobject.Chart in project cu-kfs by CU-CommunityApps.
the class CUSimpleChartValuesFinder method getKeyValues.
/**
* Creates a list of {@link Chart}s using their code as their key, and their code as the display value
*
* @see org.kuali.kfs.kns.lookup.keyvalues.KeyValuesFinder#getKeyValues()
*/
public List<KeyValue> getKeyValues() {
parameterService = SpringContext.getBean(ParameterService.class);
String defaultChartCode = "";
String defaultChartCodeMethod = "";
try {
defaultChartCode = parameterService.getParameterValueAsString(KfsParameterConstants.FINANCIAL_SYSTEM_DOCUMENT.class, CUKFSParameterKeyConstants.DEFAULT_CHART_CODE);
defaultChartCodeMethod = parameterService.getParameterValueAsString(KfsParameterConstants.FINANCIAL_SYSTEM_DOCUMENT.class, CUKFSParameterKeyConstants.DEFAULT_CHART_CODE_METHOD);
} catch (Exception e) {
// Do nothing
}
KeyValuesService boService = SpringContext.getBean(KeyValuesService.class);
Collection<Chart> chartCodes = boService.findAll(Chart.class);
List<KeyValue> chartKeyLabels = new ArrayList<KeyValue>();
// If the DEFAULT_CHART_CODE_METHOD parameter DNE or has no value assigned to it, no default
if (defaultChartCodeMethod.equals("")) {
chartKeyLabels.add(new ConcreteKeyValue("", ""));
for (Iterator<Chart> iter = chartCodes.iterator(); iter.hasNext(); ) {
Chart element = (Chart) iter.next();
if (element.isActive()) {
// only show active charts
chartKeyLabels.add(new ConcreteKeyValue(element.getChartOfAccountsCode(), element.getChartOfAccountsCode()));
}
}
}
// populate with the default chart
if (defaultChartCodeMethod.equals("1")) {
chartKeyLabels.add(new ConcreteKeyValue(defaultChartCode, defaultChartCode));
for (Iterator<Chart> iter = chartCodes.iterator(); iter.hasNext(); ) {
Chart element = (Chart) iter.next();
if (element.isActive() && !element.getChartOfAccountsCode().equals(defaultChartCode)) {
// only show active charts
chartKeyLabels.add(new ConcreteKeyValue(element.getChartOfAccountsCode(), element.getChartOfAccountsCode()));
}
}
}
// populate with chart code of the user's primary department
if (defaultChartCodeMethod.equals("2")) {
Person currentUser = GlobalVariables.getUserSession().getPerson();
String primaryDepartmentChartCode = SpringContext.getBean(FinancialSystemUserService.class).getPrimaryOrganization(currentUser, "KFS-SYS").getChartOfAccountsCode();
chartKeyLabels.add(new ConcreteKeyValue(primaryDepartmentChartCode, primaryDepartmentChartCode));
for (Iterator<Chart> iter = chartCodes.iterator(); iter.hasNext(); ) {
Chart element = (Chart) iter.next();
if (element.isActive() && !element.getChartOfAccountsCode().equals(primaryDepartmentChartCode)) {
// only show active charts
chartKeyLabels.add(new ConcreteKeyValue(element.getChartOfAccountsCode(), element.getChartOfAccountsCode()));
}
}
}
// populate with the default chart unless user's primary department has been defined
if (defaultChartCodeMethod.equals("3")) {
Person currentUser = GlobalVariables.getUserSession().getPerson();
String primaryDepartmentChartCode = SpringContext.getBean(FinancialSystemUserService.class).getPrimaryOrganization(currentUser, "KFS-SYS").getChartOfAccountsCode();
String chartUsed = null;
if (primaryDepartmentChartCode != null && !primaryDepartmentChartCode.equals("")) {
chartUsed = primaryDepartmentChartCode;
} else {
chartUsed = defaultChartCode;
}
chartKeyLabels.add(new ConcreteKeyValue(chartUsed, chartUsed));
for (Iterator<Chart> iter = chartCodes.iterator(); iter.hasNext(); ) {
Chart element = (Chart) iter.next();
if (element.isActive() && !element.getChartOfAccountsCode().equals(chartUsed)) {
// only show active charts
chartKeyLabels.add(new ConcreteKeyValue(element.getChartOfAccountsCode(), element.getChartOfAccountsCode()));
}
}
}
return chartKeyLabels;
}
use of org.kuali.kfs.coa.businessobject.Chart in project cu-kfs by CU-CommunityApps.
the class AwsAccountingXmlDocumentAccountingLineServiceImplTest method createMockChart.
private static Chart createMockChart(ChartFixture chartFixture) {
Chart chart = mock(Chart.class);
when(chart.isActive()).thenReturn(chartFixture.active);
return chart;
}
Aggregations