@driveup/schema 0.3.4 → 0.3.5

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.
@@ -11,6 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.TrainingBalanceView = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
+ // training balance = (training cost) + (total paid) - (sum of refunds)
15
+ // training cost = (administration fee) + (total sessions costs) - (sum of discounts)
14
16
  let TrainingBalanceView = class TrainingBalanceView {
15
17
  };
16
18
  exports.TrainingBalanceView = TrainingBalanceView;
@@ -25,12 +27,20 @@ __decorate([
25
27
  exports.TrainingBalanceView = TrainingBalanceView = __decorate([
26
28
  (0, typeorm_1.ViewEntity)({
27
29
  name: 'training_balance_view',
28
- dependsOn: ['training_sessions_view'],
30
+ dependsOn: ['training_sessions_view', 'training_cost_view'],
29
31
  expression: `
30
32
  SELECT
31
-
32
- FROM studentTrainings t
33
- INNER JOIN
33
+ t.id AS trainingId,
34
+ (
35
+ COALESCE(tcv.cost, 0)
36
+ + COALESCE(t.paid, 0)
37
+ - COALESCE(t.refund, 0)
38
+ ) AS balance
39
+ FROM
40
+ studentTrainings t
41
+ LEFT JOIN
42
+ training_cost_view tcv
43
+ ON t.id = tcv.trainingId
34
44
  `
35
45
  })
36
46
  ], TrainingBalanceView);
@@ -1 +1 @@
1
- {"version":3,"file":"training-balance.view.js","sourceRoot":"","sources":["../../../../../src/profile/student/program/training/training-balance.view.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAiD;AAY1C,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAO/B,CAAA;AAPY,kDAAmB;AAG/B;IADC,IAAA,oBAAU,GAAE;;uDACM;AAGnB;IADC,IAAA,oBAAU,GAAE;;oDACG;8BANJ,mBAAmB;IAV/B,IAAA,oBAAU,EAAC;QACX,IAAI,EAAE,uBAAuB;QAC7B,SAAS,EAAE,CAAC,wBAAwB,CAAC;QACrC,UAAU,EAAE;;;;;EAKX;KACD,CAAC;GACW,mBAAmB,CAO/B"}
1
+ {"version":3,"file":"training-balance.view.js","sourceRoot":"","sources":["../../../../../src/profile/student/program/training/training-balance.view.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAiD;AAEjD,uEAAuE;AACvE,qFAAqF;AAoB9E,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAO/B,CAAA;AAPY,kDAAmB;AAG/B;IADC,IAAA,oBAAU,GAAE;;uDACM;AAGnB;IADC,IAAA,oBAAU,GAAE;;oDACG;8BANJ,mBAAmB;IAlB/B,IAAA,oBAAU,EAAC;QACX,IAAI,EAAE,uBAAuB;QAC7B,SAAS,EAAE,CAAC,wBAAwB,EAAE,oBAAoB,CAAC;QAC3D,UAAU,EAAE;;;;;;;;;;;;;EAaX;KACD,CAAC;GACW,mBAAmB,CAO/B"}