mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat: licenses administration basic authentication.
feat: accounts slug. feat: duplicate accounts_balance table and merge balance with accounts table. feat: refactoring customers and vendors. feat: system user soft deleting. feat: preventing build tenant database without any subscription. feat: remove 'password' property from 'req.user' object. feat: refactoring JournalPoster class. feat: delete duplicated directories and files.
This commit is contained in:
50
server/src/repositories/VendorRepository.ts
Normal file
50
server/src/repositories/VendorRepository.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import TenantRepository from "./TenantRepository";
|
||||
|
||||
|
||||
export default class VendorRepository extends TenantRepository {
|
||||
models: any;
|
||||
cache: any;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
* @param {number} tenantId
|
||||
*/
|
||||
constructor(tenantId: number) {
|
||||
super(tenantId);
|
||||
|
||||
this.models = this.tenancy.models(tenantId);
|
||||
this.cache = this.tenancy.cache(tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the bill that associated to the given vendor id.
|
||||
* @param {number} vendorId
|
||||
*/
|
||||
getBills(vendorId: number) {
|
||||
const { Bill } = this.models;
|
||||
|
||||
return this.cache.get(`vendors.bills.${vendorId}`, () => {
|
||||
return Bill.query().where('vendor_id', vendorId);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {numner[]} vendorsIds
|
||||
*/
|
||||
vendors(vendorsIds: number[]) {
|
||||
const { Contact } = this.models;
|
||||
return Contact.query().modifier('vendor').whereIn('id', vendorsIds);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {number[]} vendorIds
|
||||
*/
|
||||
vendorsWithBills(vendorIds: number[]) {
|
||||
const { Contact } = this.models;
|
||||
return Contact.query().modify('vendor')
|
||||
.whereIn('id', vendorIds)
|
||||
.withGraphFetched('bills');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user