abhishek-akbari01 commited on
Commit
95c9acc
·
1 Parent(s): dcf70fd

fix invoice activity log issue

Browse files
src/controllers/invoice/invoice.controller.ts CHANGED
@@ -424,7 +424,7 @@ export const getInvoiceById = async (req: AuthenticatedRequest, res: Response):
424
  };
425
 
426
  const updateInvoiceDetails = async (invoiceId: number, billSplit: any[], userId: number) => {
427
- const existingInvoiceDetails = InvoiceDetail.findAll({ where: { invoice_id: invoiceId } });
428
  // Delete existing InvoiceDetails
429
  await InvoiceDetail.destroy({ where: { invoice_id: invoiceId } });
430
 
 
424
  };
425
 
426
  const updateInvoiceDetails = async (invoiceId: number, billSplit: any[], userId: number) => {
427
+ const existingInvoiceDetails = await InvoiceDetail.findAll({ where: { invoice_id: invoiceId } });
428
  // Delete existing InvoiceDetails
429
  await InvoiceDetail.destroy({ where: { invoice_id: invoiceId } });
430
 
src/controllers/invoiceActivityLogs.controller.ts CHANGED
@@ -12,8 +12,8 @@ export const logInvoiceAction = async (logData: InvoiceActivityLogInterface) =>
12
  user_id: logData.user_id,
13
  activity_type: logData.activity_type,
14
  field_name: logData.field_name,
15
- old_value: logData.old_value,
16
- new_value: logData.new_value,
17
  });
18
  } catch (error) {
19
  logger.error('Failed to log invoice action:', error);
 
12
  user_id: logData.user_id,
13
  activity_type: logData.activity_type,
14
  field_name: logData.field_name,
15
+ old_value: typeof logData.old_value !== 'string' ? JSON.stringify(logData.old_value) : logData.old_value,
16
+ new_value: typeof logData.new_value !== 'string' ? JSON.stringify(logData.new_value) : logData.new_value,
17
  });
18
  } catch (error) {
19
  logger.error('Failed to log invoice action:', error);