refactor: wip to nestjs

This commit is contained in:
Ahmed Bouhuolia
2024-12-25 00:43:55 +02:00
parent 336171081e
commit a6932d76f3
249 changed files with 21314 additions and 1616 deletions

View File

@@ -0,0 +1,23 @@
import { Injectable } from '@nestjs/common';
import { Bill } from '../models/Bill';
@Injectable()
export class GetDueBills {
constructor(private billModel: typeof Bill) {}
/**
* Retrieve all due bills or for specific given vendor id.
* @param {number} vendorId -
*/
public async getDueBills(vendorId?: number): Promise<Bill[]> {
const dueBills = await this.billModel.query().onBuild((query) => {
query.orderBy('bill_date', 'DESC');
query.modify('dueBills');
if (vendorId) {
query.where('vendor_id', vendorId);
}
});
return dueBills;
}
}