@darraghor/nest-backend-libs 2.18.7 → 2.18.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/dist/organisation-subscriptions/organisation-subscriptions.controller.js +1 -1
- 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 +39 -21
- package/dist/organisation-subscriptions/organisation-subscriptions.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ let OrganisationSubscriptionsController = class OrganisationSubscriptionsControl
|
|
|
31
31
|
return this.osrService.findAllForOwnerOfOrg(orgUuid, request.user.id);
|
|
32
32
|
}
|
|
33
33
|
async addSubscription(orgUuid, body) {
|
|
34
|
-
return this.osrService.save([body]);
|
|
34
|
+
return this.osrService.save([body], orgUuid);
|
|
35
35
|
}
|
|
36
36
|
async deleteSubscription(orgUuid, uuid) {
|
|
37
37
|
const isDeleted = await this.osrService.delete(uuid);
|
|
@@ -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;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,OAAO,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IAKK,AAAN,KAAK,CAAC,eAAe,CACC,OAAe,EACzB,IAA2C;QAEnD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;
|
|
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,OAAO,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IAKK,AAAN,KAAK,CAAC,eAAe,CACC,OAAe,EACzB,IAA2C;QAEnD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAKK,AAAN,KAAK,CAAC,kBAAkB,CACF,OAAe,EAClB,IAAY;QAE3B,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,EAAC,MAAM,EAAE,SAAS,EAAC,CAAC;IAC/B,CAAC;CACJ,CAAA;AA3BS;IAFL,IAAA,YAAG,GAAE;IACL,IAAA,uBAAa,EAAC,EAAC,IAAI,EAAE,CAAC,iEAA8B,CAAC,EAAC,CAAC;IAEnD,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;IAChB,WAAA,IAAA,gBAAO,GAAE,CAAA;;;;kEAGb;AAKK;IAHL,IAAA,2BAAmB,EAAC,YAAY,CAAC;IACjC,IAAA,aAAI,GAAE;IACN,IAAA,uBAAa,EAAC,EAAC,IAAI,EAAE,CAAC,iEAA8B,CAAC,EAAC,CAAC;IAEnD,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;IAChB,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAO,8DAAqC;;0EAGtD;AAKK;IAHL,IAAA,2BAAmB,EAAC,YAAY,CAAC;IACjC,IAAA,eAAM,EAAC,OAAO,CAAC;IACf,IAAA,uBAAa,EAAC,EAAC,IAAI,EAAE,8BAAa,EAAC,CAAC;IAEhC,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;IAChB,WAAA,IAAA,cAAK,EAAC,MAAM,CAAC,CAAA;;;;6EAIjB;AA/BQ,mCAAmC;IAJ/C,IAAA,kBAAS,EAAC,IAAA,oBAAS,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,55 @@ 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
|
+
if (!subRecord.millerPaymentReferenceUuid) {
|
|
88
|
+
this.logger.error("No organisation uuid or payment reference uuid provided. Cannot match this payment to a customer", subRecord);
|
|
89
|
+
throw new common_1.NotFoundException("No organisation uuid or payment reference uuid provided. Cannot match this payment to a customer");
|
|
90
|
+
}
|
|
91
|
+
const paymentReference = await this.paymentSessionService.findSessionByUuid(subRecord.millerPaymentReferenceUuid ?? "");
|
|
92
|
+
orgUuid = paymentReference?.organisationUuid;
|
|
87
93
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
// eslint-disable-next-line prefer-const
|
|
95
|
+
org =
|
|
96
|
+
(await this.orgRepo.findOne({
|
|
97
|
+
where: {
|
|
98
|
+
uuid: orgUuid,
|
|
99
|
+
},
|
|
100
|
+
})) || undefined;
|
|
101
|
+
existingSubscription = this.orgSubRepository.create({
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
103
|
+
organisation: org,
|
|
93
104
|
});
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
if (!org) {
|
|
106
|
+
this.logger.error("Failed to find organisation. Cannot match this payment to a customer", subRecord);
|
|
107
|
+
throw new common_1.NotFoundException("Failed to find organisation. Cannot match this payment to a customer");
|
|
108
|
+
}
|
|
96
109
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
existingSubscription.paymentSystemMode =
|
|
111
|
+
subRecord.paymentSystemMode;
|
|
112
|
+
existingSubscription.paymentSystemCustomerId =
|
|
113
|
+
subRecord.paymentSystemCustomerId;
|
|
114
|
+
existingSubscription.paymentSystemName =
|
|
115
|
+
subRecord.paymentSystemName;
|
|
116
|
+
existingSubscription.paymentSystemProductId =
|
|
117
|
+
subRecord.paymentSystemProductId;
|
|
118
|
+
existingSubscription.paymentSystemTransactionId =
|
|
102
119
|
subRecord.paymentSystemTransactionId;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
120
|
+
existingSubscription.validUntil = subRecord.validUntil;
|
|
121
|
+
existingSubscription.productDisplayName =
|
|
122
|
+
subRecord.productDisplayName;
|
|
123
|
+
const result = await this.orgSubRepository.save(existingSubscription);
|
|
106
124
|
results.push(result);
|
|
107
125
|
}
|
|
108
126
|
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;A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