Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.erp.fin.bo.invoicearback;
- import javax.persistence.Query;
- import org.jleaf.core.AbstractBusinessFunction;
- import org.jleaf.core.BusinessFunction;
- import org.jleaf.core.Dto;
- 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.fin.dao.HandoverInvoiceArDao;
- import org.jleaf.erp.fin.entity.InvoiceArBalanceHandoverForSasa;
- import org.jleaf.erp.master.entity.ProductCustom;
- import org.jleaf.util.ValidationUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- /**
- *
- * Deo, Jan 27, 2020
- *
- **/
- //@formatter:off
- @Service
- @InfoIn(value = {
- @Info(name = "tenantId", description = "tenant id", type = Long.class),
- @Info(name = "ouId", description = "ou id", type = Long.class),
- @Info(name = "employeeId", description = "employee id", type = Long.class)
- })
- @InfoOut(value = {
- @Info(name = "countInvoiceArList", description = "count invoice ar list", type = Long.class, required = false)
- })
- //@formatter:on
- public class CountGetInvoiceArListForHandoverInvoiceArBack extends AbstractBusinessFunction implements BusinessFunction {
- @Autowired
- private HandoverInvoiceArDao handoverInvoiceArDao;
- @Override
- public String getDescription() {
- return "Count Get Invoice Ar List for Handover Invoice Ar Back";
- }
- @Override
- public Dto execute(Dto inputDto) throws Exception {
- // Validation parameter input
- ValidationUtil.valDtoContainsKey(inputDto, "tenantId");
- ValidationUtil.valDtoContainsKey(inputDto, "ouId");
- ValidationUtil.valDtoContainsKey(inputDto, "employeeId");
- // Get Variable
- Long tenantId = inputDto.getLong("tenantId");
- Long ouId = inputDto.getLong("ouId");
- Long employeeId = inputDto.getLong("employeeId");
- //@formatter:off
- QueryBuilder builder = new QueryBuilder();
- builder.add(" SELECT COUNT(1) ")
- .add(" FROM "+ InvoiceArBalanceHandoverForSasa.TABLE_NAME +" A ")
- .add(" INNER JOIN vw_fi_os_debt_invoice_ar B ")
- .add(" ON A.invoice_id = B.id AND A.doc_type_id = B.doc_type_id ")
- .add(" WHERE A.tenant_id = :tenantId ")
- .add(" AND B.ou_id = :ouId ")
- .add(" AND A.employee_id = :employeeId ");
- //@formatter:on
- Query query = handoverInvoiceArDao.createNativeQuery(builder.toString());
- query.setParameter("tenantId", tenantId);
- query.setParameter("ouId", ouId);
- query.setParameter("employeeId", employeeId);
- Object result = query.getSingleResult();
- Long count = 0L;
- if(result!=null){
- count = Long.valueOf( result.toString());
- }
- return new Dto().put("count", count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement