Fixed issue with payment records on update
This commit is contained in:
@@ -31,5 +31,5 @@ export interface Payment {
|
|||||||
currency: string;
|
currency: string;
|
||||||
value: number;
|
value: number;
|
||||||
isPaid: boolean;
|
isPaid: boolean;
|
||||||
date: Date;
|
date: Date | string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,13 +22,14 @@ export default withIronSessionApiRoute(handler, sessionOptions);
|
|||||||
// because the id is not a par of the hash and payment expects date to be of type Date
|
// because the id is not a par of the hash and payment expects date to be of type Date
|
||||||
// but if it is not inserted as a string, some UI components will not work (Invalid Date)
|
// but if it is not inserted as a string, some UI components will not work (Invalid Date)
|
||||||
const addPaymentRecord = async (data: any) => {
|
const addPaymentRecord = async (data: any) => {
|
||||||
const shortUID = new ShortUniqueId();
|
await setDoc(doc(db, "payments", data.id), data);
|
||||||
await setDoc(doc(db, "payments", shortUID.randomUUID(8)), data);
|
|
||||||
}
|
}
|
||||||
const managePaymentRecords = async (user: User, userId: string | undefined): Promise<boolean> => {
|
const managePaymentRecords = async (user: User, userId: string | undefined): Promise<boolean> => {
|
||||||
try {
|
try {
|
||||||
if(user.type === 'corporate' && userId) {
|
if(user.type === 'corporate' && userId) {
|
||||||
const data = {
|
const shortUID = new ShortUniqueId();
|
||||||
|
const data: Payment = {
|
||||||
|
id: shortUID.randomUUID(8),
|
||||||
corporate: userId,
|
corporate: userId,
|
||||||
agent: user.corporateInformation.referralAgent,
|
agent: user.corporateInformation.referralAgent,
|
||||||
agentCommission: user.corporateInformation.payment!.commission,
|
agentCommission: user.corporateInformation.payment!.commission,
|
||||||
|
|||||||
Reference in New Issue
Block a user