use of org.kuali.kfs.module.purap.businessobject.PurchaseOrderAccount in project cu-kfs by CU-CommunityApps.
the class FavoriteAccountLineBuilderTest method testCreateAndAddFavoriteAccountLinesForLineItems.
/*
* Test creating favorite accounting lines for use with line items.
*/
@Test
public void testCreateAndAddFavoriteAccountLinesForLineItems() throws Exception {
reqsItem.setFavoriteAccountLineIdentifier(TEST_FAVORITE_ACCOUNT_LINE_ID);
poItem.setFavoriteAccountLineIdentifier(TEST_ALT_FAVORITE_ACCOUNT_LINE_ID);
PurchasingFavoriteAccountLineBuilderForLineItem<RequisitionAccount> reqsBuilder = createBuilderForLineItem(reqsItem, 0, new RequisitionAccount());
PurchasingFavoriteAccountLineBuilderForLineItem<PurchaseOrderAccount> poBuilder = createBuilderForLineItem(poItem, 0, new PurchaseOrderAccount());
assertAccountLineCreation(reqsBuilder, testFavoriteAccount, RequisitionAccount.class);
assertAccountLineCreation(poBuilder, testAltFavoriteAccount, PurchaseOrderAccount.class);
assertAccountLineAdditionToList(reqsBuilder, testFavoriteAccount, RequisitionAccount.class);
assertAccountLineAdditionToList(poBuilder, testAltFavoriteAccount, PurchaseOrderAccount.class);
}
use of org.kuali.kfs.module.purap.businessobject.PurchaseOrderAccount in project cu-kfs by CU-CommunityApps.
the class CuPurapAccountingServiceImpl method isFiscalOfficersForAllAcctLines.
public boolean isFiscalOfficersForAllAcctLines(PurchasingAccountsPayableDocument document) {
boolean isFoForAcctLines = true;
String personId = GlobalVariables.getUserSession().getPrincipalId();
for (SourceAccountingLine accountingLine : (List<SourceAccountingLine>) document.getSourceAccountingLines()) {
List<String> fiscalOfficers = new ArrayList<String>();
Map<String, String> roleQualifier = new HashMap<String, String>();
// KFSPTS-1273 : this method is final, so can't be overriden by REQ Auth. This is a fix for REQ existing issue. a broader solution need more work.
// the authorizer is called by validation rule and rendertag, so has to do it here. otherwise the invalid account will be saved.
boolean isExistingReqAcctline = false;
String updatedAccountNumber = KFSConstants.EMPTY_STRING;
if (accountingLine instanceof RequisitionAccount && ((RequisitionAccount) accountingLine).getAccountIdentifier() != null) {
RequisitionAccount dbAcctLine = (RequisitionAccount) getAccountFromDb((RequisitionAccount) accountingLine, RequisitionAccount.class);
if (dbAcctLine != null && !StringUtils.equals(accountingLine.getAccountNumber(), dbAcctLine.getAccountNumber())) {
updatedAccountNumber = accountingLine.getAccountNumber();
accountingLine.setAccountNumber(dbAcctLine.getAccountNumber());
isExistingReqAcctline = true;
}
}
if (accountingLine instanceof PurchaseOrderAccount && ((PurchaseOrderAccount) accountingLine).getAccountIdentifier() != null) {
PurchaseOrderAccount dbAcctLine = (PurchaseOrderAccount) getAccountFromDb((PurchaseOrderAccount) accountingLine, PurchaseOrderAccount.class);
if (dbAcctLine != null && !StringUtils.equals(accountingLine.getAccountNumber(), dbAcctLine.getAccountNumber())) {
updatedAccountNumber = accountingLine.getAccountNumber();
accountingLine.setAccountNumber(dbAcctLine.getAccountNumber());
isExistingReqAcctline = true;
}
}
if (accountingLine instanceof PaymentRequestAccount && ((PaymentRequestAccount) accountingLine).getAccountIdentifier() != null) {
PaymentRequestAccount dbAcctLine = (PaymentRequestAccount) getAccountFromDb((PaymentRequestAccount) accountingLine, PaymentRequestAccount.class);
if (dbAcctLine != null && !StringUtils.equals(accountingLine.getAccountNumber(), dbAcctLine.getAccountNumber())) {
updatedAccountNumber = accountingLine.getAccountNumber();
accountingLine.setAccountNumber(dbAcctLine.getAccountNumber());
isExistingReqAcctline = true;
}
}
roleQualifier.put(KimConstants.AttributeConstants.DOCUMENT_NUMBER, document.getDocumentNumber());
roleQualifier.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
roleQualifier.put(KfsKimAttributes.FINANCIAL_DOCUMENT_TOTAL_AMOUNT, document.getFinancialSystemDocumentHeader().getFinancialDocumentTotalAmount().toString());
roleQualifier.put(KfsKimAttributes.CHART_OF_ACCOUNTS_CODE, accountingLine.getChartOfAccountsCode());
roleQualifier.put(KfsKimAttributes.ACCOUNT_NUMBER, accountingLine.getAccountNumber());
fiscalOfficers.addAll(SpringContext.getBean(RoleService.class).getRoleMemberPrincipalIds(KFSConstants.ParameterNamespaces.KFS, KFSConstants.SysKimApiConstants.FISCAL_OFFICER_KIM_ROLE_NAME, roleQualifier));
if (!fiscalOfficers.contains(personId)) {
fiscalOfficers.addAll(SpringContext.getBean(RoleService.class).getRoleMemberPrincipalIds(KFSConstants.ParameterNamespaces.KFS, KFSConstants.SysKimApiConstants.FISCAL_OFFICER_PRIMARY_DELEGATE_KIM_ROLE_NAME, roleQualifier));
}
if (!fiscalOfficers.contains(personId)) {
fiscalOfficers.addAll(SpringContext.getBean(RoleService.class).getRoleMemberPrincipalIds(KFSConstants.ParameterNamespaces.KFS, KFSConstants.SysKimApiConstants.FISCAL_OFFICER_SECONDARY_DELEGATE_KIM_ROLE_NAME, roleQualifier));
}
if (isExistingReqAcctline) {
accountingLine.setAccountNumber(updatedAccountNumber);
}
if (!fiscalOfficers.contains(personId)) {
isFoForAcctLines = false;
break;
}
}
return isFoForAcctLines;
}
Aggregations