@dascompany/product 2.1.7 → 2.1.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/reader/CompanyDataReader.js +2 -4
- package/dist/reader/ContactDetailsReader.js +3 -7
- package/dist/reader/DeliveryDetailsReader.js +7 -16
- package/dist/reader/DeliveryStatusReader.js +2 -4
- package/dist/reader/InvoiceDetailsReader.js +5 -19
- package/dist/reader/OrderProductsReader.js +3 -5
- package/dist/reader/PersonalDataReader.js +2 -8
- package/dist/reader/ProductReader.js +2 -3
- package/dist/reader/payment/PaymentDetailsReader.js +1 -1
- package/dist/reader/payment/PaymentStatusesReader.js +2 -4
- package/dist/types/OrderProductI.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
2
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
3
2
|
import AddressesReader from "./AddressesReader";
|
|
3
|
+
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
4
4
|
export default class CompanyDataReader {
|
|
5
5
|
static async get() {
|
|
6
6
|
const companyData = await DatabaseConnection.getInstance().companyData.select();
|
|
7
7
|
if (companyData) {
|
|
8
|
-
const
|
|
9
|
-
queryOptions.setWhere([{ name: 'id', type: ParameterType.bigint, value: companyData.address_id }]);
|
|
10
|
-
const address = companyData?.address_id ? await AddressesReader.get(queryOptions) : null;
|
|
8
|
+
const address = companyData?.address_id ? await AddressesReader.get(createQueryOptionsForId(companyData.address_id)) : null;
|
|
11
9
|
return {
|
|
12
10
|
id: companyData.id,
|
|
13
11
|
name: companyData.name,
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
2
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
3
2
|
import AddressesReader from "./AddressesReader";
|
|
4
3
|
import PersonalDataReader from "./PersonalDataReader";
|
|
4
|
+
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
5
5
|
export default class ContactDetailsReader {
|
|
6
6
|
static async get(queryOptions) {
|
|
7
7
|
const contactDetails = await DatabaseConnection.getInstance().contactDetails.select(queryOptions);
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const personalData = await PersonalDataReader.get(queryOptionsPersonalData);
|
|
11
|
-
const queryOptionsAddress = new QueryOptions();
|
|
12
|
-
queryOptionsAddress.setWhere([{ name: 'id', type: ParameterType.bigint, value: contactDetails.address_id }]);
|
|
13
|
-
const address = contactDetails.address_id ? await AddressesReader.get(queryOptionsAddress) : null;
|
|
8
|
+
const personalData = await PersonalDataReader.get(createQueryOptionsForId(contactDetails.personal_data_id));
|
|
9
|
+
const address = contactDetails.address_id ? await AddressesReader.get(createQueryOptionsForId(contactDetails.address_id)) : null;
|
|
14
10
|
return {
|
|
15
11
|
id: contactDetails.id,
|
|
16
12
|
personalData,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
2
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
3
2
|
import AddressesReader from "./AddressesReader";
|
|
4
3
|
import DeliveryMethodReader from "./DeliveryMethodReader";
|
|
5
4
|
import PersonalDataReader from "./PersonalDataReader";
|
|
5
|
+
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
6
6
|
export default class DeliveryDetailsReader {
|
|
7
7
|
static async get(queryOptions) {
|
|
8
8
|
const deliveryDetails = await DatabaseConnection.getInstance().deliveryDetails.select(queryOptions);
|
|
@@ -10,21 +10,12 @@ export default class DeliveryDetailsReader {
|
|
|
10
10
|
let personalData = null;
|
|
11
11
|
let address = null;
|
|
12
12
|
let deliveryMethod = null;
|
|
13
|
-
if (deliveryDetails.personal_data_id)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const queryOptionsAddress = new QueryOptions();
|
|
20
|
-
queryOptionsAddress.setWhere([{ name: 'id', type: ParameterType.bigint, value: deliveryDetails.address_id }]);
|
|
21
|
-
address = await AddressesReader.get(queryOptionsAddress);
|
|
22
|
-
}
|
|
23
|
-
if (deliveryDetails.delivery_method_id) {
|
|
24
|
-
const queryOptionsDeliveryMethod = new QueryOptions();
|
|
25
|
-
queryOptionsDeliveryMethod.setWhere([{ name: 'id', type: ParameterType.bigint, value: deliveryDetails.delivery_method_id }]);
|
|
26
|
-
deliveryMethod = await DeliveryMethodReader.get(queryOptionsDeliveryMethod);
|
|
27
|
-
}
|
|
13
|
+
if (deliveryDetails.personal_data_id)
|
|
14
|
+
personalData = await PersonalDataReader.get(createQueryOptionsForId(deliveryDetails.personal_data_id));
|
|
15
|
+
if (deliveryDetails.address_id)
|
|
16
|
+
address = await AddressesReader.get(createQueryOptionsForId(deliveryDetails.address_id));
|
|
17
|
+
if (deliveryDetails.delivery_method_id)
|
|
18
|
+
deliveryMethod = await DeliveryMethodReader.get(createQueryOptionsForId(deliveryDetails.delivery_method_id));
|
|
28
19
|
return {
|
|
29
20
|
id,
|
|
30
21
|
personalData,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
2
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
3
3
|
export default class DeliveryStatusReader {
|
|
4
4
|
static async get(queryOptions) {
|
|
5
5
|
const deliveryStatus = await DatabaseConnection.getInstance().deliveryStatuses.select(queryOptions);
|
|
@@ -18,9 +18,7 @@ export default class DeliveryStatusReader {
|
|
|
18
18
|
return deliveryStatuses;
|
|
19
19
|
}
|
|
20
20
|
static async correctDeliveryStatus(deliveryStatus) {
|
|
21
|
-
const
|
|
22
|
-
queryOptions.setWhere([{ name: 'id', type: ParameterType.bigint, value: deliveryStatus.delivery_status_type_id }]);
|
|
23
|
-
const deliveryStatusType = await DatabaseConnection.getInstance().deliveryStatusTypes.select(queryOptions);
|
|
21
|
+
const deliveryStatusType = await DatabaseConnection.getInstance().deliveryStatusTypes.select(createQueryOptionsForId(deliveryStatus.delivery_status_type_id));
|
|
24
22
|
return {
|
|
25
23
|
id: deliveryStatus.id,
|
|
26
24
|
type: deliveryStatusType,
|
|
@@ -1,31 +1,17 @@
|
|
|
1
|
-
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
2
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
3
2
|
import AddressesReader from "./AddressesReader";
|
|
4
3
|
import PersonalDataReader from "./PersonalDataReader";
|
|
4
|
+
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
5
5
|
export default class InvoiceDetailsReader {
|
|
6
6
|
static async get(queryOptions) {
|
|
7
7
|
const invoiceDetails = await DatabaseConnection.getInstance().invoiceDetails.select(queryOptions);
|
|
8
8
|
const id = invoiceDetails.id;
|
|
9
9
|
let personalData = null;
|
|
10
10
|
let address = null;
|
|
11
|
-
if (invoiceDetails.personal_data_id)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type: ParameterType.bigint,
|
|
16
|
-
value: invoiceDetails.personal_data_id
|
|
17
|
-
}]);
|
|
18
|
-
personalData = await PersonalDataReader.get(queryOptionsPersonalData);
|
|
19
|
-
}
|
|
20
|
-
if (invoiceDetails.address_id) {
|
|
21
|
-
const queryOptionsAddress = new QueryOptions();
|
|
22
|
-
queryOptionsAddress.setWhere([{
|
|
23
|
-
name: 'id',
|
|
24
|
-
type: ParameterType.bigint,
|
|
25
|
-
value: invoiceDetails.address_id
|
|
26
|
-
}]);
|
|
27
|
-
address = await AddressesReader.get(queryOptionsAddress);
|
|
28
|
-
}
|
|
11
|
+
if (invoiceDetails.personal_data_id)
|
|
12
|
+
personalData = await PersonalDataReader.get(createQueryOptionsForId(invoiceDetails.personal_data_id));
|
|
13
|
+
if (invoiceDetails.address_id)
|
|
14
|
+
address = await AddressesReader.get(createQueryOptionsForId(invoiceDetails.address_id));
|
|
29
15
|
return {
|
|
30
16
|
id,
|
|
31
17
|
personalData,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
2
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
3
2
|
import FilesReader from "./FilesReader";
|
|
4
3
|
import PriceConverter from "../utils/PriceConverter";
|
|
4
|
+
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
5
5
|
export default class OrderProductsReader {
|
|
6
6
|
static async getAll(queryOptions) {
|
|
7
7
|
const orderProducts = await DatabaseConnection.getInstance().ordersProducts.selectAll(queryOptions);
|
|
@@ -17,9 +17,7 @@ export default class OrderProductsReader {
|
|
|
17
17
|
return correctProducts;
|
|
18
18
|
}
|
|
19
19
|
static async correctProduct(orderProduct) {
|
|
20
|
-
const
|
|
21
|
-
queryOptions.setWhere([{ name: 'id', type: ParameterType.bigint, value: orderProduct.file_id }]);
|
|
22
|
-
const file = await FilesReader.get(queryOptions);
|
|
20
|
+
const thumbnail = await FilesReader.get(createQueryOptionsForId(orderProduct.file_id));
|
|
23
21
|
const correctProduct = {
|
|
24
22
|
id: orderProduct.id,
|
|
25
23
|
orderId: orderProduct.order_id,
|
|
@@ -30,7 +28,7 @@ export default class OrderProductsReader {
|
|
|
30
28
|
netPrice: orderProduct.net_price,
|
|
31
29
|
grossPrice: PriceConverter.netToGrossPrice(orderProduct.net_price, orderProduct.vat),
|
|
32
30
|
vat: orderProduct.vat,
|
|
33
|
-
|
|
31
|
+
thumbnail,
|
|
34
32
|
}
|
|
35
33
|
};
|
|
36
34
|
return correctProduct;
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
2
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
3
2
|
import correctPhoneNumber from "../utils/correctPhoneNumber";
|
|
4
3
|
import CompanyDetailsReader from "./CompanyDetailsReader";
|
|
4
|
+
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
5
5
|
export default class PersonalDataReader {
|
|
6
6
|
static async get(queryOptions) {
|
|
7
7
|
const personalDataRow = await DatabaseConnection.getInstance().personalData.select(queryOptions);
|
|
8
8
|
const personalData = this.correctPersonalData(personalDataRow);
|
|
9
9
|
if (personalDataRow.company_details_id) {
|
|
10
|
-
|
|
11
|
-
queryOptions.setWhere([{
|
|
12
|
-
name: 'id',
|
|
13
|
-
type: ParameterType.bigint,
|
|
14
|
-
value: personalDataRow.company_details_id
|
|
15
|
-
}]);
|
|
16
|
-
personalData.companyDetails = await CompanyDetailsReader.get(queryOptions);
|
|
10
|
+
personalData.companyDetails = await CompanyDetailsReader.get(createQueryOptionsForId(personalDataRow.company_details_id));
|
|
17
11
|
personalData.isCompany = true;
|
|
18
12
|
}
|
|
19
13
|
return personalData;
|
|
@@ -3,6 +3,7 @@ import FilesReader from "./FilesReader";
|
|
|
3
3
|
import DatabaseConnection from "../DatabaseConnection";
|
|
4
4
|
import FileConnectionTypeE from "../types/FileConnectionTypeE";
|
|
5
5
|
import PriceConverter from "../utils/PriceConverter";
|
|
6
|
+
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
6
7
|
export default class ProductReader {
|
|
7
8
|
static async get(queryOption) {
|
|
8
9
|
const productRow = await DatabaseConnection.getInstance().products.select(queryOption);
|
|
@@ -37,9 +38,7 @@ export default class ProductReader {
|
|
|
37
38
|
return correctProducts;
|
|
38
39
|
}
|
|
39
40
|
static async correctProduct(product) {
|
|
40
|
-
const
|
|
41
|
-
queryOptions.setWhere([{ name: 'id', type: ParameterType.bigint, value: product.file_id }]);
|
|
42
|
-
const thumbnail = await FilesReader.get(queryOptions);
|
|
41
|
+
const thumbnail = await FilesReader.get(createQueryOptionsForId(product.file_id));
|
|
43
42
|
return {
|
|
44
43
|
id: product.id,
|
|
45
44
|
sku: product.sku,
|
|
@@ -17,7 +17,7 @@ export default class PaymentDetailsReader {
|
|
|
17
17
|
}]);
|
|
18
18
|
const queryOptionsForPaymentStatus = new QueryOptions();
|
|
19
19
|
queryOptionsForPaymentStatus.setWhere([{
|
|
20
|
-
name: '
|
|
20
|
+
name: 'payment_details_id',
|
|
21
21
|
type: ParameterType.bigint,
|
|
22
22
|
value: paymentDetails.id
|
|
23
23
|
}]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
2
1
|
import DatabaseConnection from "../../DatabaseConnection";
|
|
2
|
+
import createQueryOptionsForId from "../../utils/createQueryOptionsForId";
|
|
3
3
|
export default class PaymentStatusesReader {
|
|
4
4
|
static async get(queryOptions) {
|
|
5
5
|
const paymentStatus = await DatabaseConnection.getInstance().paymentStatuses.select(queryOptions);
|
|
@@ -18,9 +18,7 @@ export default class PaymentStatusesReader {
|
|
|
18
18
|
return paymentStatuses;
|
|
19
19
|
}
|
|
20
20
|
static async correctPaymentStatus(paymentStatus) {
|
|
21
|
-
const
|
|
22
|
-
queryOptions.setWhere([{ name: 'id', type: ParameterType.bigint, value: paymentStatus.payment_status_type_id }]);
|
|
23
|
-
const paymentStatusType = await DatabaseConnection.getInstance().paymentStatusTypes.select(queryOptions);
|
|
21
|
+
const paymentStatusType = await DatabaseConnection.getInstance().paymentStatusTypes.select(createQueryOptionsForId(paymentStatus.payment_status_type_id));
|
|
24
22
|
return {
|
|
25
23
|
id: paymentStatus.id,
|
|
26
24
|
type: paymentStatusType,
|