-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
additional fee maintenance #85 - see todo
done - add additional fee - update additional fee - reorder additional fees todo - delete additional fee - format render additional fees
- Loading branch information
Showing
39 changed files
with
1,104 additions
and
9 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
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
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,3 @@ | ||
import type { RequestHandler } from "express"; | ||
export declare const handler: RequestHandler; | ||
export default handler; |
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,14 @@ | ||
import { addLicenceCategoryAdditionalFee } from "../../helpers/licencesDB/addLicenceCategoryAdditionalFee.js"; | ||
import { getLicenceCategoryAdditionalFees } from "../../helpers/licencesDB/getLicenceCategoryAdditionalFees.js"; | ||
import * as cacheFunctions from "../../helpers/functions.cache.js"; | ||
export const handler = async (request, response) => { | ||
const licenceApprovalKey = addLicenceCategoryAdditionalFee(request.body, request.session); | ||
cacheFunctions.clearAll(); | ||
const licenceCategoryAdditionalFees = getLicenceCategoryAdditionalFees(request.body.licenceCategoryKey); | ||
response.json({ | ||
success: true, | ||
licenceCategoryAdditionalFees, | ||
licenceApprovalKey | ||
}); | ||
}; | ||
export default handler; |
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 { addLicenceCategoryAdditionalFee } from "../../helpers/licencesDB/addLicenceCategoryAdditionalFee.js"; | ||
import { getLicenceCategoryAdditionalFees } from "../../helpers/licencesDB/getLicenceCategoryAdditionalFees.js"; | ||
|
||
import * as cacheFunctions from "../../helpers/functions.cache.js"; | ||
|
||
|
||
export const handler: RequestHandler = async (request, response) => { | ||
|
||
const licenceApprovalKey = addLicenceCategoryAdditionalFee(request.body, request.session); | ||
|
||
cacheFunctions.clearAll(); | ||
|
||
const licenceCategoryAdditionalFees = getLicenceCategoryAdditionalFees(request.body.licenceCategoryKey); | ||
|
||
response.json({ | ||
success: true, | ||
licenceCategoryAdditionalFees, | ||
licenceApprovalKey | ||
}); | ||
}; | ||
|
||
|
||
export default handler; |
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,3 @@ | ||
import type { RequestHandler } from "express"; | ||
export declare const handler: RequestHandler; | ||
export default handler; |
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,14 @@ | ||
import { moveLicenceCategoryAdditionalFee } from "../../helpers/licencesDB/moveLicenceCategoryAdditionalFee.js"; | ||
import { getLicenceCategoryAdditionalFees } from "../../helpers/licencesDB/getLicenceCategoryAdditionalFees.js"; | ||
import * as cacheFunctions from "../../helpers/functions.cache.js"; | ||
export const handler = async (request, response) => { | ||
const licenceAdditionalFeeKey_from = request.body.licenceAdditionalFeeKey_from; | ||
const licenceAdditionalFeeKey_to = request.body.licenceApprovalKey_to; | ||
const licenceCategoryKey = moveLicenceCategoryAdditionalFee(licenceAdditionalFeeKey_from, licenceAdditionalFeeKey_to, request.session); | ||
cacheFunctions.clearAll(); | ||
const licenceCategoryAdditionalFees = getLicenceCategoryAdditionalFees(licenceCategoryKey); | ||
response.json({ | ||
licenceCategoryAdditionalFees | ||
}); | ||
}; | ||
export default handler; |
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 { moveLicenceCategoryAdditionalFee } from "../../helpers/licencesDB/moveLicenceCategoryAdditionalFee.js"; | ||
import { getLicenceCategoryAdditionalFees } from "../../helpers/licencesDB/getLicenceCategoryAdditionalFees.js"; | ||
|
||
import * as cacheFunctions from "../../helpers/functions.cache.js"; | ||
|
||
|
||
export const handler: RequestHandler = async (request, response) => { | ||
|
||
const licenceAdditionalFeeKey_from = request.body.licenceAdditionalFeeKey_from as string; | ||
const licenceAdditionalFeeKey_to = request.body.licenceApprovalKey_to as string; | ||
|
||
const licenceCategoryKey = moveLicenceCategoryAdditionalFee(licenceAdditionalFeeKey_from, licenceAdditionalFeeKey_to, request.session); | ||
|
||
cacheFunctions.clearAll(); | ||
const licenceCategoryAdditionalFees = getLicenceCategoryAdditionalFees(licenceCategoryKey); | ||
|
||
response.json({ | ||
licenceCategoryAdditionalFees | ||
}); | ||
}; | ||
|
||
|
||
export default handler; |
3 changes: 3 additions & 0 deletions
3
handlers/admin-post/doUpdateLicenceCategoryAdditionalFee.d.ts
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,3 @@ | ||
import type { RequestHandler } from "express"; | ||
export declare const handler: RequestHandler; | ||
export default handler; |
15 changes: 15 additions & 0 deletions
15
handlers/admin-post/doUpdateLicenceCategoryAdditionalFee.js
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,15 @@ | ||
import { updateLicenceCategoryAdditionalFee } from "../../helpers/licencesDB/updateLicenceCategoryAdditionalFee.js"; | ||
import { getLicenceCategoryAdditionalFee } from "../../helpers/licencesDB/getLicenceCategoryAdditionalFee.js"; | ||
import { getLicenceCategoryAdditionalFees } from "../../helpers/licencesDB/getLicenceCategoryAdditionalFees.js"; | ||
import * as cacheFunctions from "../../helpers/functions.cache.js"; | ||
export const handler = async (request, response) => { | ||
const success = updateLicenceCategoryAdditionalFee(request.body, request.session); | ||
cacheFunctions.clearAll(); | ||
const licenceCategoryAdditionalFee = getLicenceCategoryAdditionalFee(request.body.licenceAdditionalFeeKey); | ||
const licenceCategoryAdditionalFees = getLicenceCategoryAdditionalFees(licenceCategoryAdditionalFee.licenceCategoryKey); | ||
response.json({ | ||
success, | ||
licenceCategoryAdditionalFees | ||
}); | ||
}; | ||
export default handler; |
27 changes: 27 additions & 0 deletions
27
handlers/admin-post/doUpdateLicenceCategoryAdditionalFee.ts
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,27 @@ | ||
import type { RequestHandler } from "express"; | ||
|
||
import { updateLicenceCategoryAdditionalFee } from "../../helpers/licencesDB/updateLicenceCategoryAdditionalFee.js"; | ||
import { getLicenceCategoryAdditionalFee } from "../../helpers/licencesDB/getLicenceCategoryAdditionalFee.js"; | ||
import { getLicenceCategoryAdditionalFees } from "../../helpers/licencesDB/getLicenceCategoryAdditionalFees.js"; | ||
|
||
import * as cacheFunctions from "../../helpers/functions.cache.js"; | ||
|
||
|
||
export const handler: RequestHandler = async (request, response) => { | ||
|
||
const success = updateLicenceCategoryAdditionalFee(request.body, request.session); | ||
|
||
cacheFunctions.clearAll(); | ||
|
||
const licenceCategoryAdditionalFee = getLicenceCategoryAdditionalFee(request.body.licenceAdditionalFeeKey); | ||
|
||
const licenceCategoryAdditionalFees = getLicenceCategoryAdditionalFees(licenceCategoryAdditionalFee.licenceCategoryKey); | ||
|
||
response.json({ | ||
success, | ||
licenceCategoryAdditionalFees | ||
}); | ||
}; | ||
|
||
|
||
export default handler; |
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
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
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
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,7 @@ | ||
import type * as recordTypes from "../../types/recordTypes"; | ||
interface AddLicenceCategoryAdditionalFeeForm { | ||
licenceCategoryKey: string; | ||
additionalFee: string; | ||
} | ||
export declare const addLicenceCategoryAdditionalFee: (licenceCategoryAdditionalFeeForm: AddLicenceCategoryAdditionalFeeForm, requestSession: recordTypes.PartialSession) => string; | ||
export default addLicenceCategoryAdditionalFee; |
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,20 @@ | ||
import sqlite from "better-sqlite3"; | ||
import { licencesDB as databasePath } from "../../data/databasePaths.js"; | ||
import { getUnusedLicenceAdditionalFeeKey } from "./getUnusedKey.js"; | ||
export const addLicenceCategoryAdditionalFee = (licenceCategoryAdditionalFeeForm, requestSession) => { | ||
const licenceAdditionalFeeKey = getUnusedLicenceAdditionalFeeKey(licenceCategoryAdditionalFeeForm.licenceCategoryKey, licenceCategoryAdditionalFeeForm.additionalFee); | ||
const database = sqlite(databasePath); | ||
const rightNowMillis = Date.now(); | ||
database | ||
.prepare("insert into licenceCategoryAdditionalFees" + | ||
"(licenceAdditionalFeeKey, licenceCategoryKey, additionalFee," + | ||
" additionalFeeType, additionalFeeNumber, additionalFeeFunction," + | ||
" isRequired," + | ||
" recordCreate_userName, recordCreate_timeMillis," + | ||
" recordUpdate_userName, recordUpdate_timeMillis)" + | ||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") | ||
.run(licenceAdditionalFeeKey, licenceCategoryAdditionalFeeForm.licenceCategoryKey, licenceCategoryAdditionalFeeForm.additionalFee, "flat", 0, "", 0, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis); | ||
database.close(); | ||
return licenceAdditionalFeeKey; | ||
}; | ||
export default addLicenceCategoryAdditionalFee; |
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,49 @@ | ||
import sqlite from "better-sqlite3"; | ||
import { licencesDB as databasePath } from "../../data/databasePaths.js"; | ||
|
||
import { getUnusedLicenceAdditionalFeeKey } from "./getUnusedKey.js"; | ||
|
||
import type * as recordTypes from "../../types/recordTypes"; | ||
|
||
interface AddLicenceCategoryAdditionalFeeForm { | ||
licenceCategoryKey: string; | ||
additionalFee: string; | ||
} | ||
|
||
export const addLicenceCategoryAdditionalFee = | ||
(licenceCategoryAdditionalFeeForm: AddLicenceCategoryAdditionalFeeForm, requestSession: recordTypes.PartialSession): string => { | ||
|
||
const licenceAdditionalFeeKey = | ||
getUnusedLicenceAdditionalFeeKey(licenceCategoryAdditionalFeeForm.licenceCategoryKey, licenceCategoryAdditionalFeeForm.additionalFee); | ||
|
||
const database = sqlite(databasePath); | ||
|
||
const rightNowMillis = Date.now(); | ||
|
||
database | ||
.prepare("insert into licenceCategoryAdditionalFees" + | ||
"(licenceAdditionalFeeKey, licenceCategoryKey, additionalFee," + | ||
" additionalFeeType, additionalFeeNumber, additionalFeeFunction," + | ||
" isRequired," + | ||
" recordCreate_userName, recordCreate_timeMillis," + | ||
" recordUpdate_userName, recordUpdate_timeMillis)" + | ||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") | ||
.run(licenceAdditionalFeeKey, | ||
licenceCategoryAdditionalFeeForm.licenceCategoryKey, | ||
licenceCategoryAdditionalFeeForm.additionalFee, | ||
"flat", | ||
0, | ||
"", | ||
0, | ||
requestSession.user.userName, | ||
rightNowMillis, | ||
requestSession.user.userName, | ||
rightNowMillis); | ||
|
||
database.close(); | ||
|
||
return licenceAdditionalFeeKey; | ||
}; | ||
|
||
|
||
export default addLicenceCategoryAdditionalFee; |
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,4 @@ | ||
import sqlite from "better-sqlite3"; | ||
import type * as recordTypes from "../../types/recordTypes"; | ||
export declare const getLicenceCategoryAdditionalFee: (licenceAdditionalFeeKey: string, database?: sqlite.Database) => recordTypes.LicenceCategoryAdditionalFee; | ||
export default getLicenceCategoryAdditionalFee; |
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,23 @@ | ||
import sqlite from "better-sqlite3"; | ||
import { licencesDB as databasePath } from "../../data/databasePaths.js"; | ||
export const getLicenceCategoryAdditionalFee = (licenceAdditionalFeeKey, database) => { | ||
let doCloseDatabase = false; | ||
if (!database) { | ||
database = sqlite(databasePath, { | ||
readonly: true | ||
}); | ||
doCloseDatabase = true; | ||
} | ||
const licenceCategoryAdditionalFee = database.prepare("select licenceCategoryKey, licenceAdditionalFeeKey," + | ||
" additionalFee, additionalFeeType, additionalFeeNumber, additionalFeeFunction," + | ||
" isRequired, orderNumber" + | ||
" from LicenceCategoryAdditionalFees" + | ||
" where recordDelete_timeMillis is null" + | ||
" and licenceAdditionalFeeKey = ?") | ||
.get(licenceAdditionalFeeKey); | ||
if (doCloseDatabase) { | ||
database.close(); | ||
} | ||
return licenceCategoryAdditionalFee; | ||
}; | ||
export default getLicenceCategoryAdditionalFee; |
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,37 @@ | ||
import sqlite from "better-sqlite3"; | ||
import { licencesDB as databasePath } from "../../data/databasePaths.js"; | ||
|
||
import type * as recordTypes from "../../types/recordTypes"; | ||
|
||
|
||
export const getLicenceCategoryAdditionalFee = (licenceAdditionalFeeKey: string, database?: sqlite.Database): recordTypes.LicenceCategoryAdditionalFee => { | ||
|
||
let doCloseDatabase = false; | ||
|
||
if (!database) { | ||
|
||
database = sqlite(databasePath, { | ||
readonly: true | ||
}); | ||
|
||
doCloseDatabase = true; | ||
} | ||
|
||
const licenceCategoryAdditionalFee: recordTypes.LicenceCategoryAdditionalFee = | ||
database.prepare("select licenceCategoryKey, licenceAdditionalFeeKey," + | ||
" additionalFee, additionalFeeType, additionalFeeNumber, additionalFeeFunction," + | ||
" isRequired, orderNumber" + | ||
" from LicenceCategoryAdditionalFees" + | ||
" where recordDelete_timeMillis is null" + | ||
" and licenceAdditionalFeeKey = ?") | ||
.get(licenceAdditionalFeeKey); | ||
|
||
if (doCloseDatabase) { | ||
database.close(); | ||
} | ||
|
||
return licenceCategoryAdditionalFee; | ||
}; | ||
|
||
|
||
export default getLicenceCategoryAdditionalFee; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export declare const getUnusedLicenceCategoryKey: (licenceCategory: string) => string; | ||
export declare const getUnusedLicenceFieldKey: (licenceCategoryKey: string, licenceField: string) => string; | ||
export declare const getUnusedLicenceApprovalKey: (licenceCategoryKey: string, licenceApproval: string) => string; | ||
export declare const getUnusedLicenceAdditionalFeeKey: (licenceCategoryKey: string, additionalFee: string) => string; |
Oops, something went wrong.