@tomei/finance 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/account.d.ts +35 -35
- package/dist/account/account.js +231 -231
- package/dist/account/account.repository.d.ts +5 -5
- package/dist/account/account.repository.js +11 -11
- package/dist/account/interfaces/account-attr.interface.d.ts +29 -29
- package/dist/account/interfaces/account-attr.interface.js +2 -2
- package/dist/account-system-entity/account-system-entity.d.ts +11 -11
- package/dist/account-system-entity/account-system-entity.js +66 -66
- package/dist/account-system-entity/post-history.repository.d.ts +5 -5
- package/dist/account-system-entity/post-history.repository.js +11 -11
- package/dist/config.d.ts +1888 -1888
- package/dist/config.js +331 -331
- package/dist/customer/customer.d.ts +43 -41
- package/dist/customer/customer.js +236 -214
- package/dist/customer/customer.js.map +1 -1
- package/dist/customer/finance-customer.repository.d.ts +5 -5
- package/dist/customer/finance-customer.repository.js +25 -25
- package/dist/customer/interfaces/customer.repository.interface.d.ts +3 -3
- package/dist/customer/interfaces/customer.repository.interface.js +2 -2
- package/dist/customer/interfaces/finance-customer-attr.interface.d.ts +10 -10
- package/dist/customer/interfaces/finance-customer-attr.interface.js +2 -2
- package/dist/customer/interfaces/finance-customer.repository.interface.d.ts +3 -3
- package/dist/customer/interfaces/finance-customer.repository.interface.js +2 -2
- package/dist/database.d.ts +4 -4
- package/dist/database.js +14 -14
- package/dist/document/document-item.d.ts +38 -38
- package/dist/document/document-item.js +83 -83
- package/dist/document/document-item.repository.d.ts +5 -5
- package/dist/document/document-item.repository.js +11 -11
- package/dist/document/document.d.ts +76 -76
- package/dist/document/document.js +566 -566
- package/dist/document/document.repository.d.ts +5 -5
- package/dist/document/document.repository.js +11 -11
- package/dist/document/interfaces/document-attr.interface.d.ts +27 -27
- package/dist/document/interfaces/document-attr.interface.js +6 -6
- package/dist/document/interfaces/document-item-attr.interface.d.ts +22 -22
- package/dist/document/interfaces/document-item-attr.interface.js +6 -6
- package/dist/document/interfaces/document-item.repository.interface.d.ts +3 -3
- package/dist/document/interfaces/document-item.repository.interface.js +2 -2
- package/dist/enum/doc-type.enum.d.ts +8 -8
- package/dist/enum/doc-type.enum.js +12 -12
- package/dist/enum/document-status.enum.d.ts +6 -6
- package/dist/enum/document-status.enum.js +10 -10
- package/dist/enum/index.d.ts +8 -8
- package/dist/enum/index.js +17 -17
- package/dist/enum/payment-method.enum.d.ts +3 -3
- package/dist/enum/payment-method.enum.js +7 -7
- package/dist/enum/payment-status.enum.d.ts +4 -4
- package/dist/enum/payment-status.enum.js +8 -8
- package/dist/enum/payment-type.enum.d.ts +4 -4
- package/dist/enum/payment-type.enum.js +8 -8
- package/dist/enum/quick-book-client-scopes.enum.d.ts +13 -13
- package/dist/enum/quick-book-client-scopes.enum.js +18 -18
- package/dist/enum/transaction-type.enum.d.ts +4 -4
- package/dist/enum/transaction-type.enum.js +8 -8
- package/dist/finance-company/finance-company.d.ts +57 -57
- package/dist/finance-company/finance-company.js +1192 -1192
- package/dist/finance-company/finance-company.repository.d.ts +5 -5
- package/dist/finance-company/finance-company.repository.js +11 -11
- package/dist/helpers/typeof.d.ts +1 -1
- package/dist/helpers/typeof.js +26 -26
- package/dist/index.d.ts +17 -17
- package/dist/index.js +32 -32
- package/dist/interfaces/account-system.interface.d.ts +13 -13
- package/dist/interfaces/account-system.interface.js +2 -2
- package/dist/interfaces/index.d.ts +2 -2
- package/dist/interfaces/index.js +2 -2
- package/dist/journal-entry/interfaces/journal-entry-attr.interface.d.ts +11 -11
- package/dist/journal-entry/interfaces/journal-entry-attr.interface.js +2 -2
- package/dist/journal-entry/journal-entry.d.ts +39 -39
- package/dist/journal-entry/journal-entry.js +215 -215
- package/dist/journal-entry/journal-entry.repository.d.ts +5 -5
- package/dist/journal-entry/journal-entry.repository.js +11 -11
- package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.d.ts +17 -17
- package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.js +2 -2
- package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.d.ts +5 -5
- package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.js +2 -2
- package/dist/ledger-transaction/ledger-transaction.d.ts +48 -48
- package/dist/ledger-transaction/ledger-transaction.js +155 -155
- package/dist/ledger-transaction/ledger-transaction.repository.d.ts +5 -5
- package/dist/ledger-transaction/ledger-transaction.repository.js +11 -11
- package/dist/models/account.entity.d.ts +30 -30
- package/dist/models/account.entity.js +232 -232
- package/dist/models/customer.entity.d.ts +13 -13
- package/dist/models/customer.entity.js +109 -109
- package/dist/models/document-item.entity.d.ts +27 -27
- package/dist/models/document-item.entity.js +172 -172
- package/dist/models/document.entity.d.ts +36 -36
- package/dist/models/document.entity.js +242 -242
- package/dist/models/finance-company.entity.d.ts +9 -9
- package/dist/models/finance-company.entity.js +44 -44
- package/dist/models/journal-entry.entity.d.ts +16 -16
- package/dist/models/journal-entry.entity.js +127 -127
- package/dist/models/ledger-transaction.entity.d.ts +24 -24
- package/dist/models/ledger-transaction.entity.js +172 -172
- package/dist/models/payment-item.entity.d.ts +12 -12
- package/dist/models/payment-item.entity.js +75 -75
- package/dist/models/payment-method-type.entity.d.ts +13 -13
- package/dist/models/payment-method-type.entity.js +85 -85
- package/dist/models/payment-method.entity.d.ts +10 -10
- package/dist/models/payment-method.entity.js +62 -62
- package/dist/models/payment-paid-with.entity.d.ts +24 -24
- package/dist/models/payment-paid-with.entity.js +158 -158
- package/dist/models/payment.entity.d.ts +27 -27
- package/dist/models/payment.entity.js +188 -188
- package/dist/models/post-history.entity.d.ts +11 -11
- package/dist/models/post-history.entity.js +63 -63
- package/dist/payment/interfaces/payment-attr.interface.d.ts +22 -22
- package/dist/payment/interfaces/payment-attr.interface.js +6 -6
- package/dist/payment/interfaces/payment-params.interface.d.ts +7 -7
- package/dist/payment/interfaces/payment-params.interface.js +2 -2
- package/dist/payment/payment.d.ts +51 -51
- package/dist/payment/payment.js +179 -179
- package/dist/payment/payment.repository.d.ts +5 -5
- package/dist/payment/payment.repository.js +11 -11
- package/dist/payment-item/interfaces/payment-item-attr.interface.d.ts +10 -10
- package/dist/payment-item/interfaces/payment-item-attr.interface.js +6 -6
- package/dist/payment-item/payment-item.d.ts +23 -23
- package/dist/payment-item/payment-item.js +115 -115
- package/dist/payment-item/payment-item.repository.d.ts +5 -5
- package/dist/payment-item/payment-item.repository.js +11 -11
- package/dist/payment-method/interfaces/payment-method-attr.interface.d.ts +5 -5
- package/dist/payment-method/interfaces/payment-method-attr.interface.js +2 -2
- package/dist/payment-method/payment-method.d.ts +18 -18
- package/dist/payment-method/payment-method.js +98 -98
- package/dist/payment-method/payment-method.repository.d.ts +5 -5
- package/dist/payment-method/payment-method.repository.js +11 -11
- package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.d.ts +8 -8
- package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.js +2 -2
- package/dist/payment-method-type/payment-method-type.d.ts +16 -16
- package/dist/payment-method-type/payment-method-type.js +70 -70
- package/dist/payment-method-type/payment-method-type.repository.d.ts +5 -5
- package/dist/payment-method-type/payment-method-type.repository.js +11 -11
- package/dist/payment-paid-with/interfaces/payment-paid-with.interface.d.ts +19 -19
- package/dist/payment-paid-with/interfaces/payment-paid-with.interface.js +6 -6
- package/dist/payment-paid-with/payment-paid-with.d.ts +31 -31
- package/dist/payment-paid-with/payment-paid-with.js +52 -52
- package/dist/payment-paid-with/payment-paid-with.repository.d.ts +5 -5
- package/dist/payment-paid-with/payment-paid-with.repository.js +11 -11
- package/dist/test-document.d.ts +3 -3
- package/dist/test-document.js +18 -18
- package/dist/test.d.ts +1 -1
- package/dist/test.js +7 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/customer/customer.ts +40 -0
- package/dist/account/interfaces/account.repository.interface.d.ts +0 -3
- package/dist/account/interfaces/account.repository.interface.js +0 -3
- package/dist/account/interfaces/account.repository.interface.js.map +0 -1
- package/dist/document/interfaces/document.repository.interface.d.ts +0 -3
- package/dist/document/interfaces/document.repository.interface.js +0 -3
- package/dist/document/interfaces/document.repository.interface.js.map +0 -1
- package/dist/journal-entry/interfaces/journal-entry.repository.interface.d.ts +0 -10
- package/dist/journal-entry/interfaces/journal-entry.repository.interface.js +0 -3
- package/dist/journal-entry/interfaces/journal-entry.repository.interface.js.map +0 -1
- package/dist/payment/interfaces/payment-item-attr.interface.d.ts +0 -7
- package/dist/payment/interfaces/payment-item-attr.interface.js +0 -7
- package/dist/payment/interfaces/payment-item-attr.interface.js.map +0 -1
- package/dist/payment/interfaces/payment-item.repository.interface.d.ts +0 -3
- package/dist/payment/interfaces/payment-item.repository.interface.js +0 -3
- package/dist/payment/interfaces/payment-item.repository.interface.js.map +0 -1
- package/dist/payment/interfaces/payment.repository.interface.d.ts +0 -3
- package/dist/payment/interfaces/payment.repository.interface.js +0 -3
- package/dist/payment/interfaces/payment.repository.interface.js.map +0 -1
- package/dist/payment/payment-item.repository.d.ts +0 -17
- package/dist/payment/payment-item.repository.js +0 -51
- package/dist/payment/payment-item.repository.js.map +0 -1
package/package.json
CHANGED
package/src/customer/customer.ts
CHANGED
|
@@ -13,6 +13,7 @@ import Account from '../account/account';
|
|
|
13
13
|
import { AccountRepository } from '../account/account.repository';
|
|
14
14
|
import { type } from '../helpers/typeof';
|
|
15
15
|
import * as FinanceDb from '../database';
|
|
16
|
+
import { LedgerTransactionRepository } from '../ledger-transaction/ledger-transaction.repository';
|
|
16
17
|
|
|
17
18
|
// const AccountSystemEntity = import('../account-system-entity').then(({AccountSystemEntity}) => AccountSystemEntity);
|
|
18
19
|
export default abstract class FinanceCustomerBase
|
|
@@ -41,6 +42,8 @@ export default abstract class FinanceCustomerBase
|
|
|
41
42
|
protected _DbTransaction: any;
|
|
42
43
|
|
|
43
44
|
private static _AccountRepository = new AccountRepository();
|
|
45
|
+
private static _LedgerTransactionRepository =
|
|
46
|
+
new LedgerTransactionRepository();
|
|
44
47
|
|
|
45
48
|
// note: getDetails from spec is void type. Meaning that this probably needed a fix soon
|
|
46
49
|
async getDetails(): Promise<{
|
|
@@ -273,4 +276,41 @@ export default abstract class FinanceCustomerBase
|
|
|
273
276
|
}
|
|
274
277
|
return false;
|
|
275
278
|
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Method to calculate and return the outstanding balance for customer receivable account
|
|
282
|
+
*
|
|
283
|
+
* @param dbTransaction
|
|
284
|
+
* @returns {number}
|
|
285
|
+
*/
|
|
286
|
+
async getOutstandingBalance(dbTransaction: any): Promise<number> {
|
|
287
|
+
if (!dbTransaction) {
|
|
288
|
+
dbTransaction = await FinanceDb.getConnection().transaction();
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const ledgerTransactions =
|
|
292
|
+
await FinanceCustomerBase._LedgerTransactionRepository.findAll({
|
|
293
|
+
where: {
|
|
294
|
+
AccountNo: (await this.AccountReceivable).AccountNo,
|
|
295
|
+
},
|
|
296
|
+
transaction: dbTransaction,
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
const totalDebitAmount = ledgerTransactions.reduce(
|
|
300
|
+
(accumulator, currentValue) => accumulator + +currentValue.DebitAmount,
|
|
301
|
+
0,
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
const totalCreditAmount = ledgerTransactions.reduce(
|
|
305
|
+
(accumulator, currentValue) => accumulator + +currentValue.CreditAmount,
|
|
306
|
+
0,
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
if (totalCreditAmount > totalDebitAmount) {
|
|
310
|
+
return 0;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const balance = totalDebitAmount - totalCreditAmount;
|
|
314
|
+
return balance;
|
|
315
|
+
}
|
|
276
316
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"account.repository.interface.js","sourceRoot":"","sources":["../../../src/account/interfaces/account.repository.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document.repository.interface.js","sourceRoot":"","sources":["../../../src/document/interfaces/document.repository.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export interface IJournalEntryRepository<T> {
|
|
2
|
-
create?(data: T | any, options?: any): Promise<T> | any;
|
|
3
|
-
findAll?(options?: any): Promise<T[]>;
|
|
4
|
-
findAllWithPagination(options: any): Promise<{
|
|
5
|
-
count: number;
|
|
6
|
-
rows: T[];
|
|
7
|
-
}>;
|
|
8
|
-
findOne?(options: any): Promise<T>;
|
|
9
|
-
update?(data: any, options?: any): Promise<any>;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"journal-entry.repository.interface.js","sourceRoot":"","sources":["../../../src/journal-entry/interfaces/journal-entry.repository.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payment-item-attr.interface.js","sourceRoot":"","sources":["../../../src/payment/interfaces/payment-item-attr.interface.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAgB;CAM5B;AAND,4CAMC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payment-item.repository.interface.js","sourceRoot":"","sources":["../../../src/payment/interfaces/payment-item.repository.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payment.repository.interface.js","sourceRoot":"","sources":["../../../src/payment/interfaces/payment.repository.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { RepositoryBase } from '@tomei/general';
|
|
2
|
-
import PaymentItemModel from '../models/payment-item.entity';
|
|
3
|
-
import { IPaymentItemAttr } from './interfaces/payment-item-attr.interface';
|
|
4
|
-
import { IPaymentItemRepository } from './interfaces/payment-item.repository.interface';
|
|
5
|
-
export declare class PaymentItemRepository extends RepositoryBase<PaymentItemModel> implements IPaymentItemRepository {
|
|
6
|
-
private readonly paymentItemModel;
|
|
7
|
-
constructor(paymentItemModel: typeof PaymentItemModel);
|
|
8
|
-
create(data: IPaymentItemAttr, options?: any): Promise<PaymentItemModel> | any;
|
|
9
|
-
bulkCreate(data: IPaymentItemAttr[], options?: any): any;
|
|
10
|
-
findAll(options: any): Promise<PaymentItemModel[]>;
|
|
11
|
-
findAllWithPagination(options: any): Promise<{
|
|
12
|
-
count: number;
|
|
13
|
-
rows: PaymentItemModel[];
|
|
14
|
-
}>;
|
|
15
|
-
findOne(options: any): Promise<PaymentItemModel>;
|
|
16
|
-
update(data: IPaymentItemAttr, options?: any): any;
|
|
17
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.PaymentItemRepository = void 0;
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const sequelize_1 = require("@nestjs/sequelize");
|
|
18
|
-
const general_1 = require("@tomei/general");
|
|
19
|
-
const payment_item_entity_1 = require("../models/payment-item.entity");
|
|
20
|
-
let PaymentItemRepository = class PaymentItemRepository extends general_1.RepositoryBase {
|
|
21
|
-
constructor(paymentItemModel) {
|
|
22
|
-
super(paymentItemModel);
|
|
23
|
-
this.paymentItemModel = paymentItemModel;
|
|
24
|
-
}
|
|
25
|
-
create(data, options) {
|
|
26
|
-
return this.paymentItemModel.create(Object.assign({}, data), options);
|
|
27
|
-
}
|
|
28
|
-
bulkCreate(data, options) {
|
|
29
|
-
const payload = [...data];
|
|
30
|
-
return this.paymentItemModel.bulkCreate(payload, options);
|
|
31
|
-
}
|
|
32
|
-
findAll(options) {
|
|
33
|
-
return this.paymentItemModel.findAll(options);
|
|
34
|
-
}
|
|
35
|
-
findAllWithPagination(options) {
|
|
36
|
-
return this.paymentItemModel.findAndCountAll(options);
|
|
37
|
-
}
|
|
38
|
-
findOne(options) {
|
|
39
|
-
return this.paymentItemModel.findOne(options);
|
|
40
|
-
}
|
|
41
|
-
update(data, options) {
|
|
42
|
-
return this.paymentItemModel.update(Object.assign({}, data), options);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
PaymentItemRepository = __decorate([
|
|
46
|
-
(0, common_1.Injectable)(),
|
|
47
|
-
__param(0, (0, sequelize_1.InjectModel)(payment_item_entity_1.default)),
|
|
48
|
-
__metadata("design:paramtypes", [Object])
|
|
49
|
-
], PaymentItemRepository);
|
|
50
|
-
exports.PaymentItemRepository = PaymentItemRepository;
|
|
51
|
-
//# sourceMappingURL=payment-item.repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payment-item.repository.js","sourceRoot":"","sources":["../../src/payment/payment-item.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,iDAAgD;AAChD,4CAAgD;AAChD,uEAA6D;AAKtD,IAAM,qBAAqB,GAA3B,MAAM,qBACX,SAAQ,wBAAgC;IAGxC,YAEmB,gBAAyC;QAE1D,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAFP,qBAAgB,GAAhB,gBAAgB,CAAyB;IAG5D,CAAC;IAED,MAAM,CACJ,IAAsB,EACtB,OAAa;QAEb,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,mBAAM,IAAI,GAAI,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED,UAAU,CAAC,IAAwB,EAAE,OAAa;QAChD,MAAM,OAAO,GAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,CAAC,OAAY;QAClB,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,qBAAqB,CACnB,OAAY;QAEZ,OAAO,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,CAAC,OAAY;QAClB,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,IAAsB,EAAE,OAAa;QAC1C,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,mBAAM,IAAI,GAAI,OAAO,CAAC,CAAC;IAC5D,CAAC;CACF,CAAA;AAxCY,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,uBAAW,EAAC,6BAAgB,CAAC,CAAA;;GALrB,qBAAqB,CAwCjC;AAxCY,sDAAqB"}
|