@driveup/schema 0.2.7 → 0.2.9
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/lib/catalog/addon/addon.entity.d.ts +2 -2
- package/lib/catalog/addon/addon.entity.js +2 -2
- package/lib/catalog/addon/addon.entity.js.map +1 -1
- package/lib/catalog/addon/country.entity.d.ts +2 -2
- package/lib/catalog/addon/country.entity.js +1 -2
- package/lib/catalog/addon/country.entity.js.map +1 -1
- package/lib/catalog/priceplan/priceplan.entity.d.ts +7 -2
- package/lib/catalog/priceplan/priceplan.entity.js +10 -3
- package/lib/catalog/priceplan/priceplan.entity.js.map +1 -1
- package/lib/catalog/product/country.entity.d.ts +3 -3
- package/lib/catalog/product/country.entity.js +1 -2
- package/lib/catalog/product/country.entity.js.map +1 -1
- package/lib/catalog/product/priceplan.entity.d.ts +8 -3
- package/lib/catalog/product/priceplan.entity.js +13 -3
- package/lib/catalog/product/priceplan.entity.js.map +1 -1
- package/lib/catalog/product/product.entity.d.ts +2 -2
- package/lib/catalog/product/product.entity.js +2 -2
- package/lib/catalog/product/product.entity.js.map +1 -1
- package/lib/catalog/program/program.entity.d.ts +2 -2
- package/lib/catalog/program/program.entity.js +2 -2
- package/lib/catalog/program/program.entity.js.map +1 -1
- package/lib/catalog/seed/assets/asset.entity.d.ts +2 -2
- package/lib/catalog/seed/assets/asset.entity.js +2 -2
- package/lib/catalog/seed/assets/asset.entity.js.map +1 -1
- package/lib/catalog/seed/courses/course.entity.d.ts +2 -2
- package/lib/catalog/seed/courses/course.entity.js +2 -2
- package/lib/catalog/seed/courses/course.entity.js.map +1 -1
- package/lib/catalog/seed/courses/lesson.entity.d.ts +2 -2
- package/lib/catalog/seed/courses/lesson.entity.js +2 -2
- package/lib/catalog/seed/courses/lesson.entity.js.map +1 -1
- package/lib/catalog/seed/courses/topic.entity.d.ts +2 -2
- package/lib/catalog/seed/courses/topic.entity.js +3 -3
- package/lib/catalog/seed/courses/topic.entity.js.map +1 -1
- package/lib/catalog/seed/expense/category.entity.d.ts +2 -2
- package/lib/catalog/seed/expense/category.entity.js +2 -2
- package/lib/catalog/seed/expense/category.entity.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/profile/agent/agent.entity.d.ts +2 -1
- package/lib/profile/agent/agent.entity.js +17 -15
- package/lib/profile/agent/agent.entity.js.map +1 -1
- package/lib/profile/agent/payout.entity.d.ts +2 -2
- package/lib/profile/agent/payout.entity.js +2 -2
- package/lib/profile/agent/payout.entity.js.map +1 -1
- package/lib/profile/company/company.entity.d.ts +43 -3
- package/lib/profile/company/company.entity.js +106 -33
- package/lib/profile/company/company.entity.js.map +1 -1
- package/lib/profile/company/course/appointment.entity.d.ts +271 -0
- package/lib/profile/company/course/appointment.entity.js +736 -0
- package/lib/profile/company/course/appointment.entity.js.map +1 -0
- package/lib/profile/company/course/course.entity.d.ts +8 -2
- package/lib/profile/company/course/course.entity.js +11 -4
- package/lib/profile/company/course/course.entity.js.map +1 -1
- package/lib/profile/company/course/lesson.entity.d.ts +14 -5
- package/lib/profile/company/course/lesson.entity.js +22 -8
- package/lib/profile/company/course/lesson.entity.js.map +1 -1
- package/lib/profile/company/course/schedule.entity.d.ts +8 -4
- package/lib/profile/company/course/schedule.entity.js +5 -0
- package/lib/profile/company/course/schedule.entity.js.map +1 -1
- package/lib/profile/company/course/topic.entity.d.ts +4 -3
- package/lib/profile/company/course/topic.entity.js +3 -3
- package/lib/profile/company/course/topic.entity.js.map +1 -1
- package/lib/profile/company/finances/billing/bill.entity.d.ts +8 -1
- package/lib/profile/company/finances/billing/bill.entity.js +35 -1
- package/lib/profile/company/finances/billing/bill.entity.js.map +1 -1
- package/lib/profile/company/finances/billing/item.entity.d.ts +6 -1
- package/lib/profile/company/finances/billing/item.entity.js +5 -1
- package/lib/profile/company/finances/billing/item.entity.js.map +1 -1
- package/lib/profile/company/finances/billing/transaction.entity.d.ts +5 -3
- package/lib/profile/company/finances/billing/transaction.entity.js +2 -2
- package/lib/profile/company/finances/billing/transaction.entity.js.map +1 -1
- package/lib/profile/company/finances/invoice/invoice.entity.d.ts +2 -2
- package/lib/profile/company/finances/invoice/invoice.entity.js +6 -6
- package/lib/profile/company/finances/invoice/invoice.entity.js.map +1 -1
- package/lib/profile/company/finances/payment/method.entity.d.ts +16 -2
- package/lib/profile/company/finances/payment/method.entity.js +18 -2
- package/lib/profile/company/finances/payment/method.entity.js.map +1 -1
- package/lib/profile/company/instructor/instructor.entity.d.ts +17 -8
- package/lib/profile/company/instructor/instructor.entity.js +46 -12
- package/lib/profile/company/instructor/instructor.entity.js.map +1 -1
- package/lib/profile/company/medical/examination.entity.d.ts +2 -2
- package/lib/profile/company/medical/examination.entity.js +1 -1
- package/lib/profile/company/medical/examination.entity.js.map +1 -1
- package/lib/profile/company/medical/product.entity.d.ts +2 -3
- package/lib/profile/company/medical/product.entity.js +8 -9
- package/lib/profile/company/medical/product.entity.js.map +1 -1
- package/lib/profile/company/product/addon.entity.d.ts +2 -2
- package/lib/profile/company/product/addon.entity.js +2 -3
- package/lib/profile/company/product/addon.entity.js.map +1 -1
- package/lib/profile/company/product/priceplan.entity.d.ts +14 -13
- package/lib/profile/company/product/priceplan.entity.js +14 -15
- package/lib/profile/company/product/priceplan.entity.js.map +1 -1
- package/lib/profile/company/product/product.entity.d.ts +29 -4
- package/lib/profile/company/product/product.entity.js +54 -6
- package/lib/profile/company/product/product.entity.js.map +1 -1
- package/lib/profile/instructor/instructor.entity.d.ts +2 -2
- package/lib/profile/instructor/instructor.entity.js +4 -3
- package/lib/profile/instructor/instructor.entity.js.map +1 -1
- package/lib/profile/student/program/licence/licence.entity.d.ts +10 -2
- package/lib/profile/student/program/licence/licence.entity.js +14 -3
- package/lib/profile/student/program/licence/licence.entity.js.map +1 -1
- package/lib/profile/student/program/medical/certificate.entity.d.ts +2 -2
- package/lib/profile/student/program/medical/certificate.entity.js +2 -2
- package/lib/profile/student/program/medical/certificate.entity.js.map +1 -1
- package/lib/profile/student/program/medical/examination.entity.d.ts +2 -2
- package/lib/profile/student/program/medical/examination.entity.js +4 -4
- package/lib/profile/student/program/medical/examination.entity.js.map +1 -1
- package/lib/profile/student/program/program.entity.d.ts +4 -4
- package/lib/profile/student/program/program.entity.js +5 -10
- package/lib/profile/student/program/program.entity.js.map +1 -1
- package/lib/profile/student/program/training/appointment.entity.d.ts +14 -3
- package/lib/profile/student/program/training/appointment.entity.js +35 -9
- package/lib/profile/student/program/training/appointment.entity.js.map +1 -1
- package/lib/profile/student/program/training/exam.entity.d.ts +6 -1
- package/lib/profile/student/program/training/exam.entity.js +16 -8
- package/lib/profile/student/program/training/exam.entity.js.map +1 -1
- package/lib/profile/student/program/training/lesson.entity.d.ts +3 -3
- package/lib/profile/student/program/training/lesson.entity.js +4 -4
- package/lib/profile/student/program/training/lesson.entity.js.map +1 -1
- package/lib/profile/student/program/training/topic.entity.d.ts +6 -5
- package/lib/profile/student/program/training/topic.entity.js +9 -6
- package/lib/profile/student/program/training/topic.entity.js.map +1 -1
- package/lib/profile/student/program/training/training.entity.d.ts +2 -1
- package/lib/profile/student/program/training/training.entity.js +37 -36
- package/lib/profile/student/program/training/training.entity.js.map +1 -1
- package/lib/profile/student/program/training/transaction.entity.d.ts +2 -2
- package/lib/profile/student/program/training/transaction.entity.js +2 -2
- package/lib/profile/student/program/training/transaction.entity.js.map +1 -1
- package/lib/profile/student/student.entity.d.ts +2 -2
- package/lib/profile/student/student.entity.js +5 -4
- package/lib/profile/student/student.entity.js.map +1 -1
- package/lib/system/campaign/campaign.entity.d.ts +3 -3
- package/lib/system/campaign/campaign.entity.js +4 -4
- package/lib/system/campaign/campaign.entity.js.map +1 -1
- package/lib/system/campaign/gifcode.entity.d.ts +2 -2
- package/lib/system/campaign/gifcode.entity.js +3 -3
- package/lib/system/campaign/gifcode.entity.js.map +1 -1
- package/lib/system/country/country.entity.d.ts +2 -2
- package/lib/system/country/country.entity.js.map +1 -1
- package/lib/system/driving/category.entity.d.ts +2 -2
- package/lib/system/driving/category.entity.js +2 -2
- package/lib/system/driving/category.entity.js.map +1 -1
- package/lib/system/ical/ical.entity.d.ts +63 -0
- package/lib/system/ical/ical.entity.js +70 -0
- package/lib/system/ical/ical.entity.js.map +1 -0
- package/lib/system/policy/policy.entity.d.ts +2 -2
- package/lib/system/policy/policy.entity.js +3 -3
- package/lib/system/policy/policy.entity.js.map +1 -1
- package/lib/system/staff/staff.entity.js +2 -1
- package/lib/system/staff/staff.entity.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/user/alert.entity.d.ts +2 -2
- package/lib/user/alert.entity.js.map +1 -1
- package/lib/user/device.entity.d.ts +2 -2
- package/lib/user/device.entity.js +3 -3
- package/lib/user/device.entity.js.map +1 -1
- package/lib/user/notification.entity.d.ts +2 -2
- package/lib/user/notification.entity.js +4 -4
- package/lib/user/notification.entity.js.map +1 -1
- package/lib/user/ticket.entity.d.ts +2 -2
- package/lib/user/ticket.entity.js +5 -3
- package/lib/user/ticket.entity.js.map +1 -1
- package/lib/user/user.entity.d.ts +14 -11
- package/lib/user/user.entity.js +20 -16
- package/lib/user/user.entity.js.map +1 -1
- package/lib/utils/trackable.d.ts +12 -1
- package/lib/utils/trackable.js +55 -0
- package/lib/utils/trackable.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topic.entity.js","sourceRoot":"","sources":["../../../../src/catalog/seed/courses/topic.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"topic.entity.js","sourceRoot":"","sources":["../../../../src/catalog/seed/courses/topic.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAkD;AAClD,4CAAyE;AACzE,6CAA0C;AAC1C,qCAAyC;AACzC,qCAAoC;AAEpC,qEAAiE;AACjE,oEAA4D;AAC5D,wDAA2D;AAC3D,mDAAyD;AAEzD;;;;;;GAMG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,IAAA,gBAAM,GAAE;;uDACQ;AAUjB;IALC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;2DACsB;AASxB;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;uDACe;AAWjB;IALC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;qDACc;AAUhB;IALC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;mDACW;AAMb;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,sCAAsB,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;;qDACzB;gCApD5B,qBAAqB;IADjC,IAAA,gBAAM,EAAC,kBAAkB,CAAC;;GACd,qBAAqB,CAkJjC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Activity, Category
|
|
2
|
-
import { Language } from '@driveup/shared';
|
|
1
|
+
import { Activity, Category } from '@driveup/common';
|
|
2
|
+
import { Content, Language } from '@driveup/shared';
|
|
3
3
|
import { TrackableEntity } from '../../../utils/trackable';
|
|
4
4
|
/**
|
|
5
5
|
* Represents a seed expense category template in the system.
|
|
@@ -66,7 +66,7 @@ let SeedExpenseCategoryEntity = class SeedExpenseCategoryEntity extends trackabl
|
|
|
66
66
|
getTranslation(lang) {
|
|
67
67
|
const language = lang || nestjs_i18n_1.I18nContext.current()?.lang;
|
|
68
68
|
const translation = this.translations?.find(t => t.language === language);
|
|
69
|
-
return new
|
|
69
|
+
return new shared_1.Content({
|
|
70
70
|
title: translation?.title,
|
|
71
71
|
description: translation?.description,
|
|
72
72
|
content: translation?.content,
|
|
@@ -79,7 +79,7 @@ let SeedExpenseCategoryEntity = class SeedExpenseCategoryEntity extends trackabl
|
|
|
79
79
|
* @returns Array of Content instances for all languages
|
|
80
80
|
*/
|
|
81
81
|
getTranslations() {
|
|
82
|
-
return this.translations?.map(t => new
|
|
82
|
+
return this.translations?.map(t => new shared_1.Content({
|
|
83
83
|
title: t.title,
|
|
84
84
|
description: t.description,
|
|
85
85
|
content: t.content,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category.entity.js","sourceRoot":"","sources":["../../../../src/catalog/seed/expense/category.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"category.entity.js","sourceRoot":"","sources":["../../../../src/catalog/seed/expense/category.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAqD;AACrD,4CAAkE;AAClE,6CAA0C;AAC1C,qCAAyC;AAEzC,qEAAiE;AACjE,oEAA4D;AAC5D,wDAA2D;AAE3D;;;;;;;GAOG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,2BAAyB;IAwCvE;;;OAGG;IACH,YAAY,KAA0C;QACrD,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,IAAc;QACrB,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,IAAI,iBAAQ,CAAC;YACnB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,WAAW,EAAE,KAAK;YACzB,WAAW,EAAE,WAAW,EAAE,WAAW;YACrC,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI,IAAI,CAAC,QAAQ;YAC3C,IAAI,EAAE,IAAI,CAAC,IAAI;SACf,CAAC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,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AI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,qBAAY,CAAC,OAAO,EAAE,0BAAW,CAAC,CAAC,CAAC;QACrG,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;CACD,CAAA;AArHY,8DAAyB;AAUrC;IALC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;+DACsB;AASxB;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;uDACW;AASb;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;2DACe;AAUjB;IALC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;uDACW;oCAtCD,yBAAyB;IADrC,IAAA,gBAAM,EAAC,uBAAuB,CAAC;;GACnB,yBAAyB,CAqHrC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -28,7 +28,6 @@ export * from './profile/company/finances/invoice/invoice.entity';
|
|
|
28
28
|
export * from './profile/company/finances/invoice/item.entity';
|
|
29
29
|
export * from './profile/company/finances/payment/method.entity';
|
|
30
30
|
export * from './profile/company/instructor/activity.entity';
|
|
31
|
-
export * from './profile/company/instructor/calendar-state.entity';
|
|
32
31
|
export * from './profile/company/instructor/instructor.entity';
|
|
33
32
|
export * from './profile/company/instructor/task.entity';
|
|
34
33
|
export * from './profile/company/medical/examination.entity';
|
|
@@ -59,6 +58,7 @@ export * from './system/driving/category.entity';
|
|
|
59
58
|
export * from './system/driving/vehicle.entity';
|
|
60
59
|
export * from './system/event/event.entity';
|
|
61
60
|
export * from './system/event/log.entity';
|
|
61
|
+
export * from './system/ical/ical.entity';
|
|
62
62
|
export * from './system/policy/policy.entity';
|
|
63
63
|
export * from './system/staff/staff.entity';
|
|
64
64
|
export * from './user/alert.entity';
|
package/lib/index.js
CHANGED
|
@@ -47,7 +47,6 @@ __exportStar(require("./profile/company/finances/invoice/invoice.entity"), expor
|
|
|
47
47
|
__exportStar(require("./profile/company/finances/invoice/item.entity"), exports);
|
|
48
48
|
__exportStar(require("./profile/company/finances/payment/method.entity"), exports);
|
|
49
49
|
__exportStar(require("./profile/company/instructor/activity.entity"), exports);
|
|
50
|
-
__exportStar(require("./profile/company/instructor/calendar-state.entity"), exports);
|
|
51
50
|
__exportStar(require("./profile/company/instructor/instructor.entity"), exports);
|
|
52
51
|
__exportStar(require("./profile/company/instructor/task.entity"), exports);
|
|
53
52
|
__exportStar(require("./profile/company/medical/examination.entity"), exports);
|
|
@@ -81,6 +80,7 @@ __exportStar(require("./system/driving/category.entity"), exports);
|
|
|
81
80
|
__exportStar(require("./system/driving/vehicle.entity"), exports);
|
|
82
81
|
__exportStar(require("./system/event/event.entity"), exports);
|
|
83
82
|
__exportStar(require("./system/event/log.entity"), exports);
|
|
83
|
+
__exportStar(require("./system/ical/ical.entity"), exports);
|
|
84
84
|
__exportStar(require("./system/policy/policy.entity"), exports);
|
|
85
85
|
__exportStar(require("./system/staff/staff.entity"), exports);
|
|
86
86
|
__exportStar(require("./user/alert.entity"), exports);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,+DAA6C;AAC7C,iEAA+C;AAC/C,uEAAqD;AACrD,mEAAiD;AACjD,qEAAmD;AACnD,mEAAiD;AACjD,mEAAiD;AACjD,qEAAmD;AACnD,uEAAqD;AACrD,uEAAqD;AACrD,sEAAoD;AACpD,yEAAuD;AACvD,iBAAiB;AACjB,+DAA6C;AAC7C,+DAA6C;AAC7C,gEAA8C;AAC9C,mEAAiD;AACjD,mBAAmB;AACnB,2EAAyD;AACzD,yEAAuD;AACvD,yEAAuD;AACvD,wEAAsD;AACtD,iFAA+D;AAC/D,iFAA+D;AAC/D,wFAAsE;AACtE,qFAAmE;AACnE,oFAAkE;AAClE,sFAAoE;AACpE,oFAAkE;AAClE,iFAA+D;AAC/D,mFAAiE;AACjE,+EAA6D;AAC7D,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,+DAA6C;AAC7C,iEAA+C;AAC/C,uEAAqD;AACrD,mEAAiD;AACjD,qEAAmD;AACnD,mEAAiD;AACjD,mEAAiD;AACjD,qEAAmD;AACnD,uEAAqD;AACrD,uEAAqD;AACrD,sEAAoD;AACpD,yEAAuD;AACvD,iBAAiB;AACjB,+DAA6C;AAC7C,+DAA6C;AAC7C,gEAA8C;AAC9C,mEAAiD;AACjD,mBAAmB;AACnB,2EAAyD;AACzD,yEAAuD;AACvD,yEAAuD;AACvD,wEAAsD;AACtD,iFAA+D;AAC/D,iFAA+D;AAC/D,wFAAsE;AACtE,qFAAmE;AACnE,oFAAkE;AAClE,sFAAoE;AACpE,oFAAkE;AAClE,iFAA+D;AAC/D,mFAAiE;AACjE,+EAA6D;AAC7D,iFAA+D;AAC/D,2EAAyD;AACzD,+EAA6D;AAC7D,2EAAyD;AACzD,yEAAuD;AACvD,6EAA2D;AAC3D,2EAAyD;AACzD,2EAAyD;AACzD,mEAAiD;AACjD,sBAAsB;AACtB,yEAAuD;AACvD,oBAAoB;AACpB,mFAAiE;AACjE,uFAAqE;AACrE,uFAAqE;AACrE,wFAAsE;AACtE,iFAA+D;AAC/D,mFAAiE;AACjE,oFAAkE;AAClE,kFAAgE;AAChE,qFAAmE;AACnE,wFAAsE;AACtE,2EAAyD;AACzD,mEAAiD;AACjD,SAAS;AACT,oEAAkD;AAClD,mEAAiD;AACjD,kEAAgD;AAChD,oEAAkD;AAClD,mEAAiD;AACjD,kEAAgD;AAChD,8DAA4C;AAC5C,4DAA0C;AAC1C,4DAA0C;AAC1C,gEAA8C;AAC9C,8DAA4C;AAC5C,sDAAoC;AACpC,wDAAsC;AACtC,uDAAqC;AACrC,6DAA2C;AAC3C,uDAAqC;AACrC,qDAAmC;AACnC,6DAA2C;AAC3C,QAAQ;AACR,0DAAwC;AACxC,4DAA0C;AAC1C,4DAA0C;AAC1C,oDAAkC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Activity, Agent
|
|
1
|
+
import { Activity, Agent } from '@driveup/common';
|
|
2
|
+
import { BankAccount, Person, Preference } from '@driveup/shared';
|
|
2
3
|
import { AccountStatus, Language, PreferenceScope } from '@driveup/shared';
|
|
3
4
|
import { UserEntity } from '../../user/user.entity';
|
|
4
5
|
import { TrackableEntity } from '../../utils/trackable';
|
|
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.AgentEntity = void 0;
|
|
14
14
|
const common_1 = require("@driveup/common");
|
|
15
15
|
const shared_1 = require("@driveup/shared");
|
|
16
|
+
const shared_2 = require("@driveup/shared");
|
|
16
17
|
const typeorm_1 = require("typeorm");
|
|
17
18
|
const log_entity_1 = require("../../system/event/log.entity");
|
|
18
19
|
const user_entity_1 = require("../../user/user.entity");
|
|
@@ -60,7 +61,7 @@ let AgentEntity = AgentEntity_1 = class AgentEntity extends trackable_1.Trackabl
|
|
|
60
61
|
code: this.code,
|
|
61
62
|
percentage: this.percentage,
|
|
62
63
|
status: this.status,
|
|
63
|
-
bankAccount:
|
|
64
|
+
bankAccount: shared_1.BankAccount.toInstance(this.bankAccount)
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
@@ -83,10 +84,11 @@ let AgentEntity = AgentEntity_1 = class AgentEntity extends trackable_1.Trackabl
|
|
|
83
84
|
*/
|
|
84
85
|
async toPerson() {
|
|
85
86
|
const user = await this.user;
|
|
86
|
-
return new
|
|
87
|
+
return new shared_1.Person({
|
|
87
88
|
id: this.id,
|
|
88
89
|
name: this.name,
|
|
89
90
|
imageUrl: user.imageUrl,
|
|
91
|
+
image: user.imageUrl, // mvp only
|
|
90
92
|
phone: user.phone,
|
|
91
93
|
email: user.email
|
|
92
94
|
});
|
|
@@ -98,12 +100,12 @@ let AgentEntity = AgentEntity_1 = class AgentEntity extends trackable_1.Trackabl
|
|
|
98
100
|
getPreferences() {
|
|
99
101
|
if (!this.preferences)
|
|
100
102
|
return;
|
|
101
|
-
return this.preferences.map(
|
|
103
|
+
return this.preferences.map(shared_1.Preference.toInstance);
|
|
102
104
|
}
|
|
103
105
|
async setPreference(name, value, scope) {
|
|
104
106
|
this.preferences = this.preferences || [];
|
|
105
107
|
this.preferences = this.preferences.filter(p => p.name !== name);
|
|
106
|
-
this.preferences.push(new
|
|
108
|
+
this.preferences.push(new shared_1.Preference({
|
|
107
109
|
scope: scope,
|
|
108
110
|
name: name,
|
|
109
111
|
value: value
|
|
@@ -123,8 +125,8 @@ let AgentEntity = AgentEntity_1 = class AgentEntity extends trackable_1.Trackabl
|
|
|
123
125
|
*/
|
|
124
126
|
async getActivities() {
|
|
125
127
|
const activities = [];
|
|
126
|
-
activities.push(await (0, activity_helper_1.toActivity)(this.createdBy, this.createdOn,
|
|
127
|
-
activities.push(await (0, activity_helper_1.toActivity)(this.updatedBy, this.updatedOn,
|
|
128
|
+
activities.push(await (0, activity_helper_1.toActivity)(this.createdBy, this.createdOn, shared_2.ActivityType.created));
|
|
129
|
+
activities.push(await (0, activity_helper_1.toActivity)(this.updatedBy, this.updatedOn, shared_2.ActivityType.updated));
|
|
128
130
|
return activities.filter(a => a);
|
|
129
131
|
}
|
|
130
132
|
/**
|
|
@@ -136,8 +138,8 @@ let AgentEntity = AgentEntity_1 = class AgentEntity extends trackable_1.Trackabl
|
|
|
136
138
|
if (!this.id)
|
|
137
139
|
return;
|
|
138
140
|
await log_entity_1.LogEntity.from({
|
|
139
|
-
type:
|
|
140
|
-
profile:
|
|
141
|
+
type: shared_2.LogType.Agent,
|
|
142
|
+
profile: shared_2.ProfileType.Agent,
|
|
141
143
|
event: event,
|
|
142
144
|
entityId: this.id,
|
|
143
145
|
content: log_entity_1.LogEntity.toAgentContent(event, this.language, metadata)
|
|
@@ -153,8 +155,8 @@ let AgentEntity = AgentEntity_1 = class AgentEntity extends trackable_1.Trackabl
|
|
|
153
155
|
if (!this.id)
|
|
154
156
|
return;
|
|
155
157
|
await log_entity_1.LogEntity.from({
|
|
156
|
-
type:
|
|
157
|
-
profile:
|
|
158
|
+
type: shared_2.LogType.Agent,
|
|
159
|
+
profile: shared_2.ProfileType.Agent,
|
|
158
160
|
event: event,
|
|
159
161
|
entityId: this.id,
|
|
160
162
|
content: log_entity_1.LogEntity.toAuthorContent(event, this.language, metadata)
|
|
@@ -169,8 +171,8 @@ __decorate([
|
|
|
169
171
|
__decorate([
|
|
170
172
|
(0, typeorm_1.Column)({
|
|
171
173
|
type: 'enum',
|
|
172
|
-
enum:
|
|
173
|
-
default:
|
|
174
|
+
enum: shared_2.AccountStatus,
|
|
175
|
+
default: shared_2.AccountStatus.Pending,
|
|
174
176
|
nullable: false
|
|
175
177
|
}),
|
|
176
178
|
__metadata("design:type", String)
|
|
@@ -185,8 +187,8 @@ __decorate([
|
|
|
185
187
|
__decorate([
|
|
186
188
|
(0, typeorm_1.Column)({
|
|
187
189
|
type: 'enum',
|
|
188
|
-
enum:
|
|
189
|
-
default:
|
|
190
|
+
enum: shared_2.Language,
|
|
191
|
+
default: shared_2.Language.En,
|
|
190
192
|
nullable: true
|
|
191
193
|
}),
|
|
192
194
|
__metadata("design:type", String)
|
|
@@ -212,7 +214,7 @@ __decorate([
|
|
|
212
214
|
nullable: true,
|
|
213
215
|
default: null
|
|
214
216
|
}),
|
|
215
|
-
__metadata("design:type",
|
|
217
|
+
__metadata("design:type", shared_1.BankAccount)
|
|
216
218
|
], AgentEntity.prototype, "bankAccount", void 0);
|
|
217
219
|
__decorate([
|
|
218
220
|
(0, typeorm_1.Column)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.entity.js","sourceRoot":"","sources":["../../../src/profile/agent/agent.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"agent.entity.js","sourceRoot":"","sources":["../../../src/profile/agent/agent.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,4CAAkD;AAClD,4CAAkE;AAClE,4CAA+G;AAC/G,qCAA+D;AAE/D,8DAA0D;AAC1D,wDAAoD;AACpD,iEAAyD;AACzD,qDAAwD;AACxD,iDAAkD;AAClD,mDAAoD;AACpD,yDAA0D;AAE1D;;;;;;;GAOG;AAEI,IAAM,WAAW,mBAAjB,MAAM,WAAY,SAAQ,2BAAsB;IA4GtD;;;OAGG;IACH,YAAY,KAA4B;QACvC,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,IAAY;QAClC,OAAO,aAAW,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACxC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO;QACZ,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;QAC7B,OAAO,IAAI,cAAK,CAAC;YAChB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI;YAC5B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ;YACxC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,WAAW,EAAE,oBAAW,CAAC,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BAAM,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;+CACL;AAWnB;IAJC,IAAA,gBAAM,EAAC;QACP,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,EAAE;KACX,CAAC;;gDACkB;AAUpB;IALC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;8BACW,oBAAW;gDAAC;AAUzB;IALC,IAAA,gBAAM,EAAC;QACP,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;KACb,CAAC;;gDACwB;AAO1B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,wBAAU,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC;;yCAC/B;AAMzB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uCAAoB,EAAE,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;;+CACxB;AAM5C;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,iCAAiB,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;;4CACrB;AAGtC;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,+BAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;;2CACpB;sBA1GxB,WAAW;IADvB,IAAA,gBAAM,EAAC,QAAQ,CAAC;;GACJ,WAAW,CAyPvB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Activity,
|
|
2
|
-
import { StatusType } from '@driveup/shared';
|
|
1
|
+
import { Activity, Payout } from '@driveup/common';
|
|
2
|
+
import { BankAccount, StatusType } from '@driveup/shared';
|
|
3
3
|
import { TrackableEntity } from '../../utils/trackable';
|
|
4
4
|
import { AgentEntity } from './agent.entity';
|
|
5
5
|
import { AgentPromotionEntity } from './promotion.entity';
|
|
@@ -43,7 +43,7 @@ let AgentPayoutEntity = class AgentPayoutEntity extends trackable_1.TrackableEnt
|
|
|
43
43
|
id: this.id,
|
|
44
44
|
status: this.status,
|
|
45
45
|
amount: this.amount,
|
|
46
|
-
bankAccount:
|
|
46
|
+
bankAccount: shared_1.BankAccount.toInstance(this.bankAccount)
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
@@ -99,7 +99,7 @@ __decorate([
|
|
|
99
99
|
nullable: true,
|
|
100
100
|
default: null
|
|
101
101
|
}),
|
|
102
|
-
__metadata("design:type",
|
|
102
|
+
__metadata("design:type", shared_1.BankAccount)
|
|
103
103
|
], AgentPayoutEntity.prototype, "bankAccount", void 0);
|
|
104
104
|
__decorate([
|
|
105
105
|
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payout.entity.js","sourceRoot":"","sources":["../../../src/profile/agent/payout.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"payout.entity.js","sourceRoot":"","sources":["../../../src/profile/agent/payout.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAmD;AACnD,4CAAwE;AACxE,qCAA+D;AAE/D,kEAA8D;AAC9D,iEAAyD;AACzD,qDAAwD;AACxD,iDAA6C;AAC7C,yDAA0D;AAE1D;;;;;;GAMG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,2BAAuB;IAwE7D;;;OAGG;IACH,YAAY,KAAkC;QAC7C,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO;QACZ,OAAO,IAAI,eAAM,CAAC;YACjB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IA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OAAO,EAAE,IAAI;KACb,CAAC;8BACW,oBAAW;sDAAC;AAMzB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BAClC,IAAI;iDAAC;AAMb;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;iDAC3B;AAMf;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,0BAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;;gDACzB;AAM5B;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,uCAAoB,EAAE,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC;;qDACzB;4BAtEhC,iBAAiB;IAD7B,IAAA,gBAAM,EAAC,cAAc,CAAC;;GACV,iBAAiB,CAiH7B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Activity,
|
|
2
|
-
import { BankAccount,
|
|
1
|
+
import { Activity, Company } from '@driveup/common';
|
|
2
|
+
import { Address, BankAccount, Holiday, Link, Period, Person, Preference, Tax, WorkingHours } from '@driveup/shared';
|
|
3
3
|
import { AccountStatus, AddonType, Language, PreferenceScope } from '@driveup/shared';
|
|
4
|
+
import { EntityManager } from 'typeorm';
|
|
4
5
|
import { CountryEntity } from '../../system/country/country.entity';
|
|
5
6
|
import { TrackableEntity } from '../../utils/trackable';
|
|
6
7
|
import { AgentPromotionEntity } from '../agent/promotion.entity';
|
|
@@ -106,6 +107,16 @@ export declare class CompanyEntity extends TrackableEntity<Company> {
|
|
|
106
107
|
* Can be used by payments if company product credit is not enough
|
|
107
108
|
*/
|
|
108
109
|
credit: number;
|
|
110
|
+
/**
|
|
111
|
+
* Temprary field
|
|
112
|
+
* Company balance
|
|
113
|
+
*/
|
|
114
|
+
balance: number;
|
|
115
|
+
/**
|
|
116
|
+
* Temprary field
|
|
117
|
+
* Number of free benefits (free trainings) the company has
|
|
118
|
+
*/
|
|
119
|
+
freeBenefits: number;
|
|
109
120
|
/**
|
|
110
121
|
* Tax configuration for invoicing
|
|
111
122
|
*/
|
|
@@ -201,7 +212,7 @@ export declare class CompanyEntity extends TrackableEntity<Company> {
|
|
|
201
212
|
* Converts the entity to a Customer model for invoicing purposes
|
|
202
213
|
* @returns Customer model with company information
|
|
203
214
|
*/
|
|
204
|
-
toCustomer():
|
|
215
|
+
toCustomer(): Person;
|
|
205
216
|
/**
|
|
206
217
|
* Retrieves the owner of this company
|
|
207
218
|
* @returns Promise resolving to the CompanyInstructorEntity with Owner role
|
|
@@ -271,4 +282,33 @@ export declare class CompanyEntity extends TrackableEntity<Company> {
|
|
|
271
282
|
getPreferences(): Preference<boolean>[];
|
|
272
283
|
setPreference(name: string, value: any, scope: PreferenceScope): Promise<Preference<boolean>[]>;
|
|
273
284
|
removePreference(name: string): Promise<Preference<boolean>[]>;
|
|
285
|
+
/**
|
|
286
|
+
* Get the one company bill with the status "open"
|
|
287
|
+
*/
|
|
288
|
+
getCurrentBill(manager?: EntityManager): Promise<CompanyBillEntity>;
|
|
289
|
+
/**
|
|
290
|
+
* Checks if there are any company bills with the status "unpaid"
|
|
291
|
+
*/
|
|
292
|
+
hasUnpaidBills(): Promise<boolean>;
|
|
293
|
+
/**
|
|
294
|
+
* Gets all unpaid bills of the company, INCLUDING current month's bill
|
|
295
|
+
* @returns CompanyBillEntity[] - All bills that are active, or have not been paid yet (both current month's bill and bill for which the payment has failed)
|
|
296
|
+
*/
|
|
297
|
+
getUnpaidBills(): Promise<CompanyBillEntity[]>;
|
|
298
|
+
/**
|
|
299
|
+
* Gets the total amount of unpaid bills subTotalPrice (sum of all unpaid bills' subTotalPrice)
|
|
300
|
+
* @param manager EntityManager - Used with transactions to ensure data integrity
|
|
301
|
+
* @returns number - Total amount of unpaid bills
|
|
302
|
+
*/
|
|
303
|
+
getTotalUnpaidAmount(manager?: EntityManager): Promise<number>;
|
|
304
|
+
/**
|
|
305
|
+
* * Remaining company credit calculation steps
|
|
306
|
+
* 1. Get all unpaid bills (bills which are active or unpaid)
|
|
307
|
+
* 2. If there are no unpaid bills (which is frankly impossible), remainingCredit = company.credit
|
|
308
|
+
* 3. Sum the subtotal prices of all unpaid bills to get totalUnpaidAmount
|
|
309
|
+
* 4. If company credit is less than totalUnpaidAmount, remainingCredit is 0
|
|
310
|
+
* 5. Otherwise, remainingCredit = company.credit - totalUnpaidAmount
|
|
311
|
+
* @returns number - Remaining company credit
|
|
312
|
+
*/
|
|
313
|
+
getRemainingCredit(manager?: EntityManager): Promise<number>;
|
|
274
314
|
}
|
|
@@ -12,8 +12,8 @@ var CompanyEntity_1;
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.CompanyEntity = void 0;
|
|
14
14
|
const common_1 = require("@driveup/common");
|
|
15
|
-
const common_2 = require("@driveup/common");
|
|
16
15
|
const shared_1 = require("@driveup/shared");
|
|
16
|
+
const shared_2 = require("@driveup/shared");
|
|
17
17
|
const luxon_1 = require("luxon");
|
|
18
18
|
const typeorm_1 = require("typeorm");
|
|
19
19
|
const country_entity_1 = require("../../system/country/country.entity");
|
|
@@ -86,17 +86,17 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
86
86
|
*/
|
|
87
87
|
toModelWithDetails() {
|
|
88
88
|
const company = this.toModel();
|
|
89
|
-
company.address =
|
|
90
|
-
company.bankAccount =
|
|
91
|
-
company.tax =
|
|
89
|
+
company.address = shared_1.Address.toInstance(this.address);
|
|
90
|
+
company.bankAccount = shared_1.BankAccount.toInstance(this.bankAccount);
|
|
91
|
+
company.tax = shared_1.Tax.toInstance(this.tax);
|
|
92
92
|
company.email = this.email;
|
|
93
93
|
company.homepage = this.homepage;
|
|
94
94
|
company.rating = this.rating;
|
|
95
95
|
company.links = this.links;
|
|
96
|
-
company.workingHours = this.workingHours?.map(
|
|
97
|
-
company.holidays = this.holidays?.map(
|
|
98
|
-
company.locations = this.locations?.map(
|
|
99
|
-
company.preferences = this.preferences?.map(
|
|
96
|
+
company.workingHours = this.workingHours?.map(shared_1.WorkingHours.toInstance);
|
|
97
|
+
company.holidays = this.holidays?.map(shared_1.Holiday.toInstance);
|
|
98
|
+
company.locations = this.locations?.map(shared_1.Address.toInstance);
|
|
99
|
+
company.preferences = this.preferences?.map(shared_1.Preference.toInstance);
|
|
100
100
|
return company;
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
@@ -104,11 +104,11 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
104
104
|
* @returns Customer model with company information
|
|
105
105
|
*/
|
|
106
106
|
toCustomer() {
|
|
107
|
-
return new
|
|
107
|
+
return new shared_1.Person({
|
|
108
108
|
id: this.id,
|
|
109
109
|
name: this.name,
|
|
110
110
|
imageUrl: this.logoUrl,
|
|
111
|
-
address:
|
|
111
|
+
address: shared_1.Address.toInstance(this.address),
|
|
112
112
|
phone: this.phone,
|
|
113
113
|
email: this.email,
|
|
114
114
|
});
|
|
@@ -120,7 +120,7 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
120
120
|
async getOwner() {
|
|
121
121
|
return await instructor_entity_1.CompanyInstructorEntity.findOneBy({
|
|
122
122
|
companyId: this.id,
|
|
123
|
-
role:
|
|
123
|
+
role: shared_2.Role.Owner
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
@@ -130,7 +130,7 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
130
130
|
*/
|
|
131
131
|
async getInstructors(active = true) {
|
|
132
132
|
const instructors = (await this.instructors) || [];
|
|
133
|
-
return active ? instructors.filter(i => i.status ===
|
|
133
|
+
return active ? instructors.filter(i => i.status === shared_2.AccountStatus.Active) : instructors;
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
136
|
* Retrieves all managers (owners and managers) associated with this company
|
|
@@ -139,7 +139,7 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
139
139
|
*/
|
|
140
140
|
async getManagers(active = true) {
|
|
141
141
|
const instructors = await this.getInstructors(active);
|
|
142
|
-
const managerRoles = [
|
|
142
|
+
const managerRoles = [shared_2.Role.Owner, shared_2.Role.Manager];
|
|
143
143
|
return instructors?.filter(i => managerRoles.includes(i.role));
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
@@ -159,7 +159,7 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
159
159
|
async getAgentEarning() {
|
|
160
160
|
return await bill_entity_1.CompanyBillEntity.sum('agentProfit', {
|
|
161
161
|
companyId: this.id,
|
|
162
|
-
status:
|
|
162
|
+
status: shared_2.BillStatus.Paid
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
/**
|
|
@@ -204,8 +204,8 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
204
204
|
return await transaction_entity_1.CompanyBillTransactionEntity.createQueryBuilder('ct') // company transaction
|
|
205
205
|
.innerJoin('ct.bill', 'cb') // company bill
|
|
206
206
|
.where('cb.companyId = :companyId', { companyId: this.id })
|
|
207
|
-
.andWhere('cb.status = :unpaidStatus', { unpaidStatus:
|
|
208
|
-
.andWhere('ct.status = :failedStatus', { failedStatus:
|
|
207
|
+
.andWhere('cb.status = :unpaidStatus', { unpaidStatus: shared_2.BillStatus.Unpaid })
|
|
208
|
+
.andWhere('ct.status = :failedStatus', { failedStatus: shared_2.StatusType.Failed })
|
|
209
209
|
.getExists();
|
|
210
210
|
}
|
|
211
211
|
getHolidays(period) {
|
|
@@ -228,7 +228,7 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
228
228
|
collidesWithHolidays(period) {
|
|
229
229
|
if (!this.holidays?.length)
|
|
230
230
|
return false;
|
|
231
|
-
return this.holidays.some(i => period.collidesWith(new
|
|
231
|
+
return this.holidays.some(i => period.collidesWith(new shared_1.Period({
|
|
232
232
|
startDate: new Date(i.period.startDate),
|
|
233
233
|
endDate: new Date(i.period.endDate)
|
|
234
234
|
})));
|
|
@@ -258,7 +258,7 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
258
258
|
day: currentDay.day
|
|
259
259
|
});
|
|
260
260
|
if (lastEnd < workingStart) {
|
|
261
|
-
const nonWorking = new
|
|
261
|
+
const nonWorking = new shared_1.Period({
|
|
262
262
|
startDate: lastEnd.toJSDate(),
|
|
263
263
|
endDate: workingStart.toJSDate()
|
|
264
264
|
});
|
|
@@ -269,7 +269,7 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
269
269
|
currentDay = currentDay.plus({ days: 1 }).startOf('day');
|
|
270
270
|
}
|
|
271
271
|
if (lastEnd < periodEnd) {
|
|
272
|
-
const nonWorking = new
|
|
272
|
+
const nonWorking = new shared_1.Period({
|
|
273
273
|
startDate: lastEnd.toJSDate(),
|
|
274
274
|
endDate: periodEnd.toJSDate()
|
|
275
275
|
});
|
|
@@ -283,9 +283,9 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
283
283
|
*/
|
|
284
284
|
async getActivities() {
|
|
285
285
|
const activities = [];
|
|
286
|
-
activities.push(await (0, activity_helper_1.toActivity)(this.createdBy, this.createdOn,
|
|
287
|
-
activities.push(await (0, activity_helper_1.toActivity)(this.updatedBy, this.updatedOn,
|
|
288
|
-
activities.push(await (0, activity_helper_1.toActivity)(this.closedBy, this.closedOn,
|
|
286
|
+
activities.push(await (0, activity_helper_1.toActivity)(this.createdBy, this.createdOn, shared_2.ActivityType.created));
|
|
287
|
+
activities.push(await (0, activity_helper_1.toActivity)(this.updatedBy, this.updatedOn, shared_2.ActivityType.updated));
|
|
288
|
+
activities.push(await (0, activity_helper_1.toActivity)(this.closedBy, this.closedOn, shared_2.ActivityType.updated));
|
|
289
289
|
return activities.filter(a => a);
|
|
290
290
|
}
|
|
291
291
|
/**
|
|
@@ -295,8 +295,8 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
295
295
|
*/
|
|
296
296
|
async log(event, metadata) {
|
|
297
297
|
await log_entity_1.LogEntity.from({
|
|
298
|
-
type:
|
|
299
|
-
profile:
|
|
298
|
+
type: shared_2.LogType.Company,
|
|
299
|
+
profile: shared_2.ProfileType.Company,
|
|
300
300
|
event: event,
|
|
301
301
|
entityId: this.id,
|
|
302
302
|
content: log_entity_1.LogEntity.toCompanyContent(event, this.language, metadata)
|
|
@@ -309,12 +309,12 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
309
309
|
getPreferences() {
|
|
310
310
|
if (!this.preferences)
|
|
311
311
|
return;
|
|
312
|
-
return this.preferences.map(
|
|
312
|
+
return this.preferences.map(shared_1.Preference.toInstance);
|
|
313
313
|
}
|
|
314
314
|
async setPreference(name, value, scope) {
|
|
315
315
|
this.preferences = this.preferences || [];
|
|
316
316
|
this.preferences = this.preferences.filter(p => p.name !== name);
|
|
317
|
-
this.preferences.push(new
|
|
317
|
+
this.preferences.push(new shared_1.Preference({
|
|
318
318
|
scope: scope,
|
|
319
319
|
name: name,
|
|
320
320
|
value: value
|
|
@@ -328,6 +328,65 @@ let CompanyEntity = CompanyEntity_1 = class CompanyEntity extends trackable_1.Tr
|
|
|
328
328
|
await CompanyEntity_1.save(this);
|
|
329
329
|
return this.preferences;
|
|
330
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Get the one company bill with the status "open"
|
|
333
|
+
*/
|
|
334
|
+
async getCurrentBill(manager) {
|
|
335
|
+
const repoManager = manager ?? bill_entity_1.CompanyBillEntity.getRepository().manager;
|
|
336
|
+
return repoManager.findOne(bill_entity_1.CompanyBillEntity, {
|
|
337
|
+
where: {
|
|
338
|
+
status: shared_2.BillStatus.Open,
|
|
339
|
+
companyId: this.id
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Checks if there are any company bills with the status "unpaid"
|
|
345
|
+
*/
|
|
346
|
+
async hasUnpaidBills() {
|
|
347
|
+
return bill_entity_1.CompanyBillEntity.existsBy({
|
|
348
|
+
status: shared_2.BillStatus.Unpaid,
|
|
349
|
+
companyId: this.id
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Gets all unpaid bills of the company, INCLUDING current month's bill
|
|
354
|
+
* @returns CompanyBillEntity[] - All bills that are active, or have not been paid yet (both current month's bill and bill for which the payment has failed)
|
|
355
|
+
*/
|
|
356
|
+
async getUnpaidBills() {
|
|
357
|
+
return await bill_entity_1.CompanyBillEntity.findBy({
|
|
358
|
+
companyId: this.id,
|
|
359
|
+
status: (0, typeorm_1.Not)(shared_2.BillStatus.Paid)
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Gets the total amount of unpaid bills subTotalPrice (sum of all unpaid bills' subTotalPrice)
|
|
364
|
+
* @param manager EntityManager - Used with transactions to ensure data integrity
|
|
365
|
+
* @returns number - Total amount of unpaid bills
|
|
366
|
+
*/
|
|
367
|
+
async getTotalUnpaidAmount(manager) {
|
|
368
|
+
const billManager = manager ?? bill_entity_1.CompanyBillEntity.getRepository().manager;
|
|
369
|
+
return await billManager.sum(bill_entity_1.CompanyBillEntity, 'subtotalPrice', {
|
|
370
|
+
companyId: this.id,
|
|
371
|
+
status: (0, typeorm_1.Not)(shared_2.BillStatus.Paid)
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* * Remaining company credit calculation steps
|
|
376
|
+
* 1. Get all unpaid bills (bills which are active or unpaid)
|
|
377
|
+
* 2. If there are no unpaid bills (which is frankly impossible), remainingCredit = company.credit
|
|
378
|
+
* 3. Sum the subtotal prices of all unpaid bills to get totalUnpaidAmount
|
|
379
|
+
* 4. If company credit is less than totalUnpaidAmount, remainingCredit is 0
|
|
380
|
+
* 5. Otherwise, remainingCredit = company.credit - totalUnpaidAmount
|
|
381
|
+
* @returns number - Remaining company credit
|
|
382
|
+
*/
|
|
383
|
+
async getRemainingCredit(manager) {
|
|
384
|
+
const totalUnpaidAmount = await this.getTotalUnpaidAmount(manager);
|
|
385
|
+
if (this.credit < totalUnpaidAmount) {
|
|
386
|
+
return 0;
|
|
387
|
+
}
|
|
388
|
+
return Number(this.credit) - Number(totalUnpaidAmount);
|
|
389
|
+
}
|
|
331
390
|
};
|
|
332
391
|
exports.CompanyEntity = CompanyEntity;
|
|
333
392
|
__decorate([
|
|
@@ -342,8 +401,8 @@ __decorate([
|
|
|
342
401
|
__decorate([
|
|
343
402
|
(0, typeorm_1.Column)({
|
|
344
403
|
type: 'enum',
|
|
345
|
-
enum:
|
|
346
|
-
default:
|
|
404
|
+
enum: shared_2.AccountStatus,
|
|
405
|
+
default: shared_2.AccountStatus.Pending,
|
|
347
406
|
nullable: false
|
|
348
407
|
}),
|
|
349
408
|
__metadata("design:type", String)
|
|
@@ -365,8 +424,8 @@ __decorate([
|
|
|
365
424
|
__decorate([
|
|
366
425
|
(0, typeorm_1.Column)({
|
|
367
426
|
type: 'enum',
|
|
368
|
-
enum:
|
|
369
|
-
default:
|
|
427
|
+
enum: shared_2.Language,
|
|
428
|
+
default: shared_2.Language.De,
|
|
370
429
|
nullable: true
|
|
371
430
|
}),
|
|
372
431
|
__metadata("design:type", String)
|
|
@@ -398,7 +457,7 @@ __decorate([
|
|
|
398
457
|
nullable: true,
|
|
399
458
|
default: null
|
|
400
459
|
}),
|
|
401
|
-
__metadata("design:type",
|
|
460
|
+
__metadata("design:type", shared_1.Address)
|
|
402
461
|
], CompanyEntity.prototype, "address", void 0);
|
|
403
462
|
__decorate([
|
|
404
463
|
(0, typeorm_1.Column)({
|
|
@@ -406,7 +465,7 @@ __decorate([
|
|
|
406
465
|
nullable: true,
|
|
407
466
|
default: null
|
|
408
467
|
}),
|
|
409
|
-
__metadata("design:type",
|
|
468
|
+
__metadata("design:type", shared_1.BankAccount)
|
|
410
469
|
], CompanyEntity.prototype, "bankAccount", void 0);
|
|
411
470
|
__decorate([
|
|
412
471
|
(0, typeorm_1.Column)({
|
|
@@ -471,13 +530,27 @@ __decorate([
|
|
|
471
530
|
}),
|
|
472
531
|
__metadata("design:type", Number)
|
|
473
532
|
], CompanyEntity.prototype, "credit", void 0);
|
|
533
|
+
__decorate([
|
|
534
|
+
(0, typeorm_1.Column)({
|
|
535
|
+
type: 'decimal',
|
|
536
|
+
precision: 10,
|
|
537
|
+
scale: 2,
|
|
538
|
+
nullable: false,
|
|
539
|
+
default: 0
|
|
540
|
+
}),
|
|
541
|
+
__metadata("design:type", Number)
|
|
542
|
+
], CompanyEntity.prototype, "balance", void 0);
|
|
543
|
+
__decorate([
|
|
544
|
+
(0, typeorm_1.Column)({}),
|
|
545
|
+
__metadata("design:type", Number)
|
|
546
|
+
], CompanyEntity.prototype, "freeBenefits", void 0);
|
|
474
547
|
__decorate([
|
|
475
548
|
(0, typeorm_1.Column)({
|
|
476
549
|
type: 'simple-json',
|
|
477
550
|
nullable: true,
|
|
478
551
|
default: null
|
|
479
552
|
}),
|
|
480
|
-
__metadata("design:type",
|
|
553
|
+
__metadata("design:type", shared_1.Tax)
|
|
481
554
|
], CompanyEntity.prototype, "tax", void 0);
|
|
482
555
|
__decorate([
|
|
483
556
|
(0, typeorm_1.Column)({
|