@tomei/finance 0.0.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.
Files changed (77) hide show
  1. package/.commitlintrc.json +22 -0
  2. package/.eslintrc.js +66 -0
  3. package/.husky/commit-msg +4 -0
  4. package/.husky/pre-commit +4 -0
  5. package/.prettierrc +4 -0
  6. package/CHANGELOG.md +1 -0
  7. package/CONTRIBUTING.md +31 -0
  8. package/LICENSE +21 -0
  9. package/README.md +41 -0
  10. package/configs/config.js +83 -0
  11. package/dist/account/account.d.ts +23 -0
  12. package/dist/account/account.js +80 -0
  13. package/dist/account/account.js.map +1 -0
  14. package/dist/account/account.repository.d.ts +16 -0
  15. package/dist/account/account.repository.js +47 -0
  16. package/dist/account/account.repository.js.map +1 -0
  17. package/dist/account/entities/account.entity.d.ts +14 -0
  18. package/dist/account/entities/account.entity.js +122 -0
  19. package/dist/account/entities/account.entity.js.map +1 -0
  20. package/dist/account/index.d.ts +6 -0
  21. package/dist/account/index.js +10 -0
  22. package/dist/account/index.js.map +1 -0
  23. package/dist/account/interfaces/account-attr.interface.d.ts +25 -0
  24. package/dist/account/interfaces/account-attr.interface.js +3 -0
  25. package/dist/account/interfaces/account-attr.interface.js.map +1 -0
  26. package/dist/account/interfaces/account.repository.interface.d.ts +3 -0
  27. package/dist/account/interfaces/account.repository.interface.js +3 -0
  28. package/dist/account/interfaces/account.repository.interface.js.map +1 -0
  29. package/dist/base/account-system.interface.d.ts +7 -0
  30. package/dist/base/account-system.interface.js +3 -0
  31. package/dist/base/account-system.interface.js.map +1 -0
  32. package/dist/base/address.base.abstract.d.ts +4 -0
  33. package/dist/base/address.base.abstract.js +10 -0
  34. package/dist/base/address.base.abstract.js.map +1 -0
  35. package/dist/base/base.repository.abstract.d.ts +12 -0
  36. package/dist/base/base.repository.abstract.js +22 -0
  37. package/dist/base/base.repository.abstract.js.map +1 -0
  38. package/dist/base/base.repository.interface.d.ts +9 -0
  39. package/dist/base/base.repository.interface.js +3 -0
  40. package/dist/base/base.repository.interface.js.map +1 -0
  41. package/dist/base/index.d.ts +5 -0
  42. package/dist/base/index.js +10 -0
  43. package/dist/base/index.js.map +1 -0
  44. package/dist/base/object.base.abstract.d.ts +5 -0
  45. package/dist/base/object.base.abstract.js +11 -0
  46. package/dist/base/object.base.abstract.js.map +1 -0
  47. package/dist/base/person.base.abstract.d.ts +21 -0
  48. package/dist/base/person.base.abstract.js +17 -0
  49. package/dist/base/person.base.abstract.js.map +1 -0
  50. package/dist/index.d.ts +2 -0
  51. package/dist/index.js +19 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/test.d.ts +1 -0
  54. package/dist/test.js +8 -0
  55. package/dist/test.js.map +1 -0
  56. package/dist/tsconfig.tsbuildinfo +1 -0
  57. package/migrations/finance-account-migration.js +59 -0
  58. package/nest-cli.json +19 -0
  59. package/package.json +72 -0
  60. package/src/account/account.repository.ts +44 -0
  61. package/src/account/account.ts +124 -0
  62. package/src/account/entities/account.entity.ts +105 -0
  63. package/src/account/index.ts +19 -0
  64. package/src/account/interfaces/account-attr.interface.ts +28 -0
  65. package/src/account/interfaces/account.repository.interface.ts +4 -0
  66. package/src/base/account-system.interface.ts +7 -0
  67. package/src/base/address.base.abstract.ts +7 -0
  68. package/src/base/base.repository.abstract.ts +28 -0
  69. package/src/base/base.repository.interface.ts +9 -0
  70. package/src/base/index.ts +7 -0
  71. package/src/base/object.base.abstract.ts +8 -0
  72. package/src/base/person.base.abstract.ts +44 -0
  73. package/src/index.ts +5 -0
  74. package/src/test.ts +3 -0
  75. package/tsconfig.build.json +4 -0
  76. package/tsconfig.json +30 -0
  77. package/tslint.json +18 -0
