import { HttpClient } from '@angular/common/http' ; import { Injectable } from '@angular/core' ; import { IFindStartDateUpdateTypeInput , IStartUpdateTypeInfo , IOrganizationRecurringExpense , IOrganizationRecurringExpenseFindInput , IOrganizationRecurringExpenseForEmployeeOutput , IRecurringExpenseDeleteInput , IRecurringExpenseOrderFields } from '@gauzy/contracts' ; import { firstValueFrom } from 'rxjs' ; import { API_PREFIX } from '../constants/app.constants' ; @ Injectable ( { providedIn : 'root' } ) export class OrganizationRecurringExpenseService { private readonly API_URL = `${ API_PREFIX }/organization-recurring-expense` ; constructor ( private http ) { } create ( createInput ) { return firstValueFrom ( this . http . post < IOrganizationRecurringExpense > ( this . API_URL , createInput ) ) ; } getAll ( relations ? , findInput ? , order ? ) { const data = JSON . stringify ( { relations , findInput , order } ) ; return firstValueFrom ( this . http . get < { items : IOrganizationRecurringExpense [ ] ; total : number ; } > ( this . API_URL , { params : { data } } ) ) ; } getAllByMonth ( findInput ? ) { const data = JSON . stringify ( { findInput } ) ; return firstValueFrom ( this . http . get < { items : IOrganizationRecurringExpense [ ] ; total : number ; } > ( `${ this . API_URL }/month` , { params : { data } } ) ) ; } delete ( id , deleteInput ) { const data = JSON . stringify ( { deleteInput } ) ; return firstValueFrom ( this . http . delete ( `${ this . API_URL }/${ id }` , { params : { data } } ) ) ; } update ( id , updateInput ) { return firstValueFrom ( this . http . put ( `${ this . API_URL }/${ id }` , updateInput ) ) ; } getSplitExpensesForEmployee ( orgId , findInput ? ) { const data = JSON . stringify ( { findInput } ) ; return firstValueFrom ( this . http . get < { items : IOrganizationRecurringExpenseForEmployeeOutput [ ] ; total : number ; } > ( `${ this . API_URL }/employee/${ orgId }` , { params : { data } } ) ) ; } getStartDateUpdateType ( findInput ? ) { const data = JSON . stringify ( { findInput } ) ; return firstValueFrom ( this . http . get < IStartUpdateTypeInfo > ( `${ this . API_URL }/date-update-type` , { params : { data } } ) ) ; } }