widana

GetDraftPosTransactionList

Oct 26th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.59 KB | None | 0 0
  1. package org.jleaf.pos2.bo.postransaction;
  2.  
  3. import java.util.List;
  4.  
  5. import javax.persistence.Query;
  6.  
  7. import org.jleaf.core.AbstractBusinessFunction;
  8. import org.jleaf.core.BusinessFunction;
  9. import org.jleaf.core.Dto;
  10. import org.jleaf.core.annotation.ErrorList;
  11. import org.jleaf.core.annotation.Info;
  12. import org.jleaf.core.annotation.InfoIn;
  13. import org.jleaf.core.annotation.InfoOut;
  14. import org.jleaf.core.dao.CriteriaHelper;
  15. import org.jleaf.core.dao.QueryBuilder;
  16. import org.jleaf.pos2.PosConstants;
  17. import org.jleaf.pos2.entity.Pos;
  18. import org.jleaf.pos2.dao.PosDao;
  19. import org.jleaf.util.DtoUtil;
  20. import org.jleaf.util.ValidationUtil;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.beans.factory.annotation.Qualifier;
  23. import org.springframework.stereotype.Service;
  24.  
  25. /**
  26.  * Business Transactions: GetDraftPosTransactionList
  27.  *
  28.  * @author Widana Nur Azis , 20 Oct 2016
  29.  */
  30.  
  31. @Service
  32. @InfoIn(value = {
  33.         @Info(name = "userLoginId", description = "user login id", type = Long.class, required = true),
  34.         @Info(name = "userLoginName", description = "user login name", type = String.class, required = true),
  35.         @Info(name = "roleLoginId", description = "role login id", type = Long.class, required = true),
  36.         @Info(name = "roleLoginName", description = "role login name", type = String.class, required = true),
  37.         @Info(name = "tenantLoginId", description = "tenant login id", type = Long.class, required = true),
  38.         @Info(name = "datetime", description = "datetime", type = String.class, required = true),
  39.  
  40.         @Info(name = "posCashierId", description = "posCashierId", type = Long.class, required = true) })
  41. @InfoOut(value = { @Info(name = "draftPosTransactionList", description = "draftPosTransactionList (posId,docTypeId,docNo,docDate,extDocNo,extDocDate"
  42.         + "refDocTypeId,refId,remark,customerCode,customerName,customerPhone,salesmanCode,currCode,"
  43.         + "grossAmount,totalDiscountItem,addDiscountPercentage,addDiscountAmount,nettAmount,taxAmount,"
  44.         + "addAmount,totalAmount,roundingAmount,totalPayment,totalRefund,status,active,activeDatetime,"
  45.         + "nonActiveDatetime,version,createDatetime,createUsername,updateDatetime,updateUsername,posCashierId)")
  46.  
  47. })
  48. @ErrorList(errorKeys = {})
  49. public class GetDraftPosTransactionList extends AbstractBusinessFunction
  50.         implements BusinessFunction {
  51.  
  52.     @Autowired
  53.     PosDao posDao;
  54.  
  55.     @Override
  56.     public String getDescription() {
  57.         // TODO Auto-generated method stub
  58.         return null;
  59.     }
  60.  
  61.     @SuppressWarnings("unchecked")
  62.     @Override
  63.     public Dto execute(Dto inputDto) throws Exception {
  64.         // TODO Auto-generated method stub
  65.  
  66.         ValidationUtil.valBlankOrNull(inputDto, "posCashierId");
  67.  
  68.         ValidationUtil.valDtoContainsKey(inputDto, "posCashierId");
  69.  
  70.         List<Object[]> result = null;
  71.  
  72.         QueryBuilder builder = new QueryBuilder();
  73.         builder.add(" SELECT ")
  74.                 .add(" pos_id, doc_type_id, doc_no, doc_date, ext_doc_no, ext_doc_date,  ")
  75.                 .add(" ref_doc_type_id, ref_id, remark, customer_code, customer_name,  ")
  76.                 .add(" customer_phone, salesman_code, curr_code, gross_amount, total_discount_item, ")
  77.                 .add(" add_discount_percentage, add_discount_amount, nett_amount, tax_amount,  ")
  78.                 .add(" add_amount, total_amount, rounding_amount, total_payment, total_refund, ")
  79.                 .add(" status, active, active_datetime, non_active_datetime, A.version, ")
  80.                 .add(" A.create_datetime, A.create_username, A.update_datetime, A.update_username, ")
  81.                 .add(" A.pos_cashier_id ")
  82.                 .add(" FROM ").add(Pos.TABLE_NAME)
  83.                 .add(" A ").add(" WHERE true").add(" AND ")
  84.                 .add(" A.pos_cashier_id = :posCashierId ").add(" AND ")
  85.                 .add(" A.status = :status ").add(" ORDER BY A.create_datetime DESC, A.pos_id DESC ");
  86.  
  87.         Query query = posDao.createNativeQuery(builder.toString());
  88.         query.setParameter("posCashierId", inputDto.getLong("posCashierId"));
  89.         query.setParameter("status", PosConstants.DRAFT);
  90.        
  91.         result = query.getResultList();
  92.  
  93.         return new Dto().putList("draftPosTransactionList", DtoUtil
  94.                 .createDtoListFromArray(result, "posId", "docTypeId", "docNo",
  95.                         "docDate", "extDocNo", "extDocDate", "refDocTypeId",
  96.                         "refId", "remark", "customerCode", "customerName",
  97.                         "customerPhone", "salesmanCode", "currCode",
  98.                         "grossAmount", "totalDiscountItem",
  99.                         "addDiscountPercentage", "addDiscountAmount",
  100.                         "nettAmount", "taxAmount", "addAmount", "totalAmount",
  101.                         "roundingAmount", "totalPayment", "totalRefund",
  102.                         "status", "active", "activeDatetime",
  103.                         "nonActiveDatetime", "version", "createDatetime",
  104.                         "createUsername", "updateDatetime", "updateUsername",
  105.                         "posCashierId"));
  106.     }
  107.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment