Spaces:
Runtime error
Runtime error
Commit
·
96e90b1
1
Parent(s):
4be3772
Separate bill upload and owner portal publishing in Propertyware service
Browse files
src/shared/services/bills.service.ts
CHANGED
@@ -1,14 +1,11 @@
|
|
1 |
-
import { Request, Response } from 'express';
|
2 |
import { logger } from '../../utils/logger';
|
3 |
import Invoice from '../../models/invoice';
|
4 |
import InvoiceDetail from '../../models/invoicedetail';
|
5 |
-
import { createBill, uploadBill } from './propertyware.service';
|
6 |
import { formatDate } from '../../utils/dataUtils';
|
7 |
import ErrorLog from '../../models/errorLog';
|
8 |
import { createAuditLog } from '../../controllers/auditLog.controller';
|
9 |
import { updateInvoiceData } from '../../controllers/invoice/invoice.controller';
|
10 |
-
import fs from 'fs';
|
11 |
-
import path from 'path';
|
12 |
import axios from 'axios';
|
13 |
import FormData from 'form-data';
|
14 |
|
@@ -79,9 +76,10 @@ export const syncInvoicesService = async (): Promise<string> => {
|
|
79 |
formData.append('file', fileBuffer, {
|
80 |
filename: invoice.filename
|
81 |
});
|
82 |
-
formData.append("publishToOwnerPortal", true);
|
83 |
|
84 |
-
await uploadBill(response.id, formData);
|
|
|
|
|
85 |
|
86 |
} catch (error) {
|
87 |
console.log("Invoice file upload failed: ", error);
|
|
|
|
|
1 |
import { logger } from '../../utils/logger';
|
2 |
import Invoice from '../../models/invoice';
|
3 |
import InvoiceDetail from '../../models/invoicedetail';
|
4 |
+
import { createBill, uploadBill, uploadBillToOwnerPortal } from './propertyware.service';
|
5 |
import { formatDate } from '../../utils/dataUtils';
|
6 |
import ErrorLog from '../../models/errorLog';
|
7 |
import { createAuditLog } from '../../controllers/auditLog.controller';
|
8 |
import { updateInvoiceData } from '../../controllers/invoice/invoice.controller';
|
|
|
|
|
9 |
import axios from 'axios';
|
10 |
import FormData from 'form-data';
|
11 |
|
|
|
76 |
formData.append('file', fileBuffer, {
|
77 |
filename: invoice.filename
|
78 |
});
|
|
|
79 |
|
80 |
+
const billDocumentResponse = await uploadBill(response.id, formData);
|
81 |
+
|
82 |
+
await uploadBillToOwnerPortal(billDocumentResponse.id, invoice.filename);
|
83 |
|
84 |
} catch (error) {
|
85 |
console.log("Invoice file upload failed: ", error);
|
src/shared/services/propertyware.service.ts
CHANGED
@@ -82,6 +82,14 @@ export const uploadBill = async (billId: string, params: any) => {
|
|
82 |
return response.data;
|
83 |
};
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
export const fetchAllWorkorders = async () => {
|
86 |
const response = await apiClientPW.get(`/workorders?limit=5000`);
|
87 |
return response.data;
|
|
|
82 |
return response.data;
|
83 |
};
|
84 |
|
85 |
+
export const uploadBillToOwnerPortal = async (documentId: string, fileName: string) => {
|
86 |
+
const response = await apiClientPW.put(`/docs/${documentId}`, {
|
87 |
+
publishToOwnerPortal: true,
|
88 |
+
fileName: fileName,
|
89 |
+
});
|
90 |
+
return response.data;
|
91 |
+
};
|
92 |
+
|
93 |
export const fetchAllWorkorders = async () => {
|
94 |
const response = await apiClientPW.get(`/workorders?limit=5000`);
|
95 |
return response.data;
|