Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.erp.sls.bo.invoice;
- 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.QueryBuilder;
- import org.jleaf.erp.master.entity.CtgrPartner;
- import org.jleaf.erp.master.entity.Partner;
- import org.jleaf.erp.sls.SalesConstants;
- import org.jleaf.erp.sls.dao.SalesInvoiceDao;
- import org.jleaf.erp.sls.entity.SalesInvoice;
- import org.jleaf.util.ValidationUtil;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import javax.persistence.Query;
- import java.util.List;
- /**
- * Is InvoiceAdvance exists by id
- * @author Fredi, Sep 19, 2014
- * @version 1.0
- */
- //@ formatter:off
- @Service
- @InfoIn(value = {
- @Info(name = "invoiceId", description = "invoiceId", type = Long.class, required = true)
- })
- @InfoOut(value = {
- @Info(name = "exists", description = "InvoiceAdvance exists", type = Boolean.class, required = true),
- })
- @ErrorList(errorKeys = {
- })
- //@ formatter:on
- public class IsCtgrPartnerExistsByInvoiceId extends AbstractBusinessFunction implements BusinessFunction {
- private static Logger log = LoggerFactory.getLogger(IsCtgrPartnerExistsByInvoiceId.class);
- @Autowired
- private SalesInvoiceDao salesInvoiceDao;
- @Override
- public Dto execute(Dto inputDto) throws Exception {
- ValidationUtil.valDtoContainsKey(inputDto, "invoiceId");
- Dto outputDto = new Dto();
- List<Object[]> result = null;
- QueryBuilder builder = new QueryBuilder();
- builder.add("SELECT A FROM ")
- .add("org.jleaf.erp.sls.entity.SalesInvoice")
- .add(" A INNER JOIN ")
- .add("org.jleaf.erp.master.entity.Partner")
- .add(" B ON A.partnerId = B.id INNER JOIN ")
- .add("org.jleaf.erp.master.entity.CtgrPartner")
- .add(" C ON B.ctgrPartnerId = C.id ")
- .add(" WHERE A.id = :invoiceId ")
- .add(" AND C.code = :CLIENT_CORPORATE ");
- Query q = salesInvoiceDao.createQuery(builder.toString());
- q.setParameter("invoiceId", inputDto.getLong("invoiceId"));
- q.setParameter("CLIENT_CORPORATE", SalesConstants.CLIENT_CORPORATE);
- result = q.getResultList();
- boolean isExists = false;
- if (result != null && result.size()>0) {
- isExists = true;
- }
- outputDto.put("exists", isExists);
- log.debug("outputDtoEmailTemplate >> "+outputDto);
- log.info("outputDtoEmailTemplate >> "+outputDto);
- return outputDto;
- }
- @Override
- public String getDescription() {
- return "Is Category Parnter exists by Invoice id";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement