Advertisement
Guest User

BF CountGetInvoiceArListForHandoverInvoiceArBack

a guest
Jan 27th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. package org.jleaf.erp.fin.bo.invoicearback;
  2.  
  3.  
  4.  
  5.  
  6. import javax.persistence.Query;
  7.  
  8. import org.jleaf.core.AbstractBusinessFunction;
  9. import org.jleaf.core.BusinessFunction;
  10. import org.jleaf.core.Dto;
  11. import org.jleaf.core.annotation.Info;
  12. import org.jleaf.core.annotation.InfoIn;
  13. import org.jleaf.core.annotation.InfoOut;
  14. import org.jleaf.core.dao.QueryBuilder;
  15. import org.jleaf.erp.fin.dao.HandoverInvoiceArDao;
  16. import org.jleaf.erp.fin.entity.InvoiceArBalanceHandoverForSasa;
  17. import org.jleaf.erp.master.entity.ProductCustom;
  18. import org.jleaf.util.ValidationUtil;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.stereotype.Service;
  21.  
  22. /**
  23. *
  24. * Deo, Jan 27, 2020
  25. *
  26. **/
  27. //@formatter:off
  28. @Service
  29. @InfoIn(value = {
  30. @Info(name = "tenantId", description = "tenant id", type = Long.class),
  31. @Info(name = "ouId", description = "ou id", type = Long.class),
  32. @Info(name = "employeeId", description = "employee id", type = Long.class)
  33. })
  34. @InfoOut(value = {
  35. @Info(name = "countInvoiceArList", description = "count invoice ar list", type = Long.class, required = false)
  36. })
  37. //@formatter:on
  38. public class CountGetInvoiceArListForHandoverInvoiceArBack extends AbstractBusinessFunction implements BusinessFunction {
  39. @Autowired
  40. private HandoverInvoiceArDao handoverInvoiceArDao;
  41.  
  42. @Override
  43. public String getDescription() {
  44. return "Count Get Invoice Ar List for Handover Invoice Ar Back";
  45. }
  46.  
  47. @Override
  48. public Dto execute(Dto inputDto) throws Exception {
  49. // Validation parameter input
  50. ValidationUtil.valDtoContainsKey(inputDto, "tenantId");
  51. ValidationUtil.valDtoContainsKey(inputDto, "ouId");
  52. ValidationUtil.valDtoContainsKey(inputDto, "employeeId");
  53.  
  54. // Get Variable
  55. Long tenantId = inputDto.getLong("tenantId");
  56. Long ouId = inputDto.getLong("ouId");
  57. Long employeeId = inputDto.getLong("employeeId");
  58.  
  59. //@formatter:off
  60. QueryBuilder builder = new QueryBuilder();
  61. builder.add(" SELECT COUNT(1) ")
  62. .add(" FROM "+ InvoiceArBalanceHandoverForSasa.TABLE_NAME +" A ")
  63. .add(" INNER JOIN vw_fi_os_debt_invoice_ar B ")
  64. .add(" ON A.invoice_id = B.id AND A.doc_type_id = B.doc_type_id ")
  65. .add(" WHERE A.tenant_id = :tenantId ")
  66. .add(" AND B.ou_id = :ouId ")
  67. .add(" AND A.employee_id = :employeeId ");
  68. //@formatter:on
  69. Query query = handoverInvoiceArDao.createNativeQuery(builder.toString());
  70. query.setParameter("tenantId", tenantId);
  71. query.setParameter("ouId", ouId);
  72. query.setParameter("employeeId", employeeId);
  73.  
  74. Object result = query.getSingleResult();
  75. Long count = 0L;
  76.  
  77. if(result!=null){
  78. count = Long.valueOf( result.toString());
  79. }
  80.  
  81. return new Dto().put("count", count);
  82. }
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement