@tomei/rental 0.2.5 → 0.2.6

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 (72) hide show
  1. package/.commitlintrc.json +22 -22
  2. package/.eslintrc +16 -16
  3. package/.eslintrc.js +35 -35
  4. package/.husky/commit-msg +15 -15
  5. package/.husky/pre-commit +7 -7
  6. package/.prettierrc +4 -4
  7. package/Jenkinsfile +51 -57
  8. package/README.md +8 -8
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +17 -17
  11. package/dist/src/components/rental/rental.d.ts +35 -35
  12. package/dist/src/components/rental/rental.js +208 -208
  13. package/dist/src/components/rental/rental.repository.d.ts +8 -8
  14. package/dist/src/components/rental/rental.repository.js +66 -66
  15. package/dist/src/components/rental-price/rental-price.d.ts +12 -12
  16. package/dist/src/components/rental-price/rental-price.js +71 -71
  17. package/dist/src/components/rental-price/rental-price.repository.d.ts +8 -8
  18. package/dist/src/components/rental-price/rental-price.repository.js +66 -66
  19. package/dist/src/database.d.ts +4 -4
  20. package/dist/src/database.js +19 -19
  21. package/dist/src/enum/index.d.ts +2 -2
  22. package/dist/src/enum/index.js +5 -5
  23. package/dist/src/enum/rental-status.enum.d.ts +6 -6
  24. package/dist/src/enum/rental-status.enum.js +10 -10
  25. package/dist/src/index.d.ts +9 -9
  26. package/dist/src/index.js +30 -30
  27. package/dist/src/interfaces/index.d.ts +4 -4
  28. package/dist/src/interfaces/index.js +2 -2
  29. package/dist/src/interfaces/rental-attr.interface.d.ts +20 -20
  30. package/dist/src/interfaces/rental-attr.interface.js +2 -2
  31. package/dist/src/interfaces/rental-find-all-search-attr.interface.d.ts +8 -8
  32. package/dist/src/interfaces/rental-find-all-search-attr.interface.js +2 -2
  33. package/dist/src/interfaces/rental-price-attr.interface.d.ts +7 -7
  34. package/dist/src/interfaces/rental-price-attr.interface.js +2 -2
  35. package/dist/src/models/index.d.ts +3 -3
  36. package/dist/src/models/index.js +7 -7
  37. package/dist/src/models/rental-price.entity.d.ts +8 -8
  38. package/dist/src/models/rental-price.entity.js +58 -58
  39. package/dist/src/models/rental.entity.d.ts +23 -23
  40. package/dist/src/models/rental.entity.js +140 -138
  41. package/dist/src/models/rental.entity.js.map +1 -1
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/jest.config.js +10 -10
  44. package/migrations/rental-price-table-migration.js +32 -32
  45. package/migrations/rental-table-migrations.js +86 -84
  46. package/package.json +71 -71
  47. package/src/components/rental/rental.repository.ts +51 -51
  48. package/src/components/rental/rental.ts +285 -285
  49. package/src/components/rental-price/rental-price.repository.ts +54 -54
  50. package/src/components/rental-price/rental-price.ts +89 -89
  51. package/src/database.ts +21 -21
  52. package/src/enum/index.ts +3 -3
  53. package/src/enum/rental-status.enum.ts +6 -6
  54. package/src/index.ts +16 -16
  55. package/src/interfaces/index.ts +5 -5
  56. package/src/interfaces/rental-attr.interface.ts +21 -21
  57. package/src/interfaces/rental-find-all-search-attr.interface.ts +9 -9
  58. package/src/interfaces/rental-price-attr.interface.ts +7 -7
  59. package/src/models/index.ts +4 -4
  60. package/src/models/rental-price.entity.ts +38 -38
  61. package/src/models/rental.entity.ts +116 -114
  62. package/tsconfig.build.json +5 -5
  63. package/tsconfig.json +23 -23
  64. package/dist/jest.config.d.ts +0 -2
  65. package/dist/jest.config.js +0 -11
  66. package/dist/jest.config.js.map +0 -1
  67. package/dist/migrations/rental-price-table-migration.d.ts +0 -2
  68. package/dist/migrations/rental-price-table-migration.js +0 -43
  69. package/dist/migrations/rental-price-table-migration.js.map +0 -1
  70. package/dist/migrations/rental-table-migrations.d.ts +0 -2
  71. package/dist/migrations/rental-table-migrations.js +0 -95
  72. package/dist/migrations/rental-table-migrations.js.map +0 -1
