Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.pos2.bo.postransaction;
- import java.util.List;
- import javax.persistence.Query;
- import org.jleaf.core.AbstractBusinessFunction;
- import org.jleaf.core.BusinessFunction;
- import org.jleaf.core.Dto;
- import org.jleaf.core.annotation.ErrorList;
- import org.jleaf.core.annotation.Info;
- import org.jleaf.core.annotation.InfoIn;
- import org.jleaf.core.annotation.InfoOut;
- import org.jleaf.core.dao.CriteriaHelper;
- import org.jleaf.core.dao.QueryBuilder;
- import org.jleaf.pos2.PosConstants;
- import org.jleaf.pos2.entity.Pos;
- import org.jleaf.pos2.dao.PosDao;
- import org.jleaf.util.DtoUtil;
- import org.jleaf.util.ValidationUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Qualifier;
- import org.springframework.stereotype.Service;
- /**
- * Business Transactions: GetDraftPosTransactionList
- *
- * @author Widana Nur Azis , 20 Oct 2016
- */
- @Service
- @InfoIn(value = {
- @Info(name = "userLoginId", description = "user login id", type = Long.class, required = true),
- @Info(name = "userLoginName", description = "user login name", type = String.class, required = true),
- @Info(name = "roleLoginId", description = "role login id", type = Long.class, required = true),
- @Info(name = "roleLoginName", description = "role login name", type = String.class, required = true),
- @Info(name = "tenantLoginId", description = "tenant login id", type = Long.class, required = true),
- @Info(name = "datetime", description = "datetime", type = String.class, required = true),
- @Info(name = "posCashierId", description = "posCashierId", type = Long.class, required = true) })
- @InfoOut(value = { @Info(name = "draftPosTransactionList", description = "draftPosTransactionList (posId,docTypeId,docNo,docDate,extDocNo,extDocDate"
- + "refDocTypeId,refId,remark,customerCode,customerName,customerPhone,salesmanCode,currCode,"
- + "grossAmount,totalDiscountItem,addDiscountPercentage,addDiscountAmount,nettAmount,taxAmount,"
- + "addAmount,totalAmount,roundingAmount,totalPayment,totalRefund,status,active,activeDatetime,"
- + "nonActiveDatetime,version,createDatetime,createUsername,updateDatetime,updateUsername,posCashierId)")
- })
- @ErrorList(errorKeys = {})
- public class GetDraftPosTransactionList extends AbstractBusinessFunction
- implements BusinessFunction {
- @Autowired
- PosDao posDao;
- @Override
- public String getDescription() {
- // TODO Auto-generated method stub
- return null;
- }
- @SuppressWarnings("unchecked")
- @Override
- public Dto execute(Dto inputDto) throws Exception {
- // TODO Auto-generated method stub
- ValidationUtil.valBlankOrNull(inputDto, "posCashierId");
- ValidationUtil.valDtoContainsKey(inputDto, "posCashierId");
- List<Object[]> result = null;
- QueryBuilder builder = new QueryBuilder();
- builder.add(" SELECT ")
- .add(" pos_id, doc_type_id, doc_no, doc_date, ext_doc_no, ext_doc_date, ")
- .add(" ref_doc_type_id, ref_id, remark, customer_code, customer_name, ")
- .add(" customer_phone, salesman_code, curr_code, gross_amount, total_discount_item, ")
- .add(" add_discount_percentage, add_discount_amount, nett_amount, tax_amount, ")
- .add(" add_amount, total_amount, rounding_amount, total_payment, total_refund, ")
- .add(" status, active, active_datetime, non_active_datetime, A.version, ")
- .add(" A.create_datetime, A.create_username, A.update_datetime, A.update_username, ")
- .add(" A.pos_cashier_id ")
- .add(" FROM ").add(Pos.TABLE_NAME)
- .add(" A ").add(" WHERE true").add(" AND ")
- .add(" A.pos_cashier_id = :posCashierId ").add(" AND ")
- .add(" A.status = :status ").add(" ORDER BY A.create_datetime DESC, A.pos_id DESC ");
- Query query = posDao.createNativeQuery(builder.toString());
- query.setParameter("posCashierId", inputDto.getLong("posCashierId"));
- query.setParameter("status", PosConstants.DRAFT);
- result = query.getResultList();
- return new Dto().putList("draftPosTransactionList", DtoUtil
- .createDtoListFromArray(result, "posId", "docTypeId", "docNo",
- "docDate", "extDocNo", "extDocDate", "refDocTypeId",
- "refId", "remark", "customerCode", "customerName",
- "customerPhone", "salesmanCode", "currCode",
- "grossAmount", "totalDiscountItem",
- "addDiscountPercentage", "addDiscountAmount",
- "nettAmount", "taxAmount", "addAmount", "totalAmount",
- "roundingAmount", "totalPayment", "totalRefund",
- "status", "active", "activeDatetime",
- "nonActiveDatetime", "version", "createDatetime",
- "createUsername", "updateDatetime", "updateUsername",
- "posCashierId"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment