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.entity.PosItem;
- import org.jleaf.pos2.dao.PosItemDao;
- import org.jleaf.pos2.entity.Pos;
- import org.jleaf.pos2.entity.PosCashier;
- import org.jleaf.util.DtoUtil;
- import org.jleaf.util.ValidationUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- /**
- * Business Function: GetPosTransactionItemByPosId
- *
- * @author Widana Nur Azis 24 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 = "posId", description = "posId", type = Long.class, required = true),
- @Info(name = "posCashierId", description = "posCashierId", type = Long.class, required = true)
- })
- @InfoOut(value = {})
- @ErrorList(errorKeys = {})
- public class GetPosTransactionItemListById extends AbstractBusinessFunction
- implements BusinessFunction {
- @Autowired
- PosItemDao posItemDao;
- @Override
- public String getDescription() {
- return "GetPosTransactionItemByPosId item for buy to customer";
- }
- @SuppressWarnings("unchecked")
- @Override
- public Dto execute(Dto inputDto) throws Exception {
- ValidationUtil.valBlankOrNull(inputDto, "posId");
- ValidationUtil.valBlankOrNull(inputDto, "posCashierId");
- ValidationUtil.valDtoContainsKey(inputDto, "posId");
- ValidationUtil.valDtoContainsKey(inputDto, "posCashierId");
- List<Object[]> result = null;
- QueryBuilder builder = new QueryBuilder();
- builder.add(" SELECT ")
- .add(" A.pos_item_id, A.pos_id, A.line_no, A.product_code, A.product_serial_number, ")
- .add(" A.uom_code, A.qty, A.curr_code, A.gross_sell_price, A.tax_id, A.tax_percentage, ")
- .add(" A.tax_price, A.promo_code, A.discount_percentage, A.discount_amount, ")
- .add(" A.nett_sell_price, A.tax_amount, A.nett_amount_item, A.remark, A.active, ")
- .add(" A.active_datetime, A.non_active_datetime, A.version, A.create_datetime, ")
- .add(" A.create_username, A.update_datetime, A.update_username, A.flg_tax_amount, ")
- .add(" COALESCE(SUM(A.gross_sell_price * A.qty),0) total_amount ")
- .add(" FROM ")
- .add(PosItem.TABLE_NAME)
- .add(" A ")
- .add(" INNER JOIN ")
- .add(Pos.TABLE_NAME)
- .add(" B ")
- .add(" ON B.pos_id = A.pos_id ")
- .add(" INNER JOIN ")
- .add(PosCashier.TABLE_NAME)
- .add(" C ")
- .add(" ON C.pos_cashier_id = B.pos_cashier_id ")
- .add(" WHERE A.pos_id = :posId AND B.pos_cashier_id = :posCashierId ")
- .add(" GROUP BY ")
- .add(" A.pos_item_id, A.pos_id, A.line_no, A.product_code, A.product_serial_number, ")
- .add(" A.uom_code, A.qty, A.curr_code, A.gross_sell_price, A.tax_id, A.tax_percentage, ")
- .add(" A.tax_price, A.promo_code, A.discount_percentage, A.discount_amount, ")
- .add(" A.nett_sell_price, A.tax_amount, A.nett_amount_item, A.remark, A.active, ")
- .add(" A.active_datetime, A.non_active_datetime, A.version, A.create_datetime, ")
- .add(" A.create_username, A.update_datetime, A.update_username, A.flg_tax_amount");
- Query query = posItemDao.createNativeQuery(builder.toString());
- query.setParameter("posId", inputDto.getLong("posId"));
- query.setParameter("posCashierId", inputDto.getLong("posCashierId"));
- result = query.getResultList();
- return new Dto().putList("posItemTransaction", DtoUtil
- .createDtoListFromArray(result, "posItemId", "posId", "lineNo",
- "productCode", "productSerialNumber", "uomCode", "qty",
- "currCode", "grossSellPrice", "taxId", "taxPercentage",
- "taxPrice", "promoCode", "discountPercentage",
- "discountAmount", "nettSellPrice", "taxAmount",
- "nettAmountItem", "remark", "active", "activeDatetime",
- "nonActiveDatetime", "version", "createDatetime",
- "createUsername", "updateDatetime", "updateUsername",
- "flgTaxAmount", "totalAmount"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment