PageRenderTime 94ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/hcms-rest-api/src/main/java/com/abminvestama/hcms/rest/api/dto/response/CaStlHdrResponseWrapper.java

https://gitlab.com/baihaki/hcms-sap
Java | 421 lines | 337 code | 69 blank | 15 comment | 34 complexity | d29dc176d7fff0d19e124a5b436975f8 MD5 | raw file
  1. package com.abminvestama.hcms.rest.api.dto.response;
  2. import java.text.DateFormat;
  3. import java.text.SimpleDateFormat;
  4. import java.util.ArrayList;
  5. import java.util.List;
  6. import org.apache.commons.lang3.StringUtils;
  7. import org.springframework.hateoas.ResourceSupport;
  8. import com.abminvestama.hcms.core.model.constant.CaAdvanceCode;
  9. import com.abminvestama.hcms.core.model.constant.SettlementCASStatus;
  10. import com.abminvestama.hcms.core.model.constant.SettlementProcess;
  11. import com.abminvestama.hcms.core.model.entity.CaStlDtl;
  12. import com.abminvestama.hcms.core.model.entity.CaStlHdr;
  13. import com.abminvestama.hcms.core.model.entity.TrxApprovalProcess;
  14. import com.fasterxml.jackson.annotation.JsonInclude;
  15. import com.fasterxml.jackson.annotation.JsonInclude.Include;
  16. import com.fasterxml.jackson.annotation.JsonProperty;
  17. /**
  18. *
  19. * @since 1.0.0
  20. * @version 1.0.0
  21. * @author wijanarko (wijanarko777@gmx.com)
  22. * <br><br>
  23. * <table>
  24. * <tr><td><b>Version</td><td><b>Author</td><td><b>Description</td></tr>
  25. * <tr><td>1.0.0</td><td>Wijanarko</td><td>Development release</td></tr>
  26. * </table>
  27. *
  28. */
  29. @JsonInclude(Include.NON_NULL)
  30. public class CaStlHdrResponseWrapper extends ResourceSupport {
  31. private String reqNo;
  32. private String tcaNo;
  33. private String docNo;
  34. private String docNo2;
  35. private Long pernr;
  36. private Double totalAmount;
  37. private Double diffAmount;
  38. private String currency;
  39. private String casStatus;
  40. private String casStatusTxt;
  41. private String createdAt;
  42. private String createdByFullname;
  43. private String updatedAt;
  44. private String updatedByFullname;
  45. private Integer process;
  46. private String status;
  47. private String notes;
  48. private String bukrs;
  49. private Double refundAmount;
  50. private Double claimAmount;
  51. private String lastSync;
  52. private String sapMessage;
  53. private String reason;
  54. private String advanceCode;
  55. private String advanceCodeTxt;
  56. private String attachment1Filename;
  57. private ArrayData<CaStlDtlResponseWrapper> detail;
  58. private ArrayData<TrxApprovalProcessResponseWrapper> approvalDetail;
  59. private CaStlHdrResponseWrapper() {}
  60. public CaStlHdrResponseWrapper(CaStlHdr stlHdr) {
  61. if (stlHdr == null) {
  62. new CaStlHdrResponseWrapper();
  63. }
  64. else {
  65. // SETTLEMENT DETAILS
  66. ArrayData<CaStlDtlResponseWrapper> bunchOfCaStlDtl = new ArrayData<>();
  67. APIResponseWrapper<ArrayData<CaStlDtlResponseWrapper>> response = new APIResponseWrapper<>();
  68. response.setData(bunchOfCaStlDtl);
  69. List<CaStlDtlResponseWrapper> records = new ArrayList<>();
  70. if (stlHdr.getStlDetail() != null && stlHdr.getStlDetail().size()>0) {
  71. List<CaStlDtl> stlDtl = stlHdr.getStlDetail();
  72. for (int i = 0; i < stlDtl.size(); i++) {
  73. records.add(new CaStlDtlResponseWrapper(stlDtl.get(i)));
  74. }
  75. }
  76. bunchOfCaStlDtl.setItems(records.toArray(new CaStlDtlResponseWrapper[records.size()]));
  77. // APPROVAL DETAILS
  78. ArrayData<TrxApprovalProcessResponseWrapper> bunchOfApprovalDtl = new ArrayData<>();
  79. APIResponseWrapper<ArrayData<TrxApprovalProcessResponseWrapper>> approvalResponse = new APIResponseWrapper<>();
  80. approvalResponse.setData(bunchOfApprovalDtl);
  81. List<TrxApprovalProcessResponseWrapper> approvalRecords = new ArrayList<>();
  82. if (stlHdr.getApprovalDetail() != null && stlHdr.getApprovalDetail().size()>0) {
  83. List<TrxApprovalProcess> item = stlHdr.getApprovalDetail();
  84. for (int i = 0; i < item.size(); i++) {
  85. approvalRecords.add(new TrxApprovalProcessResponseWrapper(item.get(i)));
  86. }
  87. }
  88. bunchOfApprovalDtl.setItems(approvalRecords.toArray(new TrxApprovalProcessResponseWrapper[approvalRecords.size()]));
  89. DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  90. String settlementStatus = "";
  91. for (SettlementProcess item : SettlementProcess.values()) {
  92. if (stlHdr.getProcess().intValue() == item.val) {
  93. settlementStatus = item.name().replace("_", " ");
  94. break;
  95. }
  96. }
  97. // SETTLEMENT HEADER
  98. this
  99. .setReqNo(stlHdr.getReqNo() != null ? stlHdr.getReqNo() : StringUtils.EMPTY)
  100. .setTcaNo(stlHdr.getTcaNo() != null ? stlHdr.getTcaNo().getReqNo() : StringUtils.EMPTY)
  101. .setDocNo(stlHdr.getDocNo() != null ? stlHdr.getDocNo() : StringUtils.EMPTY)
  102. .setDocNo2(stlHdr.getDocNo2() != null ? stlHdr.getDocNo2() : StringUtils.EMPTY)
  103. .setPernr(stlHdr.getPernr() != null ? stlHdr.getPernr() : null)
  104. .setTotalAmount(stlHdr.getTotalAmount() != null ? stlHdr.getTotalAmount() : 0)
  105. .setDiffAmount(stlHdr.getDiffAmount() != null ? stlHdr.getDiffAmount() : 0)
  106. .setCurrency(StringUtils.defaultString(stlHdr.getCurrency(), StringUtils.EMPTY))
  107. .setCasStatus(StringUtils.defaultString(stlHdr.getCasStatus(), StringUtils.EMPTY))
  108. .setCasStatusTxt(SettlementCASStatus.valueOf(stlHdr.getCasStatus()).description)
  109. .setCreatedAt(stlHdr.getCreatedAt() != null ? df.format(stlHdr.getCreatedAt()) : StringUtils.EMPTY)
  110. .setCreatedByFullname(stlHdr.getCreatedBy() != null ? stlHdr.getCreatedBy().getEmployee().getEname() : StringUtils.EMPTY)
  111. .setUpdatedAt(stlHdr.getUpdatedAt() != null ? df.format(stlHdr.getUpdatedAt()) : StringUtils.EMPTY )
  112. .setUpdatedByFullname(stlHdr.getUpdatedBy() != null ? stlHdr.getUpdatedBy().getEmployee().getEname() : StringUtils.EMPTY)
  113. .setProcess(stlHdr.getProcess())
  114. .setStatus(settlementStatus)
  115. .setNotes(stlHdr.getNotes() != null ? stlHdr.getNotes() : StringUtils.EMPTY)
  116. .setBukrs(stlHdr.getBukrs() != null ? stlHdr.getBukrs().getBukrs() : StringUtils.EMPTY)
  117. .setRefundAmount(stlHdr.getRefundAmount() != null ? stlHdr.getRefundAmount() : 0)
  118. .setClaimAmount(stlHdr.getClaimAmount() != null ? stlHdr.getClaimAmount() : 0)
  119. .setLastSync(stlHdr.getLastSync() != null ? df.format(stlHdr.getLastSync()) : StringUtils.EMPTY)
  120. .setSapMessage(stlHdr.getNotes() != null ? stlHdr.getNotes() : StringUtils.EMPTY)
  121. .setReason(stlHdr.getReason() != null ? stlHdr.getReason() : StringUtils.EMPTY)
  122. .setAdvanceCode(stlHdr.getTcaNo() != null ? stlHdr.getTcaNo().getAdvanceCode() : "")
  123. .setAdvanceCodeTxt(stlHdr.getTcaNo() != null ? CaAdvanceCode.valueOf(stlHdr.getTcaNo().getAdvanceCode()).description : "")
  124. .setAttachment1Filename(StringUtils.defaultString(stlHdr.getAttachment(), StringUtils.EMPTY))
  125. .setDetail(bunchOfCaStlDtl) // SETTLEMENT DETAILS
  126. .setApprovalDetail(bunchOfApprovalDtl) // APPROVAL DETAILS
  127. ;
  128. }
  129. }
  130. @JsonProperty("req_no")
  131. public String getReqNo() {
  132. return reqNo;
  133. }
  134. public CaStlHdrResponseWrapper setReqNo(String reqNo) {
  135. this.reqNo = reqNo;
  136. return this;
  137. }
  138. @JsonProperty("tca_no")
  139. public String getTcaNo() {
  140. return tcaNo;
  141. }
  142. public CaStlHdrResponseWrapper setTcaNo(String tcaNo) {
  143. this.tcaNo = tcaNo;
  144. return this;
  145. }
  146. @JsonProperty("doc_no")
  147. public String getDocNo() {
  148. return docNo;
  149. }
  150. public CaStlHdrResponseWrapper setDocNo(String docNo) {
  151. this.docNo = docNo;
  152. return this;
  153. }
  154. @JsonProperty("doc_no2")
  155. public String getDocNo2() {
  156. return docNo2;
  157. }
  158. public CaStlHdrResponseWrapper setDocNo2(String docNo2) {
  159. this.docNo2 = docNo2;
  160. return this;
  161. }
  162. @JsonProperty("pernr")
  163. public Long getPernr() {
  164. return pernr;
  165. }
  166. public CaStlHdrResponseWrapper setPernr(Long pernr) {
  167. this.pernr = pernr;
  168. return this;
  169. }
  170. @JsonProperty("total_amount")
  171. public Double getTotalAmount() {
  172. return totalAmount;
  173. }
  174. public CaStlHdrResponseWrapper setTotalAmount(Double totalAmount) {
  175. this.totalAmount = totalAmount;
  176. return this;
  177. }
  178. @JsonProperty("diff_amount")
  179. public Double getDiffAmount() {
  180. return diffAmount;
  181. }
  182. public CaStlHdrResponseWrapper setDiffAmount(Double diffAmount) {
  183. this.diffAmount = diffAmount;
  184. return this;
  185. }
  186. @JsonProperty("currency")
  187. public String getCurrency() {
  188. return currency;
  189. }
  190. public CaStlHdrResponseWrapper setCurrency(String currency) {
  191. this.currency = currency;
  192. return this;
  193. }
  194. @JsonProperty("cas_status")
  195. public String getCasStatus() {
  196. return casStatus;
  197. }
  198. public CaStlHdrResponseWrapper setCasStatus(String casStatus) {
  199. this.casStatus = casStatus;
  200. return this;
  201. }
  202. @JsonProperty("cas_status_txt")
  203. public String getCasStatusTxt() {
  204. return casStatusTxt;
  205. }
  206. public CaStlHdrResponseWrapper setCasStatusTxt(String casStatusTxt) {
  207. this.casStatusTxt = casStatusTxt;
  208. return this;
  209. }
  210. @JsonProperty("created_at")
  211. public String getCreatedAt() {
  212. return createdAt;
  213. }
  214. public CaStlHdrResponseWrapper setCreatedAt(String createdAt) {
  215. this.createdAt = createdAt;
  216. return this;
  217. }
  218. @JsonProperty("created_by_fullname")
  219. public String getCreatedByFullname() {
  220. return createdByFullname;
  221. }
  222. public CaStlHdrResponseWrapper setCreatedByFullname(String createdByFullname) {
  223. this.createdByFullname = createdByFullname;
  224. return this;
  225. }
  226. @JsonProperty("updated_at")
  227. public String getUpdatedAt() {
  228. return updatedAt;
  229. }
  230. public CaStlHdrResponseWrapper setUpdatedAt(String updatedAt) {
  231. this.updatedAt = updatedAt;
  232. return this;
  233. }
  234. @JsonProperty("updated_by_fullname")
  235. public String getUpdatedByFullname() {
  236. return updatedByFullname;
  237. }
  238. public CaStlHdrResponseWrapper setUpdatedByFullname(String updatedByFullname) {
  239. this.updatedByFullname = updatedByFullname;
  240. return this;
  241. }
  242. @JsonProperty("process")
  243. public Integer getProcess() {
  244. return process;
  245. }
  246. public CaStlHdrResponseWrapper setProcess(Integer process) {
  247. this.process = process;
  248. return this;
  249. }
  250. @JsonProperty("status")
  251. public String getStatus() {
  252. return status;
  253. }
  254. public CaStlHdrResponseWrapper setStatus(String status) {
  255. this.status = status;
  256. return this;
  257. }
  258. @JsonProperty("notes")
  259. public String getNotes() {
  260. return notes;
  261. }
  262. public CaStlHdrResponseWrapper setNotes(String notes) {
  263. this.notes = notes;
  264. return this;
  265. }
  266. @JsonProperty("bukrs")
  267. public String getBukrs() {
  268. return bukrs;
  269. }
  270. public CaStlHdrResponseWrapper setBukrs(String bukrs) {
  271. this.bukrs = bukrs;
  272. return this;
  273. }
  274. @JsonProperty("refund_amount")
  275. public Double getRefundAmount() {
  276. return refundAmount;
  277. }
  278. public CaStlHdrResponseWrapper setRefundAmount(Double refundAmount) {
  279. this.refundAmount = refundAmount;
  280. return this;
  281. }
  282. @JsonProperty("claim_amount")
  283. public Double getClaimAmount() {
  284. return claimAmount;
  285. }
  286. public CaStlHdrResponseWrapper setClaimAmount(Double claimAmount) {
  287. this.claimAmount = claimAmount;
  288. return this;
  289. }
  290. @JsonProperty("last_sync")
  291. public String getLastSync() {
  292. return lastSync;
  293. }
  294. public CaStlHdrResponseWrapper setLastSync(String lastSync) {
  295. this.lastSync = lastSync;
  296. return this;
  297. }
  298. @JsonProperty("sap_message")
  299. public String getSapMessage() {
  300. return sapMessage;
  301. }
  302. public CaStlHdrResponseWrapper setSapMessage(String sapMessage) {
  303. this.sapMessage = sapMessage;
  304. return this;
  305. }
  306. @JsonProperty("reason")
  307. public String getReason() {
  308. return reason;
  309. }
  310. public CaStlHdrResponseWrapper setReason(String reason) {
  311. this.reason = reason;
  312. return this;
  313. }
  314. @JsonProperty("advancecode")
  315. public String getAdvanceCode() {
  316. return advanceCode;
  317. }
  318. public CaStlHdrResponseWrapper setAdvanceCode(String advanceCode) {
  319. this.advanceCode = advanceCode;
  320. return this;
  321. }
  322. @JsonProperty("attachment1_filename")
  323. public String getAttachment1Filename() {
  324. return attachment1Filename;
  325. }
  326. public CaStlHdrResponseWrapper setAttachment1Filename(String attachment1Filename) {
  327. this.attachment1Filename = attachment1Filename;
  328. return this;
  329. }
  330. @JsonProperty("advancecodetxt")
  331. public String getAdvanceCodeTxt() {
  332. return advanceCodeTxt;
  333. }
  334. public CaStlHdrResponseWrapper setAdvanceCodeTxt(String advanceCodeTxt) {
  335. this.advanceCodeTxt = advanceCodeTxt;
  336. return this;
  337. }
  338. public ArrayData<CaStlDtlResponseWrapper> getDetail() {
  339. return detail;
  340. }
  341. public CaStlHdrResponseWrapper setDetail(ArrayData<CaStlDtlResponseWrapper> detail) {
  342. this.detail = detail;
  343. return this;
  344. }
  345. public ArrayData<TrxApprovalProcessResponseWrapper> getApprovalDetail() {
  346. return approvalDetail;
  347. }
  348. public CaStlHdrResponseWrapper setApprovalDetail(ArrayData<TrxApprovalProcessResponseWrapper> approvalDetail) {
  349. this.approvalDetail = approvalDetail;
  350. return this;
  351. }
  352. }