@@ -1,209 +1,209 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Rental = void 0;
13
- const rental_status_enum_1 = require("../../enum/rental-status.enum");
14
- const rental_repository_1 = require("./rental.repository");
15
- const general_1 = require("@tomei/general");
16
- const config_1 = require("@tomei/config");
17
- const cuid = require("cuid");
18
- const sequelize_1 = require("sequelize");
19
- const activity_history_1 = require("@tomei/activity-history");
20
- class Rental {
21
- get Status() {
22
- return this._Status;
23
- }
24
- get EscheatmentYN() {
25
- return this._EscheatmentYN;
26
- }
27
- get CreatedById() {
28
- return this._CreatedById;
29
- }
30
- get CreatedAt() {
31
- return this._CreatedAt;
32
- }
33
- get UpdatedById() {
34
- return this._UpdatedById;
35
- }
36
- get UpdatedAt() {
37
- return this._UpdatedAt;
38
- }
39
- constructor(rentalAttr) {
40
- this._EscheatmentYN = 'N';
41
- if (rentalAttr) {
42
- this.RentalId = rentalAttr.RentalId;
43
- this.CustomerId = rentalAttr.CustomerId;
44
- this.CustomerType = rentalAttr.CustomerType;
45
- this.ItemId = rentalAttr.ItemId;
46
- this.ItemType = rentalAttr.ItemType;
47
- this.PriceId = rentalAttr.PriceId;
48
- this.StartDateTime = rentalAttr.StartDateTime;
49
- this.EndDateTime = rentalAttr.EndDateTime;
50
- this.CancelRemarks = rentalAttr.CancelRemarks;
51
- this.TerminateRemarks = rentalAttr.TerminateRemarks;
52
- this.AgreementNo = rentalAttr.AgreementNo;
53
- this._Status = rentalAttr.Status;
54
- this._EscheatmentYN = rentalAttr.EscheatmentYN;
55
- this._CreatedById = rentalAttr.CreatedById;
56
- this._CreatedAt = rentalAttr.CreatedAt;
57
- this._UpdatedById = rentalAttr.UpdatedById;
58
- this._UpdatedAt = rentalAttr.UpdatedAt;
59
- }
60
- }
61
- static init(dbTransaction, rentalId) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- try {
64
- if (rentalId) {
65
- const rental = yield Rental._Repo.findByPk(rentalId, dbTransaction);
66
- if (rental) {
67
- return new Rental(rental);
68
- }
69
- else {
70
- throw new general_1.ClassError('Rental', 'RentalErrMsg', 'Rental Not Found');
71
- }
72
- }
73
- return new Rental();
74
- }
75
- catch (error) {
76
- throw new general_1.ClassError('Rental', 'RentalErrMsg', 'Failed To Initialize Price');
77
- }
78
- });
79
- }
80
- create(rentalPrice, loginUser, dbTransaction) {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- try {
83
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
84
- const isPrivileged = yield loginUser.checkPrivileges(systemCode, 'Rental - Create');
85
- if (!isPrivileged) {
86
- throw new general_1.ClassError('RentalPrice', 'RentalPriceErrMsg', 'You do not have the privilege.');
87
- }
88
- const isItemAvailable = yield this.isItemAvailable(this.ItemId, this.ItemType, this.StartDateTime, this.EndDateTime, dbTransaction);
89
- if (!isItemAvailable) {
90
- throw new general_1.ClassError('Rental', 'RentalErrMsg02', 'Rental Item is not available at current date.');
91
- }
92
- yield rentalPrice.create(loginUser, dbTransaction);
93
- this.PriceId = rentalPrice.PriceId;
94
- this.RentalId = cuid();
95
- this._Status = rental_status_enum_1.RentalStatusEnum.ACTIVE;
96
- this._CreatedById = loginUser.ObjectId;
97
- this._UpdatedById = loginUser.ObjectId;
98
- this._CreatedAt = new Date();
99
- this._UpdatedAt = new Date();
100
- const data = {
101
- RentalId: this.RentalId,
102
- CustomerId: this.CustomerId,
103
- CustomerType: this.CustomerType,
104
- ItemId: this.ItemId,
105
- ItemType: this.ItemType,
106
- PriceId: this.PriceId,
107
- StartDateTime: this.StartDateTime,
108
- EndDateTime: this.EndDateTime,
109
- CancelRemarks: this.CancelRemarks,
110
- TerminateRemarks: this.TerminateRemarks,
111
- AgreementNo: this.AgreementNo,
112
- Status: this.Status,
113
- EscheatmentYN: this.EscheatmentYN,
114
- CreatedById: this.CreatedById,
115
- CreatedAt: this.CreatedAt,
116
- UpdatedById: this.UpdatedById,
117
- UpdatedAt: this.UpdatedAt,
118
- };
119
- yield Rental._Repo.create(data, dbTransaction);
120
- const activity = new activity_history_1.Activity();
121
- activity.ActivityId = cuid();
122
- activity.Action = activity_history_1.ActionEnum.ADD;
123
- activity.Description = 'Add Rental';
124
- activity.EntityType = 'Rental';
125
- activity.EntityId = this.RentalId;
126
- activity.EntityValueBefore = JSON.stringify({});
127
- activity.EntityValueAfter = JSON.stringify(data);
128
- yield activity.create(loginUser, dbTransaction);
129
- return this;
130
- }
131
- catch (error) {
132
- throw error;
133
- }
134
- });
135
- }
136
- isItemAvailable(itemId, itemType, startDateTime, endDateTime, dbTransaction) {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- try {
139
- const item = yield Rental._Repo.findOne({
140
- where: {
141
- ItemId: itemId,
142
- ItemType: itemType,
143
- StartDateTime: {
144
- [sequelize_1.Op.lte]: endDateTime,
145
- },
146
- EndDateTime: {
147
- [sequelize_1.Op.gte]: startDateTime,
148
- },
149
- },
150
- transaction: dbTransaction,
151
- });
152
- if (item) {
153
- return false;
154
- }
155
- else {
156
- return true;
157
- }
158
- }
159
- catch (error) {
160
- throw error;
161
- }
162
- });
163
- }
164
- static findAll(loginUser, dbTransaction, page, row, search) {
165
- return __awaiter(this, void 0, void 0, function* () {
166
- try {
167
- const systemCode = yield config_1.ApplicationConfig.getComponentConfigValue('system-code');
168
- const isPrivileged = yield loginUser.checkPrivileges(systemCode, 'Rental - View');
169
- if (!isPrivileged) {
170
- throw new general_1.ClassError('Rental', 'RentalErrMsg', 'You do not have the privilege.');
171
- }
172
- const queryObj = {};
173
- let options = {
174
- transaction: dbTransaction,
175
- };
176
- if (page && row) {
177
- options = Object.assign(Object.assign({}, options), { limit: row, offset: row * (page - 1), order: [['CreatedAt', 'DESC']] });
178
- }
179
- if (search) {
180
- Object.entries(search).forEach(([key, value]) => {
181
- if (key === 'StartDateTime') {
182
- queryObj[key] = {
183
- [sequelize_1.Op.gte]: value,
184
- };
185
- }
186
- else if (key === 'EndDateTime') {
187
- queryObj[key] = {
188
- [sequelize_1.Op.lte]: value,
189
- };
190
- }
191
- else {
192
- queryObj[key] = {
193
- [sequelize_1.Op.substring]: value,
194
- };
195
- }
196
- });
197
- options = Object.assign(Object.assign({}, options), { where: queryObj });
198
- }
199
- return yield Rental._Repo.findAndCountAll(options);
200
- }
201
- catch (err) {
202
- throw err;
203
- }
204
- });
205
- }
206
- }
207
- exports.Rental = Rental;
208
- Rental._Repo = new rental_repository_1.RentalRepository();
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Rental = void 0;
13
+ const rental_status_enum_1 = require("../../enum/rental-status.enum");
14
+ const rental_repository_1 = require("./rental.repository");
15
+ const general_1 = require("@tomei/general");
16
+ const config_1 = require("@tomei/config");
17
+ const cuid = require("cuid");
18
+ const sequelize_1 = require("sequelize");
19
+ const activity_history_1 = require("@tomei/activity-history");
20
+ class Rental {
21
+ get Status() {
22
+ return this._Status;
23
+ }
24
+ get EscheatmentYN() {
25
+ return this._EscheatmentYN;
26
+ }
27
+ get CreatedById() {
28
+ return this._CreatedById;
29
+ }
30
+ get CreatedAt() {
31
+ return this._CreatedAt;
32
+ }
33
+ get UpdatedById() {
34
+ return this._UpdatedById;
35
+ }
36
+ get UpdatedAt() {
37
+ return this._UpdatedAt;
38
+ }
39
+ constructor(rentalAttr) {
40
+ this._EscheatmentYN = 'N';
41
+ if (rentalAttr) {
42
+ this.RentalId = rentalAttr.RentalId;
43
+ this.CustomerId = rentalAttr.CustomerId;
44
+ this.CustomerType = rentalAttr.CustomerType;
45
+ this.ItemId = rentalAttr.ItemId;
46
+ this.ItemType = rentalAttr.ItemType;
47
+ this.PriceId = rentalAttr.PriceId;
48
+ this.StartDateTime = rentalAttr.StartDateTime;
49
+ this.EndDateTime = rentalAttr.EndDateTime;
50
+ this.CancelRemarks = rentalAttr.CancelRemarks;
51
+ this.TerminateRemarks = rentalAttr.TerminateRemarks;
52
+ this.AgreementNo = rentalAttr.AgreementNo;
53
+ this._Status = rentalAttr.Status;
54
+ this._EscheatmentYN = rentalAttr.EscheatmentYN;
55
+ this._CreatedById = rentalAttr.CreatedById;
56
+ this._CreatedAt = rentalAttr.CreatedAt;
57
+ this._UpdatedById = rentalAttr.UpdatedById;
58
+ this._UpdatedAt = rentalAttr.UpdatedAt;
59
+ }
60
+ }
61
+ static init(dbTransaction, rentalId) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ try {
64
+ if (rentalId) {
65
+ const rental = yield Rental._Repo.findByPk(rentalId, dbTransaction);
66
+ if (rental) {
67
+ return new Rental(rental);
68
+ }
69
+ else {
70
+ throw new general_1.ClassError('Rental', 'RentalErrMsg', 'Rental Not Found');
71
+ }
72
+ }
73
+ return new Rental();
74
+ }
75
+ catch (error) {
76
+ throw new general_1.ClassError('Rental', 'RentalErrMsg', 'Failed To Initialize Price');
77
+ }
78
+ });
79
+ }
80
+ create(rentalPrice, loginUser, dbTransaction) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ try {
83
+ const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
84
+ const isPrivileged = yield loginUser.checkPrivileges(systemCode, 'Rental - Create');
85
+ if (!isPrivileged) {
86
+ throw new general_1.ClassError('RentalPrice', 'RentalPriceErrMsg', 'You do not have the privilege.');
87
+ }
88
+ const isItemAvailable = yield this.isItemAvailable(this.ItemId, this.ItemType, this.StartDateTime, this.EndDateTime, dbTransaction);
89
+ if (!isItemAvailable) {
90
+ throw new general_1.ClassError('Rental', 'RentalErrMsg02', 'Rental Item is not available at current date.');
91
+ }
92
+ yield rentalPrice.create(loginUser, dbTransaction);
93
+ this.PriceId = rentalPrice.PriceId;
94
+ this.RentalId = cuid();
95
+ this._Status = rental_status_enum_1.RentalStatusEnum.ACTIVE;
96
+ this._CreatedById = loginUser.ObjectId;
97
+ this._UpdatedById = loginUser.ObjectId;
98
+ this._CreatedAt = new Date();
99
+ this._UpdatedAt = new Date();
100
+ const data = {
101
+ RentalId: this.RentalId,
102
+ CustomerId: this.CustomerId,
103
+ CustomerType: this.CustomerType,
104
+ ItemId: this.ItemId,
105
+ ItemType: this.ItemType,
106
+ PriceId: this.PriceId,
107
+ StartDateTime: this.StartDateTime,
108
+ EndDateTime: this.EndDateTime,
109
+ CancelRemarks: this.CancelRemarks,
110
+ TerminateRemarks: this.TerminateRemarks,
111
+ AgreementNo: this.AgreementNo,
112
+ Status: this.Status,
113
+ EscheatmentYN: this.EscheatmentYN,
114
+ CreatedById: this.CreatedById,
115
+ CreatedAt: this.CreatedAt,
116
+ UpdatedById: this.UpdatedById,
117
+ UpdatedAt: this.UpdatedAt,
118
+ };
119
+ yield Rental._Repo.create(data, dbTransaction);
120
+ const activity = new activity_history_1.Activity();
121
+ activity.ActivityId = cuid();
122
+ activity.Action = activity_history_1.ActionEnum.ADD;
123
+ activity.Description = 'Add Rental';
124
+ activity.EntityType = 'Rental';
125
+ activity.EntityId = this.RentalId;
126
+ activity.EntityValueBefore = JSON.stringify({});
127
+ activity.EntityValueAfter = JSON.stringify(data);
128
+ yield activity.create(loginUser, dbTransaction);
129
+ return this;
130
+ }
131
+ catch (error) {
132
+ throw error;
133
+ }
134
+ });
135
+ }
136
+ isItemAvailable(itemId, itemType, startDateTime, endDateTime, dbTransaction) {
137
+ return __awaiter(this, void 0, void 0, function* () {
138
+ try {
139
+ const item = yield Rental._Repo.findOne({
140
+ where: {
141
+ ItemId: itemId,
142
+ ItemType: itemType,
143
+ StartDateTime: {
144
+ [sequelize_1.Op.lte]: endDateTime,
145
+ },
146
+ EndDateTime: {
147
+ [sequelize_1.Op.gte]: startDateTime,
148
+ },
149
+ },
150
+ transaction: dbTransaction,
151
+ });
152
+ if (item) {
153
+ return false;
154
+ }
155
+ else {
156
+ return true;
157
+ }
158
+ }
159
+ catch (error) {
160
+ throw error;
161
+ }
162
+ });
163
+ }
164
+ static findAll(loginUser, dbTransaction, page, row, search) {
165
+ return __awaiter(this, void 0, void 0, function* () {
166
+ try {
167
+ const systemCode = yield config_1.ApplicationConfig.getComponentConfigValue('system-code');
168
+ const isPrivileged = yield loginUser.checkPrivileges(systemCode, 'Rental - View');
169
+ if (!isPrivileged) {
170
+ throw new general_1.ClassError('Rental', 'RentalErrMsg', 'You do not have the privilege.');
171
+ }
172
+ const queryObj = {};
173
+ let options = {
174
+ transaction: dbTransaction,
175
+ };
176
+ if (page && row) {
177
+ options = Object.assign(Object.assign({}, options), { limit: row, offset: row * (page - 1), order: [['CreatedAt', 'DESC']] });
178
+ }
179
+ if (search) {
180
+ Object.entries(search).forEach(([key, value]) => {
181
+ if (key === 'StartDateTime') {
182
+ queryObj[key] = {
183
+ [sequelize_1.Op.gte]: value,
184
+ };
185
+ }
186
+ else if (key === 'EndDateTime') {
187
+ queryObj[key] = {
188
+ [sequelize_1.Op.lte]: value,
189
+ };
190
+ }
191
+ else {
192
+ queryObj[key] = {
193
+ [sequelize_1.Op.substring]: value,
194
+ };
195
+ }
196
+ });
197
+ options = Object.assign(Object.assign({}, options), { where: queryObj });
198
+ }
199
+ return yield Rental._Repo.findAndCountAll(options);
200
+ }
201
+ catch (err) {
202
+ throw err;
203
+ }
204
+ });
205
+ }
206
+ }
207
+ exports.Rental = Rental;
208
+ Rental._Repo = new rental_repository_1.RentalRepository();
209
209
  //# sourceMappingURL=rental.js.map
