SHARE
TWEET

GetHistoryInvoiceTaxListForInquiryAp

tercnem Jul 18th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package org.jleaf.erp.fin.bo.inquiryap;
  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.GeneralConstants;
  11. import org.jleaf.core.annotation.ErrorList;
  12. import org.jleaf.core.annotation.Info;
  13. import org.jleaf.core.annotation.InfoIn;
  14. import org.jleaf.core.annotation.InfoOut;
  15. import org.jleaf.core.dao.QueryBuilder;
  16. import org.jleaf.erp.fin.dao.InvoiceTaxApBalanceDao;
  17. import org.jleaf.erp.fin.entity.InvoiceApBalance;
  18. import org.jleaf.erp.fin.entity.InvoiceTaxApBalance;
  19. import org.jleaf.util.DtoUtil;
  20. import org.jleaf.util.ValidationUtil;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.stereotype.Service;
  23.  
  24. //@formatter:off
  25. @Service
  26. @InfoIn(value = {
  27.     @Info(name = "tenantId", description = "Tenant id", type = Long.class),
  28.     @Info(name = "ouId", description = "OU id", type = Long.class),
  29.     @Info(name = "userId", description = "user id", type = Long.class),
  30.     @Info(name = "roleId", description = "role id", type = Long.class),
  31.     @Info(name = "partnerId", description = "partner id", type = Long.class),
  32.     @Info(name = "dateFrom", description = "date from", type = String.class),
  33.     @Info(name = "dateTo", description = "date to", type = String.class)
  34. })
  35. @InfoOut(value = {
  36.     @Info(name = "invoiceTaxList", description = "outstanding invoice tax list (invoiceTaxApBalanceId, docTypeId, invoiceApBalanceId, taxNo, taxDate, docDesc, docNo, docDate, baseCurrCode, baseAmount, currCode, taxAmount, taxCurrCode, govTaxAmount, outstandingAmount, dueDate, partnerId, partnerCode, partnerName, flgPayment)", type = List.class)
  37. })
  38. @ErrorList(errorKeys ={
  39.        
  40. })
  41. //@formatter:off
  42. public class GetHistoryInvoiceTaxListForInquiryAp  extends AbstractBusinessFunction implements BusinessFunction {
  43.  
  44.     @Autowired
  45.     private InvoiceTaxApBalanceDao invoiceTaxApBalanceDao;
  46.    
  47.     @Override
  48.     public String getDescription() {
  49.         return "Get history invoice tax list for inquiry AP";
  50.     }
  51.  
  52.     @Override
  53.     public Dto execute(Dto inputDto) throws Exception {
  54.         ValidationUtil.valDtoContainsKey(inputDto, "tenantId");
  55.         ValidationUtil.valDtoContainsKey(inputDto, "ouId");
  56.         ValidationUtil.valDtoContainsKey(inputDto, "userId");
  57.         ValidationUtil.valDtoContainsKey(inputDto, "roleId");
  58.         ValidationUtil.valDtoContainsKey(inputDto, "partnerId");
  59.         ValidationUtil.valDtoContainsKey(inputDto, "dateFrom");
  60.         ValidationUtil.valDtoContainsKey(inputDto, "dateTo");
  61.        
  62.         Long tenantId = inputDto.getLong("tenantId");
  63.         Long ouId = inputDto.getLong("ouId");
  64.         Long userId = inputDto.getLong("userId");
  65.         Long roleId = inputDto.getLong("roleId");
  66.         Long partnerId = inputDto.getLong("partnerId");
  67.         String dateFrom = inputDto.getString("dateFrom");
  68.         String dateTo = inputDto.getString("dateTo");
  69.        
  70.         QueryBuilder queryBuilder = new QueryBuilder();
  71.         queryBuilder.add(" SELECT A.invoice_tax_ap_balance_id, A.doc_type_id, A.invoice_ap_balance_id, A.tax_no, A.tax_date, f_get_doc_desc(A.doc_type_id) AS doc_desc, B.doc_no, B.doc_date, ")
  72.                     .add("        B.curr_code AS base_curr_code, B.amount AS base_amount, A.curr_code AS curr_code, A.tax_amount, A.tax_curr_code, A.gov_tax_amount, ")
  73.                     .add("        (A.gov_tax_amount - A.payment_amount) AS outstanding_amount, A.due_date, A.partner_id, f_get_partner_code(A.partner_id) AS partner_code, f_get_partner_name(A.partner_id) AS partner_name, A.flg_payment ")
  74.                     .add(" FROM ")
  75.                     .add(InvoiceTaxApBalance.TABLE_NAME)
  76.                     .add(" A ")
  77.                     .add(" INNER JOIN ")
  78.                     .add(InvoiceApBalance.TABLE_NAME)
  79.                     .add(" B ON A.invoice_ap_balance_id = B.invoice_ap_balance_id ")
  80.                     .add(" WHERE A.tenant_id = :tenantId ")
  81.                     .add(" AND A.ou_id = :ouId ")
  82.                     .add(" AND B.doc_date BETWEEN :dateFrom AND :dateTo ")
  83.                     .add(" AND f_authorize_user_role_policy_partner(:tenantId, :userId, :roleId, A.partner_id) = 1 ")
  84.                     .addIfNotEquals(partnerId, GeneralConstants.NULL_REF_VALUE_LONG, " AND A.partner_id = :partnerId ")
  85.                     .add(" ORDER BY B.doc_no ASC, B.doc_date ASC, A.tax_curr_code ASC, outstanding_amount DESC ");
  86.        
  87.         Query query = invoiceTaxApBalanceDao.createNativeQuery(queryBuilder.toString());
  88.         query.setParameter("tenantId", tenantId);
  89.         query.setParameter("ouId", ouId);
  90.         query.setParameter("userId", userId);
  91.         query.setParameter("roleId", roleId);
  92.         if (!GeneralConstants.NULL_REF_VALUE_LONG.equals(partnerId)) {
  93.             query.setParameter("partnerId", partnerId);
  94.         }
  95.         query.setParameter("dateFrom", dateFrom);
  96.         query.setParameter("dateTo", dateTo);
  97.  
  98.         List<Object[]> list = query.getResultList();
  99.        
  100.         return new Dto().put("invoiceTaxList", DtoUtil.createDtoListFromArray(list, "invoiceTaxApBalanceId", "docTypeId", "invoiceApBalanceId", "taxNo", "taxDate", "docDesc", "docNo", "docDate", "baseCurrCode", "baseAmount", "currCode", "taxAmount", "taxCurrCode", "govTaxAmount", "outstandingAmount", "dueDate", "partnerId", "partnerCode", "partnerName", "flgPayment"));
  101.     }
  102.  
  103. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top