@dascompany/product 1.1.6 → 2.0.0
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/SQL.json +39 -58
- package/dist/reader/AddressesReader.d.ts +2 -2
- package/dist/reader/AddressesReader.js +2 -6
- package/dist/reader/AdminReader.d.ts +4 -4
- package/dist/reader/AdminReader.js +4 -4
- package/dist/reader/ClientAccountReader.d.ts +2 -3
- package/dist/reader/ClientAccountReader.js +4 -8
- package/dist/reader/CompanyDataReader.js +4 -1
- package/dist/reader/CompanyDetailsReader.d.ts +2 -1
- package/dist/reader/CompanyDetailsReader.js +3 -3
- package/dist/reader/ContactDetailsReader.d.ts +2 -1
- package/dist/reader/ContactDetailsReader.js +9 -4
- package/dist/reader/DeliveryDetailsReader.d.ts +2 -1
- package/dist/reader/DeliveryDetailsReader.js +18 -8
- package/dist/reader/DeliveryMethodReader.d.ts +3 -3
- package/dist/reader/DeliveryMethodReader.js +4 -8
- package/dist/reader/DeliveryStatusReader.d.ts +3 -2
- package/dist/reader/DeliveryStatusReader.js +8 -5
- package/dist/reader/FileConnectionsReader.d.ts +2 -1
- package/dist/reader/FileConnectionsReader.js +2 -2
- package/dist/reader/FilesReader.d.ts +5 -6
- package/dist/reader/FilesReader.js +5 -5
- package/dist/reader/InvoiceDetailsReader.d.ts +2 -1
- package/dist/reader/InvoiceDetailsReader.js +21 -6
- package/dist/reader/OrderProductsReader.d.ts +2 -2
- package/dist/reader/OrderProductsReader.js +6 -17
- package/dist/reader/OrderReader.d.ts +4 -4
- package/dist/reader/OrderReader.js +13 -9
- package/dist/reader/OrderStatusReader.d.ts +3 -2
- package/dist/reader/OrderStatusReader.js +4 -4
- package/dist/reader/PersonalDataReader.d.ts +2 -1
- package/dist/reader/PersonalDataReader.js +10 -3
- package/dist/reader/ProductReader.d.ts +6 -6
- package/dist/reader/ProductReader.js +21 -17
- package/dist/reader/payment/PaymentDetailsReader.d.ts +2 -2
- package/dist/reader/payment/PaymentDetailsReader.js +17 -8
- package/dist/reader/payment/PaymentMethodReader.d.ts +3 -3
- package/dist/reader/payment/PaymentMethodReader.js +4 -8
- package/dist/reader/payment/PaymentStatusesReader.d.ts +3 -2
- package/dist/reader/payment/PaymentStatusesReader.js +8 -5
- package/dist/repo/AddressesRepo.d.ts +2 -1
- package/dist/repo/AddressesRepo.js +2 -2
- package/dist/repo/AdminRepo.d.ts +4 -4
- package/dist/repo/AdminRepo.js +4 -4
- package/dist/repo/ClientAccountRepo.d.ts +2 -3
- package/dist/repo/ClientAccountRepo.js +2 -10
- package/dist/repo/CompanyDetailsRepo.d.ts +2 -1
- package/dist/repo/CompanyDetailsRepo.js +2 -2
- package/dist/repo/ContactDetailsRepo.d.ts +2 -1
- package/dist/repo/ContactDetailsRepo.js +2 -2
- package/dist/repo/DeliveryDetailsRepo.d.ts +2 -1
- package/dist/repo/DeliveryDetailsRepo.js +2 -2
- package/dist/repo/DeliveryMethodRepo.d.ts +2 -1
- package/dist/repo/DeliveryMethodRepo.js +2 -2
- package/dist/repo/FileConnectionsRepo.d.ts +3 -2
- package/dist/repo/FileConnectionsRepo.js +4 -4
- package/dist/repo/FilesRepo.d.ts +3 -3
- package/dist/repo/FilesRepo.js +4 -4
- package/dist/repo/InvoiceDetailsRepo.d.ts +2 -1
- package/dist/repo/InvoiceDetailsRepo.js +2 -2
- package/dist/repo/OrderProductsRepo.d.ts +2 -2
- package/dist/repo/OrderProductsRepo.js +2 -15
- package/dist/repo/OrderRepo.d.ts +2 -1
- package/dist/repo/OrderRepo.js +2 -2
- package/dist/repo/OrderStatusRepo.d.ts +3 -2
- package/dist/repo/OrderStatusRepo.js +4 -4
- package/dist/repo/PaymentDetailsRepo.d.ts +2 -1
- package/dist/repo/PaymentDetailsRepo.js +2 -2
- package/dist/repo/PaymentMethodRepo.d.ts +2 -1
- package/dist/repo/PaymentMethodRepo.js +2 -2
- package/dist/repo/PersonalDataRepo.d.ts +2 -1
- package/dist/repo/PersonalDataRepo.js +2 -2
- package/dist/repo/ProductRepo.d.ts +2 -2
- package/dist/repo/ProductRepo.js +2 -6
- package/dist/stockObjects/Order.js +4 -2
- package/dist/stockObjects/PersonalData.js +6 -3
- package/dist/stockObjects/Product.js +9 -4
- package/dist/tables/clients/ClientAccountsTable.d.ts +5 -7
- package/dist/tables/clients/ClientAccountsTable.js +13 -23
- package/dist/tables/files/FileConnectionsTable.d.ts +3 -6
- package/dist/tables/files/FileConnectionsTable.js +4 -19
- package/dist/tables/files/FilesTable.d.ts +6 -7
- package/dist/tables/files/FilesTable.js +9 -12
- package/dist/tables/orders/OrdersProductsTable.d.ts +4 -5
- package/dist/tables/orders/OrdersProductsTable.js +14 -20
- package/dist/tables/orders/OrdersTable.d.ts +4 -5
- package/dist/tables/orders/OrdersTable.js +3 -10
- package/dist/tables/orders/PaymentDetailsTable.d.ts +2 -2
- package/dist/tables/orders/PaymentDetailsTable.js +2 -3
- package/dist/tables/orders/PaymentStatusTypesTable.d.ts +2 -2
- package/dist/tables/orders/PaymentStatusTypesTable.js +2 -3
- package/dist/tables/orders/PaymentStatusesTable.d.ts +3 -3
- package/dist/tables/orders/PaymentStatusesTable.js +4 -6
- package/dist/tables/orders/StatusesTable.d.ts +3 -3
- package/dist/tables/orders/StatusesTable.js +4 -6
- package/dist/tables/personalInformation/AddressesTable.d.ts +2 -2
- package/dist/tables/personalInformation/AddressesTable.js +2 -3
- package/dist/tables/personalInformation/CompanyDetailsTable.d.ts +2 -2
- package/dist/tables/personalInformation/CompanyDetailsTable.js +2 -3
- package/dist/tables/personalInformation/ContactDetailsTable.d.ts +2 -2
- package/dist/tables/personalInformation/ContactDetailsTable.js +2 -3
- package/dist/tables/personalInformation/DeliveryDetailsTable.d.ts +2 -2
- package/dist/tables/personalInformation/DeliveryDetailsTable.js +2 -3
- package/dist/tables/personalInformation/DeliveryStatusTypesTable.d.ts +2 -2
- package/dist/tables/personalInformation/DeliveryStatusTypesTable.js +2 -3
- package/dist/tables/personalInformation/DeliveryStatusesTable.d.ts +3 -3
- package/dist/tables/personalInformation/DeliveryStatusesTable.js +4 -6
- package/dist/tables/personalInformation/InvoiceDetailsTable.d.ts +2 -2
- package/dist/tables/personalInformation/InvoiceDetailsTable.js +2 -3
- package/dist/tables/personalInformation/PersonalDataTable.d.ts +2 -2
- package/dist/tables/personalInformation/PersonalDataTable.js +2 -3
- package/dist/tables/public/AdminAccountsTable.d.ts +5 -5
- package/dist/tables/public/AdminAccountsTable.js +11 -9
- package/dist/tables/public/ProductsTable.d.ts +7 -9
- package/dist/tables/public/ProductsTable.js +33 -43
- package/dist/tables/settings/DeliveryMethodsTable.d.ts +4 -5
- package/dist/tables/settings/DeliveryMethodsTable.js +10 -14
- package/dist/tables/settings/PaymentMethodsTable.d.ts +4 -5
- package/dist/tables/settings/PaymentMethodsTable.js +10 -14
- package/package.json +2 -2
|
@@ -1,16 +1,31 @@
|
|
|
1
|
+
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
1
2
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
3
|
import AddressesReader from "./AddressesReader";
|
|
3
4
|
import PersonalDataReader from "./PersonalDataReader";
|
|
4
5
|
export default class InvoiceDetailsReader {
|
|
5
|
-
static async get(
|
|
6
|
-
const invoiceDetails = await DatabaseConnection.getInstance().invoiceDetails.select(
|
|
6
|
+
static async get(queryOptions) {
|
|
7
|
+
const invoiceDetails = await DatabaseConnection.getInstance().invoiceDetails.select(queryOptions);
|
|
7
8
|
const id = invoiceDetails.id;
|
|
8
9
|
let personalData = null;
|
|
9
10
|
let address = null;
|
|
10
|
-
if (invoiceDetails.personal_data_id)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
if (invoiceDetails.personal_data_id) {
|
|
12
|
+
const queryOptionsPersonalData = new QueryOptions();
|
|
13
|
+
queryOptionsPersonalData.setWhere([{
|
|
14
|
+
name: 'id',
|
|
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
|
+
}
|
|
14
29
|
return {
|
|
15
30
|
id,
|
|
16
31
|
personalData,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
import OrderProductI from "../types/OrderProductI";
|
|
2
3
|
export default class OrderProductsReader {
|
|
3
|
-
static getAll(
|
|
4
|
-
static getForOrder(orderId: number): Promise<any[]>;
|
|
4
|
+
static getAll(queryOptions: QueryOptions): Promise<OrderProductI[]>;
|
|
5
5
|
private static correctOrderProducts;
|
|
6
6
|
private static correctProduct;
|
|
7
7
|
}
|
|
@@ -1,26 +1,13 @@
|
|
|
1
|
+
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
1
2
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
3
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
3
4
|
import FilesReader from "./FilesReader";
|
|
4
5
|
export default class OrderProductsReader {
|
|
5
|
-
static async getAll(
|
|
6
|
-
const orderProducts = await DatabaseConnection.getInstance().ordersProducts.
|
|
6
|
+
static async getAll(queryOptions) {
|
|
7
|
+
const orderProducts = await DatabaseConnection.getInstance().ordersProducts.selectAll(queryOptions);
|
|
7
8
|
const correctProducts = await this.correctOrderProducts(orderProducts);
|
|
8
9
|
return correctProducts;
|
|
9
10
|
}
|
|
10
|
-
static async getForOrder(orderId) {
|
|
11
|
-
const products = await DatabaseConnection.getInstance().ordersProducts.selectAllActive(orderId);
|
|
12
|
-
const correctProducts = [];
|
|
13
|
-
for (let i = 0; i < products.length; i++) {
|
|
14
|
-
const correctProduct = {
|
|
15
|
-
id: products[i].id,
|
|
16
|
-
orderId: products[i].order_id,
|
|
17
|
-
productId: products[i].product_id,
|
|
18
|
-
netPrice: products[i].net_price,
|
|
19
|
-
};
|
|
20
|
-
correctProducts.push(correctProduct);
|
|
21
|
-
}
|
|
22
|
-
return correctProducts;
|
|
23
|
-
}
|
|
24
11
|
static async correctOrderProducts(products) {
|
|
25
12
|
const correctProducts = [];
|
|
26
13
|
for (let i = 0; i < products.length; i++) {
|
|
@@ -30,7 +17,9 @@ export default class OrderProductsReader {
|
|
|
30
17
|
return correctProducts;
|
|
31
18
|
}
|
|
32
19
|
static async correctProduct(orderProduct) {
|
|
33
|
-
const
|
|
20
|
+
const queryOptions = new QueryOptions();
|
|
21
|
+
queryOptions.setWhere([{ name: 'id', type: ParameterType.bigint, value: orderProduct.file_id }]);
|
|
22
|
+
const file = await FilesReader.get(queryOptions);
|
|
34
23
|
const correctProduct = {
|
|
35
24
|
id: orderProduct.id,
|
|
36
25
|
orderId: orderProduct.order_id,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
2
2
|
import OrderI from "../types/OrderI";
|
|
3
3
|
export default class OrderReader {
|
|
4
|
-
static get(
|
|
5
|
-
static
|
|
6
|
-
static
|
|
4
|
+
static get(queryOptions: QueryOptions): Promise<OrderI>;
|
|
5
|
+
static getAll(queryOptions: QueryOptions): Promise<OrderI[]>;
|
|
6
|
+
static getAllForClient(queryOptions: QueryOptions): Promise<{
|
|
7
7
|
orders: OrderI[];
|
|
8
8
|
quantity: number;
|
|
9
9
|
}>;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
+
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
1
2
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
3
|
import OrderProductsReader from "./OrderProductsReader";
|
|
3
4
|
import OrderStatusReader from "./OrderStatusReader";
|
|
4
5
|
export default class OrderReader {
|
|
5
|
-
static async get(
|
|
6
|
-
const orderData = await DatabaseConnection.getInstance().orders.select(
|
|
6
|
+
static async get(queryOptions) {
|
|
7
|
+
const orderData = await DatabaseConnection.getInstance().orders.select(queryOptions);
|
|
7
8
|
return this.correctOrder(orderData);
|
|
8
9
|
}
|
|
9
|
-
static async
|
|
10
|
-
const orders = await DatabaseConnection.getInstance().orders.
|
|
10
|
+
static async getAll(queryOptions) {
|
|
11
|
+
const orders = await DatabaseConnection.getInstance().orders.selectAll(queryOptions);
|
|
11
12
|
const correctOrders = [];
|
|
12
13
|
for (let i = 0; i < orders.length; i++) {
|
|
13
14
|
const correctOrder = await this.correctOrder(orders[i]);
|
|
14
|
-
|
|
15
|
-
correctOrders.push({ ...correctOrder, products });
|
|
15
|
+
correctOrders.push(correctOrder);
|
|
16
16
|
}
|
|
17
17
|
return correctOrders;
|
|
18
18
|
}
|
|
19
|
-
static async
|
|
19
|
+
static async getAllForClient(queryOptions) {
|
|
20
20
|
const orderRows = await DatabaseConnection.getInstance().orders.selectAll(queryOptions);
|
|
21
21
|
const quantity = await DatabaseConnection.getInstance().orders.count(queryOptions);
|
|
22
22
|
const orders = await this.correctOrders(orderRows);
|
|
@@ -31,7 +31,10 @@ export default class OrderReader {
|
|
|
31
31
|
return orders;
|
|
32
32
|
}
|
|
33
33
|
static async correctOrder(order) {
|
|
34
|
-
const
|
|
34
|
+
const queryOptions = new QueryOptions();
|
|
35
|
+
queryOptions.setWhere([{ name: 'order_id', type: ParameterType.bigint, value: order.id }]);
|
|
36
|
+
const products = await OrderProductsReader.getAll(queryOptions);
|
|
37
|
+
const status = await OrderStatusReader.get(queryOptions);
|
|
35
38
|
const correctOrder = {
|
|
36
39
|
id: order.id,
|
|
37
40
|
email: order.email,
|
|
@@ -43,7 +46,8 @@ export default class OrderReader {
|
|
|
43
46
|
invoiceDetailsId: order.invoice_details_id,
|
|
44
47
|
paymentDetailsId: order.payment_details_id,
|
|
45
48
|
zsiId: order.zsi_id,
|
|
46
|
-
status
|
|
49
|
+
status,
|
|
50
|
+
products
|
|
47
51
|
};
|
|
48
52
|
return correctOrder;
|
|
49
53
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
import OrderStatusI from "../types/StatusI";
|
|
2
3
|
export default class OrderStatusReader {
|
|
3
|
-
static get(
|
|
4
|
-
static getAll(
|
|
4
|
+
static get(queryOptions: QueryOptions): Promise<OrderStatusI>;
|
|
5
|
+
static getAll(queryOptions: QueryOptions): Promise<OrderStatusI[]>;
|
|
5
6
|
private static correctStatus;
|
|
6
7
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
export default class OrderStatusReader {
|
|
3
|
-
static async get(
|
|
4
|
-
const statusRow = await DatabaseConnection.getInstance().statuses.select(
|
|
3
|
+
static async get(queryOptions) {
|
|
4
|
+
const statusRow = await DatabaseConnection.getInstance().statuses.select(queryOptions);
|
|
5
5
|
return this.correctStatus(statusRow);
|
|
6
6
|
}
|
|
7
|
-
static async getAll(
|
|
8
|
-
const statuses = await DatabaseConnection.getInstance().statuses.selectAll(
|
|
7
|
+
static async getAll(queryOptions) {
|
|
8
|
+
const statuses = await DatabaseConnection.getInstance().statuses.selectAll(queryOptions);
|
|
9
9
|
const correctStatuss = [];
|
|
10
10
|
for (let i = 0; i < statuses.length; i++) {
|
|
11
11
|
const correctStatus = this.correctStatus(statuses[i]);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
import PersonalDataI from "../types/PersonalDataI";
|
|
2
3
|
export default class PersonalDataReader {
|
|
3
|
-
static get(
|
|
4
|
+
static get(queryOptions: QueryOptions): Promise<PersonalDataI>;
|
|
4
5
|
private static correctPersonalData;
|
|
5
6
|
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
1
2
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
3
|
import correctPhoneNumber from "../utils/correctPhoneNumber";
|
|
3
4
|
import CompanyDetailsReader from "./CompanyDetailsReader";
|
|
4
5
|
export default class PersonalDataReader {
|
|
5
|
-
static async get(
|
|
6
|
-
const personalDataRow = await DatabaseConnection.getInstance().personalData.select(
|
|
6
|
+
static async get(queryOptions) {
|
|
7
|
+
const personalDataRow = await DatabaseConnection.getInstance().personalData.select(queryOptions);
|
|
7
8
|
const personalData = this.correctPersonalData(personalDataRow);
|
|
8
9
|
if (personalDataRow.company_details_id) {
|
|
9
|
-
|
|
10
|
+
const queryOptions = new QueryOptions();
|
|
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
17
|
personalData.isCompany = true;
|
|
11
18
|
}
|
|
12
19
|
return personalData;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
2
2
|
import ProductI from "../types/ProductI";
|
|
3
3
|
export default class ProductReader {
|
|
4
|
-
static get(
|
|
5
|
-
static
|
|
6
|
-
static
|
|
7
|
-
static
|
|
8
|
-
static
|
|
4
|
+
static get(queryOption: QueryOptions): Promise<ProductI>;
|
|
5
|
+
static getAll(queryOption: QueryOptions): Promise<ProductI[]>;
|
|
6
|
+
static getId(queryOptions: QueryOptions): Promise<number>;
|
|
7
|
+
static getQuantity(queryOptions: QueryOptions): Promise<number>;
|
|
8
|
+
static getMaxPrice(queryOptions: QueryOptions): Promise<number>;
|
|
9
9
|
private static correctProducts;
|
|
10
10
|
private static correctProduct;
|
|
11
11
|
}
|
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
2
2
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
3
3
|
import FilesReader from "./FilesReader";
|
|
4
4
|
import DatabaseConnection from "../DatabaseConnection";
|
|
5
|
+
import FileConnectionTypeE from "../types/FileConnectionTypeE";
|
|
5
6
|
export default class ProductReader {
|
|
6
|
-
static async get(
|
|
7
|
-
const product = await DatabaseConnection.getInstance().products.select(
|
|
8
|
-
const
|
|
9
|
-
|
|
7
|
+
static async get(queryOption) {
|
|
8
|
+
const product = await DatabaseConnection.getInstance().products.select(queryOption);
|
|
9
|
+
const queryOptionsFiles = new QueryOptions();
|
|
10
|
+
queryOptionsFiles.setWhere([{ name: 'connection_id', type: ParameterType.bigint, value: product.id }, { name: 'connection_type', type: ParameterType.string, value: FileConnectionTypeE.product }]);
|
|
11
|
+
queryOptionsFiles.setOrderBy([{ key: 'sequence', order: 'asc' }]);
|
|
12
|
+
const files = await FilesReader.getForConnection(queryOptionsFiles);
|
|
13
|
+
return { ...this.correctProduct(product), files };
|
|
10
14
|
}
|
|
11
|
-
static async
|
|
12
|
-
const
|
|
13
|
-
const files = await FilesReader.getForConnection(FileConnectionTypeE.product, product.id);
|
|
14
|
-
return this.correctProduct(product, files);
|
|
15
|
-
}
|
|
16
|
-
static async getAllActive(queryOptions) {
|
|
17
|
-
const products = await DatabaseConnection.getInstance().products.selectAllActive(queryOptions);
|
|
15
|
+
static async getAll(queryOption) {
|
|
16
|
+
const products = await DatabaseConnection.getInstance().products.selectAll(queryOption);
|
|
18
17
|
return this.correctProducts(products);
|
|
19
18
|
}
|
|
20
|
-
static async
|
|
21
|
-
return await DatabaseConnection.getInstance().products.
|
|
19
|
+
static async getId(queryOptions) {
|
|
20
|
+
return await DatabaseConnection.getInstance().products.selectId(queryOptions);
|
|
22
21
|
}
|
|
23
22
|
static async getQuantity(queryOptions) {
|
|
24
23
|
const quantity = await DatabaseConnection.getInstance().products.count(queryOptions);
|
|
25
24
|
return quantity;
|
|
26
25
|
}
|
|
26
|
+
static async getMaxPrice(queryOptions) {
|
|
27
|
+
const price = await DatabaseConnection.getInstance().products.selectMaxPrice(queryOptions);
|
|
28
|
+
return price;
|
|
29
|
+
}
|
|
27
30
|
static async correctProducts(products) {
|
|
28
31
|
const correctProducts = [];
|
|
29
32
|
for (let i = 0; i < products.length; i++) {
|
|
@@ -32,8 +35,10 @@ export default class ProductReader {
|
|
|
32
35
|
}
|
|
33
36
|
return correctProducts;
|
|
34
37
|
}
|
|
35
|
-
static async correctProduct(product
|
|
36
|
-
const
|
|
38
|
+
static async correctProduct(product) {
|
|
39
|
+
const queryOptions = new QueryOptions();
|
|
40
|
+
queryOptions.setWhere([{ name: 'id', type: ParameterType.bigint, value: product.file_id }]);
|
|
41
|
+
const thumbnail = await FilesReader.get(queryOptions);
|
|
37
42
|
return {
|
|
38
43
|
id: product.id,
|
|
39
44
|
sku: product.sku,
|
|
@@ -50,7 +55,6 @@ export default class ProductReader {
|
|
|
50
55
|
createdAt: product.created_at,
|
|
51
56
|
deleted: product.deleted,
|
|
52
57
|
thumbnail: thumbnail ? thumbnail : null,
|
|
53
|
-
files,
|
|
54
58
|
grossPrice: calculateNetToGrossPrice(product.net_price, product.vat),
|
|
55
59
|
jsonData: product.json_data
|
|
56
60
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
export default class PaymentDetailsReader {
|
|
2
|
-
static get(
|
|
3
|
-
static getPaymentOrderId(paymentDetailsId: number): Promise<any>;
|
|
3
|
+
static get(queryOptions: QueryOptions): Promise<any>;
|
|
4
4
|
private static correctPaymentDetails;
|
|
5
5
|
}
|
|
@@ -1,20 +1,29 @@
|
|
|
1
|
+
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
1
2
|
import DatabaseConnection from "../../DatabaseConnection";
|
|
2
3
|
import PaymentMethodReader from "./PaymentMethodReader";
|
|
3
4
|
import PaymentStatusesReader from "./PaymentStatusesReader";
|
|
4
5
|
export default class PaymentDetailsReader {
|
|
5
|
-
static async get(
|
|
6
|
-
const paymentDetails = await DatabaseConnection.getInstance().paymentDetails.select(
|
|
6
|
+
static async get(queryOptions) {
|
|
7
|
+
const paymentDetails = await DatabaseConnection.getInstance().paymentDetails.select(queryOptions);
|
|
7
8
|
return await this.correctPaymentDetails(paymentDetails);
|
|
8
9
|
}
|
|
9
|
-
static async getPaymentOrderId(paymentDetailsId) {
|
|
10
|
-
const paymentDetails = await DatabaseConnection.getInstance().paymentDetails.select(paymentDetailsId);
|
|
11
|
-
return paymentDetails.payment_order_id;
|
|
12
|
-
}
|
|
13
10
|
static async correctPaymentDetails(paymentDetails) {
|
|
14
11
|
const id = paymentDetails.id;
|
|
12
|
+
const queryOptionsForPaymentMethod = new QueryOptions();
|
|
13
|
+
queryOptionsForPaymentMethod.setWhere([{
|
|
14
|
+
name: 'id',
|
|
15
|
+
type: ParameterType.bigint,
|
|
16
|
+
value: paymentDetails.payment_method_id
|
|
17
|
+
}]);
|
|
18
|
+
const queryOptionsForPaymentStatus = new QueryOptions();
|
|
19
|
+
queryOptionsForPaymentStatus.setWhere([{
|
|
20
|
+
name: 'peyment_details_id',
|
|
21
|
+
type: ParameterType.bigint,
|
|
22
|
+
value: paymentDetails.id
|
|
23
|
+
}]);
|
|
15
24
|
const [paymentMethod, statuses] = await Promise.all([
|
|
16
|
-
PaymentMethodReader.get(
|
|
17
|
-
PaymentStatusesReader.getAll(
|
|
25
|
+
PaymentMethodReader.get(queryOptionsForPaymentMethod),
|
|
26
|
+
PaymentStatusesReader.getAll(queryOptionsForPaymentStatus)
|
|
18
27
|
]);
|
|
19
28
|
return {
|
|
20
29
|
id,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
import PaymentMethodI from "../../types/PaymentMethodI";
|
|
2
3
|
export default class PaymentMethodReader {
|
|
3
|
-
static get(
|
|
4
|
-
static getAll(): Promise<PaymentMethodI[]>;
|
|
5
|
-
static getAllActive(): Promise<PaymentMethodI[]>;
|
|
4
|
+
static get(queryOptions: QueryOptions): Promise<PaymentMethodI>;
|
|
5
|
+
static getAll(queryOptions: QueryOptions): Promise<PaymentMethodI[]>;
|
|
6
6
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import DatabaseConnection from "../../DatabaseConnection";
|
|
2
2
|
export default class PaymentMethodReader {
|
|
3
|
-
static async get(
|
|
4
|
-
const paymentMethod = await DatabaseConnection.getInstance().paymentMethods.select(
|
|
3
|
+
static async get(queryOptions) {
|
|
4
|
+
const paymentMethod = await DatabaseConnection.getInstance().paymentMethods.select(queryOptions);
|
|
5
5
|
return paymentMethod;
|
|
6
6
|
}
|
|
7
|
-
static async getAll() {
|
|
8
|
-
const paymentMethods = await DatabaseConnection.getInstance().paymentMethods.selectAll();
|
|
9
|
-
return paymentMethods;
|
|
10
|
-
}
|
|
11
|
-
static async getAllActive() {
|
|
12
|
-
const paymentMethods = await DatabaseConnection.getInstance().paymentMethods.selectAllActive();
|
|
7
|
+
static async getAll(queryOptions) {
|
|
8
|
+
const paymentMethods = await DatabaseConnection.getInstance().paymentMethods.selectAll(queryOptions);
|
|
13
9
|
return paymentMethods;
|
|
14
10
|
}
|
|
15
11
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
export default class PaymentStatusesReader {
|
|
2
|
-
static get(
|
|
3
|
-
static getAll(
|
|
3
|
+
static get(queryOptions: QueryOptions): Promise<any>;
|
|
4
|
+
static getAll(queryOptions: QueryOptions): Promise<any[]>;
|
|
4
5
|
private static correctPaymentStatus;
|
|
5
6
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
1
2
|
import DatabaseConnection from "../../DatabaseConnection";
|
|
2
3
|
export default class PaymentStatusesReader {
|
|
3
|
-
static async get(
|
|
4
|
-
const paymentStatus = await DatabaseConnection.getInstance().paymentStatuses.select(
|
|
4
|
+
static async get(queryOptions) {
|
|
5
|
+
const paymentStatus = await DatabaseConnection.getInstance().paymentStatuses.select(queryOptions);
|
|
5
6
|
if (paymentStatus)
|
|
6
7
|
return await this.correctPaymentStatus(paymentStatus);
|
|
7
8
|
else
|
|
8
9
|
return {};
|
|
9
10
|
}
|
|
10
|
-
static async getAll(
|
|
11
|
-
const paymentStatusesData = await DatabaseConnection.getInstance().paymentStatuses.selectAll(
|
|
11
|
+
static async getAll(queryOptions) {
|
|
12
|
+
const paymentStatusesData = await DatabaseConnection.getInstance().paymentStatuses.selectAll(queryOptions);
|
|
12
13
|
const paymentStatuses = [];
|
|
13
14
|
for (let i = 0; i < paymentStatusesData.length; i++) {
|
|
14
15
|
const paymentStatus = await this.correctPaymentStatus(paymentStatusesData[i]);
|
|
@@ -17,7 +18,9 @@ export default class PaymentStatusesReader {
|
|
|
17
18
|
return paymentStatuses;
|
|
18
19
|
}
|
|
19
20
|
static async correctPaymentStatus(paymentStatus) {
|
|
20
|
-
const
|
|
21
|
+
const queryOptions = new QueryOptions();
|
|
22
|
+
queryOptions.setWhere([{ name: 'id', type: ParameterType.bigint, value: paymentStatus.payment_status_type_id }]);
|
|
23
|
+
const paymentStatusType = await DatabaseConnection.getInstance().paymentStatusTypes.select(queryOptions);
|
|
21
24
|
return {
|
|
22
25
|
id: paymentStatus.id,
|
|
23
26
|
type: paymentStatusType,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
import Address from "../stockObjects/Address";
|
|
2
3
|
export default class AddressesRepo {
|
|
3
|
-
static get(
|
|
4
|
+
static get(queryOptions: QueryOptions): Promise<Address>;
|
|
4
5
|
private static createAddressFromRow;
|
|
5
6
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import Address from "../stockObjects/Address";
|
|
3
3
|
export default class AddressesRepo {
|
|
4
|
-
static async get(
|
|
5
|
-
const address = await DatabaseConnection.getInstance().addresses.select(
|
|
4
|
+
static async get(queryOptions) {
|
|
5
|
+
const address = await DatabaseConnection.getInstance().addresses.select(queryOptions);
|
|
6
6
|
return this.createAddressFromRow(address);
|
|
7
7
|
}
|
|
8
8
|
static createAddressFromRow(dataRow) {
|
package/dist/repo/AdminRepo.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
2
2
|
import Admin from "../stockObjects/Admin";
|
|
3
3
|
export default class AdminRepo {
|
|
4
|
-
static get(
|
|
5
|
-
static
|
|
6
|
-
static getAll(queryOptions:
|
|
4
|
+
static get(queryOptions: QueryOptions): Promise<Admin>;
|
|
5
|
+
static getId(queryOptions: QueryOptions): Promise<number>;
|
|
6
|
+
static getAll(queryOptions: QueryOptions): Promise<{
|
|
7
7
|
adminAccounts: Admin[];
|
|
8
8
|
quantity: number;
|
|
9
9
|
}>;
|
package/dist/repo/AdminRepo.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import Admin from "../stockObjects/Admin";
|
|
3
3
|
export default class AdminRepo {
|
|
4
|
-
static async get(
|
|
5
|
-
const account = await DatabaseConnection.getInstance().adminAccounts.select(
|
|
4
|
+
static async get(queryOptions) {
|
|
5
|
+
const account = await DatabaseConnection.getInstance().adminAccounts.select(queryOptions);
|
|
6
6
|
return this.createAdminFromRow(account);
|
|
7
7
|
}
|
|
8
|
-
static async
|
|
9
|
-
return await DatabaseConnection.getInstance().adminAccounts.
|
|
8
|
+
static async getId(queryOptions) {
|
|
9
|
+
return await DatabaseConnection.getInstance().adminAccounts.selectId(queryOptions);
|
|
10
10
|
}
|
|
11
11
|
static async getAll(queryOptions) {
|
|
12
12
|
const adminAccounts = await DatabaseConnection.getInstance().adminAccounts.selectAll(queryOptions);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
import Client from "../stockObjects/Client";
|
|
2
3
|
export default class ClientAccountRepo {
|
|
3
|
-
static get(
|
|
4
|
-
static getById(clientId: number): Promise<Client>;
|
|
5
|
-
static getEmailForId(clientId: number): Promise<string>;
|
|
4
|
+
static get(queryOptions: QueryOptions): Promise<Client>;
|
|
6
5
|
private static createCilentAccountFromRow;
|
|
7
6
|
}
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import Client from "../stockObjects/Client";
|
|
3
3
|
export default class ClientAccountRepo {
|
|
4
|
-
static async get(
|
|
5
|
-
const accountData = await DatabaseConnection.getInstance().clientAccounts.select(
|
|
4
|
+
static async get(queryOptions) {
|
|
5
|
+
const accountData = await DatabaseConnection.getInstance().clientAccounts.select(queryOptions);
|
|
6
6
|
return this.createCilentAccountFromRow(accountData);
|
|
7
7
|
}
|
|
8
|
-
static async getById(clientId) {
|
|
9
|
-
const client = await DatabaseConnection.getInstance().clientAccounts.select(clientId);
|
|
10
|
-
return this.createCilentAccountFromRow(client);
|
|
11
|
-
}
|
|
12
|
-
static async getEmailForId(clientId) {
|
|
13
|
-
const email = await DatabaseConnection.getInstance().clientAccounts.selectEmail(clientId);
|
|
14
|
-
return email;
|
|
15
|
-
}
|
|
16
8
|
static createCilentAccountFromRow(accountData) {
|
|
17
9
|
const client = new Client(accountData.email, accountData.activated, accountData.deleted, accountData.contact_details_id, accountData.delivery_details_id, accountData.invoice_details_id, accountData.created_at);
|
|
18
10
|
client.setId(accountData.id);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
import CompanyDetails from "../stockObjects/CompanyDetails";
|
|
2
3
|
export default class CompanyDetailsRepo {
|
|
3
|
-
static get(
|
|
4
|
+
static get(queryOptions: QueryOptions): Promise<CompanyDetails>;
|
|
4
5
|
private static createCompanyDetailsFromRow;
|
|
5
6
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import CompanyDetails from "../stockObjects/CompanyDetails";
|
|
3
3
|
export default class CompanyDetailsRepo {
|
|
4
|
-
static async get(
|
|
5
|
-
const companyDetailsRow = await DatabaseConnection.getInstance().companyDetails.select(
|
|
4
|
+
static async get(queryOptions) {
|
|
5
|
+
const companyDetailsRow = await DatabaseConnection.getInstance().companyDetails.select(queryOptions);
|
|
6
6
|
return this.createCompanyDetailsFromRow(companyDetailsRow);
|
|
7
7
|
}
|
|
8
8
|
static createCompanyDetailsFromRow(companyDetailsRow) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
import ContactDetails from "../stockObjects/ContactDetails";
|
|
2
3
|
export default class ContactDetailsRepo {
|
|
3
|
-
static get(
|
|
4
|
+
static get(queryOptions: QueryOptions): Promise<ContactDetails>;
|
|
4
5
|
static getNextId(): Promise<number>;
|
|
5
6
|
private static createContactDetailsFromRow;
|
|
6
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import ContactDetails from "../stockObjects/ContactDetails";
|
|
3
3
|
export default class ContactDetailsRepo {
|
|
4
|
-
static async get(
|
|
5
|
-
const contactDetailsRow = await DatabaseConnection.getInstance().contactDetails.select(
|
|
4
|
+
static async get(queryOptions) {
|
|
5
|
+
const contactDetailsRow = await DatabaseConnection.getInstance().contactDetails.select(queryOptions);
|
|
6
6
|
return this.createContactDetailsFromRow(contactDetailsRow);
|
|
7
7
|
}
|
|
8
8
|
static async getNextId() {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
import DeliveryDetails from "../stockObjects/DeliveryDetails";
|
|
2
3
|
export default class DeliveryDetailsRepo {
|
|
3
|
-
static get(
|
|
4
|
+
static get(queryOptions: QueryOptions): Promise<DeliveryDetails>;
|
|
4
5
|
private static createDeliveryDetailsFromRow;
|
|
5
6
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import DeliveryDetails from "../stockObjects/DeliveryDetails";
|
|
3
3
|
export default class DeliveryDetailsRepo {
|
|
4
|
-
static async get(
|
|
5
|
-
const deliveryDetailsRow = await DatabaseConnection.getInstance().deliveryDetails.select(
|
|
4
|
+
static async get(queryOptions) {
|
|
5
|
+
const deliveryDetailsRow = await DatabaseConnection.getInstance().deliveryDetails.select(queryOptions);
|
|
6
6
|
return this.createDeliveryDetailsFromRow(deliveryDetailsRow);
|
|
7
7
|
}
|
|
8
8
|
static createDeliveryDetailsFromRow(deliveryDetailsRow) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
import DeliveryMethods from "../stockObjects/DeliveryMethods";
|
|
2
3
|
export default class DeliveryMethodRepo {
|
|
3
|
-
static get(
|
|
4
|
+
static get(queryOptions: QueryOptions): Promise<DeliveryMethods>;
|
|
4
5
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import DeliveryMethods from "../stockObjects/DeliveryMethods";
|
|
3
3
|
export default class DeliveryMethodRepo {
|
|
4
|
-
static async get(
|
|
5
|
-
const deliveryMethodsRow = await DatabaseConnection.getInstance().deliveryMethods.select(
|
|
4
|
+
static async get(queryOptions) {
|
|
5
|
+
const deliveryMethodsRow = await DatabaseConnection.getInstance().deliveryMethods.select(queryOptions);
|
|
6
6
|
const deliveryMethods = new DeliveryMethods(deliveryMethodsRow.key, deliveryMethodsRow.active);
|
|
7
7
|
deliveryMethods.setId(deliveryMethodsRow.id);
|
|
8
8
|
return deliveryMethods;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
import FileConnection from "../stockObjects/FileConnection";
|
|
2
3
|
export default class FileConnectionsRepo {
|
|
3
|
-
static
|
|
4
|
-
static
|
|
4
|
+
static getAll(queryOptions: QueryOptions): Promise<FileConnection[]>;
|
|
5
|
+
static delete(id: number): Promise<boolean>;
|
|
5
6
|
private static correctFileConnections;
|
|
6
7
|
private static correctFileConnection;
|
|
7
8
|
}
|