Spaces:
Runtime error
Runtime error
abhishek-akbari01 commited on
Commit ·
68affe5
1
Parent(s): fcd4fca
ghl invoice activity logs added
Browse files
src/controllers/invoice/invoice.controller.ts
CHANGED
|
@@ -12,7 +12,7 @@ import PwBuilding from "../../models/pwBuildings";
|
|
| 12 |
import PwUnit from "../../models/pwUnits";
|
| 13 |
import { logger } from '../../utils/logger';
|
| 14 |
import ErrorLog from "../../models/errorLog";
|
| 15 |
-
import { fetchBuildingsById, fetchPortfolioById, fetchUnitsById, fetchWorkorderById, fetchBuildingPropertyManager } from "../../shared/services/propertyware.service";
|
| 16 |
import { logInvoiceAction } from "../invoiceActivityLogs.controller";
|
| 17 |
import InvoiceApproval from "../../models/invoiceApproval";
|
| 18 |
import Role from "../../models/roles";
|
|
@@ -523,6 +523,25 @@ const updateInvoiceDetails = async (invoiceId: number, billSplit: any[], userId:
|
|
| 523 |
});
|
| 524 |
}
|
| 525 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 526 |
|
| 527 |
if (newDetail.amount !== existingDetail.amount) {
|
| 528 |
await logInvoiceAction({
|
|
|
|
| 12 |
import PwUnit from "../../models/pwUnits";
|
| 13 |
import { logger } from '../../utils/logger';
|
| 14 |
import ErrorLog from "../../models/errorLog";
|
| 15 |
+
import { fetchBuildingsById, fetchPortfolioById, fetchUnitsById, fetchWorkorderById, fetchBuildingPropertyManager, fetchGLAccountById } from "../../shared/services/propertyware.service";
|
| 16 |
import { logInvoiceAction } from "../invoiceActivityLogs.controller";
|
| 17 |
import InvoiceApproval from "../../models/invoiceApproval";
|
| 18 |
import Role from "../../models/roles";
|
|
|
|
| 523 |
});
|
| 524 |
}
|
| 525 |
}
|
| 526 |
+
if (existingDetail.pw_gl_account_id !== newDetail.pw_gl_account_id)
|
| 527 |
+
{
|
| 528 |
+
const oldGhlAccountName = existingDetail.pw_gl_account_id
|
| 529 |
+
? (await fetchGLAccountById(existingDetail.pw_gl_account_id))?.name || 'Unknown GHL Account'
|
| 530 |
+
: 'null';
|
| 531 |
+
const newGhlAccountName = newDetail.pw_gl_account_id
|
| 532 |
+
? (await fetchGLAccountById(newDetail.pw_gl_account_id))?.name || ''
|
| 533 |
+
: 'null';
|
| 534 |
+
if (oldGhlAccountName !== newGhlAccountName) {
|
| 535 |
+
await logInvoiceAction({
|
| 536 |
+
invoice_id: invoiceId,
|
| 537 |
+
user_id: userId,
|
| 538 |
+
activity_type: 'update bill split',
|
| 539 |
+
field_name: 'ghl account',
|
| 540 |
+
old_value: oldGhlAccountName,
|
| 541 |
+
new_value: newGhlAccountName,
|
| 542 |
+
});
|
| 543 |
+
}
|
| 544 |
+
}
|
| 545 |
|
| 546 |
if (newDetail.amount !== existingDetail.amount) {
|
| 547 |
await logInvoiceAction({
|
src/controllers/invoiceActivityLogs.controller.ts
CHANGED
|
@@ -42,13 +42,8 @@ export const getInvoiceActivityLogs = async (req: Request, res: Response) => {
|
|
| 42 |
|
| 43 |
const whereClause = buildInvoiceLogWhereClause(filter);
|
| 44 |
|
| 45 |
-
const currentPage = parseInt(page as string) || 1;
|
| 46 |
-
const pageSize = parseInt(limit as string) || 10;
|
| 47 |
-
|
| 48 |
const options: FindOptions = {
|
| 49 |
where: whereClause,
|
| 50 |
-
limit: pageSize,
|
| 51 |
-
offset: (currentPage - 1) * pageSize,
|
| 52 |
order: []
|
| 53 |
};
|
| 54 |
|
|
@@ -63,8 +58,6 @@ export const getInvoiceActivityLogs = async (req: Request, res: Response) => {
|
|
| 63 |
]);
|
| 64 |
|
| 65 |
const responseData = {
|
| 66 |
-
page: currentPage,
|
| 67 |
-
limit: pageSize,
|
| 68 |
total: invoiceActivityLogs,
|
| 69 |
data: totalInvoiceActivityLogs
|
| 70 |
};
|
|
|
|
| 42 |
|
| 43 |
const whereClause = buildInvoiceLogWhereClause(filter);
|
| 44 |
|
|
|
|
|
|
|
|
|
|
| 45 |
const options: FindOptions = {
|
| 46 |
where: whereClause,
|
|
|
|
|
|
|
| 47 |
order: []
|
| 48 |
};
|
| 49 |
|
|
|
|
| 58 |
]);
|
| 59 |
|
| 60 |
const responseData = {
|
|
|
|
|
|
|
| 61 |
total: invoiceActivityLogs,
|
| 62 |
data: totalInvoiceActivityLogs
|
| 63 |
};
|