From c308171de5d8a2a7d3ba197afaa2ecd6f4c45708 Mon Sep 17 00:00:00 2001 From: Narayanan Madaswamy Date: Wed, 12 Aug 2026 20:00:22 +0530 Subject: [PATCH] Migration of Process Panel Done --- .../main/java/lib/models/CutoffPending.java | 13 + .../java/lib/models/CutoffPendingRecord.java | 20 ++ .../WEB-INF/app/edp/cutoff/cutoff.jsp | 4 +- .../WEB-INF/app/edp/cutoff/cutoffpending.jsp | 98 ++++++++ .../WEB-INF/app/edp/tools/edpprocesspanel.jsp | 168 ------------- .../WebContent/css/cutoff-workflows-v1.css | 59 +++++ .../js/edp/cutoff/cutoff-pending.js | 61 +++++ .../cutoff/controller/CutOffController.java | 18 ++ .../nimble/edp/tools/controller/EDPTools.java | 45 ---- .../nimble/edp/tools/model/CutOffPRecord.java | 89 ------- .../nimble/edp/tools/model/CutoffPending.java | 226 ------------------ .../matrix/services/edp/CutoffService.java | 61 ++++- .../nimble/RoleVisibleBatchMigrationTest.java | 12 +- .../resources/db/012_cutoff_workflows.sql | 6 +- .../db/015_remove_migrated_query_views.sql | 6 +- .../main/resources/db/022_cutoff_pending.sql | 18 ++ .../db/023_telesheet_zero_visit_counts.sql | 13 + .../024_telesheet_optional_report_format.sql | 13 + .../db/025_enforce_telesheet_eligibility.sql | 16 ++ .../db/026_send_to_operation_idempotency.sql | 7 + latest_queries.qry | 10 +- 21 files changed, 417 insertions(+), 546 deletions(-) create mode 100644 cygnus-lib/src/main/java/lib/models/CutoffPending.java create mode 100644 cygnus-lib/src/main/java/lib/models/CutoffPendingRecord.java create mode 100644 cygnus-onprem-app/build/WebContent/WEB-INF/app/edp/cutoff/cutoffpending.jsp delete mode 100644 cygnus-onprem-app/build/WebContent/WEB-INF/app/edp/tools/edpprocesspanel.jsp create mode 100644 cygnus-onprem-app/build/WebContent/js/edp/cutoff/cutoff-pending.js delete mode 100644 cygnus-onprem-app/src/main/java/matrix/nimble/edp/tools/model/CutOffPRecord.java delete mode 100644 cygnus-onprem-app/src/main/java/matrix/nimble/edp/tools/model/CutoffPending.java create mode 100644 cygnus-onprem-db/src/main/resources/db/022_cutoff_pending.sql create mode 100644 cygnus-onprem-db/src/main/resources/db/023_telesheet_zero_visit_counts.sql create mode 100644 cygnus-onprem-db/src/main/resources/db/024_telesheet_optional_report_format.sql create mode 100644 cygnus-onprem-db/src/main/resources/db/025_enforce_telesheet_eligibility.sql create mode 100644 cygnus-onprem-db/src/main/resources/db/026_send_to_operation_idempotency.sql diff --git a/cygnus-lib/src/main/java/lib/models/CutoffPending.java b/cygnus-lib/src/main/java/lib/models/CutoffPending.java new file mode 100644 index 0000000..2cf2dcb --- /dev/null +++ b/cygnus-lib/src/main/java/lib/models/CutoffPending.java @@ -0,0 +1,13 @@ +package lib.models; + +import java.util.ArrayList; +import java.util.List; +import lombok.Data; + +@Data +public class CutoffPending { + private List pendingList = new ArrayList<>(); + private String errMsg; + private String errCode = "1010"; + private boolean processFlag; +} diff --git a/cygnus-lib/src/main/java/lib/models/CutoffPendingRecord.java b/cygnus-lib/src/main/java/lib/models/CutoffPendingRecord.java new file mode 100644 index 0000000..2422e04 --- /dev/null +++ b/cygnus-lib/src/main/java/lib/models/CutoffPendingRecord.java @@ -0,0 +1,20 @@ +package lib.models; + +import java.util.ArrayList; +import java.util.List; +import lombok.Data; + +@Data +public class CutoffPendingRecord { + private List sublist = new ArrayList<>(); + private String cutoffTime; + private int total; + private String uuid; + private String portfolio; + private String customerName; + private boolean allocation; + private boolean telesheet; + private boolean earlier; + private boolean negative; + private boolean cutoff; +} diff --git a/cygnus-onprem-app/build/WebContent/WEB-INF/app/edp/cutoff/cutoff.jsp b/cygnus-onprem-app/build/WebContent/WEB-INF/app/edp/cutoff/cutoff.jsp index 568c45b..812ab72 100644 --- a/cygnus-onprem-app/build/WebContent/WEB-INF/app/edp/cutoff/cutoff.jsp +++ b/cygnus-onprem-app/build/WebContent/WEB-INF/app/edp/cutoff/cutoff.jsp @@ -92,7 +92,9 @@ - + diff --git a/cygnus-onprem-app/build/WebContent/WEB-INF/app/edp/cutoff/cutoffpending.jsp b/cygnus-onprem-app/build/WebContent/WEB-INF/app/edp/cutoff/cutoffpending.jsp new file mode 100644 index 0000000..a9a5c01 --- /dev/null +++ b/cygnus-onprem-app/build/WebContent/WEB-INF/app/edp/cutoff/cutoffpending.jsp @@ -0,0 +1,98 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" session="true" %> +<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%> +<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> + + + + +Cygnus 1.0 | Cut-Off Pending + + + + + + + + + + + +
+<%@ include file="/WEB-INF/app/fragments/app-shell-header.jspf" %> +
+ + +
+
+ + Cut-Off Pending + +
+
+ + + + + + + + + + + + + + + + + + + + + + +
S.NoCut-Off TimeAllocationTele-SheetEarlierNegativeCut-Off
${parentStatus.count} + + + +
No pending cut-offs found.
+
+
+ +
+
+
+
+
+ + + diff --git a/cygnus-onprem-app/build/WebContent/WEB-INF/app/edp/tools/edpprocesspanel.jsp b/cygnus-onprem-app/build/WebContent/WEB-INF/app/edp/tools/edpprocesspanel.jsp deleted file mode 100644 index 4f59140..0000000 --- a/cygnus-onprem-app/build/WebContent/WEB-INF/app/edp/tools/edpprocesspanel.jsp +++ /dev/null @@ -1,168 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> -<%@page language="java" session="true" %> -<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%> -<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %> - - - - - - - - - - - - - - - - - - -Cygnus 1.0 | Cutoff Pending - - - - - - - - - - - - - -
-<%@ include file="/WEB-INF/app/fragments/app-shell-header.jspf" %> -<%-- Shared shell owns ${Sessvals.menuHtml}. --%> -
- - -
- -
- - Cut-Off Pending - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
S.NoCutoff TimeAllocationTelesheetEarlierNegativeCutOff
${mystatus.count} - - - ${record.cutofftime} (${record.total}) - - - - - - - - - - -
-
-
- - -
- - -
-
- - - - - - - - - - diff --git a/cygnus-onprem-app/build/WebContent/css/cutoff-workflows-v1.css b/cygnus-onprem-app/build/WebContent/css/cutoff-workflows-v1.css index 24ff01e..302d72a 100644 --- a/cygnus-onprem-app/build/WebContent/css/cutoff-workflows-v1.css +++ b/cygnus-onprem-app/build/WebContent/css/cutoff-workflows-v1.css @@ -201,3 +201,62 @@ width: calc(100% - 12px) !important; } } + +.matrix-cutoff-pending .matrix-icon-button { + margin-left: auto !important; + background: transparent; +} + +.matrix-cutoff-pending .matrix-icon-button img { + width: 16px; + height: 16px; + display: block; +} + +.matrix-cutoff-pending .matrix-parent-row td:not(:nth-child(2)), +.matrix-cutoff-pending .matrix-nested-table td:not(:nth-child(2)):not(:nth-child(3)) { + text-align: center; +} + +.matrix-cutoff-pending .matrix-row-toggle { + display: inline-flex; + align-items: center; + gap: 7px; + padding: 0; + border: 0; + color: #245a91; + background: transparent; + font: inherit; + font-weight: 600; + cursor: pointer; +} + +.matrix-cutoff-pending .matrix-row-toggle__chevron { + width: 12px; + color: #516c82; + font-size: 9px; +} + +.matrix-cutoff-pending .matrix-expanded-row > td { + padding: 8px 10px !important; + background: #dfeaf3 !important; +} + +.matrix-cutoff-pending .matrix-nested-table { + width: 100% !important; + margin: 0 !important; + border: 1px solid #9fb2c3 !important; + background: #fff !important; + box-shadow: 0 2px 6px rgba(31, 52, 72, .12); +} + +.matrix-cutoff-pending .matrix-nested-table tbody tr:nth-child(even) td { + background: #f1f6fa !important; +} + +.matrix-cutoff-pending .matrix-empty-row { + padding: 18px !important; + text-align: center !important; + color: #65798a; + font-style: italic; +} diff --git a/cygnus-onprem-app/build/WebContent/js/edp/cutoff/cutoff-pending.js b/cygnus-onprem-app/build/WebContent/js/edp/cutoff/cutoff-pending.js new file mode 100644 index 0000000..f258525 --- /dev/null +++ b/cygnus-onprem-app/build/WebContent/js/edp/cutoff/cutoff-pending.js @@ -0,0 +1,61 @@ +(() => { + "use strict"; + + const form = document.getElementById("cutoffpending"); + if (!form) return; + + const submit = (endpoint) => { + form.action = endpoint; + form.target = "_self"; + form.submit(); + }; + + const parentRow = (element) => element.closest("tr[data-parent-index]"); + const children = (row) => form.querySelector(`tr[data-child-row="${row.dataset.parentIndex}"]`); + const childInputs = (row, field) => children(row)?.querySelectorAll(`[data-child-field="${field}"]`) || []; + const parentInput = (row, field) => row.querySelector(`[data-parent-field="${field}"]`); + const fields = ["allocation", "telesheet", "earlier", "negative", "cutoff"]; + + const syncParent = (row, field) => { + const inputs = [...childInputs(row, field)]; + parentInput(row, field).checked = inputs.length > 0 && inputs.every((input) => input.checked); + }; + + form.addEventListener("click", (event) => { + const action = event.target.closest("[data-action]")?.dataset.action; + if (action === "refresh") return submit("cutoffpending"); + if (action === "save") return submit("savecutoffpending"); + if (action !== "toggle") return; + const button = event.target.closest("[data-action='toggle']"); + const detail = children(parentRow(button)); + detail.hidden = !detail.hidden; + button.setAttribute("aria-expanded", String(!detail.hidden)); + button.querySelector(".matrix-row-toggle__chevron").textContent = detail.hidden ? "▶" : "▼"; + }); + + form.addEventListener("change", (event) => { + const parentField = event.target.dataset.parentField; + if (parentField) { + const row = parentRow(event.target); + const affected = parentField === "cutoff" ? fields : [parentField]; + affected.forEach((field) => { + parentInput(row, field).checked = event.target.checked; + childInputs(row, field).forEach((input) => { input.checked = event.target.checked; }); + }); + return; + } + const childField = event.target.dataset.childField; + if (!childField) return; + const detail = event.target.closest("tr[data-child-row]"); + const row = form.querySelector(`tr[data-parent-index="${detail.dataset.childRow}"]`); + if (childField === "cutoff") { + fields.forEach((field) => { + const input = event.target.closest("tr[data-child-index]").querySelector(`[data-child-field="${field}"]`); + input.checked = event.target.checked; + syncParent(row, field); + }); + } else { + syncParent(row, childField); + } + }); +})(); diff --git a/cygnus-onprem-app/src/main/java/matrix/nimble/edp/cutoff/controller/CutOffController.java b/cygnus-onprem-app/src/main/java/matrix/nimble/edp/cutoff/controller/CutOffController.java index 0067954..e57b74f 100644 --- a/cygnus-onprem-app/src/main/java/matrix/nimble/edp/cutoff/controller/CutOffController.java +++ b/cygnus-onprem-app/src/main/java/matrix/nimble/edp/cutoff/controller/CutOffController.java @@ -5,6 +5,7 @@ import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; import lib.models.Allocation; import lib.models.CutOffList; +import lib.models.CutoffPending; import lib.models.ReferenceSheet; import lib.models.SendToOperation; import lib.models.Telesheet; @@ -48,6 +49,23 @@ public class CutOffController extends AbstractAuthenticatedController { return "edp/cutoff/cutoff"; } + @RequestMapping(value = "cutoffpending", method = RequestMethod.POST) + public String cutoffPending(ModelMap model, HttpSession session, HttpServletResponse response) { + PageAuthorization auth = authorizePage("cutoffpending", model, session, response); + if (!auth.isGranted()) return auth.viewName(); + model.addAttribute("cutoffpending", cutoffService.loadCutoffPending(auth.session())); + return "edp/cutoff/cutoffpending"; + } + + @RequestMapping(value = "savecutoffpending", method = RequestMethod.POST) + public String saveCutoffPending(@ModelAttribute("cutoffpending") CutoffPending request, + ModelMap model, HttpSession session, HttpServletResponse response) { + PageAuthorization auth = authorizePage("cutoffpending", model, session, response); + if (!auth.isGranted()) return auth.viewName(); + model.addAttribute("cutoffpending", cutoffService.saveCutoffPending(auth.session(), request)); + return "edp/cutoff/cutoffpending"; + } + @RequestMapping(value = "allocation", method = RequestMethod.POST) public String allocation(ModelMap model, HttpSession session, HttpServletResponse response) { PageAuthorization auth = authorizePage("allocation", model, session, response); diff --git a/cygnus-onprem-app/src/main/java/matrix/nimble/edp/tools/controller/EDPTools.java b/cygnus-onprem-app/src/main/java/matrix/nimble/edp/tools/controller/EDPTools.java index c0a2ca2..e1f69da 100644 --- a/cygnus-onprem-app/src/main/java/matrix/nimble/edp/tools/controller/EDPTools.java +++ b/cygnus-onprem-app/src/main/java/matrix/nimble/edp/tools/controller/EDPTools.java @@ -8,7 +8,6 @@ import jakarta.servlet.http.HttpSession; import matrix.nimble.edp.tools.model.DelCaseGrid; import matrix.nimble.edp.tools.model.EdpToolsHandler; import matrix.nimble.edp.tools.model.AddEditProduct; -import matrix.nimble.edp.tools.model.CutoffPending; import matrix.nimble.model.Session; import matrix.nimble.utilities.GlobalClass; @@ -28,50 +27,6 @@ import org.springframework.web.bind.annotation.SessionAttributes; @SessionAttributes({"Sessvals"}) public class EDPTools { - @RequestMapping(value="cutoffpending",method=RequestMethod.POST ) - public String PendingProcess(ModelMap model,HttpServletRequest request,@ModelAttribute(value="Sessvals") Session Sessvals,HttpSession session) - { - CutoffPending PList=new CutoffPending(); - PList.setErrCode("1010"); - String UUID=GlobalClass.GenerateUUID(); - session.setAttribute("UUID", UUID); - PList.setSessUUID(UUID); - model.addAttribute("cutoffpending", PList.getPList(Sessvals.getCompanyID(), Sessvals.getBranchID(), Sessvals.getUserID())); - model.addAttribute("Sessvals",Sessvals); - return "edp/tools/edpprocesspanel"; - } - @RequestMapping(value="savecutoffpending",method=RequestMethod.POST ) - public String SavePendingProcess(ModelMap model,HttpServletRequest request,@ModelAttribute(value="Sessvals") Session Sessvals,@ModelAttribute(value="cutoffpending") CutoffPending CPend,HttpSession session) - { - CPend.setErrCode("1010"); - if(session.getAttribute("UUID").toString().equals(CPend.getSessUUID())) - { - CPend.FinalizeCutoffPending(Sessvals.getUserID(),Sessvals.getCompanyID(), Sessvals.getBranchID(),CPend); - } - else - { - CPend.setProcessFlag(true); - CPend.setErrMsg(""); - } - if(CPend.isProcessFlag()) - { - CutoffPending PList=new CutoffPending(); - String UUID=GlobalClass.GenerateUUID(); - session.setAttribute("UUID", UUID); - PList.setSessUUID(UUID); - model.addAttribute("cutoffpending", PList.getPList(Sessvals.getCompanyID(), Sessvals.getBranchID(), Sessvals.getUserID())); - PList.setErrCode(CPend.getErrCode()); - PList.setErrMsg(CPend.getErrMsg()); - model.addAttribute("cutoffpending", PList); - model.addAttribute("Sessvals",Sessvals); - } - else - { - model.addAttribute("cutoffpending",CPend); - } - model.addAttribute("Sessvals",Sessvals); - return "edp/tools/edpprocesspanel"; - } @RequestMapping(value="delcutoffgrid",method=RequestMethod.POST ) public String OpenEditGrid(ModelMap model,HttpServletRequest request,@ModelAttribute(value="Sessvals") Session Sessvals) { diff --git a/cygnus-onprem-app/src/main/java/matrix/nimble/edp/tools/model/CutOffPRecord.java b/cygnus-onprem-app/src/main/java/matrix/nimble/edp/tools/model/CutOffPRecord.java deleted file mode 100644 index 5aec958..0000000 --- a/cygnus-onprem-app/src/main/java/matrix/nimble/edp/tools/model/CutOffPRecord.java +++ /dev/null @@ -1,89 +0,0 @@ -package matrix.nimble.edp.tools.model; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.collections.FactoryUtils; -import org.apache.commons.collections.list.LazyList; - -public class CutOffPRecord -{ - private List pendingsublist = LazyList.decorate(new ArrayList(),FactoryUtils.instantiateFactory(CutOffPRecord.class)); - private String portfolio; - private String customername; - private String cutofftime; - private int total; - private String uuid; - private boolean allocation; - private boolean telesheet; - private boolean earlier; - private boolean negative; - private boolean cutoff; - - public String getPortfolio() { - return portfolio; - } - public void setPortfolio(String portfolio) { - this.portfolio = portfolio; - } - public String getCustomername() { - return customername; - } - public void setCustomername(String customername) { - this.customername = customername; - } - public List getPendingsublist() { - return pendingsublist; - } - public void setPendingsublist(List pendingsublist) { - this.pendingsublist = pendingsublist; - } - public String getCutofftime() { - return cutofftime; - } - public void setCutofftime(String cutofftime) { - this.cutofftime = cutofftime; - } - public int getTotal() { - return total; - } - public void setTotal(int total) { - this.total = total; - } - public String getUuid() { - return uuid; - } - public void setUuid(String uuid) { - this.uuid = uuid; - } - public boolean isAllocation() { - return allocation; - } - public void setAllocation(boolean allocation) { - this.allocation = allocation; - } - public boolean isTelesheet() { - return telesheet; - } - public void setTelesheet(boolean telesheet) { - this.telesheet = telesheet; - } - public boolean isEarlier() { - return earlier; - } - public void setEarlier(boolean earlier) { - this.earlier = earlier; - } - public boolean isNegative(){ - return negative; - } - public void setNegative(boolean negative) { - this.negative = negative; - } - public boolean isCutoff(){ - return cutoff; - } - public void setCutoff(boolean cutoff) { - this.cutoff = cutoff; - } -} diff --git a/cygnus-onprem-app/src/main/java/matrix/nimble/edp/tools/model/CutoffPending.java b/cygnus-onprem-app/src/main/java/matrix/nimble/edp/tools/model/CutoffPending.java deleted file mode 100644 index 36ae8ca..0000000 --- a/cygnus-onprem-app/src/main/java/matrix/nimble/edp/tools/model/CutoffPending.java +++ /dev/null @@ -1,226 +0,0 @@ -package matrix.nimble.edp.tools.model; - -import java.util.ArrayList; -import java.util.List; - - - -import matrix.nimble.edp.cutoff.model.Allocation; -import matrix.nimble.edp.cutoff.model.CutOffRecord; -import matrix.nimble.edp.cutoff.model.Telesheet; -import matrix.nimble.edp.output.model.ReportOutput; -import matrix.nimble.utilities.DBFunctions; -import matrix.nimble.utilities.GlobalClass; -import matrix.nimble.utilities.StringFunctions; - - -import org.apache.commons.collections.FactoryUtils; -import org.apache.commons.collections.list.LazyList; - -public class CutoffPending -{ - private List pendinglist = LazyList.decorate(new ArrayList(),FactoryUtils.instantiateFactory(CutOffPRecord.class)); - - private String ErrMsg; - private String ErrDesc; - private String ErrCode; - private String SessUUID; - private boolean ProcessFlag; - - public List getPendinglist() - { - return pendinglist; - } - public void setPendinglist(List pendinglist) - { - this.pendinglist = pendinglist; - } - public String getErrMsg() - { - return ErrMsg; - } - public void setErrMsg(String errMsg) - { - ErrMsg = errMsg; - } - public String getErrDesc() - { - return ErrDesc; - } - public void setErrDesc(String errDesc) - { - ErrDesc = errDesc; - } - public String getErrCode() - { - return ErrCode; - } - public void setErrCode(String errCode) - { - ErrCode = errCode; - } - public String getSessUUID() - { - return SessUUID; - } - public void setSessUUID(String sessUUID) - { - SessUUID = sessUUID; - } - public boolean isProcessFlag() - { - return ProcessFlag; - } - public void setProcessFlag(boolean processFlag) - { - ProcessFlag = processFlag; - } - - public CutoffPending getPList(String CompanyId,String BranchId,String UserId) - { - CutoffPending CPList=new CutoffPending(); - StringFunctions StrFunc=new StringFunctions(getErrCode()); - DBFunctions DBF=new DBFunctions(getErrCode()); - DBF.setProcessFlag(true); - String [] Vals=(CompanyId+GlobalClass.ColDelim+BranchId+GlobalClass.ColDelim).split(GlobalClass.ColDelim); - String ResultData=DBF.FetchRunQuery(49, Vals); //Generating list of portfolios those telesheet to be generated - String [] Vals1=(CompanyId+GlobalClass.ColDelim+BranchId+GlobalClass.ColDelim).split(GlobalClass.ColDelim); - String ResultData1=DBF.FetchRunQuery(50, Vals1); //Generating sublist records - - if(DBF.isProcessFlag()) - { - String [][] PListData=StrFunc.ConverTo2DArray(ResultData, GlobalClass.RowDelim, GlobalClass.ColDelim); - ArrayList Record=new ArrayList(); - for(int RecCount=0;RecCount SubRecord=new ArrayList(); - for(int ListCount=0;ListCount"; - } - } - } - if(TotEntityFailed <= 0) - { - CPend.setErrMsg(CPend.getErrCode()+"CPFAIL:Info:Cutoff Pending Successfully...
Total Success Entities ("+TotEntitySuccess+") Total Success Batches ("+TotBatchSuccess+")"); - } - else - { - msg="Total Failed Entities ("+TotEntityFailed+") Total Failed Batches ("+TotBatchFailed+")TypeUUID"+entityFailedMsg; - CPend.setErrMsg(CPend.getErrCode()+"CPFAIL:Error:"+msg+"
Cutoff Pending Failed
"); - } - } -} diff --git a/cygnus-onprem-app/src/main/java/matrix/services/edp/CutoffService.java b/cygnus-onprem-app/src/main/java/matrix/services/edp/CutoffService.java index 94c2ef2..9a95dff 100644 --- a/cygnus-onprem-app/src/main/java/matrix/services/edp/CutoffService.java +++ b/cygnus-onprem-app/src/main/java/matrix/services/edp/CutoffService.java @@ -11,6 +11,8 @@ import java.util.Map; import lib.models.Allocation; import lib.models.CutOffList; import lib.models.CutOffRecord; +import lib.models.CutoffPending; +import lib.models.CutoffPendingRecord; import lib.models.PhotoCases; import lib.models.ReferenceSheet; import lib.models.SendToOperation; @@ -61,6 +63,60 @@ public class CutoffService { return value; } + public CutoffPending loadCutoffPending(UserSession session) { + requireScope(session); + List detailRows = dbExecutor.query(50, + new Object[] {session.getCompanyId(), session.getBranchId()}); + Map> grouped = new LinkedHashMap<>(); + for (RowView row : detailRows) { + CutoffPendingRecord record = new CutoffPendingRecord(); + record.setUuid(text(row.get("uuid"))); + record.setPortfolio(text(row.get("portname"))); + record.setCustomerName(text(row.get("customername"))); + grouped.computeIfAbsent(text(row.get("cutoffon")), ignored -> new ArrayList<>()).add(record); + } + CutoffPending value = new CutoffPending(); + value.setPendingList(dbExecutor.query(49, + new Object[] {session.getCompanyId(), session.getBranchId()}).stream().map(row -> { + CutoffPendingRecord record = new CutoffPendingRecord(); + record.setCutoffTime(text(row.get("cutoffon"))); + record.setTotal(number(row, "total")); + record.setSublist(grouped.getOrDefault(record.getCutoffTime(), List.of())); + return record; + }).toList()); + return value; + } + + public CutoffPending saveCutoffPending(UserSession session, CutoffPending request) { + requireScope(session); + int changed = 0; + for (CutoffPendingRecord parent : safe(request.getPendingList())) { + if (parent.isCutoff()) { + changed += updatePending(session, parent, null, 1); + continue; + } + for (CutoffPendingRecord child : safe(parent.getSublist())) { + changed += updatePending(session, child, child.getUuid(), 0); + } + } + CutoffPending refreshed = loadCutoffPending(session); + refreshed.setProcessFlag(changed > 0); + refreshed.setErrMsg(changed > 0 + ? "1010CPDONE:Info:Cut-off pending records updated successfully." + : "1010CPNONE:Error:Please select at least one pending action."); + return refreshed; + } + + private int updatePending(UserSession session, CutoffPendingRecord record, String uuid, int mode) { + if (!record.isAllocation() && !record.isTelesheet() && !record.isEarlier() + && !record.isNegative() && !record.isCutoff()) return 0; + return dbExecutor.update(51, new Object[] { + flag01(record.isAllocation()), flag01(record.isTelesheet()), + flag01(record.isEarlier()), flag01(record.isNegative()), flag01(record.isCutoff()), + mode, uuid, mode, record.getCutoffTime(), session.getCompanyId(), session.getBranchId() + }); + } + public Allocation loadAllocation(UserSession session) { requireScope(session); dbExecutor.update(27, lockParameters(session)); @@ -250,7 +306,10 @@ public class CutoffService { record.setPortname(text(row.get("portname"))); record.setAllocation(booleanValue(row, "allocation")); record.setSms(booleanValue(row, "sms")); - record.setTelesheet(booleanValue(row, "telesheet")); + record.setTotrtv(number(row, "rtv")); + record.setTototv(number(row, "otv")); + record.setTelesheet((record.getTotrtv() > 0 || record.getTototv() > 0) + && booleanValue(row, "telesheet")); record.setEarlier(booleanValue(row, "earlier")); record.setNegative(booleanValue(row, "negative")); record.setIslocked(number(row, "islocked")); diff --git a/cygnus-onprem-app/src/test/java/matrix/nimble/RoleVisibleBatchMigrationTest.java b/cygnus-onprem-app/src/test/java/matrix/nimble/RoleVisibleBatchMigrationTest.java index e2e69c0..29dab5a 100644 --- a/cygnus-onprem-app/src/test/java/matrix/nimble/RoleVisibleBatchMigrationTest.java +++ b/cygnus-onprem-app/src/test/java/matrix/nimble/RoleVisibleBatchMigrationTest.java @@ -367,7 +367,7 @@ class RoleVisibleBatchMigrationTest { @Test void edpCutoffAndProductToolsUseResponsiveWorkspaceWithActionsPreserved() throws Exception { Path edpTools = Path.of("build/WebContent/WEB-INF/app/edp/tools"); - for (String page : List.of("delcutoffcases.jsp", "edpprocesspanel.jsp", "addproduct.jsp")) { + for (String page : List.of("delcutoffcases.jsp", "addproduct.jsp")) { String content = Files.readString(edpTools.resolve(page)); assertTrue(content.contains("matrix-shell matrix-tool-workspace"), page); assertTrue(content.contains("tool-workspace-v3.css"), page); @@ -381,10 +381,12 @@ class RoleVisibleBatchMigrationTest { assertTrue(deleteCutoff.contains("setHFList('casetable')")); assertTrue(deleteCutoff.contains("SubmitForm('deletecases','_parent','caseGrid')")); - String process = Files.readString(edpTools.resolve("edpprocesspanel.jsp")); - assertTrue(process.contains("ExpandList(this.id)")); - assertTrue(process.contains("checkUncheckList(")); - assertTrue(process.contains("SubmitForm('savecutoffpending','_parent','cutoffpending')")); + String process = Files.readString(Path.of( + "build/WebContent/WEB-INF/app/edp/cutoff/cutoffpending.jsp")); + assertTrue(process.contains("matrix-cutoff-pending")); + assertTrue(process.contains("matrix-nested-table")); + assertTrue(process.contains("data-action=\"save\"")); + assertTrue(process.contains("js/edp/cutoff/cutoff-pending.js")); String products = Files.readString(edpTools.resolve("addproduct.jsp")); assertTrue(products.contains("queueAction(this,${status.count},'remove')")); diff --git a/cygnus-onprem-db/src/main/resources/db/012_cutoff_workflows.sql b/cygnus-onprem-db/src/main/resources/db/012_cutoff_workflows.sql index 950a156..c15fa2e 100644 --- a/cygnus-onprem-db/src/main/resources/db/012_cutoff_workflows.sql +++ b/cygnus-onprem-db/src/main/resources/db/012_cutoff_workflows.sql @@ -23,10 +23,10 @@ UPDATE platform.application_query SET query_text= 'update!C0L!UPDATE main_operations mo SET islocked=?, lockedbyuser=? FROM main m WHERE m.case_id=mo.case_id AND m.isdeleted=0 AND mo.sdone=0 AND mo.cutoffby>0 AND (mo.islocked=0 OR mo.islocked=?) AND coalesce(mo.telesheetby,0)=0 AND m.company_id=? AND m.branch_id=? AND mo.telesheet=1', ismigrated=true WHERE query_id=31; UPDATE platform.application_query SET query_text= -'select!C0L!SELECT m.portfolio_id,p.portname||'' (''||count(*)||'')'' portname,sum(m.rtv) rtv,sum(m.otv) otv,sum(m.refv) refv,CASE WHEN mo.islocked<>? THEN 1 ELSE 0 END islocked,mo.telesheet,coalesce(mo.lockedbyuser,'''') lockedby,pf.tsformat outputformat,pf.tsfunction outputfunction FROM main m JOIN main_operations mo ON mo.case_id=m.case_id JOIN portfolio p ON p.portfolio_id=m.portfolio_id JOIN process_formats pf ON pf.portfolio_id=m.portfolio_id WHERE m.isdeleted=0 AND mo.sdone=0 AND coalesce(mo.telesheetby,0)=0 AND mo.cutoffby>0 AND m.company_id=? AND m.branch_id=? AND mo.telesheet=1 AND (m.rtv>0 OR m.otv>0) GROUP BY m.portfolio_id,p.portname,mo.islocked,mo.telesheet,mo.lockedbyuser,pf.tsformat,pf.tsfunction ORDER BY p.portname', ismigrated=true WHERE query_id=32; +'select!C0L!SELECT m.portfolio_id,p.portname||'' (''||count(*)||'')'' portname,sum(m.rtv) rtv,sum(m.otv) otv,sum(m.refv) refv,CASE WHEN mo.islocked<>? THEN 1 ELSE 0 END islocked,mo.telesheet,coalesce(mo.lockedbyuser,'''') lockedby,ts.docformat outputformat,ts.docfunction outputfunction FROM main m JOIN main_operations mo ON mo.case_id=m.case_id JOIN portfolio p ON p.portfolio_id=m.portfolio_id LEFT JOIN bankreport_mapping pf ON pf.portfolio_id=m.portfolio_id LEFT JOIN bankreport ts ON ts.format_id=pf.telesheet WHERE m.isdeleted=0 AND mo.sdone=0 AND coalesce(mo.telesheetby,0)=0 AND mo.cutoffby>0 AND m.company_id=? AND m.branch_id=? AND mo.telesheet=1 GROUP BY m.portfolio_id,p.portname,mo.islocked,mo.telesheet,mo.lockedbyuser,ts.docformat,ts.docfunction ORDER BY p.portname', ismigrated=true WHERE query_id=32; UPDATE platform.application_query SET query_text= -'select!C0L!SELECT m.portfolio_id,m.mvcode,m.applno,m.customername,m.apptype,m.rtv,m.otv,m.refv,CASE WHEN mo.islocked<>? THEN 1 ELSE 0 END islocked,coalesce(mo.lockedbyuser,'''') lockedby,mo.telesheet,m.uuid FROM main m JOIN main_operations mo ON mo.case_id=m.case_id WHERE m.isdeleted=0 AND mo.sdone=0 AND coalesce(mo.telesheetby,0)=0 AND mo.cutoffby>0 AND mo.islocked=? AND m.company_id=? AND m.branch_id=? AND mo.telesheet=1 AND (m.rtv=1 OR m.otv=1) ORDER BY m.portfolio_id,m.applno,m.apptype', ismigrated=true WHERE query_id=33; +'select!C0L!SELECT m.portfolio_id,m.mvcode,m.applno,m.customername,m.apptype,m.rtv,m.otv,m.refv,CASE WHEN mo.islocked<>? THEN 1 ELSE 0 END islocked,coalesce(mo.lockedbyuser,'''') lockedby,mo.telesheet,m.uuid FROM main m JOIN main_operations mo ON mo.case_id=m.case_id WHERE m.isdeleted=0 AND mo.sdone=0 AND coalesce(mo.telesheetby,0)=0 AND mo.cutoffby>0 AND mo.islocked=? AND m.company_id=? AND m.branch_id=? AND mo.telesheet=1 ORDER BY m.portfolio_id,m.applno,m.apptype', ismigrated=true WHERE query_id=33; UPDATE platform.application_query SET query_text='update!C0L!UPDATE main_operations mo SET islocked=?, lockedbyuser=CASE WHEN ?>0 THEN ? ELSE NULL END,telesheeton=CASE WHEN ?>0 THEN ?::timestamp ELSE NULL END,telesheetby=? FROM main m WHERE m.case_id=mo.case_id AND m.uuid::text=? AND m.company_id=? AND m.branch_id=?', ismigrated=true WHERE query_id=34; @@ -39,7 +39,7 @@ UPDATE platform.application_query SET query_text= UPDATE platform.application_query SET query_text= 'select!C0L!SELECT m.portfolio_id,m.mvcode,m.applno,m.customername,m.apptype,m.rv,m.ov,m.pv,m.rtv,m.otv,m.refv,CASE WHEN mo.islocked<>? THEN 1 ELSE 0 END islocked,coalesce(mo.lockedbyuser,'''') lockedby,1 oprsend,m.uuid FROM main m JOIN main_operations mo ON mo.case_id=m.case_id WHERE m.isdeleted=0 AND mo.sdone=0 AND coalesce(mo.oprsendby,0)=0 AND mo.cutoffby>0 AND mo.islocked=? AND m.company_id=? AND m.branch_id=? AND mo.oprsend<>1 AND ((mo.allocation=1 AND mo.allocatedby>0) OR mo.allocation<>1 OR (m.rv=0 AND m.ov=0 AND m.pv=0 AND mo.allocation=1)) AND ((mo.telesheet=1 AND mo.telesheetby>0) OR mo.telesheet<>1) AND (m.rv=1 OR m.ov=1 OR m.pv=1 OR m.rtv=1 OR m.otv=1) ORDER BY m.portfolio_id,m.applno,m.apptype', ismigrated=true WHERE query_id=46; -UPDATE platform.application_query SET query_text='procedure!C0L!SELECT CASE WHEN EXISTS (SELECT 1 FROM main m WHERE m.uuid::text=x.uniqueid::text AND m.company_id=x.companyid AND m.branch_id=x.branchid AND m.portfolio_id=x.portfolioid AND m.isdeleted=0) THEN sendtooperation(x.uniqueid,x.selected,x.processedon,x.userid,x.companyid,x.branchid,x.portfolioid) ELSE ''error:Access denied'' END FROM (SELECT ?::bpchar uniqueid,?::integer selected,?::bpchar processedon,?::integer userid,?::integer companyid,?::integer branchid,?::integer portfolioid) x', ismigrated=true WHERE query_id=47; +UPDATE platform.application_query SET query_text='procedure!C0L!SELECT CASE WHEN NOT EXISTS (SELECT 1 FROM main m WHERE m.uuid::text=x.uniqueid::text AND m.company_id=x.companyid AND m.branch_id=x.branchid AND m.portfolio_id=x.portfolioid AND m.isdeleted=0) THEN ''error:Access denied'' WHEN EXISTS (SELECT 1 FROM main m JOIN main_operations mo ON mo.case_id=m.case_id WHERE m.uuid::text=x.uniqueid::text AND m.company_id=x.companyid AND m.branch_id=x.branchid AND m.portfolio_id=x.portfolioid AND (mo.oprsend=1 OR coalesce(mo.oprsendby,0)>0)) THEN ''success:Already sent'' ELSE coalesce(sendtooperation(x.uniqueid,x.selected,x.processedon,x.userid,x.companyid,x.branchid,x.portfolioid),''success:Sent to operations'') END FROM (SELECT ?::bpchar uniqueid,?::integer selected,?::bpchar processedon,?::integer userid,?::integer companyid,?::integer branchid,?::integer portfolioid) x', ismigrated=true WHERE query_id=47; UPDATE platform.application_query SET query_text='insert!C0L!INSERT INTO app_documents (processtime,process,documenturl,branch_id) VALUES (?::timestamp,?,?,?)', ismigrated=true WHERE query_id=103; diff --git a/cygnus-onprem-db/src/main/resources/db/015_remove_migrated_query_views.sql b/cygnus-onprem-db/src/main/resources/db/015_remove_migrated_query_views.sql index 74943f1..7994911 100644 --- a/cygnus-onprem-db/src/main/resources/db/015_remove_migrated_query_views.sql +++ b/cygnus-onprem-db/src/main/resources/db/015_remove_migrated_query_views.sql @@ -39,10 +39,10 @@ SELECT m.portfolio_id,p.portname||' ('||count(*)||')' portname, FROM main m JOIN main_operations mo ON mo.case_id=m.case_id JOIN portfolio p ON p.portfolio_id=m.portfolio_id -JOIN bankreport_mapping pf ON pf.portfolio_id=m.portfolio_id -JOIN bankreport ts ON ts.format_id=pf.telesheet +LEFT JOIN bankreport_mapping pf ON pf.portfolio_id=m.portfolio_id +LEFT JOIN bankreport ts ON ts.format_id=pf.telesheet WHERE m.isdeleted=0 AND mo.sdone=0 AND coalesce(mo.telesheetby,0)=0 AND mo.cutoffby>0 - AND m.company_id=? AND m.branch_id=? AND mo.telesheet=1 AND (m.rtv>0 OR m.otv>0) + AND m.company_id=? AND m.branch_id=? AND mo.telesheet=1 GROUP BY m.portfolio_id,p.portname,mo.islocked,mo.telesheet,mo.lockedbyuser,ts.docformat,ts.docfunction ORDER BY p.portname$query$, ismigrated = true diff --git a/cygnus-onprem-db/src/main/resources/db/022_cutoff_pending.sql b/cygnus-onprem-db/src/main/resources/db/022_cutoff_pending.sql new file mode 100644 index 0000000..08d7459 --- /dev/null +++ b/cygnus-onprem-db/src/main/resources/db/022_cutoff_pending.sql @@ -0,0 +1,18 @@ +BEGIN; + +UPDATE platform.application_query +SET query_text = 'select!C0L!SELECT mo.cutoffon,count(m.case_id) total FROM main m JOIN main_operations mo ON mo.case_id=m.case_id WHERE m.isdeleted=0 AND mo.sdone=0 AND mo.oprsend<>1 AND mo.cutoffby>0 AND m.company_id=? AND m.branch_id=? GROUP BY mo.cutoffon ORDER BY mo.cutoffon', + ismigrated = true +WHERE query_id = 49; + +UPDATE platform.application_query +SET query_text = 'select!C0L!SELECT m.uuid,p.portname,m.customername,mo.cutoffon FROM main m JOIN main_operations mo ON mo.case_id=m.case_id JOIN portfolio p ON p.portfolio_id=m.portfolio_id WHERE m.isdeleted=0 AND mo.sdone=0 AND mo.oprsend<>1 AND mo.cutoffby>0 AND m.company_id=? AND m.branch_id=? ORDER BY mo.cutoffon,p.portname,m.customername', + ismigrated = true +WHERE query_id = 50; + +UPDATE platform.application_query +SET query_text = 'update!C0L!UPDATE main_operations mo SET allocatedby=CASE WHEN mo.allocatedby>0 AND ?::integer=1 THEN NULL ELSE mo.allocatedby END,telesheetby=CASE WHEN mo.telesheetby>0 AND ?::integer=1 THEN NULL ELSE mo.telesheetby END,earlierby=CASE WHEN mo.earlierby>0 AND ?::integer=1 THEN NULL ELSE mo.earlierby END,negativeby=CASE WHEN mo.negativeby>0 AND ?::integer=1 THEN NULL ELSE mo.negativeby END,cutoffby=CASE WHEN mo.cutoffby>0 AND ?::integer=1 THEN 0 ELSE mo.cutoffby END FROM main m WHERE m.case_id=mo.case_id AND ((?::integer=0 AND m.uuid::text=?) OR (?::integer=1 AND mo.cutoffon=?::timestamp)) AND m.company_id=? AND m.branch_id=? AND m.isdeleted=0 AND mo.sdone=0', + ismigrated = true +WHERE query_id = 51; + +COMMIT; diff --git a/cygnus-onprem-db/src/main/resources/db/023_telesheet_zero_visit_counts.sql b/cygnus-onprem-db/src/main/resources/db/023_telesheet_zero_visit_counts.sql new file mode 100644 index 0000000..d370bab --- /dev/null +++ b/cygnus-onprem-db/src/main/resources/db/023_telesheet_zero_visit_counts.sql @@ -0,0 +1,13 @@ +BEGIN; + +UPDATE platform.application_query +SET query_text = replace(query_text, ' AND (m.rtv>0 OR m.otv>0)', ''), + ismigrated = true +WHERE query_id = 32; + +UPDATE platform.application_query +SET query_text = replace(query_text, ' AND (m.rtv=1 OR m.otv=1)', ''), + ismigrated = true +WHERE query_id = 33; + +COMMIT; diff --git a/cygnus-onprem-db/src/main/resources/db/024_telesheet_optional_report_format.sql b/cygnus-onprem-db/src/main/resources/db/024_telesheet_optional_report_format.sql new file mode 100644 index 0000000..f2e0ee8 --- /dev/null +++ b/cygnus-onprem-db/src/main/resources/db/024_telesheet_optional_report_format.sql @@ -0,0 +1,13 @@ +BEGIN; + +UPDATE platform.application_query +SET query_text = replace( + replace(query_text, + 'JOIN bankreport_mapping pf ON pf.portfolio_id=m.portfolio_id', + 'LEFT JOIN bankreport_mapping pf ON pf.portfolio_id=m.portfolio_id'), + 'JOIN bankreport ts ON ts.format_id=pf.telesheet', + 'LEFT JOIN bankreport ts ON ts.format_id=pf.telesheet'), + ismigrated = true +WHERE query_id = 32; + +COMMIT; diff --git a/cygnus-onprem-db/src/main/resources/db/025_enforce_telesheet_eligibility.sql b/cygnus-onprem-db/src/main/resources/db/025_enforce_telesheet_eligibility.sql new file mode 100644 index 0000000..d40d43a --- /dev/null +++ b/cygnus-onprem-db/src/main/resources/db/025_enforce_telesheet_eligibility.sql @@ -0,0 +1,16 @@ +-- Tele-Sheet is available only when at least one RTV or OTV visit is required. +UPDATE platform.application_query SET query_text = +'select!C0L!SELECT m.portfolio_id, p.portname||'' (''||count(*)||'')'' portname, CASE WHEN sum(mo.allocation)<=0 THEN -1 ELSE 1 END allocation, CASE WHEN sum(mo.sms)<=0 THEN -1 ELSE 1 END sms, CASE WHEN sum(mo.telesheet)>=1 THEN 1 ELSE 0 END telesheet, sum(m.rtv) rtv, sum(m.otv) otv, CASE WHEN sum(mo.earlier)<=0 THEN -1 ELSE 1 END earlier, CASE WHEN sum(mo.negative)<=0 THEN -1 ELSE 1 END negative, CASE WHEN mo.islocked<>? THEN 1 ELSE 0 END islocked, coalesce(mo.lockedbyuser,'''') lockedby FROM main m JOIN main_operations mo ON mo.case_id=m.case_id JOIN portfolio p ON p.portfolio_id=m.portfolio_id WHERE m.isdeleted=0 AND mo.sdone=0 AND (mo.cutoffby IS NULL OR mo.cutoffby=0) AND m.addedby<>0 AND m.company_id=? AND m.branch_id=? GROUP BY m.portfolio_id,p.portname,mo.islocked,mo.lockedbyuser ORDER BY p.portname', ismigrated=true WHERE query_id=18; + +UPDATE platform.application_query SET query_text = +'update!C0L!UPDATE main_operations mo SET allocation=CASE WHEN x.selected THEN x.allocation ELSE mo.allocation END,sms=CASE WHEN x.selected THEN x.sms ELSE mo.sms END,smsby=CASE WHEN x.selected AND x.sms<0 THEN x.user_id ELSE mo.smsby END,telesheet=CASE WHEN x.selected THEN CASE WHEN (m.rtv<=0 AND m.otv<=0) OR mo.telesheet=0 THEN 0 ELSE x.telesheet END ELSE mo.telesheet END,telesheetby=CASE WHEN x.selected AND (m.rtv>0 OR m.otv>0) AND x.telesheet<0 THEN x.user_id ELSE mo.telesheetby END,earlier=CASE WHEN x.selected THEN x.earlier ELSE mo.earlier END,earlierby=CASE WHEN x.selected AND x.earlier<0 THEN x.user_id ELSE mo.earlierby END,negative=CASE WHEN x.selected THEN x.negative ELSE mo.negative END,negativeby=CASE WHEN x.selected AND x.negative<0 THEN x.user_id ELSE mo.negativeby END,cutoffby=CASE WHEN x.selected THEN x.user_id ELSE mo.cutoffby END,cutoffbyuser=CASE WHEN x.selected THEN x.audit_user ELSE mo.cutoffbyuser END,islocked=0,lockedbyuser=NULL,batch=CASE WHEN x.selected THEN x.batch ELSE mo.batch END,cutoffon=CASE WHEN x.selected THEN mo.cutoffon ELSE NULL END FROM main m,(SELECT ?::boolean selected,?::smallint allocation,?::smallint sms,?::smallint telesheet,?::smallint earlier,?::smallint negative,?::integer user_id,?::text audit_user,?::text batch) x WHERE m.case_id=mo.case_id AND m.company_id=? AND m.branch_id=? AND m.portfolio_id=? AND mo.cutoffon=?::timestamp AND mo.islocked=? AND (mo.cutoffby IS NULL OR mo.cutoffby=0)', ismigrated=true WHERE query_id=26; + +UPDATE platform.application_query SET query_text = regexp_replace(query_text, + ' AND mo\.telesheet=1 GROUP BY', + ' AND mo.telesheet=1 AND (m.rtv>0 OR m.otv>0) GROUP BY') +WHERE query_id=32 AND query_text NOT LIKE '%(m.rtv>0 OR m.otv>0)%'; + +UPDATE platform.application_query SET query_text = regexp_replace(query_text, + ' AND mo\.telesheet=1 ORDER BY', + ' AND mo.telesheet=1 AND (m.rtv=1 OR m.otv=1) ORDER BY') +WHERE query_id=33 AND query_text NOT LIKE '%(m.rtv=1 OR m.otv=1)%'; diff --git a/cygnus-onprem-db/src/main/resources/db/026_send_to_operation_idempotency.sql b/cygnus-onprem-db/src/main/resources/db/026_send_to_operation_idempotency.sql new file mode 100644 index 0000000..5d07057 --- /dev/null +++ b/cygnus-onprem-db/src/main/resources/db/026_send_to_operation_idempotency.sql @@ -0,0 +1,7 @@ +-- Preserve the legacy SECURITY DEFINER function. Normalize its NULL success +-- result and avoid invoking it again after the case has already been sent. +UPDATE platform.application_query +SET query_text = +'procedure!C0L!SELECT CASE WHEN NOT EXISTS (SELECT 1 FROM main m WHERE m.uuid::text=x.uniqueid::text AND m.company_id=x.companyid AND m.branch_id=x.branchid AND m.portfolio_id=x.portfolioid AND m.isdeleted=0) THEN ''error:Access denied'' WHEN EXISTS (SELECT 1 FROM main m JOIN main_operations mo ON mo.case_id=m.case_id WHERE m.uuid::text=x.uniqueid::text AND m.company_id=x.companyid AND m.branch_id=x.branchid AND m.portfolio_id=x.portfolioid AND (mo.oprsend=1 OR coalesce(mo.oprsendby,0)>0)) THEN ''success:Already sent'' ELSE coalesce(sendtooperation(x.uniqueid,x.selected,x.processedon,x.userid,x.companyid,x.branchid,x.portfolioid),''success:Sent to operations'') END FROM (SELECT ?::bpchar uniqueid,?::integer selected,?::bpchar processedon,?::integer userid,?::integer companyid,?::integer branchid,?::integer portfolioid) x', + ismigrated = true +WHERE query_id = 47; diff --git a/latest_queries.qry b/latest_queries.qry index 08666fa..0254f5f 100644 --- a/latest_queries.qry +++ b/latest_queries.qry @@ -29,8 +29,8 @@ Query28!C0L!select!C0L!select portfolio_id,(portname||' ('||count(*)||')' Query29!C0L!select!C0L!select mvcode,applno,customername,apptype,rv,ov,pv,(case when islocked!=val2 then 1 else 0 end) as islocked,(select (loginid||' ('||displayname||')') from app_user where user_id=islocked) as lockedby,allocation,rcolony,ocolony,pcolony,uuid,portgroup from cutoff_operations where (allocatedby is null or allocatedby=0) and cutoffby>0 and islocked=val2 and company_id=val0 and branch_id=val1 and allocation=1 and portfolio_id=val3 and (rv=1 or ov=1 or pv=1) order by applno,apptype Query30!C0L!procedure!C0L!select allocatecase('val0',val1,val2,val3,val4,val5,val6,val7,'val8',val9,val10,val11,'val12') Query31!C0L!update!C0L!update main_operations set islocked=val2 where cutoffby > 0 and (islocked=0 or islocked=val2) and (telesheetby is null or telesheetby=0) and company_id=val0 and branch_id=val1 and telesheet=1 -Query32!C0L!select!C0L!select c.portfolio_id,(c.portname||' ('||count(*)||')') as portname,sum(c.rtv) as rtv,sum(c.otv) as otv,sum(c.refv) as refv,(case when c.islocked!=val2 then 1 else 0 end) as islocked,c.telesheet,(select (loginid||' ('||displayname||')') from app_user where user_id=c.islocked) as lockedby,pf.tsformat as outputformat, pf.tsfunction as outputfunction,0 as temp from cutoff_operations c,process_formats pf where (c.telesheetby is null or c.telesheetby=0) and c.cutoffby>0 and c.company_id=val0 and c.branch_id=val1 and c.telesheet=1 and (c.rtv>0 or c.otv>0) and pf.portfolio_id=c.portfolio_id group by c.portfolio_id,c.portname,c.islocked,c.telesheet,tsformat,tsfunction -Query33!C0L!select!C0L!select mvcode,applno,customername,apptype,rtv,otv,refv,(case when islocked!=val2 then 1 else 0 end) as islocked,(select (loginid||' ('||displayname||')') from app_user where user_id=islocked) as lockedby,telesheet,uuid from cutoff_operations where (telesheetby is null or telesheetby=0) and cutoffby>0 and islocked=val2 and company_id=val0 and branch_id=val1 and telesheet=1 and portfolio_id=val3 and (rtv=1 or otv=1) order by applno,apptype +Query32!C0L!select!C0L!select c.portfolio_id,(c.portname||' ('||count(*)||')') as portname,sum(c.rtv) as rtv,sum(c.otv) as otv,sum(c.refv) as refv,(case when c.islocked!=val2 then 1 else 0 end) as islocked,c.telesheet,(select (loginid||' ('||displayname||')') from app_user where user_id=c.islocked) as lockedby,pf.tsformat as outputformat, pf.tsfunction as outputfunction,0 as temp from cutoff_operations c,process_formats pf where (c.telesheetby is null or c.telesheetby=0) and c.cutoffby>0 and c.company_id=val0 and c.branch_id=val1 and c.telesheet=1 and pf.portfolio_id=c.portfolio_id group by c.portfolio_id,c.portname,c.islocked,c.telesheet,tsformat,tsfunction +Query33!C0L!select!C0L!select mvcode,applno,customername,apptype,rtv,otv,refv,(case when islocked!=val2 then 1 else 0 end) as islocked,(select (loginid||' ('||displayname||')') from app_user where user_id=islocked) as lockedby,telesheet,uuid from cutoff_operations where (telesheetby is null or telesheetby=0) and cutoffby>0 and islocked=val2 and company_id=val0 and branch_id=val1 and telesheet=1 and portfolio_id=val3 order by applno,apptype Query34!C0L!update!C0L!update main_operations set islocked=val0,telesheeton='val1',telesheetby=val2 where uuid='val3' QueryXX35XX!C0L!select!C0L!select ('Tele Verification Report ( '||b.portname||' )') as title,'Received Date' as recdate,receivedate,'Branch' as region,upper(b.bkbranchname) as branchname,'Verification Code' as vercode,mvcode,'Application Ref. No.' as fileno,upper(applno),'Agency Name' as agname,upper(maincompany) as matrx,'RESIDENCE TELEPHONE' as ressec,'Name of Applicant' as appname,upper(customername),upper(apptype),'Resi Address of Applicant' as resadd,(upper(raddr1)||' '||upper(raddr2)||' '||upper(raddr3)||' '||(case when rcity='-1' then '' else upper(rcity) end)) as radd,'Permanent Add of Applicant' as permadd,'' as padd,'Contact Telephone Numbers' as ctel,(mobileno||','||rphone) as contactno,'Type of Residence' as restype,'Owned' as owned,'Rented' as rented,'Company Accomodation' as compacc,'With Parents' withpar,'With Relatives' as withrel,'With Friends' as withf,'Paying Guest' as withp,'Special Instructions' as splinst,upper(specialinst),'The following is based on Telephonic conversation :' as t1,'Name of the Person spoken to' as spkto,'' as spkto2,'Relation with application' as relwith,'' as relwith2,'The following is based on CD-ROM Check:' as t2,'Name of applicant confirmed at given telephone number' as t3,'Yes' as ys,'No' as no,'Telecalling Log' as t4,'Attempt' as atmp,'1st' as fst,'2nd' as iind,'3rd' as rd,'4th' as fth,'5th' as ffth,'Date & Time of Calling' as dtc,'' as dt1,'' as dt2,'' as dt3,'' as dt4,'' as dt5,'Other Remarks :' as othrem,'' as ln1,'' as ln2,'' as ln3,'' as ln4,'' as ln5,'Televerification Results' as rtr,'Positive' as pos,'Negative' as neg,'OFFICE TELEPHONE' as oftel,'Office Telephone Numbers' as oftelno,(mobileno||','||ophone) as ocontactno,'Extn. No.' as ext,extension,'Name of Applicant' as appname,upper(customername) as ocust,'Designation' as des,upper(designation),'Working Since' as wks,'' as wks1,'Department' as dept,upper(department) as department,'For Self employed-Type of organization' as t6,'Proprietorship' as propr,'Partnership' as partnr,'Pvt. Ltd.' as pvtld,'Public. Ltd.' as publtd,'Others' as othr,'Nature of Business' as nob,'Trading' as trd,'Manufacturing' as mfg,'Processing' as prcs,'Builder' as buildr,'Contractor' as contr,'' as nob1,'Brokerage' as brok,'Consultancy' as consult,'Professional' as profs,'Others' as othr,'' as blnk,'Nature of the Company' as noc,'' as noc1,'Office Address' as offad,(upper(oaddr1)||' '||upper(oaddr2)||' '||upper(oaddr3)||' '||(case when ocity='-1' then '' else upper(ocity) end)) as oaddr,'Landmarks' as lndm,'' as ldnmk,'Special Instructions' as sploins,upper(specialinst) as ospel,'The following is based on Telephonic conversation :' as t7,'Name of the person spoken to' as pspkto,'' as pspkt2,'Designation' as cdesig,'' as cdesig1,'Relationship with applicant' as orelwith,'Colleague' as ocoll,'Partner' as optnr,'Superior' as osup,'Relative' as orelv,'Others' as othro,'The following is based on CD-ROM Check:' as t8,'Name of applicant confirmed at given telephone number' as t9,'Yes' as oys,'No' as onso,'Telecalling Log' as t10,'Attempt' as oatmp,'1st' as of1,'2nd' as of2,'3rd' as of3,'4th' as of4,'5th' as of5,'Date & Time of Calling' as odt,'' as odt1,'' as odt2,'' as odt3,'' as odt4,'' as odt5,'Others Remarks :' as othrrem,'' as orm1,'' as orm2,'' as orm3,'' as orm4,'' as orm5,'Televerification Results' as otlst,'Positive' as opost,'Negative' as onegt,rtv,otv from cutoff_operations c,portfolio_bank_branch b where c.bank_branch_id=b.portbranch_id and c.portfolio_id=val0 and c.islocked=val1 and c.telesheeton='val2' Query36!C0L!update!C0L!update main_operations set islocked=val2 where allocation=1 and allocatedby > 0 and (islocked=0 or islocked=val2) and company_id=val0 and branch_id=val1 and sms=1 and smson is null @@ -46,9 +46,9 @@ Query45!C0L!select!C0L!select portfolio_id,(portname||' ('||count(*)||')' Query46!C0L!select!C0L!select mvcode,applno,customername,apptype,rv,ov,pv,rtv,otv,refv,(case when islocked!=val2 then 1 else 0 end) as islocked,(select (loginid||' ('||displayname||')') from app_user where user_id=islocked) as lockedby,1 as oprsend,uuid from cutoff_operations where (oprsendby is null or oprsendby=0) and cutoffby>0 and islocked=val2 and company_id=val0 and branch_id=val1 and oprsend!=1 and ((allocation=1 and allocatedby > 0) or allocation!=1 or (rv=0 and ov=0 and pv=0 and allocation=1)) and ((telesheet=1 and telesheetby>0) or telesheet!=1) and portfolio_id=val3 and (rv=1 or ov=1 or pv=1 or rtv=1 or otv=1) order by applno,apptype Query47!C0L!procedure!C0L!select sendtooperation('val0',val1,'val2',val3,val4,val5,val6) Query48!C0L!select!C0L!select displayname,receivedate,timeperiod,count(*) from edpoperator_mis where receivedate>='val2' and receivedate<='val3' and company_id=val0 and branch_id=val1 group by receivedate,timeperiod,displayname order by timeperiod -Query49!C0L!select!C0L!select cutoffon,count(uuid) as tot from cutoff_operations where oprsend!=1 and cutoffby > 0 and company_id=val0 and branch_id=val1 group by cutoffon order by cutoffon -Query50!C0L!select!C0L!select uuid,portname,customername,cutoffon from cutoff_operations where oprsend!=1 and cutoffby > 0 and company_id=val0 and branch_id=val1 group by cutoffon,uuid,portname,customername order by cutoffon,portname,customername -Query51!C0L!procedure!C0L!select cutoffpending('val0','val1','val2','val3','val4','val5','val6',val7) +Query49!C0L!select!C0L!SELECT mo.cutoffon,count(m.case_id) total FROM main m JOIN main_operations mo ON mo.case_id=m.case_id WHERE m.isdeleted=0 AND mo.sdone=0 AND mo.oprsend<>1 AND mo.cutoffby>0 AND m.company_id=? AND m.branch_id=? GROUP BY mo.cutoffon ORDER BY mo.cutoffon +Query50!C0L!select!C0L!SELECT m.uuid,p.portname,m.customername,mo.cutoffon FROM main m JOIN main_operations mo ON mo.case_id=m.case_id JOIN portfolio p ON p.portfolio_id=m.portfolio_id WHERE m.isdeleted=0 AND mo.sdone=0 AND mo.oprsend<>1 AND mo.cutoffby>0 AND m.company_id=? AND m.branch_id=? ORDER BY mo.cutoffon,p.portname,m.customername +Query51!C0L!update!C0L!UPDATE main_operations mo SET allocatedby=CASE WHEN mo.allocatedby>0 AND ?::integer=1 THEN NULL ELSE mo.allocatedby END,telesheetby=CASE WHEN mo.telesheetby>0 AND ?::integer=1 THEN NULL ELSE mo.telesheetby END,earlierby=CASE WHEN mo.earlierby>0 AND ?::integer=1 THEN NULL ELSE mo.earlierby END,negativeby=CASE WHEN mo.negativeby>0 AND ?::integer=1 THEN NULL ELSE mo.negativeby END,cutoffby=CASE WHEN mo.cutoffby>0 AND ?::integer=1 THEN 0 ELSE mo.cutoffby END FROM main m WHERE m.case_id=mo.case_id AND ((?::integer=0 AND m.uuid::text=?) OR (?::integer=1 AND mo.cutoffon=?::timestamp)) AND m.company_id=? AND m.branch_id=? AND m.isdeleted=0 AND mo.sdone=0 Query52!C0L!select!C0L!select c.uuid,c.portfolio_id,c.mvcode,c.applno,c.customername,c.apptype,(CASE WHEN c.rv = 1 THEN 'Y'::text ELSE 'N'::text END) AS rv,(CASE WHEN c.ov = 1 THEN 'Y'::text ELSE 'N'::text END) AS ov,(CASE WHEN c.pv = 1 THEN 'Y'::text ELSE 'N'::text END) AS pv,(CASE WHEN c.rtv = 1 THEN 'Y'::text ELSE 'N'::text END) AS rtv,(CASE WHEN c.otv = 1 THEN 'Y'::text ELSE 'N'::text END) AS otv,(CASE WHEN c.refv = 1 THEN 'Y'::text ELSE 'N'::text END) AS refv,(CASE WHEN c.docv = 1 THEN 'Y'::text ELSE 'N'::text END) AS docv, to_char(receivedate, 'DD/MM/YYYY') as receivedate,b.bkbranchname,'false' as delstat from cutoff_operations c,portfolio_bank_branch b where c.portfolio_id=val0 and c.branch_id=val1 and c.bank_branch_id=b.portbranch_id order by bkbranchname,customername Query53!C0L!select!C0L!select uuid, portfolio_id, mvcode, applno, customername, apptype,rv,ov,pv, to_char(receivedate, 'DD/MM/YYYY') as receivedate,(case when (rv+ov+pv)=(rvdone+ovdone+pvdone) then 'Y' else 'N' end) as done from cutoff_operations where portfolio_id=val0 and (dedcutby is null or dedcutby=0) and ((earlierby>0 and earlier=1) or earlier=0) and ((negativeby>0 and negative=1) or negative=0) and (earlier=1 or negative=1) order by done desc,applno,apptype Query54!C0L!select!C0L!select uuid, customername, mvcode, dob, mobileno,upper(raddr1||' '||raddr2||' '||raddr3) as resiaddr,upper(coalesce(companyname||' ','')||oaddr1||' '||oaddr2||' '||oaddr3) as offaddr,rphone,ophone,(case when category='-1' then 'NA' else upper(category) end) as category,0 as temp from main where uuid='val0' and isdeleted=0