Advertisement
Guest User

BT UnsubmitHandoverInvoiceARBack

a guest
Jan 23rd, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. package org.jleaf.erp.fin.bo.invoicear;
  2.  
  3.  
  4. import org.jleaf.erp.fin.FinanceConstantsForSasa;
  5. import org.jleaf.erp.fin.FinanceExceptionConstantsForSasa;
  6. import org.jleaf.erp.fin.dao.HandoverInvoiceArDao;
  7. import org.jleaf.erp.fin.entity.HandoverInvoiceAr;
  8.  
  9. import org.jleaf.common.CommonExceptionConstants;
  10. import org.jleaf.core.BusinessFunction;
  11. import org.jleaf.core.BusinessTransaction;
  12. import org.jleaf.core.CoreException;
  13. import org.jleaf.core.DefaultBusinessTransaction;
  14. import org.jleaf.core.Dto;
  15. import org.jleaf.core.annotation.ErrorList;
  16. import org.jleaf.core.annotation.Info;
  17. import org.jleaf.core.annotation.InfoIn;
  18. import org.jleaf.core.annotation.InfoOut;
  19. import org.jleaf.util.GsonUtil;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.beans.factory.annotation.Qualifier;
  22. import org.springframework.stereotype.Service;
  23.  
  24. //@formatter:off
  25. @Service
  26. @InfoIn(value = {
  27. @Info(name = "id", description = "Handover Invoice Ar back id", type = Long.class),
  28. @Info(name = "version", description = "Handover Invoice Ar back version", type = Long.class),
  29. @Info(name = "workflowStatus", description = "workflow status", type = String.class),
  30. @Info(name = "tenantLoginId", description = "tenant login id", type = Long.class),
  31. @Info(name = "userLoginId", description = "user login id", type = Long.class),
  32. @Info(name = "roleLoginId", description = "role login id", type = Long.class),
  33. @Info(name = "datetime", description = "datetime", type = String.class)
  34. })
  35. @InfoOut(value = {
  36. @Info(name = "id", description = "Handover Invoice Ar Back id", type = Long.class)
  37. })
  38. @ErrorList(errorKeys = {
  39. CommonExceptionConstants.DATA_CANT_CHANGE_CAUSE_TENANT
  40. })
  41. //@formatter:on
  42. public class UnsubmitHandoverInvoiceARBack extends DefaultBusinessTransaction implements BusinessTransaction {
  43.  
  44. @Autowired
  45. HandoverInvoiceArDao handoverInvoiceArDao;
  46.  
  47. @Autowired
  48. @Qualifier("findHandoverInvoiceArById")
  49. BusinessFunction findHandoverInvoiceArById;
  50.  
  51. @Autowired
  52. @Qualifier("valTenantLoginCanUse")
  53. BusinessFunction valTenantLoginCanUse;
  54.  
  55. @Override
  56. public String getDescription() {
  57. return "unsubmit handover invoice ar back";
  58. }
  59.  
  60. @Override
  61. public Dto prepare(Dto inputDto, Dto originalDto) throws Exception {
  62. // Validation tenant login id can be use
  63. Dto loginDto = new Dto();
  64. loginDto.put("tenantLoginId", inputDto.getLong("tenantLoginId"));
  65. loginDto.put("userLoginId", inputDto.getLong("userLoginId"));
  66. loginDto.put("roleLoginId", inputDto.getLong("roleLoginId"));
  67. valTenantLoginCanUse.execute(loginDto);
  68.  
  69. Dto handoverInvoiceArDto = findHandoverInvoiceArById.execute(inputDto);
  70.  
  71. if (!handoverInvoiceArDto.getLong("tenantId").equals(inputDto.getLong("tenantLoginId"))) {
  72. throw new CoreException(CommonExceptionConstants.DATA_CANT_CHANGE_CAUSE_TENANT, "Handover Invoice Ar Back");
  73. }
  74.  
  75. handoverInvoiceArDto.put("workflowStatus", inputDto.getString("workflowStatus"));
  76. handoverInvoiceArDto.put("statusDoc", FinanceConstantsForSasa.DRAFT_TRANSACTION);
  77. handoverInvoiceArDto.put("version", inputDto.getLong("version"));
  78.  
  79. this.prepareUpdateAudit(handoverInvoiceArDto, inputDto.getLong("userLoginId"), inputDto.getString("datetime"));
  80.  
  81. inputDto.put("handoverInvoiceArDto", handoverInvoiceArDto);
  82.  
  83. return null;
  84. }
  85.  
  86. @Override
  87. public Dto process(Dto inputDto, Dto originalDto) throws Exception {
  88. Dto handoverInvoiceArDto = inputDto.getDto("handoverInvoiceArDto");
  89. HandoverInvoiceAr handoverInvoiceAr = GsonUtil.fromDto(handoverInvoiceArDto, HandoverInvoiceAr.class);
  90. handoverInvoiceAr = handoverInvoiceArDao.merge(handoverInvoiceArDto.getLong("id"), handoverInvoiceAr);
  91.  
  92. return new Dto().put("id", handoverInvoiceAr.getId());
  93. }
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement