@darraghor/nest-backend-libs 2.18.7 → 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.
|
@@ -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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AAE;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,CAAC,eAAe,CAAC,CAAC;SACrD;QAED,OAAO,GAAG,CAAC,mBAAmB,CAAC;IACnC,CAAC;IACD,KAAK,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