Skip to content

Commit

Permalink
Merge pull request #962 from deepa-s-13/Dev-2.0
Browse files Browse the repository at this point in the history
Receipts key is passed as per module and pdf service is called
  • Loading branch information
sriranjan-s authored Mar 5, 2024
2 parents c70bb60 + 5951ab4 commit 3b53a93
Show file tree
Hide file tree
Showing 24 changed files with 774 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useQuery } from "react-query";
import { PaymentService } from "../../services/elements/Payment";

const useTLPaymentHistory = (tenantId, id, config = {}) => {
return useQuery(["PAYMENT_HISTORY", id], () => PaymentService.getReciept(tenantId, "", { consumerCodes: id }), { ...config });
return useQuery(["PAYMENT_HISTORY", id], () => PaymentService.getReciept(tenantId, "TL", { consumerCodes: id }), { ...config });
};

export default useTLPaymentHistory;
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const PaymentService = {
getReciept: (tenantId, businessservice, filters = {}) =>
Request({
url:
businessservice && businessservice !== "BPAREG"
businessservice && businessservice !== "BPAREG" || businessservice && businessservice !== "TL"
? `${Urls.payment.print_reciept}/${businessservice}/_search`
: `${Urls.payment.print_reciept}/_search`,
useCache: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ReceiptsService = {
newParam['consumerCode']=consumerCode;
}
return Request({
url: Urls.mcollect.receipt_download,
url: Urls.receipts.receipt_download,
data: {},
useCache: true,
method: "POST",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Banner, Card, CardText, Loader, Row, StatusTable, SubmitBar, DownloadPrefixIcon } from "@upyog/digit-ui-react-components";
import { Banner, Card, CardText, Loader, Row, StatusTable, SubmitBar, DownloadPrefixIcon } from "@egovernments/digit-ui-react-components";
import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useQueryClient } from "react-query";
Expand Down Expand Up @@ -167,6 +167,7 @@ export const convertEpochToDate = (dateEpoch) => {
// };

const printReciept = async () => {
let generatePdfKeyForWs="ws-onetime-receipt";
if (printing) return;
setPrinting(true);
let paymentArray=[];
Expand Down Expand Up @@ -221,10 +222,16 @@ export const convertEpochToDate = (dateEpoch) => {
}
payments.Payments[0].additionalDetails=details;
paymentArray[0]=payments.Payments[0]
console.log("paymentArray",paymentArray)
response = await Digit.PaymentService.generatePdf(state, { Payments: paymentArray }, generatePdfKey);
console.log("generatedpdfkey",generatePdfKey)
if(business_service=="WS" || business_service=="SW"){
response = await Digit.PaymentService.generatePdf(state, { Payments: [{...paymentData}] }, generatePdfKeyForWs);
}
else{
response = await Digit.PaymentService.generatePdf(state, { Payments: [{...paymentData}] }, generatePdfKey);
}

}
}
}
const fileStore = await Digit.PaymentService.printReciept(state, { fileStoreIds: response.filestoreIds[0] });
if (fileStore && fileStore[response.filestoreIds[0]]) {
window.open(fileStore[response.filestoreIds[0]], "_blank");
Expand Down Expand Up @@ -486,7 +493,7 @@ export const convertEpochToDate = (dateEpoch) => {
assessmentYearForReceipt=fromDate+"-"+toDate;


payloadReceiptDetails.Payments[0].paymentDetails[0].bill.billDetails[0].billAccountDetails.map(ele => {
payments.Payments[0].paymentDetails[0].bill.billDetails[0].billAccountDetails.map(ele => {

if(ele.taxHeadCode == "PT_TAX")
{tax=ele.adjustedAmount;
Expand Down Expand Up @@ -538,7 +545,7 @@ export const convertEpochToDate = (dateEpoch) => {
"adhoc_penalty":adhoc_penalty,
"adhoc_rebate":adhoc_rebate,
"roundoff":roundoff,
"total": payloadReceiptDetails.Payments[0].paymentDetails[0].bill.billDetails[0].amountPaid
"total": payments.Payments[0].paymentDetails[0].bill.billDetails[0].amountPaid

};
taxRow={
Expand All @@ -554,7 +561,7 @@ export const convertEpochToDate = (dateEpoch) => {
"adhoc_penalty":adhoc_penaltyT,
"adhoc_rebate":adhoc_rebateT,
"roundoff":roundoffT,
"total": payloadReceiptDetails.Payments[0].paymentDetails[0].bill.billDetails[0].amount
"total": payments.Payments[0].paymentDetails[0].bill.billDetails[0].amount
};
arrearArray.push(arrearRow);
taxArray.push(taxRow);
Expand Down Expand Up @@ -607,7 +614,7 @@ export const convertEpochToDate = (dateEpoch) => {
rowContainerStyle={rowContainerStyle}
last
label={t("CS_PAYMENT_BILLING_PERIOD")}
text={getBillingPeriod(reciept_data?.paymentDetails[0]?.bill?.billDetails[0])}
text={getBillingPeriod(paymentData?.paymentDetails[0]?.bill?.billDetails[0])}
/>
)}

Expand All @@ -616,7 +623,7 @@ export const convertEpochToDate = (dateEpoch) => {
rowContainerStyle={rowContainerStyle}
last
label={t("CS_PAYMENT_AMOUNT_PENDING")}
text={(reciept_data?.paymentDetails?.[0]?.totalDue && reciept_data?.paymentDetails?.[0]?.totalAmountPaid ) ? `₹ ${reciept_data?.paymentDetails?.[0]?.totalDue - reciept_data?.paymentDetails?.[0]?.totalAmountPaid}` : `₹ ${0}`}
text={paymentData?.totalDue-paymentData?.totalAmountPaid || (reciept_data?.paymentDetails?.[0]?.totalDue && reciept_data?.paymentDetails?.[0]?.totalAmountPaid ) ? `₹ ${reciept_data?.paymentDetails?.[0]?.totalDue - reciept_data?.paymentDetails?.[0]?.totalAmountPaid}` : `₹ ${0}`}
/>
)}

Expand All @@ -625,7 +632,7 @@ export const convertEpochToDate = (dateEpoch) => {
rowContainerStyle={rowContainerStyle}
last
label={t(ommitRupeeSymbol ? "CS_PAYMENT_AMOUNT_PAID_WITHOUT_SYMBOL" : "CS_PAYMENT_AMOUNT_PAID")}
text={reciept_data?.paymentDetails?.[0]?.totalAmountPaid ? ("₹ " + reciept_data?.paymentDetails?.[0]?.totalAmountPaid) : `₹ 0` }
text={paymentData?.totalAmountPaid ||( reciept_data?.paymentDetails?.[0]?.totalAmountPaid ? ("₹ " + reciept_data?.paymentDetails?.[0]?.totalAmountPaid) : `₹ 0`) }
/>
{(business_service !== "PT" || workflw) && (
<Row
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react";
import { Banner, Card, CardText, SubmitBar, ActionBar, DownloadPrefixIcon, Loader, Menu } from "@upyog/digit-ui-react-components";
import { Banner, Card, CardText, SubmitBar, ActionBar, DownloadPrefixIcon, Loader, Menu } from "@egovernments/digit-ui-react-components";
import { useHistory, useParams, Link, LinkLabel } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { useQueryClient } from "react-query";
Expand Down Expand Up @@ -363,7 +363,7 @@ export const SuccessfulPayment = (props) => {
assessmentYearForReceipt=fromDate+"-"+toDate;


payloadReceiptDetails.Payments[0].paymentDetails[0].bill.billDetails[0].billAccountDetails.map(ele => {
payments.Payments[0].paymentDetails[0].bill.billDetails[0].billAccountDetails.map(ele => {

if(ele.taxHeadCode == "PT_TAX")
{tax=ele.adjustedAmount;
Expand Down Expand Up @@ -415,7 +415,7 @@ export const SuccessfulPayment = (props) => {
"adhoc_penalty":adhoc_penalty,
"adhoc_rebate":adhoc_rebate,
"roundoff":roundoff,
"total": payloadReceiptDetails.Payments[0].paymentDetails[0].bill.billDetails[0].amountPaid
"total": payments.Payments[0].paymentDetails[0].bill.billDetails[0].amountPaid

};
taxRow={
Expand All @@ -431,7 +431,7 @@ export const SuccessfulPayment = (props) => {
"adhoc_penalty":adhoc_penaltyT,
"adhoc_rebate":adhoc_rebateT,
"roundoff":roundoffT,
"total": payloadReceiptDetails.Payments[0].paymentDetails[0].bill.billDetails[0].amount
"total": payments.Payments[0].paymentDetails[0].bill.billDetails[0].amount
};
arrearArray.push(arrearRow);
taxArray.push(taxRow);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { Header, Card, KeyNote, LinkButton, Loader, MultiLink } from "@upyog/digit-ui-react-components";
import { Header, Card, KeyNote, LinkButton, Loader, MultiLink } from "@egovernments/digit-ui-react-components";
import { useHistory, useLocation, useParams } from "react-router-dom";
import getPDFData from "../../getPDFData";
import { getVehicleType } from "../../utils";
Expand Down Expand Up @@ -45,7 +45,7 @@ const ApplicationDetails = () => {
const downloadPaymentReceipt = async () => {
const receiptFile = { filestoreIds: [paymentsHistory.Payments[0]?.fileStoreId] };

if (!receiptFile?.fileStoreIds?.[0]) {
if (!receiptFile?.filestoreIds?.[0]) {
const newResponse = await Digit.PaymentService.generatePdf(state, { Payments: [paymentsHistory.Payments[0]] }, "fsm-receipt");
const fileStore = await Digit.PaymentService.printReciept(state, { fileStoreIds: newResponse.filestoreIds[0] });
window.open(fileStore[newResponse.filestoreIds[0]], "_blank");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StatusTable, Header, Card, CardHeader, Row, PDFSvg, CardSectionHeader, MultiLink, Loader } from "@upyog/digit-ui-react-components";
import { StatusTable, Header, Card, CardHeader, Row, PDFSvg, CardSectionHeader, MultiLink, Loader } from "@egovernments/digit-ui-react-components";
import React, { Fragment, useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import { useTranslation } from "react-i18next";
Expand Down Expand Up @@ -39,14 +39,16 @@ const ApplicationDetails = () => {
useEffect(() => {
if (License) {
if (reciept_data?.Payments?.length > 0) {
//console.log("reciept_data?.Payments",reciept_data?.Payments)
setDowloadOptions([
{
label: t("TL_RECEIPT"),
onClick: () =>
downloadAndPrintReciept(
reciept_data?.Payments?.[0]?.paymentDetails?.[0]?.businessService || "BPAREG",
License?.applicationNumber,
License?.tenantId
License?.tenantId,
reciept_data?.Payments
),
},
]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CardHeader, Header, Toast, Card, StatusTable, Row, Loader, Menu, PDFSvg, SubmitBar, LinkButton, ActionBar, CheckBox, MultiLink, CardText, CardSubHeader } from "@upyog/digit-ui-react-components";
import { CardHeader, Header, Toast, Card, StatusTable, Row, Loader, Menu, PDFSvg, SubmitBar, LinkButton, ActionBar, CheckBox, MultiLink, CardText, CardSubHeader } from "@egovernments/digit-ui-react-components";
import React, { Fragment, useEffect, useState } from "react";
import { useParams, useHistory } from "react-router-dom";
import { useQueryClient } from "react-query";
Expand Down Expand Up @@ -107,8 +107,13 @@ const BpaApplicationDetail = () => {


async function getRecieptSearch({tenantId, payments, ...params}) {
let response = { filestoreIds: [payments?.fileStoreId] };
response = await Digit.PaymentService.generatePdf(tenantId, { Payments: [{...payments}] }, "bpa-receipt");
let response=null;
if (payments?.fileStoreId ) {
response = { filestoreIds: [payments?.fileStoreId] };
}
else{
response = await Digit.PaymentService.generatePdf(tenantId, { Payments: [{...payments}] }, "bpa-receipt");
}
const fileStore = await Digit.PaymentService.printReciept(tenantId, { fileStoreIds: response.filestoreIds[0] });
window.open(fileStore[response?.filestoreIds[0]], "_blank");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Fragment, useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { Header, CardSectionHeader, PDFSvg, StatusTable, Row, MultiLink } from "@upyog/digit-ui-react-components";
import { Header, CardSectionHeader, PDFSvg, StatusTable, Row, MultiLink } from "@egovernments/digit-ui-react-components";
import ApplicationDetailsTemplate from "../../../../../templates/ApplicationDetails";
import { downloadAndPrintReciept } from "../../../utils";

Expand Down Expand Up @@ -34,11 +34,11 @@ const ApplicationDetail = () => {
};

let dowloadOptions = [];

console.log("applicationDetails",applicationDetails)
if (applicationDetails?.payments?.length > 0) {
dowloadOptions.push({
label: t("TL_RECEIPT"),
onClick: () => downloadAndPrintReciept(applicationDetails?.payments?.[0]?.paymentDetails?.[0]?.businessService || "BPAREG", applicationDetails?.applicationData?.applicationNumber, applicationDetails?.applicationData?.tenantId),
onClick: () => downloadAndPrintReciept(applicationDetails?.payments?.[0]?.paymentDetails?.[0]?.businessService || "BPAREG", applicationDetails?.applicationData?.applicationNumber, applicationDetails?.applicationData?.tenantId,applicationDetails?.payments),
})
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, Fragment, useEffect } from "react";
import { useParams, useHistory } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { FormComposer, Header, Card, CardSectionHeader, PDFSvg, Loader, StatusTable, Row, ActionBar, SubmitBar, MultiLink } from "@upyog/digit-ui-react-components";
import { FormComposer, Header, Card, CardSectionHeader, PDFSvg, Loader, StatusTable, Row, ActionBar, SubmitBar, MultiLink } from "@egovernments/digit-ui-react-components";
import ApplicationDetailsTemplate from "../../../../../templates/ApplicationDetails";
import { newConfig as newConfigFI } from "../../../config/InspectionReportConfig";
import get from "lodash/get";
Expand All @@ -10,6 +10,7 @@ import { getBusinessServices, convertDateToEpoch, downloadPdf, printPdf } from "
import cloneDeep from "lodash/cloneDeep";

const BpaApplicationDetail = () => {

const { id } = useParams();
const { t } = useTranslation();
const tenantId = Digit.ULBService.getCurrentTenantId();
Expand Down Expand Up @@ -73,10 +74,13 @@ const BpaApplicationDetail = () => {
},[bpaDocs,data])

async function getRecieptSearch({tenantId, payments, ...params}) {
let response = { filestoreIds: [payments?.fileStoreId] };
//if (!payments?.fileStoreId) {
response = await Digit.PaymentService.generatePdf(tenantId, { Payments: [{...payments}] }, "bpa-receipt");
//}
let response=null;
if (payments?.fileStoreId ) {
response = { filestoreIds: [payments?.fileStoreId] };
}
else{
response = await Digit.PaymentService.generatePdf(tenantId, { Payments: [{...payments}] }, "bpa-receipt");
}
const fileStore = await Digit.PaymentService.printReciept(tenantId, { fileStoreIds: response.filestoreIds[0] });
window.open(fileStore[response?.filestoreIds[0]], "_blank");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,18 @@ export const printPdf = (blob) => {
}
};

export const downloadAndPrintReciept = async (bussinessService, consumerCode, tenantId, mode = "download", pdfKey = "bpa-receipt") => {
const response = await Digit.OBPSService.receipt_download(bussinessService, consumerCode, tenantId, { pdfKey: pdfKey });
export const downloadAndPrintReciept = async (bussinessService, consumerCode, tenantId,payments , mode = "download", pdfKey = "bpa-receipt") => {
let response=null;
console.log("payments",payments)
if (payments[0]?.fileStoreId ) {
response = { filestoreIds: [payments[0]?.fileStoreId] };
}
else{
response = await Digit.PaymentService.generatePdf(tenantId, { Payments: payments }, "bpa-receipt");
//response = await Digit.OBPSService.receipt_download(bussinessService, consumerCode, tenantId, { pdfKey: pdfKey });
}
const fileStore = await Digit.PaymentService.printReciept(tenantId, { fileStoreIds: response.filestoreIds[0] });
window.open(fileStore[response?.filestoreIds[0]], "_blank");
const responseStatus = parseInt(response.status, 10);
if (responseStatus === 201 || responseStatus === 200) {
let fileName =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card, CardSubHeader, Header, LinkButton, Loader, Row, StatusTable, MultiLink, PopUp, Toast, SubmitBar } from "@upyog/digit-ui-react-components";
import { Card, CardSubHeader, Header, LinkButton, Loader, Row, StatusTable, MultiLink, PopUp, Toast, SubmitBar } from "@egovernments/digit-ui-react-components";
import React, { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { useHistory, useParams } from "react-router-dom";
Expand All @@ -7,7 +7,7 @@ import PropertyDocument from "../../pageComponents/PropertyDocument";
import PTWFApplicationTimeline from "../../pageComponents/PTWFApplicationTimeline";
import { getCityLocale, getPropertyTypeLocale, propertyCardBodyStyle, getMohallaLocale, pdfDownloadLink } from "../../utils";
import PTCitizenFeedbackPopUp from "../../pageComponents/PTCitizenFeedbackPopUp";
//import PTCitizenFeedback from "@upyog/digit-ui-module-core/src/components/PTCitizenFeedback";
//import PTCitizenFeedback from "@egovernments/digit-ui-module-core/src/components/PTCitizenFeedback";

import get from "lodash/get";
import { size } from "lodash";
Expand Down Expand Up @@ -206,9 +206,15 @@ const PTApplicationDetails = () => {

async function getRecieptSearch({ tenantId, payments, ...params }) {
let response = { filestoreIds: [payments?.fileStoreId] };
response = await Digit.PaymentService.generatePdf(tenantId, { Payments: [{ ...payments }] }, "consolidatedreceipt");
const fileStore = await Digit.PaymentService.printReciept(tenantId, { fileStoreIds: response.filestoreIds[0] });
window.open(fileStore[response?.filestoreIds[0]], "_blank");
if(response!==null){
const fileStore = await Digit.PaymentService.printReciept(tenantId, { fileStoreIds: response.filestoreIds[0] });
window.open(fileStore[response?.filestoreIds[0]], "_blank");
}
else{
response = await Digit.PaymentService.generatePdf(tenantId, { Payments: [{ ...payments }] }, "property-receipt");
const fileStore = await Digit.PaymentService.printReciept(tenantId, { fileStoreIds: response.filestoreIds[0] });
window.open(fileStore[response?.filestoreIds[0]], "_blank");
}
}

const handleDownload = async (document, tenantid) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card, CardSubHeader, Header, LinkButton, Loader, Row, StatusTable, MultiLink } from "@upyog/digit-ui-react-components";
import { Card, CardSubHeader, Header, LinkButton, Loader, Row, StatusTable, MultiLink } from "@egovernments/digit-ui-react-components";
import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";
Expand Down Expand Up @@ -172,9 +172,15 @@ const MutationApplicationDetails = ({ propertyId, acknowledgementIds, workflowDe

async function getRecieptSearch({tenantId,payments,...params}) {
let response = { filestoreIds: [payments?.fileStoreId] };
response = await Digit.PaymentService.generatePdf(tenantId, { Payments: [{...payments}] }, "consolidatedreceipt");
const fileStore = await Digit.PaymentService.printReciept(tenantId, { fileStoreIds: response.filestoreIds[0] });
if(response!==null){
const fileStore = await Digit.PaymentService.printReciept(tenantId, { fileStoreIds: response.filestoreIds[0] });
window.open(fileStore[response?.filestoreIds[0]], "_blank");
}
else{
response = await Digit.PaymentService.generatePdf(tenantId, { Payments: [{...payments}] }, "property-receipt");
const fileStore = await Digit.PaymentService.printReciept(tenantId, { fileStoreIds: response.filestoreIds[0] });
window.open(fileStore[response?.filestoreIds[0]], "_blank");
}
}

const closeModal = () => {
Expand Down
Loading

0 comments on commit 3b53a93

Please sign in to comment.