示例#1
0
 private void createMiscBill() {
   Miscbilldetail miscbilldetail = new Miscbilldetail();
   // Since we are not creating any bill for advance payment, we are updating bill no, bill date
   // and bill amount from ARF
   miscbilldetail.setBillnumber(advanceRequisition.getAdvanceRequisitionNumber());
   miscbilldetail.setBilldate(advanceRequisition.getAdvanceRequisitionDate());
   miscbilldetail.setBillamount(advanceRequisition.getAdvanceRequisitionAmount());
   miscbilldetail.setPassedamount(advanceRequisition.getAdvanceRequisitionAmount());
   miscbilldetail.setPaidamount(advanceRequisition.getAdvanceRequisitionAmount());
   miscbilldetail.setPaidto(advanceRequisition.getEgAdvanceReqMises().getPayto());
   miscbilldetail.setPayVoucherHeader(paymentheader.getVoucherheader());
   miscbilldetailService.persist(miscbilldetail);
 }
示例#2
0
  @ValidationErrorPage(value = NEW)
  @Action(value = "/payment/advancePayment-save")
  public String save() {

    voucherHeader.setType(FinancialConstants.STANDARD_VOUCHER_TYPE_PAYMENT);
    voucherHeader.setName(FinancialConstants.PAYMENTVOUCHER_NAME_ADVANCE);
    voucherHeader.setDescription(description);
    try {
      validateAdvancePaymentExists();
      if (commonBean.getModeOfPayment().equalsIgnoreCase(FinancialConstants.MODEOFPAYMENT_RTGS)) {
        validateRTGS();
      }
      voucherHeader = createVoucherAndledger();
      paymentheader =
          paymentService.createPaymentHeader(
              voucherHeader,
              Integer.valueOf(commonBean.getAccountNumberId()),
              commonBean.getModeOfPayment(),
              advanceRequisition.getAdvanceRequisitionAmount());

      createMiscBill();
      paymentheader.start().withOwner(paymentService.getPosition());
      advanceRequisition.getEgAdvanceReqMises().setVoucherheader(paymentheader.getVoucherheader());
      sendForApproval();
      addActionMessage(
          getText("arf.payment.transaction.success") + " " + voucherHeader.getVoucherNumber());

    } catch (ValidationException e) {
      List<ValidationError> errorList = e.getErrors();
      for (ValidationError error : errorList) {
        if (error.getMessage().contains("DatabaseSequenceFirstTimeException")) {
          prepare();
          throw new ValidationException(
              Arrays.asList(new ValidationError("error", error.getMessage())));
        } else throw new ValidationException(e.getErrors());
      }
      populateBankAccounts(Integer.parseInt(commonBean.getBankId().split("-")[1]), fund.getId());
    } catch (NumberFormatException e) {
      LOGGER.error(e.getMessage(), e);
      throw e;
    } catch (ApplicationRuntimeException e) {
      LOGGER.error(e.getMessage(), e);
      throw e;
    } finally {
      loadApproverUser(FinancialConstants.STANDARD_VOUCHER_TYPE_PAYMENT);
    }
    return VIEW;
  }
示例#3
0
  private CVoucherHeader createVoucherAndledger() {
    try {
      final HashMap<String, Object> headerDetails = createHeaderAndMisDetails();
      headerDetails.put(
          VoucherConstant.SOURCEPATH, "/EGF/payment/advancePayment!view.action?voucherHeader.id=");
      HashMap<String, Object> detailMap = null;
      HashMap<String, Object> subledgertDetailMap = null;
      final List<HashMap<String, Object>> accountdetails = new ArrayList<HashMap<String, Object>>();
      final List<HashMap<String, Object>> subledgerDetails =
          new ArrayList<HashMap<String, Object>>();

      detailMap = new HashMap<String, Object>();
      detailMap.put(VoucherConstant.CREDITAMOUNT, advanceRequisition.getAdvanceRequisitionAmount());
      detailMap.put(VoucherConstant.DEBITAMOUNT, ZERO);
      Bankaccount account =
          (Bankaccount)
              HibernateUtil.getCurrentSession()
                  .load(Bankaccount.class, Integer.valueOf(commonBean.getAccountNumberId()));
      detailMap.put(VoucherConstant.GLCODE, account.getChartofaccounts().getGlcode());
      accountdetails.add(detailMap);
      Map<String, Object> glcodeMap = new HashMap<String, Object>();
      detailMap = new HashMap<String, Object>();

      detailMap.put(VoucherConstant.DEBITAMOUNT, advanceRequisition.getAdvanceRequisitionAmount());
      detailMap.put(VoucherConstant.CREDITAMOUNT, ZERO);
      for (EgAdvanceRequisitionDetails advanceRequisitionDetails :
          advanceRequisition.getEgAdvanceReqDetailses()) {
        detailMap.put(
            VoucherConstant.GLCODE, advanceRequisitionDetails.getChartofaccounts().getGlcode());
      }
      accountdetails.add(detailMap);
      glcodeMap.put(detailMap.get(VoucherConstant.GLCODE).toString(), VoucherConstant.DEBIT);

      subledgertDetailMap = new HashMap<String, Object>();
      for (EgAdvanceRequisitionDetails advanceDetail :
          advanceRequisition.getEgAdvanceReqDetailses()) {
        for (EgAdvanceReqPayeeDetails payeeDetail : advanceDetail.getEgAdvanceReqpayeeDetailses()) {
          subledgertDetailMap = new HashMap<String, Object>();
          subledgertDetailMap.put(VoucherConstant.DEBITAMOUNT, payeeDetail.getDebitAmount());
          subledgertDetailMap.put(VoucherConstant.CREDITAMOUNT, payeeDetail.getCreditAmount());
          subledgertDetailMap.put(
              VoucherConstant.DETAILTYPEID, payeeDetail.getAccountDetailType().getId());
          subledgertDetailMap.put(VoucherConstant.DETAILKEYID, payeeDetail.getAccountdetailKeyId());
          subledgertDetailMap.put(
              VoucherConstant.GLCODE, advanceDetail.getChartofaccounts().getGlcode());
          subledgerDetails.add(subledgertDetailMap);
        }
      }

      final CreateVoucher cv = new CreateVoucher();
      voucherHeader = cv.createPreApprovedVoucher(headerDetails, accountdetails, subledgerDetails);

    } catch (final HibernateException e) {
      LOGGER.error(e.getMessage(), e);
      throw new ValidationException(
          Arrays.asList(new ValidationError(EXCEPTION_WHILE_SAVING_DATA, FAILED)));
    } catch (final ApplicationRuntimeException e) {
      LOGGER.error(e.getMessage(), e);
      throw new ValidationException(
          Arrays.asList(new ValidationError(e.getMessage(), e.getMessage())));
    } catch (final ValidationException e) {
      LOGGER.error(e.getMessage(), e);
      throw e;
    } catch (final Exception e) {
      // handle engine exception
      LOGGER.error(e.getMessage(), e);
      throw new ValidationException(
          Arrays.asList(new ValidationError(e.getMessage(), e.getMessage())));
    }
    if (LOGGER.isDebugEnabled()) LOGGER.debug("Posted to Ledger " + voucherHeader.getId());
    return voucherHeader;
  }