- feat: Optimize tenancy software architecture.

This commit is contained in:
Ahmed Bouhuolia
2020-08-30 22:11:14 +02:00
parent 74321a2886
commit ca251a2d28
53 changed files with 1581 additions and 1055 deletions

View File

@@ -74,7 +74,7 @@ export default class Bill extends mixin(TenantModel, [CachableModel]) {
* @return {Array}
*/
static async getNotFoundBills(billsIds, vendorId) {
const storedBills = await this.tenant().query()
const storedBills = await this.query()
.onBuild((builder) => {
builder.whereIn('id', billsIds);
@@ -94,8 +94,7 @@ export default class Bill extends mixin(TenantModel, [CachableModel]) {
static changePaymentAmount(billId, amount) {
const changeMethod = amount > 0 ? 'increment' : 'decrement';
return this.tenant()
.query()
return this.query()
.where('id', billId)
[changeMethod]('payment_amount', Math.abs(amount));
}