@@ -1,8 +1,8 @@
1
- import { RepositoryBase, IRepositoryBase } from '@tomei/general';
2
- import { RentalModel } from '../../models/rental.entity';
3
- export declare class RentalRepository extends RepositoryBase<RentalModel> implements IRepositoryBase<RentalModel> {
4
- constructor();
5
- findByPk(id: string, transaction?: any): Promise<RentalModel | null>;
6
- delete(RentalId: string, dbTransaction?: any): Promise<void>;
7
- findAndCountAll(options?: any): Promise<any>;
8
- }
1
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
2
+ import { RentalModel } from '../../models/rental.entity';
3
+ export declare class RentalRepository extends RepositoryBase<RentalModel> implements IRepositoryBase<RentalModel> {
4
+ constructor();
5
+ findByPk(id: string, transaction?: any): Promise<RentalModel | null>;
6
+ delete(RentalId: string, dbTransaction?: any): Promise<void>;
7
+ findAndCountAll(options?: any): Promise<any>;
8
+ }
@@ -1,67 +1,67 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.RentalRepository = void 0;
13
- const general_1 = require("@tomei/general");
14
- const rental_entity_1 = require("../../models/rental.entity");
15
- class RentalRepository extends general_1.RepositoryBase {
16
- constructor() {
17
- super(rental_entity_1.RentalModel);
18
- }
19
- findByPk(id, transaction) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- try {
22
- const result = yield rental_entity_1.RentalModel.findByPk(id, {
23
- transaction: transaction,
24
- });
25
- return result;
26
- }
27
- catch (error) {
28
- throw new Error(`An Error occured when fetching : ${error.message}`);
29
- }
30
- });
31
- }
32
- delete(RentalId, dbTransaction) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- try {
35
- const options = {
36
- where: {
37
- RentalId: RentalId,
38
- },
39
- transaction: dbTransaction,
40
- };
41
- yield rental_entity_1.RentalModel.destroy(options);
42
- }
43
- catch (error) {
44
- throw new Error(`An Error occured when delete : ${error.message}`);
45
- }
46
- });
47
- }
48
- findAndCountAll(options) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- try {
51
- let Rentals;
52
- if (options) {
53
- Rentals = yield rental_entity_1.RentalModel.findAndCountAll(options);
54
- }
55
- else {
56
- Rentals = yield rental_entity_1.RentalModel.findAndCountAll();
57
- }
58
- return Rentals;
59
- }
60
- catch (error) {
61
- throw new Error(`An Error occured when retriving : ${error.message}`);
62
- }
63
- });
64
- }
65
- }
66
- exports.RentalRepository = RentalRepository;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RentalRepository = void 0;
13
+ const general_1 = require("@tomei/general");
14
+ const rental_entity_1 = require("../../models/rental.entity");
15
+ class RentalRepository extends general_1.RepositoryBase {
16
+ constructor() {
17
+ super(rental_entity_1.RentalModel);
18
+ }
19
+ findByPk(id, transaction) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ try {
22
+ const result = yield rental_entity_1.RentalModel.findByPk(id, {
23
+ transaction: transaction,
24
+ });
25
+ return result;
26
+ }
27
+ catch (error) {
28
+ throw new Error(`An Error occured when fetching : ${error.message}`);
29
+ }
30
+ });
31
+ }
32
+ delete(RentalId, dbTransaction) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ try {
35
+ const options = {
36
+ where: {
37
+ RentalId: RentalId,
38
+ },
39
+ transaction: dbTransaction,
40
+ };
41
+ yield rental_entity_1.RentalModel.destroy(options);
42
+ }
43
+ catch (error) {
44
+ throw new Error(`An Error occured when delete : ${error.message}`);
45
+ }
46
+ });
47
+ }
48
+ findAndCountAll(options) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ try {
51
+ let Rentals;
52
+ if (options) {
53
+ Rentals = yield rental_entity_1.RentalModel.findAndCountAll(options);
54
+ }
55
+ else {
56
+ Rentals = yield rental_entity_1.RentalModel.findAndCountAll();
57
+ }
58
+ return Rentals;
59
+ }
60
+ catch (error) {
61
+ throw new Error(`An Error occured when retriving : ${error.message}`);
62
+ }
63
+ });
64
+ }
65
+ }
66
+ exports.RentalRepository = RentalRepository;
67
67
  //# sourceMappingURL=rental.repository.js.map
@@ -1,12 +1,12 @@
1
- import { LoginUser } from '@tomei/sso';
2
- export declare class RentalPrice {
3
- PriceId: string;
4
- RetailPrice: number;
5
- Currency: string;
6
- PromoCode: string;
7
- Remarks: string;
8
- private static _Repo;
9
- private constructor();
10
- static init(dbTransaction?: any, priceId?: string): Promise<RentalPrice>;
11
- create(loginUser: LoginUser, dbTransaction?: any): Promise<this>;
12
- }
1
+ import { LoginUser } from '@tomei/sso';
2
+ export declare class RentalPrice {
3
+ PriceId: string;
4
+ RetailPrice: number;
5
+ Currency: string;
6
+ PromoCode: string;
7
+ Remarks: string;
8
+ private static _Repo;
9
+ private constructor();
10
+ static init(dbTransaction?: any, priceId?: string): Promise<RentalPrice>;
11
+ create(loginUser: LoginUser, dbTransaction?: any): Promise<this>;
12
+ }