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

ParameterTypeDescription
paramsCalculateFinesParamsthe 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() ​

ts
protected configureLogger(logger): void;

Parameters ​

ParameterType
loggerLogger

Returns ​

void

Inherited from ​

WithManager.configureLogger


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(params, createdBy): Promise<FineHandoutEvent>;

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

Parameters ​

ParameterTypeDescription
paramsHandOutFinesParamssee HandOutFinesParams: referenceDate is the date the fines are based on; userIds are the users to fine.
createdByUseruser handing out the fines.

Returns ​

Promise<FineHandoutEvent>


sendDebtNotifications() ​

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

ParameterTypeDescription
paramsSendDebtNotificationsParamssee SendDebtNotificationsParams: userIds are the users to remind.

Returns ​

Promise<void>


sendFineWarnings() ​

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

ParameterTypeDescription
paramsHandOutFinesParamssee HandOutFinesParams for referenceDate and userIds.

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