@darraghor/nest-backend-libs 2.18.6 → 2.18.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/organisation-subscriptions/organisation-subscriptions.controller.d.ts +1 -1
- package/dist/organisation-subscriptions/organisation-subscriptions.controller.js +3 -2
- package/dist/organisation-subscriptions/organisation-subscriptions.controller.js.map +1 -1
- package/dist/organisation-subscriptions/organisation-subscriptions.service.d.ts +1 -1
- package/dist/organisation-subscriptions/organisation-subscriptions.service.js +35 -21
- package/dist/organisation-subscriptions/organisation-subscriptions.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,6 +7,6 @@ export declare class OrganisationSubscriptionsController {
|
|
|
7
7
|
private readonly osrService;
|
|
8
8
|
constructor(osrService: OrganisationSubscriptionService);
|
|
9
9
|
findAll(orgUuid: string, request: RequestWithUser): Promise<OrganisationSubscriptionRecord[]>;
|
|
10
|
-
addSubscription(orgUuid: string, body: SaveOrganisationSubscriptionRecordDto
|
|
10
|
+
addSubscription(orgUuid: string, body: SaveOrganisationSubscriptionRecordDto): Promise<OrganisationSubscriptionRecord[]>;
|
|
11
11
|
deleteSubscription(orgUuid: string, uuid: string): Promise<BooleanResult>;
|
|
12
12
|
}
|
|
@@ -20,6 +20,7 @@ const passport_1 = require("@nestjs/passport");
|
|
|
20
20
|
const organisation_subscription_entity_1 = require("./entities/organisation-subscription.entity");
|
|
21
21
|
const organisation_subscriptions_service_1 = require("./organisation-subscriptions.service");
|
|
22
22
|
const authz_1 = require("../authz");
|
|
23
|
+
const fulfillSubscriptionDto_1 = require("./models/fulfillSubscriptionDto");
|
|
23
24
|
const boolean_result_1 = require("../root-app/models/boolean-result");
|
|
24
25
|
let OrganisationSubscriptionsController = class OrganisationSubscriptionsController {
|
|
25
26
|
osrService;
|
|
@@ -30,7 +31,7 @@ let OrganisationSubscriptionsController = class OrganisationSubscriptionsControl
|
|
|
30
31
|
return this.osrService.findAllForOwnerOfOrg(orgUuid, request.user.id);
|
|
31
32
|
}
|
|
32
33
|
async addSubscription(orgUuid, body) {
|
|
33
|
-
return this.osrService.save(body);
|
|
34
|
+
return this.osrService.save([body]);
|
|
34
35
|
}
|
|
35
36
|
async deleteSubscription(orgUuid, uuid) {
|
|
36
37
|
const isDeleted = await this.osrService.delete(uuid);
|
|
@@ -53,7 +54,7 @@ __decorate([
|
|
|
53
54
|
__param(0, (0, common_1.Param)("orgUuid")),
|
|
54
55
|
__param(1, (0, common_1.Body)()),
|
|
55
56
|
__metadata("design:type", Function),
|
|
56
|
-
__metadata("design:paramtypes", [String,
|
|
57
|
+
__metadata("design:paramtypes", [String, fulfillSubscriptionDto_1.SaveOrganisationSubscriptionRecordDto]),
|
|
57
58
|
__metadata("design:returntype", Promise)
|
|
58
59
|
], OrganisationSubscriptionsController.prototype, "addSubscription", null);
|
|
59
60
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation-subscriptions.controller.js","sourceRoot":"","sources":["../../src/organisation-subscriptions/organisation-subscriptions.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAgD;AAChD,2CASwB;AACxB,6CAAsE;AACtE,+CAA2C;AAE3C,kGAA2F;AAC3F,6FAAqF;AACrF,oCAAuE;
|
|
1
|
+
{"version":3,"file":"organisation-subscriptions.controller.js","sourceRoot":"","sources":["../../src/organisation-subscriptions/organisation-subscriptions.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAgD;AAChD,2CASwB;AACxB,6CAAsE;AACtE,+CAA2C;AAE3C,kGAA2F;AAC3F,6FAAqF;AACrF,oCAAuE;AACvE,4EAAsF;AACtF,sEAAgE;AAMzD,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IACf;IAA7B,YAA6B,UAA2C;QAA3C,eAAU,GAAV,UAAU,CAAiC;IAAG,CAAC;IAItE,AAAN,KAAK,CAAC,OAAO,CACS,OAAe,EACtB,OAAwB;QAEnC,OAA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AS,EAAC,KAAK,CAAC,EAAE,gCAAwB,CAAC;IACrD,IAAA,uBAAa,GAAE;IACf,IAAA,mBAAU,EAAC,qCAAqC,CAAC;IACjD,IAAA,iBAAO,EAAC,4BAA4B,CAAC;qCAEO,oEAA+B;GAD/D,mCAAmC,CAgC/C;AAhCY,kFAAmC"}
|
|
@@ -13,6 +13,6 @@ export declare class OrganisationSubscriptionService {
|
|
|
13
13
|
private notFoundMessage;
|
|
14
14
|
findAllForOwnerOfOrg(orgUuid: string, currentUserId: number): Promise<OrganisationSubscriptionRecord[]>;
|
|
15
15
|
findAllForOrg(orgUuid: string): Promise<OrganisationSubscriptionRecord[]>;
|
|
16
|
-
save(subRecordDtoCollection: SaveOrganisationSubscriptionRecordDto[]): Promise<OrganisationSubscriptionRecord[]>;
|
|
16
|
+
save(subRecordDtoCollection: SaveOrganisationSubscriptionRecordDto[], orgUuid?: string): Promise<OrganisationSubscriptionRecord[]>;
|
|
17
17
|
delete(subUuid: string): Promise<boolean>;
|
|
18
18
|
}
|
|
@@ -72,37 +72,51 @@ let OrganisationSubscriptionService = class OrganisationSubscriptionService {
|
|
|
72
72
|
}
|
|
73
73
|
return org.subscriptionRecords;
|
|
74
74
|
}
|
|
75
|
-
async save(subRecordDtoCollection) {
|
|
75
|
+
async save(subRecordDtoCollection, orgUuid) {
|
|
76
76
|
const results = [];
|
|
77
77
|
for (const subRecord of subRecordDtoCollection) {
|
|
78
|
-
let
|
|
78
|
+
let existingSubscription = await this.orgSubRepository.findOne({
|
|
79
79
|
where: {
|
|
80
80
|
paymentSystemTransactionId: subRecord.paymentSystemTransactionId,
|
|
81
81
|
},
|
|
82
82
|
});
|
|
83
|
-
if (!
|
|
84
|
-
if
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
if (!existingSubscription) {
|
|
84
|
+
// if no existing subscription then create a new one, get the org
|
|
85
|
+
let org;
|
|
86
|
+
if (!orgUuid) {
|
|
87
|
+
const paymentReference = await this.paymentSessionService.findSessionByUuid(subRecord.millerPaymentReferenceUuid ?? "");
|
|
88
|
+
orgUuid = paymentReference?.organisationUuid;
|
|
87
89
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
// eslint-disable-next-line prefer-const
|
|
91
|
+
org =
|
|
92
|
+
(await this.orgRepo.findOne({
|
|
93
|
+
where: {
|
|
94
|
+
uuid: orgUuid,
|
|
95
|
+
},
|
|
96
|
+
})) || undefined;
|
|
97
|
+
existingSubscription = this.orgSubRepository.create({
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
99
|
+
organisation: org,
|
|
93
100
|
});
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
if (!org) {
|
|
102
|
+
this.logger.error("Failed to find organisation. Cannot match this payment to a customer", subRecord);
|
|
103
|
+
throw new common_1.NotFoundException("Failed to find organisation. Cannot match this payment to a customer");
|
|
104
|
+
}
|
|
96
105
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
existingSubscription.paymentSystemMode =
|
|
107
|
+
subRecord.paymentSystemMode;
|
|
108
|
+
existingSubscription.paymentSystemCustomerId =
|
|
109
|
+
subRecord.paymentSystemCustomerId;
|
|
110
|
+
existingSubscription.paymentSystemName =
|
|
111
|
+
subRecord.paymentSystemName;
|
|
112
|
+
existingSubscription.paymentSystemProductId =
|
|
113
|
+
subRecord.paymentSystemProductId;
|
|
114
|
+
existingSubscription.paymentSystemTransactionId =
|
|
102
115
|
subRecord.paymentSystemTransactionId;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
116
|
+
existingSubscription.validUntil = subRecord.validUntil;
|
|
117
|
+
existingSubscription.productDisplayName =
|
|
118
|
+
subRecord.productDisplayName;
|
|
119
|
+
const result = await this.orgSubRepository.save(existingSubscription);
|
|
106
120
|
results.push(result);
|
|
107
121
|
}
|
|
108
122
|
return results;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation-subscriptions.service.js","sourceRoot":"","sources":["../../src/organisation-subscriptions/organisation-subscriptions.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAA6D;AAC7D,6CAAiD;AACjD,qCAAmC;AACnC,oFAA4D;AAC5D,6DAAoD;AACpD,sFAA0E;AAC1E,yFAAkF;AAClF,kGAA2F;AAIpF,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAEnB;IAET;IAEA;IACS;IANrB,YACqB,MAAyB,EAElC,OAAiC,EAEjC,gBAA4D,EACnD,qBAA4C;QAL5C,WAAM,GAAN,MAAM,CAAmB;QAElC,YAAO,GAAP,OAAO,CAA0B;QAEjC,qBAAgB,GAAhB,gBAAgB,CAA4C;QACnD,0BAAqB,GAArB,qBAAqB,CAAuB;IAC9D,CAAC;IACI,eAAe,GACnB,mDAAmD,CAAC;IACxD,KAAK,CAAC,oBAAoB,CACtB,OAAe,EACf,aAAqB;QAErB,oCAAoC;QACpC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;YACnC,KAAK,EAAE;gBACH,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE;oBACT,QAAQ,EAAE,aAAa;oBACvB,KAAK,EAAE;wBACH,IAAI,EAAE,iBAAK,CAAC,KAAK;qBACpB;iBACJ;aACJ;YACD,SAAS,EAAE;gBACP,mBAAmB,EAAE,IAAI;aAC5B;SACJ,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,EAAE;YACN,MAAM,IAAI,0BAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;SACrD;QAED,OAAO,GAAG,CAAC,mBAAmB,CAAC;IACnC,CAAC;IACD,KAAK,CAAC,aAAa,CACf,OAAe;QAEf,oCAAoC;QACpC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;YACnC,KAAK,EAAE;gBACH,IAAI,EAAE,OAAO;aAChB;YACD,SAAS,EAAE;gBACP,mBAAmB,EAAE,IAAI;aAC5B;SACJ,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,EAAE;YACN,MAAM,IAAI,0BAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;SACrD;QAED,OAAO,GAAG,CAAC,mBAAmB,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,IAAI,CACN,sBAA+D
|
|
1
|
+
{"version":3,"file":"organisation-subscriptions.service.js","sourceRoot":"","sources":["../../src/organisation-subscriptions/organisation-subscriptions.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAA6D;AAC7D,6CAAiD;AACjD,qCAAmC;AACnC,oFAA4D;AAC5D,6DAAoD;AACpD,sFAA0E;AAC1E,yFAAkF;AAClF,kGAA2F;AAIpF,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAEnB;IAET;IAEA;IACS;IANrB,YACqB,MAAyB,EAElC,OAAiC,EAEjC,gBAA4D,EACnD,qBAA4C;QAL5C,WAAM,GAAN,MAAM,CAAmB;QAElC,YAAO,GAAP,OAAO,CAA0B;QAEjC,qBAAgB,GAAhB,gBAAgB,CAA4C;QACnD,0BAAqB,GAArB,qBAAqB,CAAuB;IAC9D,CAAC;IACI,eAAe,GACnB,mDAAmD,CAAC;IACxD,KAAK,CAAC,oBAAoB,CACtB,OAAe,EACf,aAAqB;QAErB,oCAAoC;QACpC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;YACnC,KAAK,EAAE;gBACH,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE;oBACT,QAAQ,EAAE,aAAa;oBACvB,KAAK,EAAE;wBACH,IAAI,EAAE,iBAAK,CAAC,KAAK;qBACpB;iBACJ;aACJ;YACD,SAAS,EAAE;gBACP,mBAAmB,EAAE,IAAI;aAC5B;SACJ,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,EAAE;YACN,MAAM,IAAI,0BAAiB,CAAC,IAAI,CA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