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(params): 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 |
|---|---|---|
params | CalculateFinesParams | the filter fields (see CalculateFinesParams): userTypes and userIds narrow which users are considered; referenceDates lists the dates on which the user must have a negative balance (the first date determines the size of the fine). |
Returns ​
Promise<UserToFineResponse[]>
configureLogger() ​
protected configureLogger(logger): void;Parameters ​
| Parameter | Type |
|---|---|
logger | Logger |
Returns ​
void
Inherited from ​
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(params, createdBy): Promise<FineHandoutEvent>;Write fines in a single database transaction to database for all given user ids.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
params | HandOutFinesParams | see HandOutFinesParams: referenceDate is the date the fines are based on; userIds are the users to fine. |
createdBy | User | user handing out the fines. |
Returns ​
Promise<FineHandoutEvent>
sendDebtNotifications() ​
sendDebtNotifications(params): Promise<void>;Email all users with the given IDs that their balance is currently negative. The email does not mention fines. Users who are not in debt (anymore) are skipped.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
params | SendDebtNotificationsParams | see SendDebtNotificationsParams: userIds are the users to remind. |
Returns ​
Promise<void>
sendFineWarnings() ​
sendFineWarnings(params): Promise<void>;Send an email to all users with the given ID, notifying them that they will get fined a certain amount. The fine amount and the balance in the email are based on the reference date. Users who are not at or below -5 EUR on the reference date are skipped and not sent an email. Users who are fined in the same round should not be passed here: the fined email already warns about future fines.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
params | HandOutFinesParams | see HandOutFinesParams for referenceDate and userIds. |
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 |