-
-
- Date:{" "}
- {formatUTCToLocalTime(payment.paymentReceivedDate)}
-
{" "}
-
- {formatFigure(payment.amount, {
- type: "currency",
- currency: "INR",
- })}
-
+
+
+
+
+ Transaction Date:
+ {" "}
+ {formatUTCToLocalTime(payment.paymentReceivedDate)}
+
+
+ {formatFigure(payment.amount, {
+ type: "currency",
+ currency: "INR",
+ })}
+
+
+
+
+
Received By:{" "}
+
{" "}
+ {payment?.createdBy?.firstName}{" "}
+ {payment.createdBy?.lastName}
+
@@ -152,17 +179,14 @@ const AddPayment = ({ onClose }) => {
{payment.transactionId}
-
-
-
Received By:{" "}
-
{" "}
- {payment?.createdBy?.firstName}{" "}
- {payment.createdBy?.lastName}
-
+
+
+ {formatFigure(payment.amount, {
+ type: "currency",
+ currency: "INR",
+ })}
+
+
{payment?.comment}
diff --git a/src/components/collections/Comment.jsx b/src/components/collections/Comment.jsx
new file mode 100644
index 00000000..6edbedc1
--- /dev/null
+++ b/src/components/collections/Comment.jsx
@@ -0,0 +1,84 @@
+import { zodResolver } from "@hookform/resolvers/zod";
+import React from "react";
+import { useForm } from "react-hook-form";
+import { CommentSchema } from "./collectionSchema";
+import { useAddComment } from "../../hooks/useCollections";
+import Avatar from "../common/Avatar";
+import { formatUTCToLocalTime } from "../../utils/dateUtils";
+import moment from "moment";
+
+const Comment = ({ invoice }) => {
+ const {
+ register,
+ handleSubmit,
+ formState: { errors },
+ } = useForm({
+ resolver: zodResolver(CommentSchema),
+ defaultValues: { comment: "" },
+ });
+
+ const { mutate: AddComment, isPending } = useAddComment(() => {});
+
+ const onSubmit = (formData) => {
+ const payload = { ...formData, invoiceId: invoice?.id };
+ debugger;
+ AddComment(payload);
+ };
+ return (
+
+ {invoice?.comments?.length > 0 ? (
+ invoice.comments.map((comment, index) => (
+
+
+
+
+
+ {comment?.createdBy?.firstName} {comment?.createdBy?.lastName}
+
+
+
+
+ {moment.utc(comment?.createdAt).local().fromNow()}
+
+
+
+
{comment?.comment}
+
+ ))
+ ) : (
+
No comments yet.
+ )}
+
+
+
+ );
+};
+
+export default Comment;
diff --git a/src/components/collections/PaymentHistoryTable.jsx b/src/components/collections/PaymentHistoryTable.jsx
new file mode 100644
index 00000000..6ce11909
--- /dev/null
+++ b/src/components/collections/PaymentHistoryTable.jsx
@@ -0,0 +1,56 @@
+import React from 'react'
+import { formatUTCToLocalTime } from '../../utils/dateUtils'
+import { formatFigure } from '../../utils/appUtils'
+import Avatar from '../common/Avatar'
+
+const PaymentHistoryTable = ({data}) => {
+ return (
+
+
+ {data?.receivedInvoicePayments?.length > 0 && (
+
+
Received Payments
+
+
+
+ Sr.No |
+ Transaction ID |
+ Received Date |
+ Amount |
+ Updated By |
+
+
+
+ {data.receivedInvoicePayments.map((payment, index) => (
+
+ {index + 1} |
+ {payment.transactionId} |
+ {formatUTCToLocalTime(payment.paymentReceivedDate)} |
+
+ {formatFigure(payment.amount, {
+ type: "currency",
+ currency: "INR",
+ })}
+ |
+
+
+
+ {payment.createdBy?.firstName}{" "}
+ {payment.createdBy?.lastName}
+
+ |
+
+ ))}
+
+
+
+ )}
+
+ )
+}
+
+export default PaymentHistoryTable
diff --git a/src/components/collections/ViewCollection.jsx b/src/components/collections/ViewCollection.jsx
index f12d9f75..c86fe308 100644
--- a/src/components/collections/ViewCollection.jsx
+++ b/src/components/collections/ViewCollection.jsx
@@ -4,6 +4,8 @@ import { useCollection } from "../../hooks/useCollections";
import { formatUTCToLocalTime } from "../../utils/dateUtils";
import { formatFigure } from "../../utils/appUtils";
import Avatar from "../common/Avatar";
+import PaymentHistoryTable from "./PaymentHistoryTable";
+import Comment from "./Comment";
const ViewCollection = () => {
const { viewCollection } = useCollectionContext();
@@ -14,61 +16,65 @@ const ViewCollection = () => {
Collection Details
-
-
{data?.title}
-
{data?.description}
-
-
-
-
-
Invoice Number: {data?.invoiceNumber}
+
+
-
-
E-Invoice Number: {data?.eInvoiceNumber}
+
+
+ {data?.isActive ? "Active" : "Inactive"}
+
+
+
+
+
+
Project:
{" "}
+ {data?.project?.name}
+
+
+
+
+
Invoice Number:
{" "}
+ {data?.invoiceNumber}
+
+
+
E-Invoice Number:
{" "}
+ {data?.eInvoiceNumber}
-
- Project: {data?.project?.name}
-
-
- Status: {data?.isActive ? "Active" : "Inactive"}
-
-
-
-
-
-
Invoice Date:{" "}
+
+
Invoice Date:
{" "}
{formatUTCToLocalTime(data?.invoiceDate)}
-
-
Client Submitted Date:{" "}
+
+
Client Submitted Date:
{" "}
{formatUTCToLocalTime(data?.clientSubmitedDate)}
-
-
Expected Payment Date:{" "}
+
+
Expected Payment Date:
{" "}
{formatUTCToLocalTime(data?.exceptedPaymentDate)}
-
-
Mark as Completed:{" "}
+
+
Mark as Completed:
{" "}
{data?.markAsCompleted ? "Yes" : "No"}
-
-
Basic Amount:{" "}
+
+
Basic Amount:
{" "}
{formatFigure(data?.basicAmount, {
type: "currency",
currency: "INR",
})}
-
-
Tax Amount:{" "}
+
+
Tax Amount:
{" "}
{formatFigure(data?.taxAmount, {
type: "currency",
currency: "INR",
@@ -77,76 +83,85 @@ const ViewCollection = () => {
-
-
Balance Amount:{" "}
+
+
Balance Amount:
{" "}
{formatFigure(data?.balanceAmount, {
type: "currency",
currency: "INR",
})}
-
-
Created At: {formatUTCToLocalTime(data?.createdAt)}
+
+
Created At:
{" "}
+ {formatUTCToLocalTime(data?.createdAt)}
-
-
Created By:{" "}
+
+
Created By:
{" "}
- {data?.createdBy?.firstName} {data?.createdBy?.lastName} (
- {data?.createdBy?.jobRoleName})
+ {data?.createdBy?.firstName} {data?.createdBy?.lastName}
{" "}
- {/*
Updated At: {data?.updatedAt ? formatUTCToLocalTime(data?.updatedAt) : "-"}
*/}
+
+
+
Description :
+ {data?.description}
+
- {data?.receivedInvoicePayments?.length > 0 && (
-
-
Received Payments
-
-
-
- Sr,No |
- Transaction ID |
- Received Date |
- Amount |
- Received By |
-
-
-
- {data.receivedInvoicePayments.map((payment, index) => (
-
- {index + 1} |
- {payment.transactionId} |
- {formatUTCToLocalTime(payment.paymentReceivedDate)} |
-
- {formatFigure(payment.amount, {
- type: "currency",
- currency: "INR",
- })}
- |
-
-
-
- {payment.createdBy?.firstName}{" "}
- {payment.createdBy?.lastName}
-
- |
-
- ))}
-
-
+
+ {/* Tabs Navigation */}
+
+ -
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+ {/* Payments History Tab Content */}
+
- )}
+
);
diff --git a/src/components/collections/collectionSchema.jsx b/src/components/collections/collectionSchema.jsx
index 2d0509c1..598c7541 100644
--- a/src/components/collections/collectionSchema.jsx
+++ b/src/components/collections/collectionSchema.jsx
@@ -77,6 +77,7 @@ export const paymentSchema = z.object({
paymentReceivedDate: z.string().min(1, { message: "Date is required" }),
transactionId: z.string().min(1, "Transaction ID is required"),
amount: z.number().min(1, "Amount must be greater than zero"),
+ comment:z.string().min(1,{message:"Comment required"})
});
// Default Value
@@ -84,4 +85,10 @@ export const defaultPayment = {
paymentReceivedDate: null,
transactionId: "",
amount: 0,
+ comment:""
};
+
+
+export const CommentSchema = z.object({
+ comment:z.string().min(1,{message:"Comment required"})
+})
diff --git a/src/components/common/Avatar.jsx b/src/components/common/Avatar.jsx
index 5c3f25e6..04b36f3c 100644
--- a/src/components/common/Avatar.jsx
+++ b/src/components/common/Avatar.jsx
@@ -51,7 +51,7 @@ const Avatar = ({ firstName, lastName, size = "sm", classAvatar }) => {
return (
-
+
{generateAvatarText(firstName, lastName)}
diff --git a/src/hooks/useCollections.js b/src/hooks/useCollections.js
index 6f00697e..fd4e51bb 100644
--- a/src/hooks/useCollections.js
+++ b/src/hooks/useCollections.js
@@ -109,4 +109,23 @@ export const useAddPayment = (onSuccessCallBack) => {
);
},
});
+};
+
+export const useAddComment = (onSuccessCallBack) => {
+ const client = useQueryClient();
+
+ return useMutation({
+ mutationFn: (payload) => CollectionRepository.addComment(payload),
+ onSuccess: () => {
+ client.invalidateQueries({ queryKey: ["collections"] });
+ client.invalidateQueries({ queryKey: ["collection"] });
+ showToast("Comment Successfully", "success");
+ if (onSuccessCallBack) onSuccessCallBack();
+ },
+ onError: (error) => {
+ showToast(
+ error?.response?.data?.message || error.message || "Something Went wrong"
+ );
+ },
+ });
};
\ No newline at end of file
diff --git a/src/repositories/ColllectionRepository.jsx b/src/repositories/ColllectionRepository.jsx
index 432cab76..e2807bbf 100644
--- a/src/repositories/ColllectionRepository.jsx
+++ b/src/repositories/ColllectionRepository.jsx
@@ -19,6 +19,7 @@ export const CollectionRepository = {
makeReceivePayment:(data)=> api.post(`/api/Collection/invoice/payment/received`,data),
markPaymentReceived:(invoiceId)=>api.put(`/api/Collection/invoice/marked/completed/${invoiceId}`),
- getCollection:(id)=>api.get(`/api/Collection/invoice/details/${id}`)
+ getCollection:(id)=>api.get(`/api/Collection/invoice/details/${id}`),
+ addComment:(data)=>api.post(`/api/Collection/invoice/add/comment`,data)
};
diff --git a/src/utils/appUtils.js b/src/utils/appUtils.js
index f9be1ebd..bfe9b692 100644
--- a/src/utils/appUtils.js
+++ b/src/utils/appUtils.js
@@ -113,7 +113,7 @@ export const formatFigure = (
type = "number",
currency = "INR",
locale = "en-US",
- notation = "compact",
+ notation = "standard", // standard or compact
compactDisplay = "short",
minimumFractionDigits = 0,
maximumFractionDigits = 2,