mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
- feat: Sales estimates.
- feat: Sales invoices. - feat: Sales payment receives. - feat: Purchases bills. - feat: Purchases bills payments that made to the vendors.
This commit is contained in:
26
server/src/repositories/CustomerRepository.js
Normal file
26
server/src/repositories/CustomerRepository.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Customer } from '@/models';
|
||||
|
||||
export default class CustomerRepository {
|
||||
|
||||
static changeDiffBalance(customerId, oldCustomerId, amount, oldAmount) {
|
||||
const diffAmount = (amount - oldAmount) * -1;
|
||||
const asyncOpers = [];
|
||||
|
||||
if (customerId != oldCustomerId) {
|
||||
const oldCustomerOper = Customer.changeBalance(
|
||||
oldCustomerId,
|
||||
oldAmount
|
||||
);
|
||||
const customerOper = Customer.changeBalance(
|
||||
customerId,
|
||||
(amount + diffAmount) * -1
|
||||
);
|
||||
asyncOpers.push(customerOper);
|
||||
asyncOpers.push(oldCustomerOper);
|
||||
} else {
|
||||
const balanceChangeOper = Customer.changeBalance(customerId, diffAmount);
|
||||
asyncOpers.push(balanceChangeOper);
|
||||
}
|
||||
return Promise.all(asyncOpers);
|
||||
}
|
||||
}
|
||||
0
server/src/repositories/ItemEntryRepository.js
Normal file
0
server/src/repositories/ItemEntryRepository.js
Normal file
55
server/src/repositories/PaymentReceiveEntryRepository.js
Normal file
55
server/src/repositories/PaymentReceiveEntryRepository.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import { omit } from 'lodash';
|
||||
import BaseModelRepository from '@/repositories/BaseModelRepository';
|
||||
import { PaymentReceiveEntry } from '@/models';
|
||||
|
||||
export default class PaymentReceiveEntryRepository extends BaseModelRepository {
|
||||
/**
|
||||
* Insert payment receive entries in bulk.
|
||||
* @param {Array} entries
|
||||
* @param {Integr} paymentReceiveId
|
||||
* @return {Promise}
|
||||
*/
|
||||
static insertBulk(entries, paymentReceiveId) {
|
||||
const opers = [];
|
||||
entries.forEach((entry) => {
|
||||
const insertOper = PaymentReceiveEntry.tenant()
|
||||
.query()
|
||||
.insert({
|
||||
payment_receive_id: paymentReceiveId,
|
||||
...entry,
|
||||
});
|
||||
opers.push(insertOper);
|
||||
});
|
||||
return Promise.all(opers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update payment receive entries in bulk.
|
||||
* @param {Array} entries
|
||||
* @return {Promise}
|
||||
*/
|
||||
static updateBulk(entries) {
|
||||
const opers = [];
|
||||
entries.forEach((entry) => {
|
||||
const updateOper = PaymentReceiveEntry.tenant()
|
||||
.query()
|
||||
.patchAndFetchById(entry.id, {
|
||||
...omit(entry, ['id', 'index']),
|
||||
});
|
||||
opers.push(updateOper);
|
||||
});
|
||||
return Promise.all(opers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the given payment receive entries ids in bulk.
|
||||
* @param {Array} entriesIds
|
||||
* @return {Promise}
|
||||
*/
|
||||
static deleteBulk(entriesIds) {
|
||||
return PaymentReceiveEntry.tenant()
|
||||
.query()
|
||||
.whereIn('id', entriesIds)
|
||||
.delete();
|
||||
}
|
||||
}
|
||||
7
server/src/repositories/PaymentReceiveRepository.js
Normal file
7
server/src/repositories/PaymentReceiveRepository.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { omit } from 'lodash';
|
||||
import { PaymentReceiveEntry } from '@/models';
|
||||
import BaseModelRepository from '@/repositories/BaseModelRepository';
|
||||
|
||||
export default class PaymentReceiveRepository extends BaseModelRepository {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user