@@ -0,0 +1,22 @@
1
+ {
2
+ "extends": [
3
+ "@commitlint/config-conventional"
4
+ ],
5
+ "rules": {
6
+ "header-max-length": [ 2, "always", 120 ],
7
+ "type-enum": [
8
+ 2,
9
+ "always",
10
+ [
11
+ "breaking",
12
+ "feat",
13
+ "fix",
14
+ "refactor",
15
+ "config",
16
+ "test",
17
+ "docs",
18
+ "chore"
19
+ ]
20
+ ]
21
+ }
22
+ }
package/.eslintrc.js ADDED
@@ -0,0 +1,66 @@
1
+ module.exports = {
2
+ parser: '@typescript-eslint/parser',
3
+ parserOptions: {
4
+ project: 'tsconfig.json',
5
+ sourceType: 'module',
6
+ },
7
+ plugins: ['@typescript-eslint/eslint-plugin'],
8
+ extends: [
9
+ 'plugin:@typescript-eslint/recommended',
10
+ 'plugin:prettier/recommended',
11
+ ],
12
+ root: true,
13
+ env: {
14
+ node: true,
15
+ jest: true,
16
+ },
17
+ ignorePatterns: ['.eslintrc.js', 'db/config.js'],
18
+ rules: {
19
+ "no-unused-vars": "off",
20
+ "@typescript-eslint/no-unused-vars": ["error"],
21
+ '@typescript-eslint/interface-name-prefix': 'off',
22
+ '@typescript-eslint/explicit-function-return-type': 'off',
23
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
24
+ '@typescript-eslint/no-explicit-any': 'off',
25
+ '@typescript-eslint/naming-convention': [
26
+ "error",
27
+ {
28
+ "selector": ["variable", "function"],
29
+ "format": ["camelCase"],
30
+ "leadingUnderscore": "forbid",
31
+ "trailingUnderscore": "forbid",
32
+ },
33
+ {
34
+ "selector": ["class"],
35
+ "format": ["PascalCase"],
36
+ "leadingUnderscore": "forbid",
37
+ "trailingUnderscore": "forbid",
38
+ },
39
+ {
40
+ "selector": "variable",
41
+ "types": ["boolean"],
42
+ "format": ["PascalCase"],
43
+ "leadingUnderscore": "forbid",
44
+ "trailingUnderscore": "forbid",
45
+ "prefix": ["is", "should", "has", "can", "did", "will"]
46
+ },
47
+ {
48
+ "selector": "interface",
49
+ "format": ["PascalCase"],
50
+ "leadingUnderscore": "forbid",
51
+ "trailingUnderscore": "forbid",
52
+ "custom": {
53
+ "regex": "^I[A-Z]",
54
+ "match": true
55
+ }
56
+ },
57
+ {
58
+ "selector": "variable",
59
+ "modifiers": ["const"],
60
+ "format": ["camelCase","UPPER_CASE", "PascalCase"],
61
+ "leadingUnderscore": "forbid",
62
+ "trailingUnderscore": "forbid",
63
+ }
64
+ ]
65
+ },
66
+ };
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npx commitlint --edit $1
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npx lint-staged
package/.prettierrc ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "singleQuote": true,
3
+ "trailingComma": "all"
4
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ RELEASE 1.0.0
@@ -0,0 +1,31 @@
1
+ # Contributing
2
+
3
+ 1. [Fork it](https://help.github.com/articles/fork-a-repo/)
4
+ 2. Install dependencies (`npm install`)
5
+ 3. Create your feature branch (`git checkout -b my-new-feature`)
6
+ 4. Commit your changes (`git commit -am 'Added some feature'`)
7
+ 5. Test your changes (`npm test`)
8
+ 6. Push to the branch (`git push origin my-new-feature`)
9
+ 7. [Create new Pull Request](https://help.github.com/articles/creating-a-pull-request/)
10
+
11
+ ## Testing
12
+
13
+ We use [Jest](https://github.com/facebook/jest) to write tests. Run our test suite with this command:
14
+
15
+ ```
16
+ npm test
17
+ ```
18
+
19
+ ## Code Style
20
+
21
+ We use [Prettier](https://prettier.io/) and tslint to maintain code style and best practices.
22
+ Please make sure your PR adheres to the guides by running:
23
+
24
+ ```
25
+ npm run format
26
+ ```
27
+
28
+ and
29
+ ```
30
+ npm run lint
31
+ ```
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 John Biundo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ <h1 align="center"></h1>
2
+
3
+ <div align="center">
4
+ <a href="http://nestjs.com/" target="_blank">
5
+ <img src="https://nestjs.com/img/logo_text.svg" width="150" alt="Nest Logo" />
6
+ </a>
7
+ </div>
8
+
9
+ <h3 align="center">NestJS npm Package Starter</h3>
10
+
11
+ <div align="center">
12
+ <a href="https://nestjs.com" target="_blank">
13
+ <img src="https://img.shields.io/badge/built%20with-NestJs-red.svg" alt="Built with NestJS">
14
+ </a>
15
+ </div>
16
+
17
+ ### Installation
18
+
19
+ 1. Clone the repo
20
+ 2. Run npm/yarn install
21
+
22
+ ```bash
23
+ cd nestjs-package-starter
24
+ npm install
25
+ ```
26
+
27
+ ## Change Log
28
+
29
+ See [Changelog](CHANGELOG.md) for more information.
30
+
31
+ ## Contributing
32
+
33
+ Contributions welcome! See [Contributing](CONTRIBUTING.md).
34
+
35
+ ## Author
36
+
37
+ **John Biundo (Y Prospect on [Discord](https://discord.gg/G7Qnnhy))**
38
+
39
+ ## License
40
+
41
+ Licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,83 @@
1
+ require('dotenv').config();
2
+
3
+ const config = {
4
+ development: {
5
+ env: 'development',
6
+ accountingSystem: {
7
+ quickbooks: {
8
+ packageName: process.env.PACKAGE_NAME,
9
+ accountSystemClass: process.env.ACCOUNT_SYSTEM_CLASS,
10
+ API_Url: process.env.API_URL,
11
+ },
12
+ xero: {
13
+ packageName: process.env.PACKAGE_NAME,
14
+ accountSystemClass: process.env.ACCOUNT_SYSTEM_CLASS,
15
+ API_Url: process.env.API_URL,
16
+ },
17
+ },
18
+ systemConfig: {
19
+ EZC: {
20
+ accountingSystem: 'quickbooks',
21
+ companyName: process.env.COMPANY_NAME,
22
+ API_Key: process.env.API_KEY,
23
+ API_Secret: process.env.API_SECRET,
24
+ redirectUrl: process.env.REDIRECT_URL,
25
+ },
26
+ EZG: {
27
+ accountingSystem: 'xero',
28
+ companyName: process.env.COMPANY_NAME,
29
+ API_Key: process.env.API_KEY,
30
+ API_Secret: process.env.API_SECRET,
31
+ redirectUrl: process.env.REDIRECT_URL,
32
+ },
33
+ },
34
+ },
35
+ test: {
36
+ env: 'development',
37
+ accountingSystem: {
38
+ quickbooks: {
39
+ packageName: '',
40
+ accountSystemClass: '',
41
+ API_Url: '',
42
+ },
43
+ xero: {
44
+ packageName: '',
45
+ accountSystemClass: '',
46
+ API_Url: '',
47
+ },
48
+ },
49
+ systemConfig: {
50
+ EZC: {
51
+ accountingSystem: 'quickbooks',
52
+ companyName: '',
53
+ API_Key: '',
54
+ API_Secret: '',
55
+ },
56
+ EZG: {
57
+ accountingSystem: 'xero',
58
+ companyName: '',
59
+ API_Key: '',
60
+ API_Secret: '',
61
+ },
62
+ },
63
+ },
64
+ staging: {},
65
+ production: {},
66
+ };
67
+
68
+ const getConfig = () => {
69
+ switch (process.env.NODE_ENV) {
70
+ case 'development':
71
+ return config['development'];
72
+ case 'test':
73
+ return config['test'];
74
+ case 'staging':
75
+ return config['staging'];
76
+ case 'production':
77
+ return config['production'];
78
+ default:
79
+ break;
80
+ }
81
+ };
82
+
83
+ module.exports = () => getConfig();
@@ -0,0 +1,23 @@
1
+ import { ObjectBase } from 'src/base/object.base.abstract';
2
+ import { PersonBase } from 'src/base/person.base.abstract';
3
+ import { IAccountOptions, ICreateAccountAttr } from './interfaces/account-attr.interface';
4
+ import { IAccountRepository } from './interfaces/account.repository.interface';
5
+ export declare class Account {
6
+ accountRepository: IAccountRepository;
7
+ intuitClient: any;
8
+ config: any;
9
+ OwnerId: string;
10
+ OwnerType: string;
11
+ RelatedObjectId: string;
12
+ RelatedObjectType: string;
13
+ AccSystemId: string;
14
+ parentAccount: Account;
15
+ Owner: PersonBase;
16
+ RelatedObject: ObjectBase;
17
+ isParamsInitialized: boolean;
18
+ constructor(accountRepository: IAccountRepository, SysCode: string, options?: IAccountOptions);
19
+ init(params: ICreateAccountAttr): void;
20
+ connect(): string;
21
+ createToken(url: string): Promise<any>;
22
+ createAccount(): Promise<void>;
23
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Account = void 0;
4
+ const OAuthClient = require("intuit-oauth");
5
+ const config_1 = require("../../configs/config");
6
+ class Account {
7
+ constructor(accountRepository, SysCode, options) {
8
+ this.accountRepository = accountRepository;
9
+ this.AccSystemId = SysCode;
10
+ this.config = (0, config_1.default)();
11
+ if (options) {
12
+ if (options.params) {
13
+ this.init(options.params);
14
+ }
15
+ if (options.account) {
16
+ this.parentAccount = options.account;
17
+ }
18
+ }
19
+ if (!this.config) {
20
+ throw new Error('Environment variable required not found');
21
+ }
22
+ this.intuitClient = new OAuthClient({
23
+ clientId: this.config.systemConfig[this.AccSystemId].API_Key,
24
+ clientSecret: this.config.systemConfig[this.AccSystemId].API_Secret,
25
+ environment: this.config.env !== 'production' ? 'sandbox' : 'production',
26
+ redirectUri: this.config.systemConfig[this.AccSystemId].redirectUrl,
27
+ });
28
+ }
29
+ init(params) {
30
+ this.Owner = params.Owner;
31
+ this.RelatedObject = params.RelatedObject;
32
+ const ownerData = this.Owner.getDetails();
33
+ if (!ownerData) {
34
+ throw new Error('Please save owner information in the database before creating an account');
35
+ }
36
+ let isFull = true;
37
+ for (const key in ownerData) {
38
+ if (ownerData.hasOwnProperty(key)) {
39
+ if (!ownerData[key]) {
40
+ isFull = false;
41
+ break;
42
+ }
43
+ }
44
+ }
45
+ if (!isFull) {
46
+ throw new Error('Please save owner information in the database before creating an account');
47
+ }
48
+ this.OwnerId = params.Owner.Id;
49
+ this.OwnerType = 'Owner';
50
+ this.RelatedObjectId = params.RelatedObject.Id;
51
+ this.RelatedObjectType = 'RelatedObject';
52
+ this.isParamsInitialized = true;
53
+ }
54
+ connect() {
55
+ const authUri = this.intuitClient.authorizeUri({
56
+ scope: [OAuthClient.scopes.Accounting, OAuthClient.scopes.OpenId],
57
+ state: 'testState',
58
+ });
59
+ return authUri;
60
+ }
61
+ async createToken(url) {
62
+ try {
63
+ const response = await this.intuitClient.createToken(url);
64
+ return response;
65
+ }
66
+ catch (error) {
67
+ throw error;
68
+ }
69
+ }
70
+ async createAccount() {
71
+ if (!this.Owner || !this.RelatedObject) {
72
+ throw new Error('Owner must be set before creating an account." or "RelatedObject must be set before creating an account.');
73
+ }
74
+ if (!this.isParamsInitialized) {
75
+ throw new Error('Account parameters must be initialized before creating an account.');
76
+ }
77
+ }
78
+ }
79
+ exports.Account = Account;
80
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/account/account.ts"],"names":[],"mappings":";;;AAOA,4CAA4C;AAC5C,iDAA0C;AAE1C,MAAa,OAAO;IAiBlB,YACE,iBAAqC,EACrC,OAAe,EACf,OAAyB;QAEzB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAC;QACvB,IAAI,OAAO,EAAE;YACX,IAAI,OAAO,CAAC,MAAM,EAAE;gBAClB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CA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AM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAC;SACH;QAED,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QAC/C,IAAI,CAAC,iBAAiB,GAAG,eAAe,CAAC;QACzC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAClC,CAAC;IAED,OAAO;QACL,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;YAC7C,KAAK,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;YACjE,KAAK,EAAE,WAAW;SACnB,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,GAAW;QAC3B,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YAC1D,OAAO,QAAQ,CAAC;SACjB;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,KAAK,CAAC;SACb;IACH,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACtC,MAAM,IAAI,KAAK,CACb,0GAA0G,CAC3G,CAAC;SACH;QAED,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;YAC7B,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;SACH;IACH,CAAC;CACF;AAjHD,0BAiHC"}
@@ -0,0 +1,16 @@
1
+ import { BaseRepository } from '../base/base.repository.abstract';
2
+ import { AccountModel } from './entities/account.entity';
3
+ import { IAccountAttr, ICreateAccountAttr } from './interfaces/account-attr.interface';
4
+ import { IAccountRepository } from './interfaces/account.repository.interface';
5
+ export declare class AccountRepository extends BaseRepository<AccountModel> implements IAccountRepository {
6
+ private readonly accountModel;
7
+ constructor(accountModel: typeof AccountModel);
8
+ create(data: ICreateAccountAttr, options?: any): Promise<AccountModel> | any;
9
+ findAll(options: any): Promise<AccountModel[]>;
10
+ findAllWithPagination(options: any): Promise<{
11
+ count: number;
12
+ rows: AccountModel[];
13
+ }>;
14
+ findOne(options: any): Promise<AccountModel>;
15
+ update(data: IAccountAttr, options?: any): any;
16
+ }
@@ -0,0 +1,47 @@
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.AccountRepository = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const sequelize_1 = require("@nestjs/sequelize");
18
+ const base_repository_abstract_1 = require("../base/base.repository.abstract");
19
+ const account_entity_1 = require("./entities/account.entity");
20
+ let AccountRepository = class AccountRepository extends base_repository_abstract_1.BaseRepository {
21
+ constructor(accountModel) {
22
+ super(accountModel);
23
+ this.accountModel = accountModel;
24
+ }
25
+ create(data, options) {
26
+ return this.accountModel.create(Object.assign({}, data), options);
27
+ }
28
+ findAll(options) {
29
+ return this.accountModel.findAll(options);
30
+ }
31
+ findAllWithPagination(options) {
32
+ return this.accountModel.findAndCountAll(options);
33
+ }
34
+ findOne(options) {
35
+ return this.accountModel.findOne(options);
36
+ }
37
+ update(data, options) {
38
+ return this.accountModel.update(Object.assign({}, data), options);
39
+ }
40
+ };
41
+ AccountRepository = __decorate([
42
+ (0, common_1.Injectable)(),
43
+ __param(0, (0, sequelize_1.InjectModel)(account_entity_1.AccountModel)),
44
+ __metadata("design:paramtypes", [Object])
45
+ ], AccountRepository);
46
+ exports.AccountRepository = AccountRepository;
47
+ //# sourceMappingURL=account.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.repository.js","sourceRoot":"","sources":["../../src/account/account.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,iDAAgD;AAChD,+EAAkE;AAClE,8DAAyD;AAQlD,IAAM,iBAAiB,GAAvB,MAAM,iBACX,SAAQ,yCAA4B;IAGpC,YAEmB,YAAiC;QAElD,KAAK,CAAC,YAAY,CAAC,CAAC;QAFH,iBAAY,GAAZ,YAAY,CAAqB;IAGpD,CAAC;IAED,MAAM,CAAC,IAAwB,EAAE,OAAa;QAC5C,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,mBAAM,IAAI,GAAI,OAAO,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,CAAC,OAAY;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,qBAAqB,CACnB,OAAY;QAEZ,OAAO,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,CAAC,OAAY;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,IAAkB,EAAE,OAAa;QACtC,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,mBAAM,IAAI,GAAI,OAAO,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AAhCY,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,uBAAW,EAAC,6BAAY,CAAC,CAAA;;GALjB,iBAAiB,CAgC7B;AAhCY,8CAAiB"}
@@ -0,0 +1,14 @@
1
+ import { Model } from 'sequelize-typescript';
2
+ export declare class AccountModel extends Model {
3
+ AccountNo: string;
4
+ SystemCode: string;
5
+ Name: string;
6
+ OwnerId: string;
7
+ OwnerType: string;
8
+ RelatedObjectId: string;
9
+ RelatedObjectType: string;
10
+ CreatedAt: Date;
11
+ CreatedById: string;
12
+ UpdatedAt: Date;
13
+ UpdatedById: string;
14
+ }
@@ -0,0 +1,122 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AccountModel = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const sequelize_typescript_1 = require("sequelize-typescript");
15
+ let AccountModel = class AccountModel extends sequelize_typescript_1.Model {
16
+ };
17
+ __decorate([
18
+ (0, swagger_1.ApiProperty)({ type: String, description: 'AccountNo' }),
19
+ (0, sequelize_typescript_1.Column)({
20
+ primaryKey: true,
21
+ allowNull: false,
22
+ type: sequelize_typescript_1.DataType.STRING(30),
23
+ }),
24
+ __metadata("design:type", String)
25
+ ], AccountModel.prototype, "AccountNo", void 0);
26
+ __decorate([
27
+ (0, swagger_1.ApiProperty)({
28
+ type: String,
29
+ description: 'System Code eg. "EZC", "CRM"',
30
+ }),
31
+ (0, sequelize_typescript_1.Column)({
32
+ allowNull: false,
33
+ type: sequelize_typescript_1.DataType.STRING(10),
34
+ }),
35
+ __metadata("design:type", String)
36
+ ], AccountModel.prototype, "SystemCode", void 0);
37
+ __decorate([
38
+ (0, swagger_1.ApiProperty)({
39
+ type: String,
40
+ description: 'Name of the account',
41
+ }),
42
+ (0, sequelize_typescript_1.Column)({
43
+ allowNull: true,
44
+ type: sequelize_typescript_1.DataType.STRING(200),
45
+ }),
46
+ __metadata("design:type", String)
47
+ ], AccountModel.prototype, "Name", void 0);
48
+ __decorate([
49
+ (0, swagger_1.ApiProperty)({
50
+ type: String,
51
+ description: 'Owner id of the account',
52
+ }),
53
+ (0, sequelize_typescript_1.Column)({
54
+ allowNull: false,
55
+ type: sequelize_typescript_1.DataType.STRING(30),
56
+ }),
57
+ __metadata("design:type", String)
58
+ ], AccountModel.prototype, "OwnerId", void 0);
59
+ __decorate([
60
+ (0, swagger_1.ApiProperty)({
61
+ type: String,
62
+ description: 'Owner type',
63
+ }),
64
+ (0, sequelize_typescript_1.Column)({
65
+ allowNull: false,
66
+ type: sequelize_typescript_1.DataType.STRING(30),
67
+ }),
68
+ __metadata("design:type", String)
69
+ ], AccountModel.prototype, "OwnerType", void 0);
70
+ __decorate([
71
+ (0, swagger_1.ApiProperty)({ type: String, description: 'Associated Object id' }),
72
+ (0, sequelize_typescript_1.Column)({
73
+ allowNull: false,
74
+ type: sequelize_typescript_1.DataType.STRING(30),
75
+ }),
76
+ __metadata("design:type", String)
77
+ ], AccountModel.prototype, "RelatedObjectId", void 0);
78
+ __decorate([
79
+ (0, swagger_1.ApiProperty)({ type: String, description: 'Associated Object type' }),
80
+ (0, sequelize_typescript_1.Column)({
81
+ allowNull: false,
82
+ type: sequelize_typescript_1.DataType.STRING(200),
83
+ }),
84
+ __metadata("design:type", String)
85
+ ], AccountModel.prototype, "RelatedObjectType", void 0);
86
+ __decorate([
87
+ (0, swagger_1.ApiProperty)({
88
+ example: new Date(),
89
+ description: 'Timestamp for data creation.',
90
+ }),
91
+ sequelize_typescript_1.CreatedAt,
92
+ __metadata("design:type", Date)
93
+ ], AccountModel.prototype, "CreatedAt", void 0);
94
+ __decorate([
95
+ (0, swagger_1.ApiProperty)({
96
+ example: '138140891dd211b288d34bc7b4312a49',
97
+ description: 'The CreatedById for Media.',
98
+ }),
99
+ (0, sequelize_typescript_1.Column)({ allowNull: false, type: sequelize_typescript_1.DataType.STRING(30) }),
100
+ __metadata("design:type", String)
101
+ ], AccountModel.prototype, "CreatedById", void 0);
102
+ __decorate([
103
+ (0, swagger_1.ApiProperty)({
104
+ example: new Date(),
105
+ description: 'Timestamp for latest data modification',
106
+ }),
107
+ sequelize_typescript_1.UpdatedAt,
108
+ __metadata("design:type", Date)
109
+ ], AccountModel.prototype, "UpdatedAt", void 0);
110
+ __decorate([
111
+ (0, swagger_1.ApiProperty)({
112
+ example: '138140891dd211b288d34bc7b4312a49',
113
+ description: 'The UpdatedById for Media.',
114
+ }),
115
+ (0, sequelize_typescript_1.Column)({ allowNull: false, type: sequelize_typescript_1.DataType.STRING(30) }),
116
+ __metadata("design:type", String)
117
+ ], AccountModel.prototype, "UpdatedById", void 0);
118
+ AccountModel = __decorate([
119
+ (0, sequelize_typescript_1.Table)({ tableName: 'finance_Account', createdAt: false, updatedAt: false })
120
+ ], AccountModel);
121
+ exports.AccountModel = AccountModel;
122
+ //# sourceMappingURL=account.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.entity.js","sourceRoot":"","sources":["../../../src/account/entities/account.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,+DAO8B;AAGvB,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,4BAAK;CA6FtC,CAAA;AA5FC;IAAC,IAAA,qBAAW,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 import { Account } from './account';
3
+ import { AccountRepository } from './account.repository';
4
+ import { IAccountOptions, IAccountAttr, ICreateAccountAttr } from './interfaces/account-attr.interface';
5
+ import { IAccountRepository } from './interfaces/account.repository.interface';
6
+ export { AccountModel, Account, AccountRepository, IAccountOptions, IAccountAttr, ICreateAccountAttr, IAccountRepository, };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountRepository = exports.Account = exports.AccountModel = void 0;
4
+ const account_entity_1 = require("./entities/account.entity");
5
+ Object.defineProperty(exports, "AccountModel", { enumerable: true, get: function () { return account_entity_1.AccountModel; } });
6
+ const account_1 = require("./account");
7
+ Object.defineProperty(exports, "Account", { enumerable: true, get: function () { return account_1.Account; } });
8
+ const account_repository_1 = require("./account.repository");
9
+ Object.defineProperty(exports, "AccountRepository", { enumerable: true, get: function () { return account_repository_1.AccountRepository; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/account/index.ts"],"names":[],"mappings":";;;AAAA,8DAAyD;AAWvD,6FAXO,6BAAY,OAWP;AAVd,uCAAoC;AAWlC,wFAXO,iBAAO,OAWP;AAVT,6DAAyD;AAWvD,kGAXO,sCAAiB,OAWP"}
@@ -0,0 +1,25 @@
1
+ import { ObjectBase } from 'src/base/object.base.abstract';
2
+ import { PersonBase } from 'src/base/person.base.abstract';
3
+ import { Account } from '../account';
4
+ export interface IAccountAttr {
5
+ AccountNo: string;
6
+ SystemCode: string;
7
+ Name: string;
8
+ OwnerId: string;
9
+ OwnerType: string;
10
+ RelatedObjectId: string;
11
+ RelatedObjectType: string;
12
+ CreatedAt: Date;
13
+ CreatedById: string;
14
+ UpdatedAt: Date;
15
+ UpdatedById: string;
16
+ }
17
+ export interface ICreateAccountAttr {
18
+ Owner: PersonBase;
19
+ RelatedObject: ObjectBase;
20
+ AccSystemId: string;
21
+ }
22
+ export interface IAccountOptions {
23
+ params?: ICreateAccountAttr;
24
+ account?: Account;
25
+ }