Пример #1
0
  public Reconciliation clearStatusByname(String logstr, Long userid, Long orderid)
      throws Exception {
    // TODO Auto-generated method stub

    Reconciliation rec = reconciliationRepository.findByUseridAndOrderid(userid, orderid);
    logger.debug(logstr + "Fetch reconciliation entry" + rec.fetchLogDetails());
    try {
      rec.setStatus("Closed");
      rec.setAmountpaid(rec.getOrdercost());
      rec = update(logstr, rec);
    } catch (Exception e) {
      throw new Exception();
    }
    return rec;
  }
Пример #2
0
  // calculate amount
  public Reconciliation calculateamt(String logstr, ReconciliationDto tobemerged) throws Exception {
    // TODO Auto-generated method stub
    int qty;
    double fprice, amt = 0;
    Date date = new Date();
    // if (tobemerged.getOrderid() == null)
    //		throw new ReconcileException("Order item list is empty");

    // Finding all order to the perticular user
    List<OrderItem> orderRecords =
        orderItemRepository.findByUidAndOid(tobemerged.getUserid(), tobemerged.getOrderid());
    if (orderRecords == null) {
      logger.debug(logstr + "Reconciliation record does not exist according to oid and uid");
      throw new Exception();
    }

    for (OrderItem orderItem : orderRecords) {
      FoodItem foodItem = foodItemRepository.findOne(orderItem.getItem_id());
      amt = amt + orderItem.getQty() * foodItem.getPrice();
    }

    // Create Reconcile entity
    Reconciliation reconciliation = new Reconciliation();

    logger.debug(logstr + "create reconciliation entry" + reconciliation.fetchLogDetails());
    // reconciliation.setDate(getDate);
    reconciliation.setOrderid(tobemerged.getOrderid());
    reconciliation.setOrdercost(amt);
    reconciliation.setAmountpaid(tobemerged.getAmtpaid());
    reconciliation.setUserid(tobemerged.getUserid());
    reconciliation.setStatus("processed");
    reconciliation.setDate(date);

    // new update for another update by same user
    Reconciliation recRecords =
        reconciliationRepository.findByUseridAndOrderid(
            tobemerged.getUserid(), tobemerged.getOrderid());
    if (recRecords != null) {
      reconciliation.setId(recRecords.getId());
      reconciliation.setAmountpaid(tobemerged.getAmtpaid() + recRecords.getAmountpaid());
      update(logstr, reconciliation);
    } else {
      reconciliation = reconciliationRepository.save(reconciliation);
    }
    logger.debug(logstr + "created reconciliation entry " + reconciliation.fetchLogDetails());
    return reconciliation;
  }