Package com.san.my.dataobj

Examples of com.san.my.dataobj.SlipDO


        AccountDO hamaliAccountDO = accountDAO.loadAccountDO(2L);
        AccountDO ccAccountDO = accountDAO.loadAccountDO(3L);
        AccountDO mfAccountDO = accountDAO.loadAccountDO(4L);
        SeedDO seedDO = seedDAO.loadSeed(purchaseSlip.getSeedKey());
       
    SlipDO slipDO = new SlipDO();
    slipDO.setAutoCalculate(!"on".equalsIgnoreCase(purchaseSlip.getDoNotCalculate()));
    slipDO.setAdthiRate(purchaseSlip.getAdthiRate());
    slipDO.setHamaliRate(purchaseSlip.getHamaliRate());
    slipDO.setCcRate(purchaseSlip.getCashCommissionRate());
   
    slipDO.setBags(purchaseSlip.getBags());   
    slipDO.setBarthi(purchaseSlip.getBagwt());
    slipDO.setDatetime(currentTime);
       
        slipDO.setBuyer(buyerAccountDO);
        slipDO.setSupplier(supplierAccountDO);
   
    slipDO.setQtls(purchaseSlip.getQtls());
    slipDO.setLooseBag(purchaseSlip.getSmallBag())
        slipDO.setRate(purchaseSlip.getCost());
       
        slipDO.setStatus(purchaseSlip.getStatus());
       
    slipDO.setDescription(purchaseSlip.getDescription());
       
        slipDO.setSeed(seedDO);
   
        List<BussinessTransactionDO> transactionObjects = new LinkedList<BussinessTransactionDO>();
       
        //Debit from buyer transaction.
    BussinessTransactionDO buyerTransactionDO = new BussinessTransactionDO();
        buyerTransactionDO.setDatetime(currentTime);
        buyerTransactionDO.setAmount(purchaseSlip.getGrossTotal());
        buyerTransactionDO.setAccount(buyerAccountDO);
        buyerTransactionDO.setSlip(slipDO);
        buyerTransactionDO.setTransFlow(Constants.DEBIT); // flow is debit
        buyerTransactionDO.setPaymentMode(Constants.PAYMENT_MODE_CASH);
        buyerTransactionDO.setDescription("Debited from firm to indicate that buyer has to pay to firm");
       
        transactionObjects.add(buyerTransactionDO);
       
        //Credit to supplier transaction.
        BussinessTransactionDO supplierTransactionDO = new BussinessTransactionDO();
        supplierTransactionDO.setDatetime(currentTime);
        supplierTransactionDO.setAmount(purchaseSlip.getNetTotal());
        supplierTransactionDO.setAccount(supplierAccountDO);
        supplierTransactionDO.setSlip(slipDO);
        supplierTransactionDO.setTransFlow(Constants.CREDIT);
        supplierTransactionDO.setPaymentMode(Constants.PAYMENT_MODE_CASH);
        supplierTransactionDO.setDescription("Credited to firm to indicate that firm has to pay to supplier");
       
        transactionObjects.add(supplierTransactionDO);
       
        //Credit to HAMALI transaction.
        BussinessTransactionDO hamaliTransactionDO = new BussinessTransactionDO();
        hamaliTransactionDO.setDatetime(currentTime);
        hamaliTransactionDO.setAmount(purchaseSlip.getTotalHamali());
        hamaliTransactionDO.setAccount(hamaliAccountDO);
        hamaliTransactionDO.setSlip(slipDO);
        hamaliTransactionDO.setTransFlow(Constants.CREDIT);
        hamaliTransactionDO.setPaymentMode(Constants.PAYMENT_MODE_CASH);
        hamaliTransactionDO.setDescription("Credited to firm to indicate that firm has to pay to Hamali");
       
        transactionObjects.add(hamaliTransactionDO);
       
       
        //Credit to CC transaction.
        BussinessTransactionDO ccTransactionDO = new BussinessTransactionDO();
        ccTransactionDO.setDatetime(currentTime);
        ccTransactionDO.setAmount(purchaseSlip.getTotalCc());
        ccTransactionDO.setAccount(ccAccountDO);
        ccTransactionDO.setSlip(slipDO);
        ccTransactionDO.setTransFlow(Constants.CREDIT);
        ccTransactionDO.setPaymentMode(Constants.PAYMENT_MODE_CASH);
        ccTransactionDO.setDescription("Credited to firm to indicate that firm has to pay to CC account");
       
        transactionObjects.add(ccTransactionDO);
       
        //Credit to MF transaction.
        BussinessTransactionDO mfTransactionDO = new BussinessTransactionDO();
        mfTransactionDO.setDatetime(currentTime);
        mfTransactionDO.setAmount(purchaseSlip.getTotalMf());
        mfTransactionDO.setAccount(mfAccountDO);
        mfTransactionDO.setSlip(slipDO);
        mfTransactionDO.setTransFlow(Constants.CREDIT);
        mfTransactionDO.setPaymentMode(Constants.PAYMENT_MODE_CASH);
        mfTransactionDO.setDescription("Credited to firm to indicate that firm has to pay to MF account");
       
        transactionObjects.add(mfTransactionDO);
       
        //Insert payment transaction if purchase status is not pending.
        if(!purchaseSlip.getStatus().equals(Constants.BILL_STATUS_PENDING)){
            //payment transaction.
            BussinessTransactionDO payment = new BussinessTransactionDO();
            payment.setDatetime(currentTime);
            payment.setAmount(purchaseSlip.getPaymentAmount());
            payment.setAccount(supplierAccountDO);
            payment.setSlip(slipDO);
            payment.setTransFlow(Constants.DEBIT);
           
            if(purchaseSlip.getPaymentMode().equals(Constants.PAYMENT_MODE_CASH)){
                payment.setPaymentMode(Constants.PAYMENT_MODE_CASH);
            }else{
                PaymentDetailsDO paymentDetails = new PaymentDetailsDO();
                paymentDetails.setDatetime(currentTime);
                paymentDetails.setAmount(purchaseSlip.getPaymentAmount());
                paymentDetails.setCheckNumber(purchaseSlip.getCheckNumber());
                paymentDetails.setBankName(purchaseSlip.getBankName());
                paymentDetails.setBranchName(purchaseSlip.getBranchName());
                paymentDetails.setBusinessTransaction(payment);
                paymentDetails.setDescription("Firm has paid this amount towards this bill");
               
                payment.setPaymentMode(Constants.PAYMENT_MODE_CHECK);
                payment.setPaymentDetails(paymentDetails);
            }
           
            payment.setDescription("Firm has paid this amount to supplier");
           
            transactionObjects.add(payment);
        }
       
    transactionsDAO.saveBusinessTransactions(transactionObjects);
       
    purchaseSlip.setSlipId(slipDO.getSlipId());
  }
