Skip to content

SudoSOS Back-end API / debtors / DebtorService

Class: DebtorService ​

Extends ​

Constructors ​

Constructor ​

ts
new DebtorService(manager?): DebtorService;

Parameters ​

ParameterType
manager?EntityManager

Returns ​

DebtorService

Inherited from ​

WithManager.constructor

Properties ​

PropertyModifierTypeInherited from
managerprotectedEntityManagerWithManager.manager

Methods ​

calculateFinesOnDate() ​

ts
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 ​

ParameterTypeDescription
userTypesCalculateFinesParamsList of all user types fines should be calculated for

Returns ​

Promise<UserToFineResponse[]>


deleteFine() ​

ts
deleteFine(id): Promise<void>;

Delete a fine with its transfer, but keep the FineHandoutEvent (they can be empty)

Parameters ​

ParameterTypeDescription
idnumber-

Returns ​

Promise<void>


deleteFineHandout() ​

ts
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 ​

ParameterTypeDescription
fineHandoutEventFineHandoutEventThe fine handout event to delete

Returns ​

Promise<void>

Throws ​

Error if the 'fines' relation is not loaded


getFineHandoutEvents() ​

ts
getFineHandoutEvents(pagination?): Promise<[FineHandoutEvent[], number]>;

Get a list of all fine handout events in chronological order

Parameters ​

ParameterType
paginationPaginationParameters

Returns ​

Promise<[FineHandoutEvent[], number]>


getFineReport() ​

ts
getFineReport(fromDate, toDate): Promise<FineReport>;

Get a report of all fines

Parameters ​

ParameterTypeDescription
fromDateDate-
toDateDate-

Returns ​

Promise<FineReport>


getSingleFineHandoutEvent() ​

ts
getSingleFineHandoutEvent(id): Promise<FineHandoutEvent>;

Return the fine handout event with the given id. Includes all its fines with the corresponding user

Parameters ​

ParameterType
idnumber

Returns ​

Promise<FineHandoutEvent>


handOutFines() ​

ts
handOutFines(referenceDate, createdBy): Promise<FineHandoutEvent>;

Write fines in a single database transaction to database for all given user ids.

Parameters ​

ParameterTypeDescription
referenceDateHandOutFinesParamsDate to base fines on
createdByUserUser handing out fines

Returns ​

Promise<FineHandoutEvent>


sendFineWarnings() ​

ts
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 ​

ParameterTypeDescription
referenceDateHandOutFinesParams-

Returns ​

Promise<void>


waiveFines() ​

ts
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 ​

ParameterTypeDescription
userIdnumberUser to waive fines for
paramsWaiveFinesParams-

Returns ​

Promise<UserFineGroup>


asBaseFineHandoutEventResponse() ​

ts
static asBaseFineHandoutEventResponse(e): BaseFineHandoutEventResponse;

Parameters ​

ParameterType
eFineHandoutEvent

Returns ​

BaseFineHandoutEventResponse


asFineHandoutEventResponse() ​

ts
static asFineHandoutEventResponse(e): FineHandoutEventResponse;

Parameters ​

ParameterType
eFineHandoutEvent

Returns ​

FineHandoutEventResponse


asFineResponse() ​

ts
static asFineResponse(fine): FineResponse;

Parameters ​

ParameterType
fineFine

Returns ​

FineResponse


asUserFineGroupResponse() ​

ts
static asUserFineGroupResponse(e): UserFineGroupResponse;

Parameters ​

ParameterType
eUserFineGroup

Returns ​

UserFineGroupResponse