@spytecgps/nova-orm 1.0.7 → 1.0.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Enums } from '../..';
|
|
2
|
-
import { Billing, BillingSubscriptionBraintree, Client, Device, IccidStatus, ImeiIccidCarrier, } from '../../entities';
|
|
2
|
+
import { Billing, BillingSubscriptionBraintree, Client, CustomerAttribute, Device, IccidStatus, ImeiIccidCarrier, } from '../../entities';
|
|
3
3
|
export const getCanceledImeis = async (novaDataSource, params, logger) => {
|
|
4
4
|
if (!params?.filters?.minCancellationDate ||
|
|
5
5
|
!params?.filters?.maxCancellationDate ||
|
|
@@ -17,6 +17,7 @@ export const getCanceledImeis = async (novaDataSource, params, logger) => {
|
|
|
17
17
|
.innerJoin(ImeiIccidCarrier, 'imeiIccidCarrier', 'imeiIccidCarrier.imei = billing.imei')
|
|
18
18
|
.innerJoin(Device, 'device', 'device.imei = billing.imei')
|
|
19
19
|
.innerJoin(Client, 'client', 'client.id = device.clientId')
|
|
20
|
+
.leftJoin(CustomerAttribute, 'customerAttribute', 'client.id = customerAttribute.clientId')
|
|
20
21
|
.innerJoin(IccidStatus, 'iccidStatus', 'iccidStatus.iccid = imeiIccidCarrier.iccid')
|
|
21
22
|
.where(`iccidStatus.processing = :processing`, {
|
|
22
23
|
processing: false,
|
|
@@ -55,8 +56,8 @@ export const getCanceledImeis = async (novaDataSource, params, logger) => {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
if (params.filters.excludeB2B) {
|
|
58
|
-
queryBuilder = queryBuilder.andWhere(`
|
|
59
|
-
|
|
59
|
+
queryBuilder = queryBuilder.andWhere(`(customerAttribute.enterprise is null OR customerAttribute.enterprise = :enterprise)`, {
|
|
60
|
+
enterprise: false,
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
if (params.filters.excludeTest) {
|
|
@@ -77,8 +78,12 @@ export const getCanceledImeis = async (novaDataSource, params, logger) => {
|
|
|
77
78
|
'billingSubscriptionBraintree.updatedAt as updatedAt',
|
|
78
79
|
'billingSubscriptionBraintree.status as status',
|
|
79
80
|
'imeiIccidCarrier.carrier as carrier',
|
|
81
|
+
'customerAttribute.enterprise as isEnterpriseCustomer',
|
|
80
82
|
])
|
|
81
83
|
.getRawMany();
|
|
82
|
-
return result
|
|
84
|
+
return result.map(row => ({
|
|
85
|
+
...row,
|
|
86
|
+
isEnterpriseCustomer: row.isEnterpriseCustomer === 1,
|
|
87
|
+
}));
|
|
83
88
|
}, 'BillingRepository::getCanceledImeis');
|
|
84
89
|
};
|
|
@@ -27,7 +27,7 @@ export const getCanceledImeisMatchingMagentoData = async (novaDataSource, params
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
const excludeB2bCondition = params.filters.excludeB2B
|
|
30
|
-
? `AND
|
|
30
|
+
? `AND customerAttribute.enterprise != true `
|
|
31
31
|
: '';
|
|
32
32
|
const excludeTestCondition = params.filters.excludeTest
|
|
33
33
|
? `AND client.clientTypeId != ${Enums.HapnClientType.test} `
|
|
@@ -42,7 +42,8 @@ export const getCanceledImeisMatchingMagentoData = async (novaDataSource, params
|
|
|
42
42
|
billingSubscriptionBraintree.createdAt,
|
|
43
43
|
billingSubscriptionBraintree.updatedAt,
|
|
44
44
|
billingSubscriptionBraintree.status,
|
|
45
|
-
imeiIccidCarrier.carrier
|
|
45
|
+
imeiIccidCarrier.carrier,
|
|
46
|
+
customerAttribute.enterprise as isEnterpriseCustomer
|
|
46
47
|
FROM
|
|
47
48
|
billing
|
|
48
49
|
INNER JOIN
|
|
@@ -53,6 +54,8 @@ export const getCanceledImeisMatchingMagentoData = async (novaDataSource, params
|
|
|
53
54
|
device ON device.imei = billing.imei
|
|
54
55
|
INNER JOIN
|
|
55
56
|
client ON client.id = device.clientId
|
|
57
|
+
LEFT JOIN
|
|
58
|
+
customerAttribute ON customerAttribute.clientId = client.id
|
|
56
59
|
INNER JOIN
|
|
57
60
|
iccidStatus ON iccidStatus.iccid = imeiIccidCarrier.iccid
|
|
58
61
|
WHERE
|
|
@@ -95,6 +98,7 @@ export const getCanceledImeisMatchingMagentoData = async (novaDataSource, params
|
|
|
95
98
|
updatedAt: item.updatedAt,
|
|
96
99
|
status: item.status,
|
|
97
100
|
carrier: item.carrier,
|
|
101
|
+
isEnterpriseCustomer: item.isEnterpriseCustomer === 1,
|
|
98
102
|
}));
|
|
99
103
|
}, 'BillingRepository::getCanceledImeisMatchingMagentoData');
|
|
100
104
|
};
|
package/dist/types/billing.d.ts
CHANGED