SudoSOS Back-end API / debtors / DebtorService
Class: DebtorService ​
Extends ​
Constructors ​
Constructor ​
new DebtorService(manager?): DebtorService;Parameters ​
| Parameter | Type |
|---|---|
manager? | EntityManager |
Returns ​
DebtorService
Inherited from ​
Properties ​
| Property | Modifier | Type | Inherited from |
|---|---|---|---|
manager | protected | EntityManager | WithManager.manager |
Methods ​
calculateFinesOnDate() ​
calculateFinesOnDate(userTypes): Promise<UserToFineResponse[]>;Return all users that had at most -5 euros balance both now and on the reference date For all these users, also return their fine based on the reference date.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
userTypes | CalculateFinesParams | List of all user types fines should be calculated for |
Returns ​
Promise<UserToFineResponse[]>
deleteFine() ​
deleteFine(id): Promise<void>;Delete a fine with its transfer, but keep the FineHandoutEvent (they can be empty)
Parameters ​
| Parameter | Type | Description |
|---|---|---|
id | number | - |
Returns ​
Promise<void>
deleteFineHandout() ​
deleteFineHandout(fineHandoutEvent): Promise<void>;Deletes a fine handout event, all its associated fines, and the transfers linked to those fines. Throws an Error if the 'fines' relation is not loaded on the provided fine handout event.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
fineHandoutEvent | FineHandoutEvent | The fine handout event to delete |
Returns ​
Promise<void>
Throws ​
Error if the 'fines' relation is not loaded
getFineHandoutEvents() ​
getFineHandoutEvents(pagination?): Promise<[FineHandoutEvent[], number]>;Get a list of all fine handout events in chronological order
Parameters ​
| Parameter | Type |
|---|---|
pagination | PaginationParameters |
Returns ​
Promise<[FineHandoutEvent[], number]>
getFineReport() ​
getFineReport(fromDate, toDate): Promise<FineReport>;Get a report of all fines
Parameters ​
| Parameter | Type | Description |
|---|---|---|
fromDate | Date | - |
toDate | Date | - |
Returns ​
Promise<FineReport>
getSingleFineHandoutEvent() ​
getSingleFineHandoutEvent(id): Promise<FineHandoutEvent>;Return the fine handout event with the given id. Includes all its fines with the corresponding user
Parameters ​
| Parameter | Type |
|---|---|
id | number |
Returns ​
Promise<FineHandoutEvent>
handOutFines() ​
handOutFines(referenceDate, createdBy): Promise<FineHandoutEvent>;Write fines in a single database transaction to database for all given user ids.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
referenceDate | HandOutFinesParams | Date to base fines on |
createdBy | User | User handing out fines |
Returns ​
Promise<FineHandoutEvent>
sendFineWarnings() ​
sendFineWarnings(referenceDate): Promise<void>;Send an email to all users with the given ID, notifying them that they will get fined a certain amount. The date the fine and email will be based on is the reference date, the date of the last fine handout event or the current date (in this order if one is undefined). However, users only receive an email when they have a debt both on the reference date and now. If a user has no debt, they will be skipped and not sent an email.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
referenceDate | HandOutFinesParams | - |
Returns ​
Promise<void>
waiveFines() ​
waiveFines(userId, params): Promise<UserFineGroup>;Waive a user's unpaid fines (partially) by creating a transfer which puts some money back into the user's account. If the user's fines were already (partially) waived, the existing transfer waiving the fines will be replaced by a new transfer.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
userId | number | User to waive fines for |
params | WaiveFinesParams | - |
Returns ​
Promise<UserFineGroup>
asBaseFineHandoutEventResponse() ​
static asBaseFineHandoutEventResponse(e): BaseFineHandoutEventResponse;Parameters ​
| Parameter | Type |
|---|---|
e | FineHandoutEvent |
Returns ​
asFineHandoutEventResponse() ​
static asFineHandoutEventResponse(e): FineHandoutEventResponse;Parameters ​
| Parameter | Type |
|---|---|
e | FineHandoutEvent |
Returns ​
asFineResponse() ​
static asFineResponse(fine): FineResponse;Parameters ​
| Parameter | Type |
|---|---|
fine | Fine |
Returns ​
asUserFineGroupResponse() ​
static asUserFineGroupResponse(e): UserFineGroupResponse;Parameters ​
| Parameter | Type |
|---|---|
e | UserFineGroup |