use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class CuRequisitionDocument method isB2BAutoPurchaseOrder.
protected boolean isB2BAutoPurchaseOrder() {
boolean returnValue = false;
VendorDetail vendorDetail = SpringContext.getBean(VendorService.class).getVendorDetail(this.getVendorHeaderGeneratedIdentifier(), this.getVendorDetailAssignedIdentifier());
if (vendorDetail != null) {
if (vendorDetail.isB2BVendor()) {
returnValue = isB2BTotalAmountForAutoPO();
} else {
returnValue = false;
}
return returnValue;
}
return false;
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class CuRequisitionDocument method toCopyFromGateway.
/**
* toCopyFromGateway
*/
public void toCopyFromGateway() throws WorkflowException, ValidationException {
// no validation for the KFS copy requisition rules:
String sourceDocumentHeaderId = getDocumentNumber();
setNewDocumentHeader();
getDocumentHeader().setDocumentTemplateNumber(sourceDocumentHeaderId);
// Clear out existing notes.
if (getNotes() != null) {
getNotes().clear();
}
addCopyErrorDocumentNote("copied from document " + sourceDocumentHeaderId);
// --- LedgerPostingDocumentBase:
setAccountingPeriod(retrieveCurrentAccountingPeriod());
// --GeneralLedgerPostingDocumentBase:
getGeneralLedgerPendingEntries().clear();
// --AccountingDocumentBase:
copyAccountingLines(false);
updatePostingYearForAccountingLines(getSourceAccountingLines());
updatePostingYearForAccountingLines(getTargetAccountingLines());
// --RequisitionDocument:
// Clear related views
this.setAccountsPayablePurchasingDocumentLinkIdentifier(null);
this.setRelatedViews(null);
Person currentUser = GlobalVariables.getUserSession().getPerson();
ChartOrgHolder purapChartOrg = SpringContext.getBean(FinancialSystemUserService.class).getPrimaryOrganization(currentUser, PurapConstants.PURAP_NAMESPACE);
this.setPurapDocumentIdentifier(null);
// Set req status to INPR.
// for app doc status
updateAndSaveAppDocStatus(PurapConstants.RequisitionStatuses.APPDOC_IN_PROCESS);
// Set fields from the user.
if (ObjectUtils.isNotNull(purapChartOrg)) {
this.setChartOfAccountsCode(purapChartOrg.getChartOfAccountsCode());
this.setOrganizationCode(purapChartOrg.getOrganizationCode());
}
this.setPostingYear(SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear());
boolean activeVendor = true;
boolean activeContract = true;
Date today = SpringContext.getBean(DateTimeService.class).getCurrentDate();
VendorContract vendorContract = new VendorContract();
vendorContract.setVendorContractGeneratedIdentifier(this.getVendorContractGeneratedIdentifier());
Map keys = SpringContext.getBean(PersistenceService.class).getPrimaryKeyFieldValues(vendorContract);
vendorContract = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(VendorContract.class, keys);
if (!(vendorContract != null && today.after(vendorContract.getVendorContractBeginningDate()) && today.before(vendorContract.getVendorContractEndDate()))) {
activeContract = false;
}
VendorDetail vendorDetail = SpringContext.getBean(VendorService.class).getVendorDetail(this.getVendorHeaderGeneratedIdentifier(), this.getVendorDetailAssignedIdentifier());
if (!(vendorDetail != null && vendorDetail.isActiveIndicator())) {
activeVendor = false;
}
// KFSPTS-916 : need vendor address key for business rules and only way to get it is to retrieve the default PO address for the vendor.
if (vendorDetail != null) {
VendorAddress vendorAddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(this.getVendorHeaderGeneratedIdentifier(), this.getVendorDetailAssignedIdentifier(), VendorConstants.AddressTypes.PURCHASE_ORDER, "");
if (vendorAddress != null) {
super.templateVendorAddress(vendorAddress);
}
}
// B2B - only copy if contract and vendor are both active (throw separate errors to print to screen)
if (this.getRequisitionSourceCode().equals(PurapConstants.RequisitionSources.B2B)) {
if (!activeContract) {
// -- throw new ValidationException(PurapKeyConstants.ERROR_REQ_COPY_EXPIRED_CONTRACT);
}
if (!activeVendor) {
// -- throw new ValidationException(PurapKeyConstants.ERROR_REQ_COPY_INACTIVE_VENDOR);
}
}
if (!activeVendor) {
this.setVendorContractGeneratedIdentifier(null);
}
if (!activeContract) {
this.setVendorContractGeneratedIdentifier(null);
}
// These fields should not be set in this method; force to be null
this.setOrganizationAutomaticPurchaseOrderLimit(null);
this.setPurchaseOrderAutomaticIndicator(false);
for (Iterator iter = this.getItems().iterator(); iter.hasNext(); ) {
RequisitionItem item = (RequisitionItem) iter.next();
item.setPurapDocumentIdentifier(null);
item.setItemIdentifier(null);
for (Iterator acctIter = item.getSourceAccountingLines().iterator(); acctIter.hasNext(); ) {
RequisitionAccount account = (RequisitionAccount) acctIter.next();
account.setAccountIdentifier(null);
account.setItemIdentifier(null);
}
}
if (!PurapConstants.RequisitionSources.B2B.equals(this.getRequisitionSourceCode())) {
SpringContext.getBean(PurapService.class).addBelowLineItems(this);
}
this.setOrganizationAutomaticPurchaseOrderLimit(SpringContext.getBean(PurapService.class).getApoLimit(this.getVendorContractGeneratedIdentifier(), this.getChartOfAccountsCode(), this.getOrganizationCode()));
clearCapitalAssetFields();
SpringContext.getBean(PurapService.class).clearTax(this, this.isUseTaxIndicator());
this.refreshNonUpdateableReferences();
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class CuPurchasingProcessVendorValidation method validate.
@Override
public boolean validate(AttributedDocumentEvent event) {
boolean valid = true;
PurchasingDocument purDocument = (PurchasingDocument) event.getDocument();
MessageMap errorMap = GlobalVariables.getMessageMap();
errorMap.clearErrorPath();
errorMap.addToErrorPath(PurapConstants.VENDOR_ERRORS);
if (!purDocument.getRequisitionSourceCode().equals(PurapConstants.RequisitionSources.B2B)) {
// CU enhancement here. Replaced foundation implementation block
if ((purDocument.getVendorHeaderGeneratedIdentifier() != null) && (!(isDocumentInNodeWhereMopotDataValidationIsBypassed(purDocument))) && (purDocument.getPurchaseOrderTransmissionMethodCode().equals(CUPurapConstants.POTransmissionMethods.EMAIL) || purDocument.getPurchaseOrderTransmissionMethodCode().equals(PurapConstants.POTransmissionMethods.FAX) || purDocument.getPurchaseOrderTransmissionMethodCode().equals(CUPurapConstants.POTransmissionMethods.MANUAL))) {
valid &= this.validateDataForMethodOfPOTransmissionExistsOnVendorAddress(purDocument);
// called routine took care of presenting error message to user
}
}
VendorDetail vendorDetail = getVendorService().getVendorDetail(purDocument.getVendorHeaderGeneratedIdentifier(), purDocument.getVendorDetailAssignedIdentifier());
if (ObjectUtils.isNull(vendorDetail)) {
return valid;
}
VendorHeader vendorHeader = vendorDetail.getVendorHeader();
// make sure that the vendor is not debarred
if (vendorDetail.isVendorDebarred()) {
if (getParameterService().getParameterValueAsBoolean(KFSConstants.OptionalModuleNamespaces.PURCHASING_ACCOUNTS_PAYABLE, "Requisition", PurapParameterConstants.SHOW_DEBARRED_VENDOR_WARNING_IND)) {
if (StringUtils.isEmpty(((PurchasingDocumentBase) purDocument).getJustification())) {
errorMap.putWarning(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.WARNING_DEBARRED_VENDOR, vendorDetail.getVendorName());
valid &= false;
}
} else {
errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_DEBARRED_VENDOR);
valid &= false;
}
}
// make sure that the vendor is of allowed type
List<String> allowedVendorTypes = new ArrayList<String>(getParameterService().getParameterValuesAsString(KfsParameterConstants.PURCHASING_DOCUMENT.class, PurapRuleConstants.PURAP_VENDOR_TYPE_ALLOWED_ON_REQ_AND_PO));
if (allowedVendorTypes != null && !allowedVendorTypes.isEmpty()) {
if (ObjectUtils.isNotNull(vendorHeader) && ObjectUtils.isNotNull(vendorHeader.getVendorTypeCode()) && !allowedVendorTypes.contains(vendorHeader.getVendorTypeCode())) {
valid &= false;
errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_INVALID_VENDOR_TYPE);
}
}
// make sure that the vendor is active
if (!vendorDetail.isActiveIndicator()) {
valid &= false;
errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_INACTIVE_VENDOR);
}
// make sure that the vendor contract is active and not expired.
// KFSUPGRADE-266 remove kfsmi-8690/kfscntrb-929
// if (ObjectUtils.isNotNull(purDocument.getVendorContractGeneratedIdentifier())) {
// VendorContract vendorContract = SpringContext.getBean(BusinessObjectService.class).findBySinglePrimaryKey(VendorContract.class, purDocument.getVendorContractGeneratedIdentifier());
// Date currentDate = SpringContext.getBean(DateTimeService.class).getCurrentSqlDate();
//
// if (currentDate.compareTo(vendorContract.getVendorContractEndDate()) > 0 || !vendorContract.isActive()) {
// valid &= false;
// errorMap.putError(VendorPropertyConstants.VENDOR_CONTRACT_NAME, PurapKeyConstants.ERROR_INACTIVE_OR_EXPIRED_VENDOR_CONTRACT);
// }
// }
// validate vendor address
getPostalCodeValidationService().validateAddress(purDocument.getVendorCountryCode(), purDocument.getVendorStateCode(), purDocument.getVendorPostalCode(), PurapPropertyConstants.VENDOR_STATE_CODE, PurapPropertyConstants.VENDOR_POSTAL_CODE);
errorMap.clearErrorPath();
return valid;
}
use of org.kuali.kfs.vnd.businessobject.VendorDetail in project cu-kfs by CU-CommunityApps.
the class CuPurchaseOrderProcessVendorValidation method validate.
@Override
public boolean validate(AttributedDocumentEvent event) {
boolean valid = super.validate(event);
PurchasingAccountsPayableDocument purapDocument = (PurchasingAccountsPayableDocument) event.getDocument();
PurchaseOrderDocument poDocument = (PurchaseOrderDocument) purapDocument;
MessageMap errorMap = GlobalVariables.getMessageMap();
errorMap.clearErrorPath();
errorMap.addToErrorPath(PurapConstants.VENDOR_ERRORS);
// check to see if the vendor exists in the database, i.e. its ID is not null
Integer vendorHeaderID = poDocument.getVendorHeaderGeneratedIdentifier();
if (ObjectUtils.isNull(vendorHeaderID)) {
valid = false;
errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_NONEXIST_VENDOR);
}
// vendor active validation...
VendorDetail vendorDetail = super.getVendorService().getVendorDetail(poDocument.getVendorHeaderGeneratedIdentifier(), poDocument.getVendorDetailAssignedIdentifier());
if (ObjectUtils.isNull(vendorDetail)) {
return valid;
}
// make sure that the vendor is active
if (!vendorDetail.isActiveIndicator()) {
valid &= false;
errorMap.putError(VendorPropertyConstants.VENDOR_NAME, PurapKeyConstants.ERROR_INACTIVE_VENDOR);
}
// validate vendor address
super.getPostalCodeValidationService().validateAddress(poDocument.getVendorCountryCode(), poDocument.getVendorStateCode(), poDocument.getVendorPostalCode(), PurapPropertyConstants.VENDOR_STATE_CODE, PurapPropertyConstants.VENDOR_POSTAL_CODE);
// Do checks for alternate payee vendor.
Integer alternateVendorHdrGeneratedId = poDocument.getAlternateVendorHeaderGeneratedIdentifier();
Integer alternateVendorHdrDetailAssignedId = poDocument.getAlternateVendorDetailAssignedIdentifier();
VendorDetail alternateVendor = super.getVendorService().getVendorDetail(alternateVendorHdrGeneratedId, alternateVendorHdrDetailAssignedId);
if (alternateVendor != null) {
if (alternateVendor.isVendorDebarred()) {
errorMap.putError(PurapPropertyConstants.ALTERNATE_VENDOR_NAME, PurapKeyConstants.ERROR_PURCHASE_ORDER_ALTERNATE_VENDOR_DEBARRED);
valid &= false;
}
if (StringUtils.equals(alternateVendor.getVendorHeader().getVendorTypeCode(), VendorTypes.DISBURSEMENT_VOUCHER)) {
errorMap.putError(PurapPropertyConstants.ALTERNATE_VENDOR_NAME, PurapKeyConstants.ERROR_PURCHASE_ORDER_ALTERNATE_VENDOR_DV_TYPE);
valid &= false;
}
if (!alternateVendor.isActiveIndicator()) {
errorMap.putError(PurapPropertyConstants.ALTERNATE_VENDOR_NAME, PurapKeyConstants.ERROR_PURCHASE_ORDER_ALTERNATE_VENDOR_INACTIVE, PODocumentsStrings.ALTERNATE_PAYEE_VENDOR);
valid &= false;
}
}
// make sure that the vendor contract expiration date and not marked inactive.
// KFSUPGRADE-266 remove kfsmi-8690/kfscntrb-929
// if (StringUtils.isNotBlank(poDocument.getVendorContractName())) {
// if (super.getVendorService().isVendorContractExpired(poDocument, poDocument.getVendorContractGeneratedIdentifier(), vendorDetail)) {
// errorMap.putError(VendorPropertyConstants.VENDOR_CONTRACT_END_DATE, PurapKeyConstants.ERROR_EXPIRED_CONTRACT_END_DATE);
// valid &= false;
// }
// }
errorMap.clearErrorPath();
return valid;
}
Aggregations