View Full Code Here


        this.seedDAO = seedDAO;
    }

    public void editPurchase(PurchaseSlip purchaseSlip)
    {
        SlipDO slip = slipDAO.loadSlip(purchaseSlip.getSlipId());
        AccountDO supplier = accountDAO.loadAccountDO(purchaseSlip.getSupplierKey());
        AccountDO buyer = accountDAO.loadAccountDO(purchaseSlip.getBuyerAccountIdKey());
       
        //edit slip transactions.
        Set<BussinessTransactionDO> transactions = slip.getTransactions();
        //TODO: this set size should not be greater than 5 check for this
        for(BussinessTransactionDO transaction : transactions){
            if(transaction.getAccount().getAccountId().equals(Constants.HAMALI_ID)){
                transaction.setAmount(purchaseSlip.getTotalHamali());
            }else if(transaction.getAccount().getAccountId().equals(Constants.CC_ID)){
                transaction.setAmount(purchaseSlip.getTotalCc());
            }else if(transaction.getAccount().getAccountId().equals(Constants.MF_ID)){
                transaction.setAmount(purchaseSlip.getTotalMf());
            /*
             * If transaction account is other than HAMALI, CC, MF.. then transaction with flow
             *    -- CR is assumed as supplier transaction.
             *    -- DR is assumed as buyer transaction.
             * The alternative to this assumption could be to have previous supplier and
             * buyer information in the purchase slip while editing the slip.
             */
            }else if(transaction.getTransFlow().equals(Constants.CREDIT)){ //Supplier transaction.
                transaction.setAmount(purchaseSlip.getNetTotal());
                transaction.setAccount(supplier);
            }else if(transaction.getTransFlow().equals(Constants.DEBIT)){ //Buyer transaction
                transaction.setAmount(purchaseSlip.getGrossTotal());
                transaction.setAccount(buyer);
            }
        }
       
        //Insert payment transaction if purchase status is not pending.
        if(!purchaseSlip.getStatus().equals(Constants.BILL_STATUS_PENDING)){
            Date currentTime = Calendar.getInstance().getTime();
            //payment transaction.
            BussinessTransactionDO payment = new BussinessTransactionDO();
            payment.setDatetime(currentTime);
            payment.setAmount(purchaseSlip.getPaymentAmount());
            payment.setAccount(supplier);
            payment.setSlip(slip);
            payment.setTransFlow(Constants.DEBIT);
           
            if(purchaseSlip.getPaymentMode().equals(Constants.PAYMENT_MODE_CASH)){
                payment.setPaymentMode(Constants.PAYMENT_MODE_CASH);
            }else{
                PaymentDetailsDO paymentDetails = new PaymentDetailsDO();
                paymentDetails.setDatetime(currentTime);
                paymentDetails.setAmount(purchaseSlip.getPaymentAmount());
                paymentDetails.setCheckNumber(purchaseSlip.getCheckNumber());
                paymentDetails.setBankName(purchaseSlip.getBankName());
                paymentDetails.setBranchName(purchaseSlip.getBranchName());
                paymentDetails.setBusinessTransaction(payment);
                paymentDetails.setDescription("Firm has paid this amount towards this bill");
               
                payment.setPaymentMode(Constants.PAYMENT_MODE_CHECK);
                payment.setPaymentDetails(paymentDetails);
            }
           
            payment.setDescription("Firm has paid this amount to supplier");
           
            transactionsDAO.saveBusinessTransaction(payment);
        }
       
        //Edit slip
        SeedDO seed = seedDAO.loadSeed(purchaseSlip.getSeedKey());
        slip.setSeed(seed);
        slip.setSupplier(supplier);
        slip.setBuyer(buyer);
        slip.setBarthi(purchaseSlip.getBagwt());
        slip.setBags(purchaseSlip.getBags());
        slip.setLooseBag(purchaseSlip.getSmallBag());
        slip.setRate(purchaseSlip.getCost());
        slip.setQtls(purchaseSlip.getQtls());
        slip.setHamaliRate(purchaseSlip.getHamaliRate());
        slip.setCcRate(purchaseSlip.getCashCommissionRate());
        slip.setAdthiRate(purchaseSlip.getAdthiRate());
        slip.setStatus(purchaseSlip.getStatus());
        slip.setDescription(purchaseSlip.getDescription());       
    }
