mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
refactoring: bills service.
refactoring: bills payments made service.
This commit is contained in:
@@ -17,6 +17,15 @@ export default class VendorRepository extends TenantRepository {
|
||||
this.cache = this.tenancy.cache(tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve vendor details of the given id.
|
||||
* @param {number} vendorId - Vendor id.
|
||||
*/
|
||||
findById(vendorId: number) {
|
||||
const { Contact } = this.models;
|
||||
return Contact.query().findById(vendorId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the bill that associated to the given vendor id.
|
||||
* @param {number} vendorId - Vendor id.
|
||||
@@ -49,4 +58,23 @@ export default class VendorRepository extends TenantRepository {
|
||||
.whereIn('id', vendorIds)
|
||||
.withGraphFetched('bills');
|
||||
}
|
||||
|
||||
changeBalance(vendorId: number, amount: number) {
|
||||
const { Contact } = this.models;
|
||||
const changeMethod = (amount > 0) ? 'increment' : 'decrement';
|
||||
|
||||
return Contact.query()
|
||||
.where('id', vendorId)
|
||||
[changeMethod]('balance', Math.abs(amount));
|
||||
}
|
||||
|
||||
|
||||
changeDiffBalance(
|
||||
vendorId: number,
|
||||
amount: number,
|
||||
oldAmount: number,
|
||||
oldVendorId?: number,
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user