Skip to main content

Class: InflowsService

Service responsible for managing inflow (income) operations. Handles CRUD operations, statistics, and data aggregation for inflows.

Constructors

new InflowsService()

new InflowsService(drizzleService, usersService): InflowsService

Parameters

drizzleService

DrizzleService

usersService

UsersService

Returns

InflowsService

Methods

create()

create(userId, createInflowDto): Promise<InflowDto>

Creates a new inflow record for a user

Parameters

userId

string

The ID of the user creating the inflow

createInflowDto

CreateInflowDto

The inflow data to create

Returns

Promise<InflowDto>

The created inflow record


findAll()

findAll(userId, params?): Promise<InflowSearchDto>

Retrieves all inflows for a user with optional filtering and pagination

Parameters

userId

string

The ID of the user

params?

Optional search parameters

string

Search term for filtering by description or tags

tags?

string[]

Array of tags to filter by

page?

number

Page number for pagination

limit?

number

Number of items per page

Returns

Promise<InflowSearchDto>

Paginated list of inflows matching the criteria


findById()

findById(userId, id): Promise<any>

Finds a specific inflow by ID for a user

Parameters

userId

string

The ID of the user

id

string

The ID of the inflow to find

Returns

Promise<any>

The found inflow record

Throws

NotFoundException if the inflow doesn't exist


update()

update(userId, id, updateInflowDto): Promise<any>

Updates an existing inflow record

Parameters

userId

string

The ID of the user

id

string

The ID of the inflow to update

updateInflowDto

UpdateInflowDto

The data to update

Returns

Promise<any>

The updated inflow record

Throws

NotFoundException if the inflow doesn't exist


remove()

remove(userId, id): Promise<any>

Removes an inflow record

Parameters

userId

string

The ID of the user

id

string

The ID of the inflow to remove

Returns

Promise<any>

The removed inflow record

Throws

NotFoundException if the inflow doesn't exist


getTotalInflow()

getTotalInflow(userId): Promise<any>

Calculates the total amount of all inflows for a user

Parameters

userId

string

The ID of the user

Returns

Promise<any>

The total amount of all inflows


getTagStats()

getTagStats(userId): Promise<TagStatistics[]>

Retrieves statistics about inflow tags

Parameters

userId

string

The ID of the user

Returns

Promise<TagStatistics[]>

Array of tag statistics including usage count and total amount


getMonthlyStats()

getMonthlyStats(userId, year): Promise<MonthlyStats[]>

Retrieves monthly statistics for inflows in a specific year

Parameters

userId

string

The ID of the user

year

number

The year to get statistics for

Returns

Promise<MonthlyStats[]>

Array of monthly statistics