Spaces:
Runtime error
Runtime error
abhishek-akbari01 commited on
Commit ·
c8c1310
1
Parent(s): 8fe9aa3
fix invoice approval for admin
Browse files
src/controllers/invoice/invoice.controller.ts
CHANGED
|
@@ -697,8 +697,15 @@ export const approveInvoice = async (req: AuthenticatedRequest, res: Response):
|
|
| 697 |
res.status(400).json({ error: 'Invalid approval role ID' });
|
| 698 |
return;
|
| 699 |
}
|
|
|
|
|
|
|
| 700 |
|
| 701 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 702 |
if (roleData.name === 'Property Manager' || roleData.name === 'Accounting Supervisor') {
|
| 703 |
await approveAndCreateRecord(invoice.id as number, userData.id, roleData.id, comment);
|
| 704 |
|
|
|
|
| 697 |
res.status(400).json({ error: 'Invalid approval role ID' });
|
| 698 |
return;
|
| 699 |
}
|
| 700 |
+
if (roleData.name === "Admin") {
|
| 701 |
+
await approveAndCreateRecord(invoice.id as number, userData.id, roleData.id, comment);
|
| 702 |
|
| 703 |
+
invoice.status = 'Approved';
|
| 704 |
+
await invoice.save();
|
| 705 |
+
|
| 706 |
+
res.status(200).json({ message: 'Invoice approved' });
|
| 707 |
+
|
| 708 |
+
} else if (invoice.total < 1500) {
|
| 709 |
if (roleData.name === 'Property Manager' || roleData.name === 'Accounting Supervisor') {
|
| 710 |
await approveAndCreateRecord(invoice.id as number, userData.id, roleData.id, comment);
|
| 711 |
|