@tamu-dor/famis-db 3.0.0-beta.2 → 3.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.vite/manifest.json +1 -0
- package/dist/index.d.mts +59 -45
- package/dist/index.d.ts +59 -45
- package/dist/main.cjs +64 -24
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +64 -24
- package/dist/main.js.map +1 -1
- package/package.json +11 -11
package/dist/.vite/manifest.json
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -51,32 +51,32 @@ export declare interface AccountPayload {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export declare interface Contact {
|
|
54
|
-
fax
|
|
55
|
-
city
|
|
56
|
-
name
|
|
57
|
-
email
|
|
58
|
-
phone
|
|
59
|
-
state
|
|
60
|
-
country
|
|
61
|
-
address1
|
|
62
|
-
address2
|
|
63
|
-
mailstop
|
|
64
|
-
department
|
|
65
|
-
postalCode
|
|
66
|
-
institution
|
|
54
|
+
fax?: string | null;
|
|
55
|
+
city?: string | null;
|
|
56
|
+
name?: string;
|
|
57
|
+
email?: string | null;
|
|
58
|
+
phone?: string | null;
|
|
59
|
+
state?: string | null;
|
|
60
|
+
country?: string | null;
|
|
61
|
+
address1?: string | null;
|
|
62
|
+
address2?: string | null;
|
|
63
|
+
mailstop?: string | null;
|
|
64
|
+
department?: string | null;
|
|
65
|
+
postalCode?: string | null;
|
|
66
|
+
institution?: string | null;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
export declare interface Core {
|
|
70
|
-
id
|
|
70
|
+
id?: number;
|
|
71
71
|
account?: string;
|
|
72
72
|
effective?: string;
|
|
73
|
-
facility
|
|
73
|
+
facility?: string;
|
|
74
74
|
contact: string;
|
|
75
75
|
contactEmail: string;
|
|
76
76
|
systemId: number;
|
|
77
77
|
enabled: boolean;
|
|
78
78
|
deleted: string | null;
|
|
79
|
-
coreEmail
|
|
79
|
+
coreEmail?: string | null;
|
|
80
80
|
corePhone: string | null;
|
|
81
81
|
coreAddress: string | null;
|
|
82
82
|
from_email: string | null;
|
|
@@ -91,7 +91,7 @@ export declare interface Core {
|
|
|
91
91
|
|
|
92
92
|
export declare interface CoreAccount {
|
|
93
93
|
id?: number;
|
|
94
|
-
account
|
|
94
|
+
account?: string;
|
|
95
95
|
coreId: number;
|
|
96
96
|
coreAccountId?: number;
|
|
97
97
|
coreAccountActive?: boolean | null;
|
|
@@ -100,9 +100,9 @@ export declare interface CoreAccount {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
export declare interface CoreAccountEmail {
|
|
103
|
-
uid
|
|
104
|
-
core_id
|
|
105
|
-
account_number
|
|
103
|
+
uid?: string;
|
|
104
|
+
core_id?: number;
|
|
105
|
+
account_number?: string;
|
|
106
106
|
email: string;
|
|
107
107
|
created?: Date | null;
|
|
108
108
|
deleted?: Date | null;
|
|
@@ -115,7 +115,7 @@ export declare interface CorePayload {
|
|
|
115
115
|
|
|
116
116
|
export declare interface CoreUser {
|
|
117
117
|
id?: number;
|
|
118
|
-
userId
|
|
118
|
+
userId?: string;
|
|
119
119
|
coreId: number;
|
|
120
120
|
coreUserId?: number;
|
|
121
121
|
email?: boolean | null;
|
|
@@ -281,8 +281,15 @@ export declare interface Edge {
|
|
|
281
281
|
declare class FAMISDb {
|
|
282
282
|
private db;
|
|
283
283
|
private people;
|
|
284
|
-
constructor(config: any, people: any);
|
|
285
|
-
|
|
284
|
+
constructor(config: any, people: any, debug: boolean);
|
|
285
|
+
/**
|
|
286
|
+
* Initializes the database connection and sets up the Knex instance for interacting with PostgreSQL database.
|
|
287
|
+
*
|
|
288
|
+
* @param {any} config - The configuration object that includes details about how to connect to a PostgreSQL database. This should include properties such as `host`, `user`, `password`, etc.
|
|
289
|
+
* @param {any} people - The data related to the 'people' entity. It could be an array of person objects or any other format depending on your application requirements.
|
|
290
|
+
* @param {boolean} debug - A flag indicating whether to enable debugging for Knex queries. Defaults to `false`. If set to `true`, it will log all SQL queries that are executed against the database in the console.
|
|
291
|
+
*/
|
|
292
|
+
init(config: any, people?: any, debug?: boolean): void;
|
|
286
293
|
/**
|
|
287
294
|
*
|
|
288
295
|
* Extract customer account and po number
|
|
@@ -472,11 +479,11 @@ declare class FAMISDb {
|
|
|
472
479
|
*
|
|
473
480
|
* Updates an invoice
|
|
474
481
|
* @param {string} uid
|
|
475
|
-
* @param {
|
|
476
|
-
* @returns {Promise<
|
|
482
|
+
* @param {Invoice} invoice
|
|
483
|
+
* @returns {Promise<Invoice>} invoice object
|
|
477
484
|
* @memberof FAMISDb
|
|
478
485
|
*/
|
|
479
|
-
updateInvoice(uid: string, invoice:
|
|
486
|
+
updateInvoice(uid: string, invoice: Invoice): Promise<InvoicePayload>;
|
|
480
487
|
/**
|
|
481
488
|
*
|
|
482
489
|
* Toggles an invoice as paid
|
|
@@ -918,6 +925,13 @@ declare class FAMISDb {
|
|
|
918
925
|
* @property {date} created - created date
|
|
919
926
|
* @property {date} deleted - deleted date
|
|
920
927
|
*/
|
|
928
|
+
/**
|
|
929
|
+
* Create an invoice comment file.
|
|
930
|
+
* @param {InvoiceCommentFile} file - JSON object representing the comment file
|
|
931
|
+
* @returns {Promise<InvoiceCommentFile>} - Promise that resolves to the comment file object
|
|
932
|
+
* @memberof FAMISDb
|
|
933
|
+
*/
|
|
934
|
+
saveCommentFile(file: InvoiceCommentFile): Promise<InvoiceCommentFile | null>;
|
|
921
935
|
/**
|
|
922
936
|
* Get invoice comment files.
|
|
923
937
|
* @param {string} commentUid - Comment UID
|
|
@@ -1019,11 +1033,11 @@ declare class FAMISDb {
|
|
|
1019
1033
|
}
|
|
1020
1034
|
|
|
1021
1035
|
export declare interface Invoice {
|
|
1022
|
-
uid
|
|
1023
|
-
number
|
|
1024
|
-
lab
|
|
1025
|
-
totalAmount
|
|
1026
|
-
date
|
|
1036
|
+
uid?: string | null;
|
|
1037
|
+
number?: string | null;
|
|
1038
|
+
lab?: string | null;
|
|
1039
|
+
totalAmount?: string;
|
|
1040
|
+
date?: string;
|
|
1027
1041
|
data: TransactionData;
|
|
1028
1042
|
invoiced: boolean;
|
|
1029
1043
|
type: string;
|
|
@@ -1034,21 +1048,21 @@ declare class FAMISDb {
|
|
|
1034
1048
|
postedDate: string | null;
|
|
1035
1049
|
emailed: boolean;
|
|
1036
1050
|
replace_data?: object | null;
|
|
1037
|
-
fingerprint
|
|
1038
|
-
core
|
|
1039
|
-
customerAccountInfo
|
|
1040
|
-
isIdt
|
|
1041
|
-
poNumber
|
|
1042
|
-
pi
|
|
1043
|
-
highRiskInfo
|
|
1044
|
-
comments
|
|
1051
|
+
fingerprint?: string | null;
|
|
1052
|
+
core?: Core | null;
|
|
1053
|
+
customerAccountInfo?: CustomerAccountInfo | null;
|
|
1054
|
+
isIdt?: boolean | null;
|
|
1055
|
+
poNumber?: string | null;
|
|
1056
|
+
pi?: PI | null;
|
|
1057
|
+
highRiskInfo?: HighRiskInfo | null;
|
|
1058
|
+
comments?: InvoiceComment[] | null;
|
|
1045
1059
|
}
|
|
1046
1060
|
|
|
1047
1061
|
export declare interface InvoiceComment {
|
|
1048
1062
|
id?: number;
|
|
1049
|
-
uid
|
|
1063
|
+
uid?: string;
|
|
1050
1064
|
invoice_id: string;
|
|
1051
|
-
user_id
|
|
1065
|
+
user_id?: string | null;
|
|
1052
1066
|
comment: string | null;
|
|
1053
1067
|
type: string | null;
|
|
1054
1068
|
created: string | null;
|
|
@@ -1056,7 +1070,7 @@ declare class FAMISDb {
|
|
|
1056
1070
|
}
|
|
1057
1071
|
|
|
1058
1072
|
export declare type InvoiceCommentFile = {
|
|
1059
|
-
id
|
|
1073
|
+
id?: number;
|
|
1060
1074
|
uid: string;
|
|
1061
1075
|
invoice_id: string;
|
|
1062
1076
|
comment_id: string;
|
|
@@ -1126,9 +1140,9 @@ declare class FAMISDb {
|
|
|
1126
1140
|
fein: string;
|
|
1127
1141
|
agency: string;
|
|
1128
1142
|
checkAddress: string;
|
|
1129
|
-
credit
|
|
1130
|
-
creditUrl
|
|
1131
|
-
creditFee
|
|
1143
|
+
credit?: boolean | null;
|
|
1144
|
+
creditUrl?: string | null;
|
|
1145
|
+
creditFee?: string | null;
|
|
1132
1146
|
part: string;
|
|
1133
1147
|
abbrev: string;
|
|
1134
1148
|
aggiebuy: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -51,32 +51,32 @@ export declare interface AccountPayload {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export declare interface Contact {
|
|
54
|
-
fax
|
|
55
|
-
city
|
|
56
|
-
name
|
|
57
|
-
email
|
|
58
|
-
phone
|
|
59
|
-
state
|
|
60
|
-
country
|
|
61
|
-
address1
|
|
62
|
-
address2
|
|
63
|
-
mailstop
|
|
64
|
-
department
|
|
65
|
-
postalCode
|
|
66
|
-
institution
|
|
54
|
+
fax?: string | null;
|
|
55
|
+
city?: string | null;
|
|
56
|
+
name?: string;
|
|
57
|
+
email?: string | null;
|
|
58
|
+
phone?: string | null;
|
|
59
|
+
state?: string | null;
|
|
60
|
+
country?: string | null;
|
|
61
|
+
address1?: string | null;
|
|
62
|
+
address2?: string | null;
|
|
63
|
+
mailstop?: string | null;
|
|
64
|
+
department?: string | null;
|
|
65
|
+
postalCode?: string | null;
|
|
66
|
+
institution?: string | null;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
export declare interface Core {
|
|
70
|
-
id
|
|
70
|
+
id?: number;
|
|
71
71
|
account?: string;
|
|
72
72
|
effective?: string;
|
|
73
|
-
facility
|
|
73
|
+
facility?: string;
|
|
74
74
|
contact: string;
|
|
75
75
|
contactEmail: string;
|
|
76
76
|
systemId: number;
|
|
77
77
|
enabled: boolean;
|
|
78
78
|
deleted: string | null;
|
|
79
|
-
coreEmail
|
|
79
|
+
coreEmail?: string | null;
|
|
80
80
|
corePhone: string | null;
|
|
81
81
|
coreAddress: string | null;
|
|
82
82
|
from_email: string | null;
|
|
@@ -91,7 +91,7 @@ export declare interface Core {
|
|
|
91
91
|
|
|
92
92
|
export declare interface CoreAccount {
|
|
93
93
|
id?: number;
|
|
94
|
-
account
|
|
94
|
+
account?: string;
|
|
95
95
|
coreId: number;
|
|
96
96
|
coreAccountId?: number;
|
|
97
97
|
coreAccountActive?: boolean | null;
|
|
@@ -100,9 +100,9 @@ export declare interface CoreAccount {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
export declare interface CoreAccountEmail {
|
|
103
|
-
uid
|
|
104
|
-
core_id
|
|
105
|
-
account_number
|
|
103
|
+
uid?: string;
|
|
104
|
+
core_id?: number;
|
|
105
|
+
account_number?: string;
|
|
106
106
|
email: string;
|
|
107
107
|
created?: Date | null;
|
|
108
108
|
deleted?: Date | null;
|
|
@@ -115,7 +115,7 @@ export declare interface CorePayload {
|
|
|
115
115
|
|
|
116
116
|
export declare interface CoreUser {
|
|
117
117
|
id?: number;
|
|
118
|
-
userId
|
|
118
|
+
userId?: string;
|
|
119
119
|
coreId: number;
|
|
120
120
|
coreUserId?: number;
|
|
121
121
|
email?: boolean | null;
|
|
@@ -281,8 +281,15 @@ export declare interface Edge {
|
|
|
281
281
|
declare class FAMISDb {
|
|
282
282
|
private db;
|
|
283
283
|
private people;
|
|
284
|
-
constructor(config: any, people: any);
|
|
285
|
-
|
|
284
|
+
constructor(config: any, people: any, debug: boolean);
|
|
285
|
+
/**
|
|
286
|
+
* Initializes the database connection and sets up the Knex instance for interacting with PostgreSQL database.
|
|
287
|
+
*
|
|
288
|
+
* @param {any} config - The configuration object that includes details about how to connect to a PostgreSQL database. This should include properties such as `host`, `user`, `password`, etc.
|
|
289
|
+
* @param {any} people - The data related to the 'people' entity. It could be an array of person objects or any other format depending on your application requirements.
|
|
290
|
+
* @param {boolean} debug - A flag indicating whether to enable debugging for Knex queries. Defaults to `false`. If set to `true`, it will log all SQL queries that are executed against the database in the console.
|
|
291
|
+
*/
|
|
292
|
+
init(config: any, people?: any, debug?: boolean): void;
|
|
286
293
|
/**
|
|
287
294
|
*
|
|
288
295
|
* Extract customer account and po number
|
|
@@ -472,11 +479,11 @@ declare class FAMISDb {
|
|
|
472
479
|
*
|
|
473
480
|
* Updates an invoice
|
|
474
481
|
* @param {string} uid
|
|
475
|
-
* @param {
|
|
476
|
-
* @returns {Promise<
|
|
482
|
+
* @param {Invoice} invoice
|
|
483
|
+
* @returns {Promise<Invoice>} invoice object
|
|
477
484
|
* @memberof FAMISDb
|
|
478
485
|
*/
|
|
479
|
-
updateInvoice(uid: string, invoice:
|
|
486
|
+
updateInvoice(uid: string, invoice: Invoice): Promise<InvoicePayload>;
|
|
480
487
|
/**
|
|
481
488
|
*
|
|
482
489
|
* Toggles an invoice as paid
|
|
@@ -918,6 +925,13 @@ declare class FAMISDb {
|
|
|
918
925
|
* @property {date} created - created date
|
|
919
926
|
* @property {date} deleted - deleted date
|
|
920
927
|
*/
|
|
928
|
+
/**
|
|
929
|
+
* Create an invoice comment file.
|
|
930
|
+
* @param {InvoiceCommentFile} file - JSON object representing the comment file
|
|
931
|
+
* @returns {Promise<InvoiceCommentFile>} - Promise that resolves to the comment file object
|
|
932
|
+
* @memberof FAMISDb
|
|
933
|
+
*/
|
|
934
|
+
saveCommentFile(file: InvoiceCommentFile): Promise<InvoiceCommentFile | null>;
|
|
921
935
|
/**
|
|
922
936
|
* Get invoice comment files.
|
|
923
937
|
* @param {string} commentUid - Comment UID
|
|
@@ -1019,11 +1033,11 @@ declare class FAMISDb {
|
|
|
1019
1033
|
}
|
|
1020
1034
|
|
|
1021
1035
|
export declare interface Invoice {
|
|
1022
|
-
uid
|
|
1023
|
-
number
|
|
1024
|
-
lab
|
|
1025
|
-
totalAmount
|
|
1026
|
-
date
|
|
1036
|
+
uid?: string | null;
|
|
1037
|
+
number?: string | null;
|
|
1038
|
+
lab?: string | null;
|
|
1039
|
+
totalAmount?: string;
|
|
1040
|
+
date?: string;
|
|
1027
1041
|
data: TransactionData;
|
|
1028
1042
|
invoiced: boolean;
|
|
1029
1043
|
type: string;
|
|
@@ -1034,21 +1048,21 @@ declare class FAMISDb {
|
|
|
1034
1048
|
postedDate: string | null;
|
|
1035
1049
|
emailed: boolean;
|
|
1036
1050
|
replace_data?: object | null;
|
|
1037
|
-
fingerprint
|
|
1038
|
-
core
|
|
1039
|
-
customerAccountInfo
|
|
1040
|
-
isIdt
|
|
1041
|
-
poNumber
|
|
1042
|
-
pi
|
|
1043
|
-
highRiskInfo
|
|
1044
|
-
comments
|
|
1051
|
+
fingerprint?: string | null;
|
|
1052
|
+
core?: Core | null;
|
|
1053
|
+
customerAccountInfo?: CustomerAccountInfo | null;
|
|
1054
|
+
isIdt?: boolean | null;
|
|
1055
|
+
poNumber?: string | null;
|
|
1056
|
+
pi?: PI | null;
|
|
1057
|
+
highRiskInfo?: HighRiskInfo | null;
|
|
1058
|
+
comments?: InvoiceComment[] | null;
|
|
1045
1059
|
}
|
|
1046
1060
|
|
|
1047
1061
|
export declare interface InvoiceComment {
|
|
1048
1062
|
id?: number;
|
|
1049
|
-
uid
|
|
1063
|
+
uid?: string;
|
|
1050
1064
|
invoice_id: string;
|
|
1051
|
-
user_id
|
|
1065
|
+
user_id?: string | null;
|
|
1052
1066
|
comment: string | null;
|
|
1053
1067
|
type: string | null;
|
|
1054
1068
|
created: string | null;
|
|
@@ -1056,7 +1070,7 @@ declare class FAMISDb {
|
|
|
1056
1070
|
}
|
|
1057
1071
|
|
|
1058
1072
|
export declare type InvoiceCommentFile = {
|
|
1059
|
-
id
|
|
1073
|
+
id?: number;
|
|
1060
1074
|
uid: string;
|
|
1061
1075
|
invoice_id: string;
|
|
1062
1076
|
comment_id: string;
|
|
@@ -1126,9 +1140,9 @@ declare class FAMISDb {
|
|
|
1126
1140
|
fein: string;
|
|
1127
1141
|
agency: string;
|
|
1128
1142
|
checkAddress: string;
|
|
1129
|
-
credit
|
|
1130
|
-
creditUrl
|
|
1131
|
-
creditFee
|
|
1143
|
+
credit?: boolean | null;
|
|
1144
|
+
creditUrl?: string | null;
|
|
1145
|
+
creditFee?: string | null;
|
|
1132
1146
|
part: string;
|
|
1133
1147
|
abbrev: string;
|
|
1134
1148
|
aggiebuy: string;
|
package/dist/main.cjs
CHANGED
|
@@ -190,16 +190,23 @@ class FAMISDb {
|
|
|
190
190
|
db;
|
|
191
191
|
//@ts-ignore
|
|
192
192
|
people;
|
|
193
|
-
constructor(config, people) {
|
|
193
|
+
constructor(config, people, debug) {
|
|
194
194
|
if (config) {
|
|
195
|
-
this.init(config, people);
|
|
195
|
+
this.init(config, people, debug || false);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Initializes the database connection and sets up the Knex instance for interacting with PostgreSQL database.
|
|
200
|
+
*
|
|
201
|
+
* @param {any} config - The configuration object that includes details about how to connect to a PostgreSQL database. This should include properties such as `host`, `user`, `password`, etc.
|
|
202
|
+
* @param {any} people - The data related to the 'people' entity. It could be an array of person objects or any other format depending on your application requirements.
|
|
203
|
+
* @param {boolean} debug - A flag indicating whether to enable debugging for Knex queries. Defaults to `false`. If set to `true`, it will log all SQL queries that are executed against the database in the console.
|
|
204
|
+
*/
|
|
205
|
+
init(config, people = null, debug = false) {
|
|
199
206
|
this.db = knex({
|
|
200
207
|
client: "pg",
|
|
201
208
|
connection: config,
|
|
202
|
-
debug
|
|
209
|
+
debug,
|
|
203
210
|
pool: {
|
|
204
211
|
min: 0,
|
|
205
212
|
max: 10,
|
|
@@ -684,13 +691,13 @@ class FAMISDb {
|
|
|
684
691
|
*
|
|
685
692
|
* Updates an invoice
|
|
686
693
|
* @param {string} uid
|
|
687
|
-
* @param {
|
|
688
|
-
* @returns {Promise<
|
|
694
|
+
* @param {Invoice} invoice
|
|
695
|
+
* @returns {Promise<Invoice>} invoice object
|
|
689
696
|
* @memberof FAMISDb
|
|
690
697
|
*/
|
|
691
698
|
async updateInvoice(uid, invoice) {
|
|
692
699
|
let records;
|
|
693
|
-
invoice.details.forEach((d) => {
|
|
700
|
+
invoice.data.details.forEach((d) => {
|
|
694
701
|
if (!d.other) {
|
|
695
702
|
d.other = "0.00";
|
|
696
703
|
}
|
|
@@ -702,20 +709,27 @@ class FAMISDb {
|
|
|
702
709
|
}
|
|
703
710
|
});
|
|
704
711
|
try {
|
|
712
|
+
const {
|
|
713
|
+
comments,
|
|
714
|
+
isIdt,
|
|
715
|
+
poNumber,
|
|
716
|
+
totalAmount,
|
|
717
|
+
data,
|
|
718
|
+
customerAccount,
|
|
719
|
+
sellingAccount,
|
|
720
|
+
fingerprint,
|
|
721
|
+
...rest
|
|
722
|
+
} = invoice;
|
|
705
723
|
const record = {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
sellingAccount: getCoreAccountNumber(invoice.details[0].famis),
|
|
713
|
-
fingerprint: invoice.fingerprint ? invoice.fingerprint : null
|
|
724
|
+
...rest,
|
|
725
|
+
totalAmount: parseFloat(totalAmount.replace("$", "")),
|
|
726
|
+
data: JSON.stringify(data),
|
|
727
|
+
customerAccount: this.getAccountNumber(data.details[0].famis).accountNumber,
|
|
728
|
+
sellingAccount: getCoreAccountNumber(data.details[0].famis),
|
|
729
|
+
fingerprint: fingerprint ? fingerprint : null
|
|
714
730
|
};
|
|
715
|
-
if (invoice.replace_data) {
|
|
716
|
-
record.replace_data = invoice.replace_data;
|
|
717
|
-
}
|
|
718
731
|
records = await this.db("invoices").returning(returningColumns).update(record).where("uid", uid);
|
|
732
|
+
records = await this.getInvoiceByUid(uid);
|
|
719
733
|
} catch (e) {
|
|
720
734
|
throw e;
|
|
721
735
|
}
|
|
@@ -1843,8 +1857,7 @@ class FAMISDb {
|
|
|
1843
1857
|
let retVal = null;
|
|
1844
1858
|
const columns = ["id", "userId", "admin", "role", "roleName", "roleEmail", "deleted"];
|
|
1845
1859
|
try {
|
|
1846
|
-
if ("id" in user)
|
|
1847
|
-
retVal = await this.db("users").returning(columns).update(user).where("id", user.id);
|
|
1860
|
+
if ("id" in user) retVal = await this.db("users").returning(columns).update(user).where("id", user.id);
|
|
1848
1861
|
} catch (e) {
|
|
1849
1862
|
throw e;
|
|
1850
1863
|
}
|
|
@@ -1932,8 +1945,7 @@ class FAMISDb {
|
|
|
1932
1945
|
if (objCode && objCode.srs && acct && acct.srs && isFederal && !srsApproved && invoice.isIdt) {
|
|
1933
1946
|
srsHighRisk = true;
|
|
1934
1947
|
let val = [detail];
|
|
1935
|
-
if (objectCodes.has(objCode.expense))
|
|
1936
|
-
val.push(...objectCodes.get(objCode.expense));
|
|
1948
|
+
if (objectCodes.has(objCode.expense)) val.push(...objectCodes.get(objCode.expense));
|
|
1937
1949
|
objectCodes.set(objCode.expense, val);
|
|
1938
1950
|
}
|
|
1939
1951
|
}
|
|
@@ -2037,6 +2049,35 @@ class FAMISDb {
|
|
|
2037
2049
|
* @property {date} created - created date
|
|
2038
2050
|
* @property {date} deleted - deleted date
|
|
2039
2051
|
*/
|
|
2052
|
+
/**
|
|
2053
|
+
* Create an invoice comment file.
|
|
2054
|
+
* @param {InvoiceCommentFile} file - JSON object representing the comment file
|
|
2055
|
+
* @returns {Promise<InvoiceCommentFile>} - Promise that resolves to the comment file object
|
|
2056
|
+
* @memberof FAMISDb
|
|
2057
|
+
*/
|
|
2058
|
+
async saveCommentFile(file) {
|
|
2059
|
+
const returningColumns2 = [
|
|
2060
|
+
"id",
|
|
2061
|
+
"uid",
|
|
2062
|
+
"invoice_id",
|
|
2063
|
+
"comment_id",
|
|
2064
|
+
"original_filename",
|
|
2065
|
+
"filename",
|
|
2066
|
+
"created",
|
|
2067
|
+
"deleted"
|
|
2068
|
+
];
|
|
2069
|
+
let response;
|
|
2070
|
+
try {
|
|
2071
|
+
response = await this.db("invoice_comment_files").returning(returningColumns2).insert(file);
|
|
2072
|
+
if (response && Array.isArray(response) && response.length) {
|
|
2073
|
+
response = response[0];
|
|
2074
|
+
}
|
|
2075
|
+
} catch (e) {
|
|
2076
|
+
console.log(e);
|
|
2077
|
+
throw e;
|
|
2078
|
+
}
|
|
2079
|
+
return response;
|
|
2080
|
+
}
|
|
2040
2081
|
/**
|
|
2041
2082
|
* Get invoice comment files.
|
|
2042
2083
|
* @param {string} commentUid - Comment UID
|
|
@@ -2064,8 +2105,7 @@ class FAMISDb {
|
|
|
2064
2105
|
let response = null;
|
|
2065
2106
|
try {
|
|
2066
2107
|
const records = await this.db("invoice_comment_files").where({ uid: fileUid });
|
|
2067
|
-
if (records.length)
|
|
2068
|
-
response = records[0];
|
|
2108
|
+
if (records.length) response = records[0];
|
|
2069
2109
|
} catch (e) {
|
|
2070
2110
|
console.log(e);
|
|
2071
2111
|
throw e;
|