View Full Code Here

        slip.setDescription(purchaseSlip.getDescription());       
    }

    public void loadSlip(PurchaseSlip purchaseSlip) throws BusinessServiceException
    {
        SlipDO slip = slipDAO.loadSlip(purchaseSlip.getSlipId());
        if(slip==null){
          throw new BusinessServiceException("Slip ID not found");
        }
        purchaseSlip.setSlipId(slip.getSlipId());
        purchaseSlip.setAdthiRate(slip.getAdthiRate());
        purchaseSlip.setHamaliRate(slip.getHamaliRate());
        purchaseSlip.setCashCommissionRate(slip.getCcRate());
       
        purchaseSlip.setPurchaseDate(slip.getDatetime());
        purchaseSlip.setSeed(slip.getSeed().getName());
        purchaseSlip.setSeedKey(slip.getSeed().getSeedId());
        purchaseSlip.setBagwt(slip.getBarthi());
        purchaseSlip.setBags(slip.getBags());
        purchaseSlip.setSmallBag(slip.getLooseBag());
        purchaseSlip.setCost(slip.getRate());
       
        purchaseSlip.setBuyerAccountId(slip.getBuyer().getLoginName());
        purchaseSlip.setBuyerAccountIdKey(slip.getBuyer().getAccountId());
        purchaseSlip.setSupplier(slip.getSupplier().getLoginName());
        purchaseSlip.setSupplierKey(slip.getSupplier().getAccountId());
        purchaseSlip.setSupplierCity(slip.getSupplier().getVillage());
       
        Set<BussinessTransactionDO> transactions = slip.getTransactions();
        List<BussinessTransactionDO> payments = new ArrayList<BussinessTransactionDO>();
       
        for(BussinessTransactionDO transaction : transactions){
            if(transaction.getAccount().getAccountId().equals(slip.getBuyer().getAccountId()) && transaction.getTransFlow().equals(Constants.DEBIT)){
                purchaseSlip.setGrossTotal(transaction.getAmount());
            }else if(transaction.getAccount().getAccountId().equals(slip.getSupplier().getAccountId()) && transaction.getTransFlow().equals(Constants.CREDIT)){
                purchaseSlip.setNetTotal(transaction.getAmount());
            }else if(transaction.getAccount().getAccountId().equals(Constants.HAMALI_ID) && transaction.getTransFlow().equals(Constants.CREDIT)){
                purchaseSlip.setTotalHamali(transaction.getAmount());
            }else if(transaction.getAccount().getAccountId().equals(Constants.CC_ID) && transaction.getTransFlow().equals(Constants.CREDIT)){
                purchaseSlip.setTotalCc(transaction.getAmount());
            }else if(transaction.getAccount().getAccountId().equals(Constants.MF_ID) && transaction.getTransFlow().equals(Constants.CREDIT)){
                purchaseSlip.setTotalMf(transaction.getAmount());
            }else if(transaction.getAccount().getAccountId().equals(slip.getSupplier().getAccountId()) && transaction.getTransFlow().equals(Constants.DEBIT)){
                payments.add(transaction);
            }
        }
       
        purchaseSlip.setPayments(payments);
        purchaseSlip.setStatus(slip.getStatus());
        purchaseSlip.setDescription(slip.getDescription());
    }
View Full Code Here

        transaction.setAmount(form.getAmount());
       
        if(form.getSlipId() == null){
            transaction.setSlip(null);
        }else{
            SlipDO slip = (SlipDO)slipDAO.loadSlip(form.getSlipId());
            transaction.setSlip(slip);
        }
       
        String action = form.getAction();
        if(action.equals(Constants.TRANSACTION_PAYMENT)){
View Full Code Here

                           //accountsDO.setAccountId(2);
                           accountsDO.setName("gfeabcaaaaad");
                           accountsDO.setLoginName("gfeaaaaaaa");
                           session.merge(accountsDO);
                         
                           SlipDO slip  = (SlipDO)objectDAO.load(SlipDO.class,new Integer(21070));
                          
                         }
                         catch (Exception ex) {
                             status.setRollbackOnly();
                             ex.printStackTrace();                       
View Full Code Here

TOP

Related Classes of com.san.my.dataobj.SlipDO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.