-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #137
- Loading branch information
Showing
71 changed files
with
1,090 additions
and
3,876 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import type { RequestHandler } from "express"; | ||
export declare const handler: RequestHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.handler = void 0; | ||
const addOrganizationBankRecord_1 = require("../../helpers/licencesDB/addOrganizationBankRecord"); | ||
exports.handler = (req, res) => { | ||
const success = addOrganizationBankRecord_1.addOrganizationBankRecord(req.body, req.session); | ||
if (success) { | ||
return res.json({ | ||
success: true, | ||
message: "Record added successfully." | ||
}); | ||
} | ||
else { | ||
return res.json({ | ||
success: false, | ||
message: "Please make sure that the record you are trying to create does not already exist." | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { RequestHandler } from "express"; | ||
|
||
import { addOrganizationBankRecord } from "../../helpers/licencesDB/addOrganizationBankRecord"; | ||
|
||
|
||
export const handler: RequestHandler = (req, res) => { | ||
|
||
const success = addOrganizationBankRecord(req.body, req.session); | ||
|
||
if (success) { | ||
|
||
return res.json({ | ||
success: true, | ||
message: "Record added successfully." | ||
}); | ||
|
||
} else { | ||
|
||
return res.json({ | ||
success: false, | ||
message: "Please make sure that the record you are trying to create does not already exist." | ||
}); | ||
|
||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import type { RequestHandler } from "express"; | ||
export declare const handler: RequestHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.handler = void 0; | ||
const deleteOrganizationBankRecord_1 = require("../../helpers/licencesDB/deleteOrganizationBankRecord"); | ||
exports.handler = (req, res) => { | ||
const success = deleteOrganizationBankRecord_1.deleteOrganizationBankRecord(req.body.organizationID, req.body.recordIndex, req.session); | ||
if (success) { | ||
res.json({ | ||
success: true, | ||
message: "Organization updated successfully." | ||
}); | ||
} | ||
else { | ||
res.json({ | ||
success: false, | ||
message: "Record Not Saved" | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { RequestHandler } from "express"; | ||
|
||
import { deleteOrganizationBankRecord } from "../../helpers/licencesDB/deleteOrganizationBankRecord"; | ||
|
||
|
||
export const handler: RequestHandler = (req, res) => { | ||
|
||
const success = | ||
deleteOrganizationBankRecord(req.body.organizationID, req.body.recordIndex, req.session); | ||
|
||
if (success) { | ||
res.json({ | ||
success: true, | ||
message: "Organization updated successfully." | ||
}); | ||
} else { | ||
res.json({ | ||
success: false, | ||
message: "Record Not Saved" | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import type { RequestHandler } from "express"; | ||
export declare const handler: RequestHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.handler = void 0; | ||
const updateOrganizationBankRecord_1 = require("../../helpers/licencesDB/updateOrganizationBankRecord"); | ||
exports.handler = (req, res) => { | ||
const success = updateOrganizationBankRecord_1.updateOrganizationBankRecord(req.body, req.session); | ||
if (success) { | ||
return res.json({ | ||
success: true, | ||
message: "Record updated successfully." | ||
}); | ||
} | ||
else { | ||
return res.json({ | ||
success: false, | ||
message: "Please try again." | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { RequestHandler } from "express"; | ||
|
||
import { updateOrganizationBankRecord } from "../../helpers/licencesDB/updateOrganizationBankRecord"; | ||
|
||
|
||
export const handler: RequestHandler = (req, res) => { | ||
|
||
const success = updateOrganizationBankRecord(req.body, req.session); | ||
|
||
if (success) { | ||
|
||
return res.json({ | ||
success: true, | ||
message: "Record updated successfully." | ||
}); | ||
|
||
} else { | ||
|
||
return res.json({ | ||
success: false, | ||
message: "Please try again." | ||
}); | ||
|
||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import type { RequestHandler } from "express"; | ||
export declare const handler: RequestHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.handler = void 0; | ||
const addOrganizationBankRecord_1 = require("../../helpers/licencesDB/addOrganizationBankRecord"); | ||
const updateOrganizationBankRecord_1 = require("../../helpers/licencesDB/updateOrganizationBankRecord"); | ||
const deleteOrganizationBankRecord_1 = require("../../helpers/licencesDB/deleteOrganizationBankRecord"); | ||
const bankRecordIsBlank = (bankRecord) => { | ||
if (bankRecord.recordDateString === "" && bankRecord.recordNote === "" && !bankRecord.recordIsNA) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
exports.handler = (req, res) => { | ||
const organizationID = parseInt(req.body.organizationID, 10); | ||
const accountNumber = req.body.accountNumber; | ||
const bankingYear = parseInt(req.body.bankingYear, 10); | ||
const bankingMonth = parseInt(req.body.bankingMonth, 10); | ||
const maxBankRecordTypeIndex = parseInt(req.body.bankRecordTypeIndex, 10); | ||
let success = true; | ||
for (let typeIndex = 0; typeIndex <= maxBankRecordTypeIndex; typeIndex += 1) { | ||
const typeIndexString = typeIndex.toString(); | ||
const recordIndex = (req.body["recordIndex-" + typeIndexString] === "" ? null : parseInt(req.body["recordIndex-" + typeIndexString], 10)); | ||
const bankRecord = { | ||
recordType: "bankRecord", | ||
organizationID, | ||
accountNumber, | ||
bankingYear, | ||
bankingMonth, | ||
recordIndex, | ||
bankRecordType: req.body["bankRecordType-" + typeIndexString], | ||
recordDateString: req.body["recordDateString-" + typeIndexString], | ||
recordNote: req.body["recordNote-" + typeIndexString], | ||
recordIsNA: (req.body["recordIsNA-" + typeIndexString] === "1") | ||
}; | ||
if (req.body["recordIndex-" + typeIndexString] === "") { | ||
if (!bankRecordIsBlank(bankRecord)) { | ||
const addSuccess = addOrganizationBankRecord_1.addOrganizationBankRecord(bankRecord, req.session); | ||
if (!addSuccess) { | ||
success = false; | ||
} | ||
} | ||
} | ||
else { | ||
if (bankRecordIsBlank(bankRecord)) { | ||
const deleteSuccess = deleteOrganizationBankRecord_1.deleteOrganizationBankRecord(organizationID, recordIndex, req.session); | ||
if (!deleteSuccess) { | ||
success = false; | ||
} | ||
} | ||
else { | ||
const updateSuccess = updateOrganizationBankRecord_1.updateOrganizationBankRecord(bankRecord, req.session); | ||
if (!updateSuccess) { | ||
success = false; | ||
} | ||
} | ||
} | ||
} | ||
if (success) { | ||
return res.json({ | ||
success: true | ||
}); | ||
} | ||
else { | ||
return res.json({ | ||
success: false, | ||
message: "Please try again." | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import type { RequestHandler } from "express"; | ||
|
||
import { addOrganizationBankRecord } from "../../helpers/licencesDB/addOrganizationBankRecord"; | ||
import { updateOrganizationBankRecord } from "../../helpers/licencesDB/updateOrganizationBankRecord"; | ||
import { deleteOrganizationBankRecord } from "../../helpers/licencesDB/deleteOrganizationBankRecord"; | ||
|
||
import type * as llm from "../../types/recordTypes"; | ||
|
||
|
||
const bankRecordIsBlank = (bankRecord: llm.OrganizationBankRecord) => { | ||
|
||
if (bankRecord.recordDateString === "" && bankRecord.recordNote === "" && !bankRecord.recordIsNA) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
|
||
|
||
export const handler: RequestHandler = (req, res) => { | ||
|
||
const organizationID = parseInt(req.body.organizationID, 10); | ||
const accountNumber = req.body.accountNumber; | ||
const bankingYear = parseInt(req.body.bankingYear, 10); | ||
const bankingMonth = parseInt(req.body.bankingMonth, 10); | ||
|
||
const maxBankRecordTypeIndex = parseInt(req.body.bankRecordTypeIndex, 10); | ||
|
||
let success = true; | ||
|
||
for (let typeIndex = 0; typeIndex <= maxBankRecordTypeIndex; typeIndex += 1) { | ||
|
||
const typeIndexString = typeIndex.toString(); | ||
|
||
const recordIndex = (req.body["recordIndex-" + typeIndexString] === "" ? null : parseInt(req.body["recordIndex-" + typeIndexString], 10)); | ||
|
||
const bankRecord: llm.OrganizationBankRecord = { | ||
recordType: "bankRecord", | ||
organizationID, | ||
accountNumber, | ||
bankingYear, | ||
bankingMonth, | ||
recordIndex, | ||
bankRecordType: req.body["bankRecordType-" + typeIndexString], | ||
recordDateString: req.body["recordDateString-" + typeIndexString], | ||
recordNote: req.body["recordNote-" + typeIndexString], | ||
recordIsNA: (req.body["recordIsNA-" + typeIndexString] === "1") | ||
}; | ||
|
||
if (req.body["recordIndex-" + typeIndexString] === "") { | ||
|
||
if (!bankRecordIsBlank(bankRecord)) { | ||
const addSuccess = addOrganizationBankRecord(bankRecord, req.session); | ||
if (!addSuccess) { | ||
success = false; | ||
} | ||
} | ||
|
||
} else { | ||
|
||
if (bankRecordIsBlank(bankRecord)) { | ||
const deleteSuccess = deleteOrganizationBankRecord(organizationID, recordIndex, req.session); | ||
if (!deleteSuccess) { | ||
success = false; | ||
} | ||
} else { | ||
const updateSuccess = updateOrganizationBankRecord(bankRecord, req.session); | ||
if (!updateSuccess) { | ||
success = false; | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (success) { | ||
return res.json({ | ||
success: true | ||
}); | ||
|
||
} else { | ||
return res.json({ | ||
success: false, | ||
message: "Please try again." | ||
}); | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.