public void validateCoop(AdDcCoopBean coop) throws ApplicationException { if (coop.getDivisionTaken() == 1) { if (coop.getDivisionRejectReason() > 0) { throw new ApplicationException( "A division reject message was specified when accepting the division record. Please reject the record or remove the reject message. Coop ID: " + coop.getCoopId()); } } else if (coop.getDivisionTaken() == -1) { if (coop.getDivisionRejectReason() <= 0) { throw new ApplicationException( "A reject message must be specified when rejecting the division record. Coop ID: " + coop.getCoopId()); } if (coop.getEstimatedCases() > 0) { throw new ApplicationException( "A positive estimated case count can not be specified when rejecting the division record. Coop ID: " + coop.getCoopId()); } } if (coop.getAccountRejectReason() > 0) { if (Utils.hasContent(coop.getBillSign())) { throw new ApplicationException( "The entry cannot have a billing signature when it is rejected. Coop ID: " + coop.getCoopId()); } else if (coop.getBillDate() != null) { throw new ApplicationException( "The entry cannot have a billing date when it is rejected. Coop ID: " + coop.getCoopId()); } } }
public void storeAdDcCoop(AdDcCoopBean adcb) throws ApplicationException { boolean success = false; try { // DBHelper.startTransaction(NFCCoreVariables.DATASOURCE_WAG_JNDI, false); // Get the AdDcCoop entry from the database AdDcCoopBean temp = getAdDcCoopByIdAndDivision(adcb.getCoopId(), adcb.getRegionMemberId()); // If the AdDcCoop was not already in the database ... if (temp == null) { // Create the AdDcCoop entry in the database AdDcCoopManager.createDivisionCoop( adcb.getCoopId(), adcb.getRegionMemberId(), adcb.getInitialAmount(), adcb.getBilledAmount(), adcb.getEstimatedCases(), adcb.getActualCases(), adcb.getWorkFlowPhaseId(), adcb.getDivisionTaken(), adcb.getDivisionRejectReason(), adcb.getBillDate(), adcb.getBillSign(), adcb.getAccountRejectReason(), adcb.getAccountingExportWeek(), adcb.getAccountingExportPeriod(), adcb.getAccountingExportYear()); } else { // Update the AdDcCoop entry AdDcCoopManager.updateDivisionCoop( adcb.getRegionMemberId(), adcb.getInitialAmount(), adcb.getBilledAmount(), adcb.getEstimatedCases(), adcb.getActualCases(), adcb.getWorkFlowPhaseId(), adcb.getDivisionTaken(), adcb.getDivisionRejectReason(), adcb.getBillDate(), adcb.getBillSign(), adcb.getAccountRejectReason(), adcb.getCoopId(), adcb.getAccountingExportWeek(), adcb.getAccountingExportPeriod(), adcb.getAccountingExportYear()); } success = true; } finally { // DBHelper.finalizeActiveTransaction(NFCCoreVariables.DATASOURCE_WAG_JNDI, success); } }