@dascompany/database 0.0.8 → 1.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 +10 -17
- package/dist/index.d.ts +74 -54
- package/dist/index.js +55 -48
- package/dist/reader/DeliveryDetailsReader.js +1 -6
- package/dist/reader/FilesReader.js +1 -0
- package/dist/reader/OrderProductsReader.d.ts +2 -5
- package/dist/reader/OrderProductsReader.js +15 -56
- package/dist/reader/OrderReader.js +11 -9
- package/dist/reader/OrderStatusReader.d.ts +1 -1
- package/dist/reader/OrderStatusReader.js +4 -3
- package/dist/reader/ProductReader.d.ts +2 -4
- package/dist/reader/ProductReader.js +14 -33
- package/dist/repo/OrderProductsRepo.d.ts +1 -1
- package/dist/repo/OrderProductsRepo.js +2 -2
- package/dist/repo/OrderStatusRepo.js +2 -2
- package/dist/repo/ProductRepo.js +0 -1
- package/dist/stockObjects/Order.js +10 -5
- package/dist/tables/orders/OrdersProductsTable.d.ts +2 -4
- package/dist/tables/orders/OrdersProductsTable.js +2 -14
- package/dist/tables/orders/StatusesTable.d.ts +2 -3
- package/dist/tables/orders/StatusesTable.js +5 -11
- package/dist/tables/public/ProductsTable.d.ts +4 -5
- package/dist/tables/public/ProductsTable.js +18 -27
- package/dist/types/DeliveryDetailsI.d.ts +2 -1
- package/dist/types/OrderProductI.d.ts +0 -1
- package/dist/types/ProductI.d.ts +0 -2
- package/dist/types/StatusI.d.ts +3 -1
- package/dist/types/rows/OrderProductRow.d.ts +4 -0
- package/dist/utils/parameters/ParameterFilterSystem.js +9 -5
- package/package.json +1 -1
- package/dist/types/OrderStatusI.d.ts +0 -7
- package/dist/types/OrderStatusI.js +0 -1
package/dist/SQL.json
CHANGED
|
@@ -40,8 +40,6 @@
|
|
|
40
40
|
},
|
|
41
41
|
"addresses": {
|
|
42
42
|
"select": "SELECT id, country, city, postal_code, street, house_number, apartment_number FROM personal_information.addresses WHERE id = $id::BIGINT",
|
|
43
|
-
"selectTypes": "SELECT type FROM personal_information.addresses WHERE account_id = $account_id::BIGINT",
|
|
44
|
-
"selectId": "SELECT id FROM personal_information.addresses WHERE account_id = $account_id::BIGINT AND type = $type::SMALLINT",
|
|
45
43
|
"insert": "INSERT INTO personal_information.addresses( id, country, city, postal_code, street, house_number, apartment_number) VALUES( $id::BIGINT, $country::TEXT, $city::TEXT, $postal_code::TEXT, $street::TEXT, $house_number::TEXT, $apartment_number::TEXT) ",
|
|
46
44
|
"update": "UPDATE personal_information.addresses SET country = $country::TEXT, city = $city::TEXT, postal_code = $postal_code::TEXT , street = $street::TEXT , house_number = $house_number::TEXT , apartment_number = $apartment_number::TEXT WHERE id = $id::BIGINT",
|
|
47
45
|
"selectNextId": "SELECT nextval('personal_information.addresses_id'::regclass)"
|
|
@@ -57,20 +55,18 @@
|
|
|
57
55
|
"insert": "INSERT INTO personal_information.company_details( id, name, tax_number ) VALUES ($id::BIGINT, $name::TEXT, $tax_number::TEXT )",
|
|
58
56
|
"update": "UPDATE personal_information.company_details SET name = $name::TEXT, tax_number = $tax_number::TEXT WHERE id = $id::BIGINT",
|
|
59
57
|
"delete": "DELETE FROM personal_information.company_details WHERE id = $id::BIGINT",
|
|
60
|
-
"selectIfIs": "SELECT FROM personal_information.company_details WHERE id = $id::BIGINT",
|
|
61
58
|
"selectNextId": "SELECT nextval('personal_information.company_details_id'::regclass)"
|
|
62
59
|
},
|
|
63
60
|
"products": {
|
|
64
61
|
"select": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products WHERE id = $id::BIGINT",
|
|
65
|
-
"
|
|
66
|
-
"
|
|
62
|
+
"selectForUrl": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products WHERE LOWER( url ) = LOWER($url::TEXT)",
|
|
63
|
+
"selectForSku": "SELECT * FROM products WHERE LOWER( sku ) = LOWER($sku::TEXT)",
|
|
64
|
+
"selectAll": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products $WHERE $ORDERBY LIMIT $limit::BIGINT OFFSET $offset::BIGINT",
|
|
65
|
+
"selectAllActive": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products WHERE deleted = false $PARAMS $ORDERBY LIMIT $limit::BIGINT OFFSET $offset::BIGINT",
|
|
67
66
|
"selectIdForSku": "SELECT id FROM products WHERE LOWER( sku ) = LOWER($sku::TEXT) AND deleted = false",
|
|
68
67
|
"insert": "INSERT INTO products( id, sku, url, title, description, net_price, vat, color, quantity, width, length, height, file_id, deleted) VALUES ($id::BIGINT, $sku::TEXT, $url::TEXT, $title::TEXT, $description::TEXT, $net_price::DOUBLE PRECISION, $vat::INT, $color::TEXT, $quantity::INT, $width::INT, $length::INT, $height::DOUBLE PRECISION,$file_id::BIGINT ,false::BOOL)",
|
|
69
|
-
"update": "UPDATE products SET url = $url::TEXT, title = $title::TEXT
|
|
68
|
+
"update": "UPDATE products SET url = $url::TEXT, title = $title::TEXT, description = $description::TEXT , net_price = $net_price::DOUBLE PRECISION, vat = $vat::INT, color = $color::TEXT, quantity = $quantity::INT, width = $width::INT, length = $length::INT, height = $height::DOUBLE PRECISION, file_id = $file_id::BIGINT WHERE id = $id::BIGINT",
|
|
70
69
|
"delete": "UPDATE products SET deleted = true WHERE id = $id::BIGINT",
|
|
71
|
-
"restore": "UPDATE products SET deleted = false WHERE id = $id::BIGINT",
|
|
72
|
-
"selectForSku": "SELECT * FROM products WHERE LOWER( sku ) = LOWER($sku::TEXT)",
|
|
73
|
-
"selectForUrl": "SELECT id, sku, url, title, description, net_price, vat, color, quantity, width, height, length, file_id, created_at, deleted FROM products WHERE LOWER( url ) = LOWER($url::TEXT)",
|
|
74
70
|
"selectNextId": "SELECT nextval('product_id'::regclass)",
|
|
75
71
|
"count": "SELECT COUNT(*) AS total_rows FROM products WHERE deleted = false $PARAMS"
|
|
76
72
|
},
|
|
@@ -84,18 +80,15 @@
|
|
|
84
80
|
"count": "SELECT COUNT (*) AS TOTAL_ROWS FROM orders.orders as o JOIN orders.statuses as os ON o.id = os.order_id JOIN (SELECT order_id, MAX(id) as max_id FROM orders.statuses GROUP BY order_id) as latest ON os.order_id = latest.order_id AND os.id = latest.max_id $WHERE"
|
|
85
81
|
},
|
|
86
82
|
"ordersProducts": {
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"selectAll": "SELECT * FROM orders.orders_products $WHERE",
|
|
90
|
-
"getAllActiveForOrderId": "SELECT * FROM orders.orders_products WHERE order_id = $order_id::BIGINT and in_order = true",
|
|
83
|
+
"selectAll": "SELECT op.id, order_id, product_id, title, sku, vat, p.file_id, op.net_price FROM orders.orders_products WHERE order_id = $order_id::BIGINT",
|
|
84
|
+
"selectAllActive": "SELECT op.id, order_id, product_id, title, sku, vat, p.file_id, op.net_price FROM orders.orders_products as op JOIN products as p ON op.product_id = p.id WHERE order_id = $order_id::BIGINT and in_order = true",
|
|
91
85
|
"insert": "INSERT INTO orders.orders_products( id, order_id, product_id, net_price ) VALUES ( $id::BIGINT , $order_id::BIGINT, $product_id::BIGINT, $net_price::DOUBLE PRECISION )",
|
|
92
86
|
"selectNextId": "SELECT nextval('orders.orders_products_id'::regclass)",
|
|
93
87
|
"delete": "UPDATE orders.orders_products SET in_order = false WHERE id = $id::BIGINT"
|
|
94
88
|
},
|
|
95
89
|
"statuses": {
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"selectAllForOrder": "SELECT s.id, order_id, created_at, user_id, st.key as type FROM orders.statuses as s JOIN orders.status_types as st ON s.type = st.id WHERE order_id = $order_id::BIGINT ORDER BY s.id DESC",
|
|
90
|
+
"select": "SELECT s.id, s.order_id, created_at, user_id, s.type as type_id, st.key as type_name FROM orders.statuses as s JOIN orders.status_types as st ON s.type = st.id WHERE s.order_id = $order_id::BIGINT ORDER BY s.id DESC LIMIT 1",
|
|
91
|
+
"selectAll": "SELECT s.id, s.order_id, created_at, user_id, s.type as type_id, st.key as type_name FROM orders.statuses as s JOIN orders.status_types as st ON s.type = st.id WHERE order_id = $order_id::BIGINT ORDER BY s.id DESC",
|
|
99
92
|
"insert": "INSERT INTO orders.statuses( id, type, order_id, user_id ) VALUES ($id::BIGINT, $type::BIGINT, $order_id::BIGINT, $user_id::BIGINT)",
|
|
100
93
|
"selectNextId": "SELECT nextval('orders.statuses_id'::regclass)"
|
|
101
94
|
},
|
|
@@ -109,7 +102,7 @@
|
|
|
109
102
|
"selectId": "SELECT id FROM files.files $WHERE",
|
|
110
103
|
"selectAll": "SELECT f.id, f.name, f.orginal_name, f.catalog, f.size_kb, f.type, f.created_at FROM files.files as f $WHERE $ORDERBY",
|
|
111
104
|
"select": "SELECT id, name, orginal_name, catalog, size_kb, type, created_at FROM files.files WHERE id = $id::BIGINT",
|
|
112
|
-
"selectForConnection": "SELECT id, name, catalog, type FROM files.files JOIN files.file_connections ON file_id = id WHERE connection_type = $connection_type::TEXT AND connection_id = $connection_id::BIGINT ORDER BY sequence",
|
|
105
|
+
"selectForConnection": "SELECT id, name, catalog, type, sequence FROM files.files JOIN files.file_connections ON file_id = id WHERE connection_type = $connection_type::TEXT AND connection_id = $connection_id::BIGINT ORDER BY sequence",
|
|
113
106
|
"selectNextId": "SELECT nextval('files.files_id'::regclass)",
|
|
114
107
|
"insert": "INSERT INTO files.files( id, name, orginal_name, catalog, size_kb, type, created_at ) VALUES ( $id::BIGINT, $name::TEXT, $orginal_name::TEXT, $catalog::TEXT, $size_kb::BIGINT, $type::TEXT, now() )",
|
|
115
108
|
"update": "UPDATE files.files SET name = $name::TEXT, orginal_name = $orginal_name::TEXT, catalog = $catalog::TEXT, size_kb = $size_kb::BIGINT, type = $type::TEXT WHERE id = $id::BIGINT ",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,71 +1,91 @@
|
|
|
1
1
|
import DatabaseConnection from "./DatabaseConnection";
|
|
2
2
|
import StockObject from "./types/StockObject";
|
|
3
3
|
import StockObjectMapper from "./types/StockObjectMapper";
|
|
4
|
-
import
|
|
4
|
+
import Table from "./Table";
|
|
5
|
+
import Query from "./query/Query";
|
|
6
|
+
import TableConnection from './TableConnection';
|
|
7
|
+
import ParameterType from './types/parameters/ParameterType';
|
|
8
|
+
import ParameterFilter from './types/parameters/ParameterFilter';
|
|
9
|
+
import ConnectorE from './types/ConnectorE';
|
|
10
|
+
import ParameterI from './types/ParameterI';
|
|
11
|
+
import QueryOptionsI from './types/QueryOptionsI';
|
|
12
|
+
import ResultLimitationI from './types/ResultLimitationI';
|
|
13
|
+
import Parameters from './utils/Parameters';
|
|
14
|
+
import OrderByI from "./utils/OrderByI";
|
|
15
|
+
import QueryOptions from './query/QueryOptions';
|
|
16
|
+
import Client from "./stockObjects/Client";
|
|
17
|
+
import ClientAccountRepo from "./repo/ClientAccountRepo";
|
|
5
18
|
import ClientAccountReader from "./reader/ClientAccountReader";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import InvoiceDetailsReader from "./reader/InvoiceDetailsReader";
|
|
11
|
-
import OrderProductsReader from "./reader/OrderProductsReader";
|
|
12
|
-
import OrderReader from "./reader/OrderReader";
|
|
13
|
-
import FilesReader from './reader/FilesReader';
|
|
14
|
-
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
15
|
-
import OrderStatusRepo from "./repo/OrderStatusRepo";
|
|
16
|
-
import PaymentDetailsReader from "./reader/payment/PaymentDetailsReader";
|
|
17
|
-
import PaymentMethodReader from "./reader/payment/PaymentMethodReader";
|
|
18
|
-
import PaymentStatusesReader from "./reader/payment/PaymentStatusesReader";
|
|
19
|
-
import PersonalDataReader from "./reader/PersonalDataReader";
|
|
20
|
-
import ProductReader from "./reader/ProductReader";
|
|
19
|
+
import Admin from "./stockObjects/Admin";
|
|
20
|
+
import AdminRepo from './repo/AdminRepo';
|
|
21
|
+
import Address from "./stockObjects/Address";
|
|
22
|
+
import AddressI from "./types/AddressI";
|
|
21
23
|
import AddressesRepo from "./repo/AddressesRepo";
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import CompanyDataRepo from "./repo/CompanyDataRepo";
|
|
25
|
-
import ContactDetailsRepo from "./repo/ContactDetailsRepo";
|
|
26
|
-
import DeliveryDetailsRepo from "./repo/DeliveryDetailsRepo";
|
|
27
|
-
import InvoiceDetailsRepo from "./repo/InvoiceDetailsRepo";
|
|
28
|
-
import OrderRepo from "./repo/OrderRepo";
|
|
29
|
-
import PaymentDetailsRepo from "./repo/PaymentDetailsRepo";
|
|
24
|
+
import AddressesReader from "./reader/AddressesReader";
|
|
25
|
+
import PersonalData from "./stockObjects/PersonalData";
|
|
30
26
|
import PersonalDataRepo from "./repo/PersonalDataRepo";
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import Address from "./stockObjects/Address";
|
|
34
|
-
import Admin from "./stockObjects/Admin";
|
|
27
|
+
import PersonalDataReader from "./reader/PersonalDataReader";
|
|
28
|
+
import PersonalDataI from "./types/PersonalDataI";
|
|
35
29
|
import CompanyDetails from "./stockObjects/CompanyDetails";
|
|
30
|
+
import CompanyDetailsRepo from "./repo/CompanyDetailsRepo";
|
|
31
|
+
import CompanyDetailsReader from "./reader/CompanyDetailsReader";
|
|
32
|
+
import CompanyDetailsI from "./types/CompanyDetailsI";
|
|
36
33
|
import ContactDetails from "./stockObjects/ContactDetails";
|
|
34
|
+
import ContactDetailsRepo from "./repo/ContactDetailsRepo";
|
|
35
|
+
import ContactDetailsReader from "./reader/ContactDetailsReader";
|
|
36
|
+
import ContactDetailsI from "./types/ContactDetailsI";
|
|
37
37
|
import DeliveryDetails from "./stockObjects/DeliveryDetails";
|
|
38
|
+
import DeliveryDetailsRepo from "./repo/DeliveryDetailsRepo";
|
|
39
|
+
import DeliveryDetailsReader from "./reader/DeliveryDetailsReader";
|
|
40
|
+
import DeliveryDetailsI from "./types/DeliveryDetailsI";
|
|
41
|
+
import DeliveryMethods from "./stockObjects/DeliveryMethods";
|
|
42
|
+
import DeliveryMethodRepo from './repo/DeliveryMethodRepo';
|
|
43
|
+
import DeliveryMethodReader from "./reader/DeliveryMethodReader";
|
|
44
|
+
import DeliveryMethodI from "./types/DeliveryMethodI";
|
|
38
45
|
import DeliveryStatus from "./stockObjects/DeliveryStatus";
|
|
46
|
+
import DeliveryStatusReader from './reader/DeliveryStatusReader';
|
|
39
47
|
import InvoiceDetails from "./stockObjects/InvoiceDetails";
|
|
40
|
-
import
|
|
41
|
-
import
|
|
48
|
+
import InvoiceDetailsRepo from "./repo/InvoiceDetailsRepo";
|
|
49
|
+
import InvoiceDetailsReader from "./reader/InvoiceDetailsReader";
|
|
50
|
+
import InvoiceDetailsI from "./types/InvoiceDetailsI";
|
|
42
51
|
import PaymentDetails from "./stockObjects/PaymentDetails";
|
|
52
|
+
import PaymentDetailsRepo from "./repo/PaymentDetailsRepo";
|
|
53
|
+
import PaymentDetailsReader from "./reader/payment/PaymentDetailsReader";
|
|
54
|
+
import PaymentDetailsI from "./types/PaymentDetailsI";
|
|
55
|
+
import PaymentMethods from "./stockObjects/PaymentMethods";
|
|
56
|
+
import PaymentMethodRepo from './repo/PaymentMethodRepo';
|
|
57
|
+
import PaymentMethodReader from "./reader/payment/PaymentMethodReader";
|
|
58
|
+
import PaymentMethodE from "./types/PaymentMethodE";
|
|
59
|
+
import PaymentMethodI from "./types/PaymentMethodI";
|
|
43
60
|
import PaymentStatus from "./stockObjects/PaymentStatus";
|
|
44
|
-
import
|
|
45
|
-
import Product from "./stockObjects/Product";
|
|
46
|
-
import Status from "./stockObjects/Status";
|
|
47
|
-
import Client from "./stockObjects/Client";
|
|
48
|
-
import AdminRepo from './repo/AdminRepo';
|
|
49
|
-
import TableConnection from './TableConnection';
|
|
50
|
-
import ParameterType from './types/parameters/ParameterType';
|
|
51
|
-
import DeliveryStatusReader from './reader/DeliveryStatusReader';
|
|
52
|
-
import ConnectorE from './types/ConnectorE';
|
|
53
|
-
import ParameterI from './types/ParameterI';
|
|
54
|
-
import QueryOptionsI from './types/QueryOptionsI';
|
|
55
|
-
import ResultLimitationI from './types/ResultLimitationI';
|
|
56
|
-
import ParameterFilter from './types/parameters/ParameterFilter';
|
|
61
|
+
import PaymentStatusesReader from "./reader/payment/PaymentStatusesReader";
|
|
57
62
|
import PaymentStatusE from './types/PaymentStatusE';
|
|
63
|
+
import Order from "./stockObjects/Order";
|
|
64
|
+
import OrderRepo from "./repo/OrderRepo";
|
|
65
|
+
import OrderReader from "./reader/OrderReader";
|
|
66
|
+
import OrderProduct from "./stockObjects/OrderProduct";
|
|
67
|
+
import OrderProductsRepo from "./repo/OrderProductsRepo";
|
|
68
|
+
import OrderProductsReader from "./reader/OrderProductsReader";
|
|
58
69
|
import OrderProductI from './types/OrderProductI';
|
|
59
|
-
import
|
|
60
|
-
import
|
|
61
|
-
import
|
|
62
|
-
import
|
|
63
|
-
import
|
|
64
|
-
import
|
|
65
|
-
import
|
|
66
|
-
import
|
|
70
|
+
import Status from "./stockObjects/Status";
|
|
71
|
+
import OrderStatusRepo from "./repo/OrderStatusRepo";
|
|
72
|
+
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
73
|
+
import StatusI from "./types/StatusI";
|
|
74
|
+
import ProductI from './types/ProductI';
|
|
75
|
+
import Product from "./stockObjects/Product";
|
|
76
|
+
import ProductRepo from "./repo/ProductRepo";
|
|
77
|
+
import ProductReader from "./reader/ProductReader";
|
|
67
78
|
import File from './stockObjects/File';
|
|
68
|
-
import
|
|
69
|
-
import
|
|
79
|
+
import FilesRepo from './repo/FilesRepo';
|
|
80
|
+
import FilesReader from './reader/FilesReader';
|
|
81
|
+
import FileI from "./types/FileI";
|
|
82
|
+
import FileConnection from "./stockObjects/FileConnection";
|
|
83
|
+
import FileConnectionsRepo from "./repo/FileConnectionsRepo";
|
|
84
|
+
import FileConnectionsReader from "./reader/FileConnectionsReader";
|
|
70
85
|
import FileConnectionTypeE from './types/FileConnectionTypeE';
|
|
71
|
-
|
|
86
|
+
import CompanyData from "./stockObjects/CompanyData";
|
|
87
|
+
import CompanyDataRepo from "./repo/CompanyDataRepo";
|
|
88
|
+
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
89
|
+
import CompanyDataI from "./types/CompanyDataI";
|
|
90
|
+
import StatusTypesReader from './reader/StatusTypesReader';
|
|
91
|
+
export { DatabaseConnection, StockObject, StockObjectMapper, Table, Query, TableConnection, ParameterType, ParameterFilter, ConnectorE, ParameterI, QueryOptionsI, ResultLimitationI, Parameters, OrderByI, QueryOptions, Client, ClientAccountRepo, ClientAccountReader, Admin, AdminRepo, Address, AddressI, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, PersonalDataI, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, CompanyDetailsI, ContactDetails, ContactDetailsRepo, ContactDetailsReader, ContactDetailsI, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryDetailsI, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryMethodI, DeliveryStatus, DeliveryStatusReader, InvoiceDetails, InvoiceDetailsRepo, InvoiceDetailsReader, InvoiceDetailsI, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentDetailsI, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentMethodI, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, OrderProductI, Status, OrderStatusRepo, OrderStatusReader, StatusI, ProductI, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileI, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, CompanyDataI, StatusTypesReader, };
|
package/dist/index.js
CHANGED
|
@@ -1,64 +1,71 @@
|
|
|
1
1
|
import DatabaseConnection from "./DatabaseConnection";
|
|
2
2
|
import StockObject from "./types/StockObject";
|
|
3
|
-
import
|
|
3
|
+
import Table from "./Table";
|
|
4
|
+
import Query from "./query/Query";
|
|
5
|
+
import TableConnection from './TableConnection';
|
|
6
|
+
import ParameterType from './types/parameters/ParameterType';
|
|
7
|
+
import ConnectorE from './types/ConnectorE';
|
|
8
|
+
import Parameters from './utils/Parameters';
|
|
9
|
+
import QueryOptions from './query/QueryOptions';
|
|
10
|
+
import Client from "./stockObjects/Client";
|
|
11
|
+
import ClientAccountRepo from "./repo/ClientAccountRepo";
|
|
4
12
|
import ClientAccountReader from "./reader/ClientAccountReader";
|
|
13
|
+
import Admin from "./stockObjects/Admin";
|
|
14
|
+
import AdminRepo from './repo/AdminRepo';
|
|
15
|
+
import Address from "./stockObjects/Address";
|
|
16
|
+
import AddressesRepo from "./repo/AddressesRepo";
|
|
17
|
+
import AddressesReader from "./reader/AddressesReader";
|
|
18
|
+
import PersonalData from "./stockObjects/PersonalData";
|
|
19
|
+
import PersonalDataRepo from "./repo/PersonalDataRepo";
|
|
20
|
+
import PersonalDataReader from "./reader/PersonalDataReader";
|
|
21
|
+
import CompanyDetails from "./stockObjects/CompanyDetails";
|
|
22
|
+
import CompanyDetailsRepo from "./repo/CompanyDetailsRepo";
|
|
5
23
|
import CompanyDetailsReader from "./reader/CompanyDetailsReader";
|
|
24
|
+
import ContactDetails from "./stockObjects/ContactDetails";
|
|
25
|
+
import ContactDetailsRepo from "./repo/ContactDetailsRepo";
|
|
6
26
|
import ContactDetailsReader from "./reader/ContactDetailsReader";
|
|
27
|
+
import DeliveryDetails from "./stockObjects/DeliveryDetails";
|
|
28
|
+
import DeliveryDetailsRepo from "./repo/DeliveryDetailsRepo";
|
|
7
29
|
import DeliveryDetailsReader from "./reader/DeliveryDetailsReader";
|
|
30
|
+
import DeliveryMethods from "./stockObjects/DeliveryMethods";
|
|
31
|
+
import DeliveryMethodRepo from './repo/DeliveryMethodRepo';
|
|
8
32
|
import DeliveryMethodReader from "./reader/DeliveryMethodReader";
|
|
33
|
+
import DeliveryStatus from "./stockObjects/DeliveryStatus";
|
|
34
|
+
import DeliveryStatusReader from './reader/DeliveryStatusReader';
|
|
35
|
+
import InvoiceDetails from "./stockObjects/InvoiceDetails";
|
|
36
|
+
import InvoiceDetailsRepo from "./repo/InvoiceDetailsRepo";
|
|
9
37
|
import InvoiceDetailsReader from "./reader/InvoiceDetailsReader";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import FilesReader from './reader/FilesReader';
|
|
13
|
-
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
14
|
-
import OrderStatusRepo from "./repo/OrderStatusRepo";
|
|
38
|
+
import PaymentDetails from "./stockObjects/PaymentDetails";
|
|
39
|
+
import PaymentDetailsRepo from "./repo/PaymentDetailsRepo";
|
|
15
40
|
import PaymentDetailsReader from "./reader/payment/PaymentDetailsReader";
|
|
41
|
+
import PaymentMethods from "./stockObjects/PaymentMethods";
|
|
42
|
+
import PaymentMethodRepo from './repo/PaymentMethodRepo';
|
|
16
43
|
import PaymentMethodReader from "./reader/payment/PaymentMethodReader";
|
|
44
|
+
import PaymentMethodE from "./types/PaymentMethodE";
|
|
45
|
+
import PaymentStatus from "./stockObjects/PaymentStatus";
|
|
17
46
|
import PaymentStatusesReader from "./reader/payment/PaymentStatusesReader";
|
|
18
|
-
import
|
|
19
|
-
import ProductReader from "./reader/ProductReader";
|
|
20
|
-
import AddressesRepo from "./repo/AddressesRepo";
|
|
21
|
-
import ClientAccountRepo from "./repo/ClientAccountRepo";
|
|
22
|
-
import CompanyDetailsRepo from "./repo/CompanyDetailsRepo";
|
|
23
|
-
import CompanyDataRepo from "./repo/CompanyDataRepo";
|
|
24
|
-
import ContactDetailsRepo from "./repo/ContactDetailsRepo";
|
|
25
|
-
import DeliveryDetailsRepo from "./repo/DeliveryDetailsRepo";
|
|
26
|
-
import InvoiceDetailsRepo from "./repo/InvoiceDetailsRepo";
|
|
27
|
-
import OrderRepo from "./repo/OrderRepo";
|
|
28
|
-
import PaymentDetailsRepo from "./repo/PaymentDetailsRepo";
|
|
29
|
-
import PersonalDataRepo from "./repo/PersonalDataRepo";
|
|
30
|
-
import PaymentMethodRepo from './repo/PaymentMethodRepo';
|
|
31
|
-
import ProductRepo from "./repo/ProductRepo";
|
|
32
|
-
import Address from "./stockObjects/Address";
|
|
33
|
-
import Admin from "./stockObjects/Admin";
|
|
34
|
-
import CompanyDetails from "./stockObjects/CompanyDetails";
|
|
35
|
-
import ContactDetails from "./stockObjects/ContactDetails";
|
|
36
|
-
import DeliveryDetails from "./stockObjects/DeliveryDetails";
|
|
37
|
-
import DeliveryStatus from "./stockObjects/DeliveryStatus";
|
|
38
|
-
import InvoiceDetails from "./stockObjects/InvoiceDetails";
|
|
47
|
+
import PaymentStatusE from './types/PaymentStatusE';
|
|
39
48
|
import Order from "./stockObjects/Order";
|
|
49
|
+
import OrderRepo from "./repo/OrderRepo";
|
|
50
|
+
import OrderReader from "./reader/OrderReader";
|
|
40
51
|
import OrderProduct from "./stockObjects/OrderProduct";
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import PersonalData from "./stockObjects/PersonalData";
|
|
44
|
-
import Product from "./stockObjects/Product";
|
|
52
|
+
import OrderProductsRepo from "./repo/OrderProductsRepo";
|
|
53
|
+
import OrderProductsReader from "./reader/OrderProductsReader";
|
|
45
54
|
import Status from "./stockObjects/Status";
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
50
|
-
import
|
|
51
|
-
import ConnectorE from './types/ConnectorE';
|
|
52
|
-
import PaymentStatusE from './types/PaymentStatusE';
|
|
53
|
-
import Parameters from './utils/Parameters';
|
|
54
|
-
import DeliveryMethodRepo from './repo/DeliveryMethodRepo';
|
|
55
|
-
import StatusTypesReader from './reader/StatusTypesReader';
|
|
56
|
-
import FileConnectionsReader from "./reader/FileConnectionsReader";
|
|
57
|
-
import FileConnectionsRepo from "./repo/FileConnectionsRepo";
|
|
58
|
-
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
59
|
-
import FilesRepo from './repo/FilesRepo';
|
|
55
|
+
import OrderStatusRepo from "./repo/OrderStatusRepo";
|
|
56
|
+
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
57
|
+
import Product from "./stockObjects/Product";
|
|
58
|
+
import ProductRepo from "./repo/ProductRepo";
|
|
59
|
+
import ProductReader from "./reader/ProductReader";
|
|
60
60
|
import File from './stockObjects/File';
|
|
61
|
-
import
|
|
62
|
-
import
|
|
61
|
+
import FilesRepo from './repo/FilesRepo';
|
|
62
|
+
import FilesReader from './reader/FilesReader';
|
|
63
|
+
import FileConnection from "./stockObjects/FileConnection";
|
|
64
|
+
import FileConnectionsRepo from "./repo/FileConnectionsRepo";
|
|
65
|
+
import FileConnectionsReader from "./reader/FileConnectionsReader";
|
|
63
66
|
import FileConnectionTypeE from './types/FileConnectionTypeE';
|
|
64
|
-
|
|
67
|
+
import CompanyData from "./stockObjects/CompanyData";
|
|
68
|
+
import CompanyDataRepo from "./repo/CompanyDataRepo";
|
|
69
|
+
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
70
|
+
import StatusTypesReader from './reader/StatusTypesReader';
|
|
71
|
+
export { DatabaseConnection, StockObject, Table, Query, TableConnection, ParameterType, ConnectorE, Parameters, QueryOptions, Client, ClientAccountRepo, ClientAccountReader, Admin, AdminRepo, Address, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, ContactDetails, ContactDetailsRepo, ContactDetailsReader, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryStatus, DeliveryStatusReader, InvoiceDetails, InvoiceDetailsRepo, InvoiceDetailsReader, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, Status, OrderStatusRepo, OrderStatusReader, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, StatusTypesReader, };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import AddressesReader from "./AddressesReader";
|
|
3
3
|
import DeliveryMethodReader from "./DeliveryMethodReader";
|
|
4
|
-
import DeliveryStatusReader from "./DeliveryStatusReader";
|
|
5
4
|
import PersonalDataReader from "./PersonalDataReader";
|
|
6
5
|
export default class DeliveryDetailsReader {
|
|
7
6
|
static async get(deliveryDetailsId) {
|
|
@@ -17,15 +16,11 @@ export default class DeliveryDetailsReader {
|
|
|
17
16
|
address = await AddressesReader.get(deliveryDetails.address_id);
|
|
18
17
|
if (deliveryDetails.delivery_method_id)
|
|
19
18
|
deliveryMethod = await DeliveryMethodReader.get(deliveryDetails.delivery_method_id);
|
|
20
|
-
const status = await DeliveryStatusReader.get(deliveryDetails.id);
|
|
21
|
-
const statuses = await DeliveryStatusReader.getAll(deliveryDetails.id);
|
|
22
19
|
return {
|
|
23
20
|
id,
|
|
24
21
|
personalData,
|
|
25
22
|
address,
|
|
26
|
-
deliveryMethod
|
|
27
|
-
status,
|
|
28
|
-
statuses,
|
|
23
|
+
deliveryMethod
|
|
29
24
|
};
|
|
30
25
|
}
|
|
31
26
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import OrderProductI from "../types/OrderProductI";
|
|
2
2
|
export default class OrderProductsReader {
|
|
3
|
-
static getForOrder(orderId: number): Promise<any[]>;
|
|
4
3
|
static getAll(orderId: number): Promise<OrderProductI[]>;
|
|
4
|
+
static getForOrder(orderId: number): Promise<any[]>;
|
|
5
|
+
private static correctOrderProducts;
|
|
5
6
|
private static correctProduct;
|
|
6
|
-
static get(orderId: number): Promise<OrderProductI[]>;
|
|
7
|
-
static getAllForIds(orderProductsIds: number[]): Promise<any[]>;
|
|
8
|
-
private static correctOrdersProducts;
|
|
9
|
-
private static correctOrderProduct;
|
|
10
7
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
-
import ConnectorE from "../types/ConnectorE";
|
|
3
|
-
import ParameterType from "../types/parameters/ParameterType";
|
|
4
2
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
5
3
|
import FilesReader from "./FilesReader";
|
|
6
|
-
import ProductReader from "./ProductReader";
|
|
7
4
|
export default class OrderProductsReader {
|
|
5
|
+
static async getAll(orderId) {
|
|
6
|
+
const connection = DatabaseConnection.get();
|
|
7
|
+
const orderProducts = await connection.ordersProducts.selectAllActive(orderId);
|
|
8
|
+
const correctProducts = await this.correctOrderProducts(orderProducts);
|
|
9
|
+
return correctProducts;
|
|
10
|
+
}
|
|
8
11
|
static async getForOrder(orderId) {
|
|
9
12
|
const connection = DatabaseConnection.get();
|
|
10
|
-
const products = await connection.ordersProducts.
|
|
13
|
+
const products = await connection.ordersProducts.selectAllActive(orderId);
|
|
11
14
|
const correctProducts = [];
|
|
12
15
|
for (let i = 0; i < products.length; i++) {
|
|
13
16
|
const correctProduct = {
|
|
@@ -20,9 +23,7 @@ export default class OrderProductsReader {
|
|
|
20
23
|
}
|
|
21
24
|
return correctProducts;
|
|
22
25
|
}
|
|
23
|
-
static async
|
|
24
|
-
const connection = DatabaseConnection.get();
|
|
25
|
-
const products = await connection.ordersProducts.selectAll(orderId);
|
|
26
|
+
static async correctOrderProducts(products) {
|
|
26
27
|
const correctProducts = [];
|
|
27
28
|
for (let i = 0; i < products.length; i++) {
|
|
28
29
|
const correctProduct = await this.correctProduct(products[i]);
|
|
@@ -31,62 +32,20 @@ export default class OrderProductsReader {
|
|
|
31
32
|
return correctProducts;
|
|
32
33
|
}
|
|
33
34
|
static async correctProduct(orderProduct) {
|
|
34
|
-
const
|
|
35
|
-
const file = await FilesReader.get(product.fileId);
|
|
35
|
+
const file = await FilesReader.get(orderProduct.file_id);
|
|
36
36
|
const correctProduct = {
|
|
37
37
|
id: orderProduct.id,
|
|
38
|
-
productId: orderProduct.product_id,
|
|
39
38
|
orderId: orderProduct.order_id,
|
|
40
39
|
product: {
|
|
41
|
-
id:
|
|
42
|
-
sku:
|
|
43
|
-
title:
|
|
44
|
-
netPrice:
|
|
45
|
-
grossPrice: calculateNetToGrossPrice(
|
|
46
|
-
vat:
|
|
40
|
+
id: orderProduct.product_id,
|
|
41
|
+
sku: orderProduct.sku,
|
|
42
|
+
title: orderProduct.title,
|
|
43
|
+
netPrice: orderProduct.net_price,
|
|
44
|
+
grossPrice: calculateNetToGrossPrice(orderProduct.net_price, orderProduct.vat),
|
|
45
|
+
vat: orderProduct.vat,
|
|
47
46
|
file,
|
|
48
47
|
}
|
|
49
48
|
};
|
|
50
49
|
return correctProduct;
|
|
51
50
|
}
|
|
52
|
-
static async get(orderId) {
|
|
53
|
-
const connection = DatabaseConnection.get();
|
|
54
|
-
const orderProducts = await connection.ordersProducts.selectProducts(orderId);
|
|
55
|
-
for (const product of orderProducts) {
|
|
56
|
-
const file = await FilesReader.get(product.file_id);
|
|
57
|
-
product.file = file;
|
|
58
|
-
}
|
|
59
|
-
return this.correctOrdersProducts(orderProducts);
|
|
60
|
-
}
|
|
61
|
-
static async getAllForIds(orderProductsIds) {
|
|
62
|
-
const connection = DatabaseConnection.get();
|
|
63
|
-
const queryOptions = {
|
|
64
|
-
where: {
|
|
65
|
-
connector: ConnectorE.and,
|
|
66
|
-
parameters: [
|
|
67
|
-
{ name: 'id', type: ParameterType.arrayBigint, value: orderProductsIds },
|
|
68
|
-
]
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const orderProducts = await connection.ordersProducts.selectAllForIds(queryOptions);
|
|
72
|
-
return orderProducts;
|
|
73
|
-
}
|
|
74
|
-
static correctOrdersProducts(productRows) {
|
|
75
|
-
const products = [];
|
|
76
|
-
for (let i = 0; i < productRows.length; i++) {
|
|
77
|
-
const product = this.correctOrderProduct(productRows[i]);
|
|
78
|
-
products.push(product);
|
|
79
|
-
}
|
|
80
|
-
return products;
|
|
81
|
-
}
|
|
82
|
-
static correctOrderProduct(product) {
|
|
83
|
-
return {
|
|
84
|
-
orderProductId: product.id,
|
|
85
|
-
netPrice: product.net_price,
|
|
86
|
-
id: product.product_id,
|
|
87
|
-
title: product.title,
|
|
88
|
-
sku: product.sku,
|
|
89
|
-
file: product.file
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
51
|
}
|
|
@@ -12,28 +12,29 @@ export default class OrderReader {
|
|
|
12
12
|
const orders = await connection.orders.selectForClient(clientAccountId);
|
|
13
13
|
const correctOrders = [];
|
|
14
14
|
for (let i = 0; i < orders.length; i++) {
|
|
15
|
-
const correctOrder = this.correctOrder(orders[i]);
|
|
15
|
+
const correctOrder = await this.correctOrder(orders[i]);
|
|
16
16
|
const products = await OrderProductsReader.getAll(orders[i].id);
|
|
17
|
-
|
|
18
|
-
correctOrders.push({ ...correctOrder, status, products });
|
|
17
|
+
correctOrders.push({ ...correctOrder, products });
|
|
19
18
|
}
|
|
20
19
|
return correctOrders;
|
|
21
20
|
}
|
|
22
21
|
static async getAll(queryOptions) {
|
|
23
22
|
const connection = DatabaseConnection.get();
|
|
24
|
-
const
|
|
23
|
+
const orderRows = await connection.orders.selectAll(queryOptions);
|
|
25
24
|
const quantity = await connection.orders.count(queryOptions);
|
|
26
|
-
|
|
25
|
+
const orders = await this.correctOrders(orderRows);
|
|
26
|
+
return { orders, quantity };
|
|
27
27
|
}
|
|
28
|
-
static correctOrders(orderRows) {
|
|
28
|
+
static async correctOrders(orderRows) {
|
|
29
29
|
const orders = [];
|
|
30
30
|
for (let i = 0; i < orderRows.length; i++) {
|
|
31
|
-
const order = this.correctOrder(orderRows[i]);
|
|
31
|
+
const order = await this.correctOrder(orderRows[i]);
|
|
32
32
|
orders.push(order);
|
|
33
33
|
}
|
|
34
34
|
return orders;
|
|
35
35
|
}
|
|
36
|
-
static correctOrder(order) {
|
|
36
|
+
static async correctOrder(order) {
|
|
37
|
+
const status = await OrderStatusReader.get(order.id);
|
|
37
38
|
const correctOrder = {
|
|
38
39
|
id: order.id,
|
|
39
40
|
email: order.email,
|
|
@@ -44,7 +45,8 @@ export default class OrderReader {
|
|
|
44
45
|
deliveryDetailsId: order.delivery_details_id,
|
|
45
46
|
invoiceDetailsId: order.invoice_details_id,
|
|
46
47
|
paymentDetailsId: order.payment_details_id,
|
|
47
|
-
zsiId: order.zsi_id
|
|
48
|
+
zsiId: order.zsi_id,
|
|
49
|
+
status
|
|
48
50
|
};
|
|
49
51
|
return correctOrder;
|
|
50
52
|
}
|
|
@@ -2,12 +2,12 @@ import DatabaseConnection from "../DatabaseConnection";
|
|
|
2
2
|
export default class OrderStatusReader {
|
|
3
3
|
static async get(orderId) {
|
|
4
4
|
const connection = DatabaseConnection.get();
|
|
5
|
-
const statusRow = await connection.statuses.
|
|
5
|
+
const statusRow = await connection.statuses.select(orderId);
|
|
6
6
|
return this.correctStatus(statusRow);
|
|
7
7
|
}
|
|
8
8
|
static async getAll(orderId) {
|
|
9
9
|
const connection = DatabaseConnection.get();
|
|
10
|
-
const statuses = await connection.statuses.
|
|
10
|
+
const statuses = await connection.statuses.selectAll(orderId);
|
|
11
11
|
const correctStatuss = [];
|
|
12
12
|
for (let i = 0; i < statuses.length; i++) {
|
|
13
13
|
const correctStatus = this.correctStatus(statuses[i]);
|
|
@@ -21,7 +21,8 @@ export default class OrderStatusReader {
|
|
|
21
21
|
orderId: status.order_id,
|
|
22
22
|
createdAt: status.created_at,
|
|
23
23
|
userId: status.user_id,
|
|
24
|
-
|
|
24
|
+
typeId: status.type_id,
|
|
25
|
+
typeName: status.type_name,
|
|
25
26
|
};
|
|
26
27
|
return correctStatus;
|
|
27
28
|
}
|
|
@@ -2,12 +2,10 @@ import ProductI from "../types/ProductI";
|
|
|
2
2
|
import QueryOptionsI from "../types/QueryOptionsI";
|
|
3
3
|
export default class ProductReader {
|
|
4
4
|
static get(productId: number): Promise<ProductI>;
|
|
5
|
-
static getIdForSku(productSku: string): Promise<number>;
|
|
6
5
|
static getForUrl(productUrl: string): Promise<ProductI>;
|
|
7
|
-
static
|
|
6
|
+
static getAllActive(queryOptions: QueryOptionsI): Promise<ProductI[]>;
|
|
7
|
+
static getIdForSku(productSku: string): Promise<number>;
|
|
8
8
|
static getQuantity(queryOptions: QueryOptionsI): Promise<number>;
|
|
9
|
-
static getListForOrder(): Promise<any>;
|
|
10
9
|
private static correctProducts;
|
|
11
10
|
private static correctProduct;
|
|
12
|
-
private static correctProductForOrderList;
|
|
13
11
|
}
|
|
@@ -6,49 +6,39 @@ export default class ProductReader {
|
|
|
6
6
|
static async get(productId) {
|
|
7
7
|
const connection = DatabaseConnection.get();
|
|
8
8
|
const product = await connection.products.select(productId);
|
|
9
|
-
const thumbnail = await FilesReader.get(product.file_id);
|
|
10
9
|
const files = await FilesReader.getForConnection(FileConnectionTypeE.product, product.id);
|
|
11
|
-
return this.correctProduct(product,
|
|
12
|
-
}
|
|
13
|
-
static async getIdForSku(productSku) {
|
|
14
|
-
const connection = DatabaseConnection.get();
|
|
15
|
-
return await connection.products.selectIdForSku(productSku);
|
|
10
|
+
return this.correctProduct(product, files);
|
|
16
11
|
}
|
|
17
12
|
static async getForUrl(productUrl) {
|
|
18
13
|
const connection = DatabaseConnection.get();
|
|
19
14
|
const product = await connection.products.selectForUrl(productUrl);
|
|
20
|
-
|
|
15
|
+
const files = await FilesReader.getForConnection(FileConnectionTypeE.product, product.id);
|
|
16
|
+
return this.correctProduct(product, files);
|
|
21
17
|
}
|
|
22
|
-
static async
|
|
18
|
+
static async getAllActive(queryOptions) {
|
|
23
19
|
const connection = DatabaseConnection.get();
|
|
24
|
-
const products = await connection.products.
|
|
20
|
+
const products = await connection.products.selectAllActive(queryOptions);
|
|
25
21
|
return this.correctProducts(products);
|
|
26
22
|
}
|
|
23
|
+
static async getIdForSku(productSku) {
|
|
24
|
+
const connection = DatabaseConnection.get();
|
|
25
|
+
return await connection.products.selectIdForSku(productSku);
|
|
26
|
+
}
|
|
27
27
|
static async getQuantity(queryOptions) {
|
|
28
28
|
const connection = DatabaseConnection.get();
|
|
29
29
|
const quantity = await connection.products.count(queryOptions);
|
|
30
30
|
return quantity;
|
|
31
31
|
}
|
|
32
|
-
static async
|
|
33
|
-
const connection = DatabaseConnection.get();
|
|
34
|
-
let correctProducts = [];
|
|
35
|
-
const products = await connection.products.selectListForOrder();
|
|
36
|
-
for (const product of products) {
|
|
37
|
-
const file = await FilesReader.get(product.file_id);
|
|
38
|
-
product.file = file;
|
|
39
|
-
correctProducts.push(this.correctProductForOrderList(product));
|
|
40
|
-
}
|
|
41
|
-
return correctProducts;
|
|
42
|
-
}
|
|
43
|
-
static correctProducts(products) {
|
|
32
|
+
static async correctProducts(products) {
|
|
44
33
|
const correctProducts = [];
|
|
45
34
|
for (let i = 0; i < products.length; i++) {
|
|
46
|
-
const correctProduct = this.correctProduct(products[i]);
|
|
35
|
+
const correctProduct = await this.correctProduct(products[i]);
|
|
47
36
|
correctProducts.push(correctProduct);
|
|
48
37
|
}
|
|
49
38
|
return correctProducts;
|
|
50
39
|
}
|
|
51
|
-
static correctProduct(product,
|
|
40
|
+
static async correctProduct(product, files) {
|
|
41
|
+
const thumbnail = await FilesReader.get(product.file_id);
|
|
52
42
|
return {
|
|
53
43
|
id: product.id,
|
|
54
44
|
sku: product.sku,
|
|
@@ -65,17 +55,8 @@ export default class ProductReader {
|
|
|
65
55
|
createdAt: product.created_at,
|
|
66
56
|
deleted: product.deleted,
|
|
67
57
|
thumbnail: thumbnail ? thumbnail : null,
|
|
68
|
-
files
|
|
58
|
+
files,
|
|
69
59
|
grossPrice: calculateNetToGrossPrice(product.net_price, product.vat)
|
|
70
60
|
};
|
|
71
61
|
}
|
|
72
|
-
static correctProductForOrderList(product) {
|
|
73
|
-
return {
|
|
74
|
-
id: product.id,
|
|
75
|
-
title: product.title,
|
|
76
|
-
sku: product.sku,
|
|
77
|
-
file: product.file,
|
|
78
|
-
netPrice: product.net_price
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
62
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import OrderProduct from "../stockObjects/OrderProduct";
|
|
2
2
|
export default class OrderProductsRepo {
|
|
3
|
-
static
|
|
3
|
+
static getAllActive(orderId: number): Promise<OrderProduct[]>;
|
|
4
4
|
static getAllForIds(orderProductsIds: number[]): Promise<OrderProduct[]>;
|
|
5
5
|
private static createOrdersProductsFromRows;
|
|
6
6
|
private static createOrdersProductFromRow;
|
|
@@ -3,9 +3,9 @@ import OrderProduct from "../stockObjects/OrderProduct";
|
|
|
3
3
|
import ConnectorE from "../types/ConnectorE";
|
|
4
4
|
import ParameterType from "../types/parameters/ParameterType";
|
|
5
5
|
export default class OrderProductsRepo {
|
|
6
|
-
static async
|
|
6
|
+
static async getAllActive(orderId) {
|
|
7
7
|
const connection = DatabaseConnection.get();
|
|
8
|
-
const orderProducts = await connection.ordersProducts.
|
|
8
|
+
const orderProducts = await connection.ordersProducts.selectAllActive(orderId);
|
|
9
9
|
return this.createOrdersProductsFromRows(orderProducts);
|
|
10
10
|
}
|
|
11
11
|
static async getAllForIds(orderProductsIds) {
|
|
@@ -3,12 +3,12 @@ import Status from "../stockObjects/Status";
|
|
|
3
3
|
export default class OrderStatusRepo {
|
|
4
4
|
static async get(orderId) {
|
|
5
5
|
const connection = DatabaseConnection.get();
|
|
6
|
-
const status = await connection.statuses.
|
|
6
|
+
const status = await connection.statuses.select(orderId);
|
|
7
7
|
return this.createStatusFromRow(status);
|
|
8
8
|
}
|
|
9
9
|
static async getAll(orderId) {
|
|
10
10
|
const connection = DatabaseConnection.get();
|
|
11
|
-
const statuses = await connection.statuses.
|
|
11
|
+
const statuses = await connection.statuses.selectAll(orderId);
|
|
12
12
|
return this.createStatusesFromRows(statuses);
|
|
13
13
|
}
|
|
14
14
|
static async createStatusesFromRows(dataRows) {
|
package/dist/repo/ProductRepo.js
CHANGED
|
@@ -9,7 +9,6 @@ export default class ProductRepo {
|
|
|
9
9
|
static async getForSku(productSku) {
|
|
10
10
|
const connection = DatabaseConnection.get();
|
|
11
11
|
const product = await connection.products.selectForSku(productSku);
|
|
12
|
-
console.log(product);
|
|
13
12
|
return this.createProductFromRow(product);
|
|
14
13
|
}
|
|
15
14
|
static createProductFromRow(productRow) {
|
|
@@ -84,12 +84,17 @@ export default class Order extends StockObject {
|
|
|
84
84
|
this.zsiId = zsiId;
|
|
85
85
|
}
|
|
86
86
|
async calculateAndUpdatePrice() {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
const id = this.getId();
|
|
88
|
+
if (id) {
|
|
89
|
+
let totalPrice = 0;
|
|
90
|
+
const orderProducts = await OrderProductsRepo.getAllActive(id);
|
|
91
|
+
for (const product of orderProducts) {
|
|
92
|
+
totalPrice += product.getNetPrice();
|
|
93
|
+
}
|
|
94
|
+
this.setPrice(totalPrice);
|
|
91
95
|
}
|
|
92
|
-
|
|
96
|
+
else
|
|
97
|
+
throw Error('The price of an uncreated order cannot be calculated');
|
|
93
98
|
}
|
|
94
99
|
getMapper() {
|
|
95
100
|
return new OrderMapper(this);
|
|
@@ -3,10 +3,8 @@ import OrderProductRow from '../../types/rows/OrderProductRow';
|
|
|
3
3
|
import OrderProduct from '../../stockObjects/OrderProduct';
|
|
4
4
|
import QueryOptionsI from '../../types/QueryOptionsI';
|
|
5
5
|
export default class OrdersProductsTable extends Table {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
selectProducts(orderId: number): Promise<OrderProductRow[]>;
|
|
9
|
-
selectAllForIds(queryOprions: QueryOptionsI): Promise<OrderProduct[]>;
|
|
6
|
+
selectAllActive(orderId: number): Promise<OrderProductRow[]>;
|
|
7
|
+
selectAllForIds(queryOprions: QueryOptionsI): Promise<OrderProductRow[]>;
|
|
10
8
|
delete(orderProduct: OrderProduct): Promise<boolean>;
|
|
11
9
|
private bindParams;
|
|
12
10
|
insert(orderProduct: OrderProduct): Promise<boolean>;
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
import Table from '../../Table';
|
|
2
2
|
import * as SQL from '../../SQL.json';
|
|
3
3
|
export default class OrdersProductsTable extends Table {
|
|
4
|
-
async
|
|
5
|
-
const query = this.createQuery(SQL.ordersProducts.
|
|
6
|
-
query.bindParameter('order_id', orderId);
|
|
7
|
-
const result = await query.execute();
|
|
8
|
-
return result.getRows();
|
|
9
|
-
}
|
|
10
|
-
async getAllActiveForOrderId(orderId) {
|
|
11
|
-
const query = this.createQuery(SQL.ordersProducts.getAllActiveForOrderId);
|
|
12
|
-
query.bindParameter('order_id', orderId);
|
|
13
|
-
const result = await query.execute();
|
|
14
|
-
return result.getRows();
|
|
15
|
-
}
|
|
16
|
-
async selectProducts(orderId) {
|
|
17
|
-
const query = this.createQuery(SQL.ordersProducts.selectProducts);
|
|
4
|
+
async selectAllActive(orderId) {
|
|
5
|
+
const query = this.createQuery(SQL.ordersProducts.selectAllActive);
|
|
18
6
|
query.bindParameter('order_id', orderId);
|
|
19
7
|
const result = await query.execute();
|
|
20
8
|
return result.getRows();
|
|
@@ -2,9 +2,8 @@ import Table from '../../Table';
|
|
|
2
2
|
import Status from '../../stockObjects/Status';
|
|
3
3
|
import StatusRow from '../../types/rows/StatusRow';
|
|
4
4
|
export default class StatusesTable extends Table {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
selectAllForOrder(orderId: number): Promise<StatusRow[]>;
|
|
5
|
+
select(orderId: number): Promise<StatusRow>;
|
|
6
|
+
selectAll(orderId: number): Promise<StatusRow[]>;
|
|
8
7
|
insert(status: Status): Promise<void>;
|
|
9
8
|
private bindParameters;
|
|
10
9
|
private selectNextId;
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import Table from '../../Table';
|
|
2
2
|
import * as SQL from '../../SQL.json';
|
|
3
3
|
export default class StatusesTable extends Table {
|
|
4
|
-
async
|
|
5
|
-
const query = this.createQuery(SQL.statuses.
|
|
4
|
+
async select(orderId) {
|
|
5
|
+
const query = this.createQuery(SQL.statuses.select);
|
|
6
6
|
query.bindParameter('order_id', orderId);
|
|
7
7
|
const result = await query.execute();
|
|
8
8
|
return result.getRow();
|
|
9
9
|
}
|
|
10
|
-
async
|
|
11
|
-
const query = this.createQuery(SQL.statuses.
|
|
12
|
-
query.bindParameter('order_id', orderId);
|
|
13
|
-
const result = await query.execute();
|
|
14
|
-
return result.getRow();
|
|
15
|
-
}
|
|
16
|
-
async selectAllForOrder(orderId) {
|
|
17
|
-
const query = this.createQuery(SQL.statuses.selectAllForOrder);
|
|
10
|
+
async selectAll(orderId) {
|
|
11
|
+
const query = this.createQuery(SQL.statuses.selectAll);
|
|
18
12
|
query.bindParameter('order_id', orderId);
|
|
19
13
|
const result = await query.execute();
|
|
20
14
|
return result.getRows();
|
|
@@ -30,7 +24,7 @@ export default class StatusesTable extends Table {
|
|
|
30
24
|
bindParameters(query, status) {
|
|
31
25
|
query.bindParameter('order_id', status.getOrderId());
|
|
32
26
|
query.bindParameter('user_id', status.getUserId());
|
|
33
|
-
query.bindParameter('type', status.
|
|
27
|
+
query.bindParameter('type', status.getTypeId());
|
|
34
28
|
}
|
|
35
29
|
async selectNextId() {
|
|
36
30
|
const query = this.createQuery(SQL.statuses.selectNextId);
|
|
@@ -4,16 +4,15 @@ import QueryOptionsI from '../../types/QueryOptionsI';
|
|
|
4
4
|
import ProductRow from '../../types/rows/ProductRow';
|
|
5
5
|
export default class ProductsTable extends Table {
|
|
6
6
|
select(productId: number): Promise<ProductRow>;
|
|
7
|
-
selectForSku(sku: string): Promise<ProductRow>;
|
|
8
|
-
selectIdForSku(sku: string): Promise<number>;
|
|
9
|
-
selectListForOrder(): Promise<ProductRow[]>;
|
|
10
7
|
selectAll(queryOption: QueryOptionsI): Promise<ProductRow[]>;
|
|
8
|
+
selectAllActive(queryOption: QueryOptionsI): Promise<ProductRow[]>;
|
|
9
|
+
selectForSku(sku: string): Promise<ProductRow>;
|
|
11
10
|
selectForUrl(url: string): Promise<ProductRow>;
|
|
11
|
+
selectIdForSku(sku: string): Promise<number>;
|
|
12
12
|
insert(productData: Product): Promise<number>;
|
|
13
|
-
count(queryOption: QueryOptionsI): Promise<number>;
|
|
14
13
|
update(product: Product): Promise<boolean>;
|
|
15
14
|
delete(productId: number): Promise<number>;
|
|
16
|
-
|
|
15
|
+
count(queryOption: QueryOptionsI): Promise<number>;
|
|
17
16
|
private bindParameters;
|
|
18
17
|
private selectNextId;
|
|
19
18
|
}
|
|
@@ -7,27 +7,21 @@ export default class ProductsTable extends Table {
|
|
|
7
7
|
const result = await query.execute();
|
|
8
8
|
return result.getRow();
|
|
9
9
|
}
|
|
10
|
-
async
|
|
11
|
-
const query = this.createQuery(SQL.products.
|
|
12
|
-
query.bindParameter('sku', String(sku).toUpperCase());
|
|
13
|
-
const result = await query.execute();
|
|
14
|
-
return result.getRow();
|
|
15
|
-
}
|
|
16
|
-
async selectIdForSku(sku) {
|
|
17
|
-
const query = this.createQuery(SQL.products.selectIdForSku);
|
|
18
|
-
query.bindParameter('sku', String(sku).toUpperCase());
|
|
10
|
+
async selectAll(queryOption) {
|
|
11
|
+
const query = this.createQuery(SQL.products.selectAll, queryOption);
|
|
19
12
|
const result = await query.execute();
|
|
20
|
-
return result.
|
|
13
|
+
return result.getRows();
|
|
21
14
|
}
|
|
22
|
-
async
|
|
23
|
-
const query = this.createQuery(SQL.products.
|
|
15
|
+
async selectAllActive(queryOption) {
|
|
16
|
+
const query = this.createQuery(SQL.products.selectAllActive, queryOption);
|
|
24
17
|
const result = await query.execute();
|
|
25
18
|
return result.getRows();
|
|
26
19
|
}
|
|
27
|
-
async
|
|
28
|
-
const query = this.createQuery(SQL.products.
|
|
20
|
+
async selectForSku(sku) {
|
|
21
|
+
const query = this.createQuery(SQL.products.selectForSku);
|
|
22
|
+
query.bindParameter('sku', String(sku).toUpperCase());
|
|
29
23
|
const result = await query.execute();
|
|
30
|
-
return result.
|
|
24
|
+
return result.getRow();
|
|
31
25
|
}
|
|
32
26
|
async selectForUrl(url) {
|
|
33
27
|
const query = this.createQuery(SQL.products.selectForUrl);
|
|
@@ -35,6 +29,12 @@ export default class ProductsTable extends Table {
|
|
|
35
29
|
const result = await query.execute();
|
|
36
30
|
return result.getRow();
|
|
37
31
|
}
|
|
32
|
+
async selectIdForSku(sku) {
|
|
33
|
+
const query = this.createQuery(SQL.products.selectIdForSku);
|
|
34
|
+
query.bindParameter('sku', String(sku).toUpperCase());
|
|
35
|
+
const result = await query.execute();
|
|
36
|
+
return result.getValue();
|
|
37
|
+
}
|
|
38
38
|
async insert(productData) {
|
|
39
39
|
const sku = productData.getSku();
|
|
40
40
|
let productId = await this.selectIdForSku(sku);
|
|
@@ -49,11 +49,6 @@ export default class ProductsTable extends Table {
|
|
|
49
49
|
await query.execute();
|
|
50
50
|
return productId;
|
|
51
51
|
}
|
|
52
|
-
async count(queryOption) {
|
|
53
|
-
const query = this.createQuery(SQL.products.count, queryOption);
|
|
54
|
-
const result = await query.execute();
|
|
55
|
-
return result.getValue();
|
|
56
|
-
}
|
|
57
52
|
async update(product) {
|
|
58
53
|
const query = this.createQuery(SQL.products.update);
|
|
59
54
|
query.bindParameter('id', product.getId());
|
|
@@ -67,14 +62,10 @@ export default class ProductsTable extends Table {
|
|
|
67
62
|
const result = await query.execute();
|
|
68
63
|
return result.getRowCount();
|
|
69
64
|
}
|
|
70
|
-
async
|
|
71
|
-
const
|
|
72
|
-
if (productId)
|
|
73
|
-
throw Error(`This product cannot be restored because it has been edited. There is a newer version of this product (id: ${productId})`);
|
|
74
|
-
const query = this.createQuery(SQL.products.restore);
|
|
75
|
-
query.bindParameter('id', product.getId());
|
|
65
|
+
async count(queryOption) {
|
|
66
|
+
const query = this.createQuery(SQL.products.count, queryOption);
|
|
76
67
|
const result = await query.execute();
|
|
77
|
-
return result.
|
|
68
|
+
return result.getValue();
|
|
78
69
|
}
|
|
79
70
|
bindParameters(query, productData) {
|
|
80
71
|
query.bindParameter('sku', productData.getSku());
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import AddressI from "./AddressI";
|
|
2
|
+
import DeliveryMethodI from "./DeliveryMethodI";
|
|
2
3
|
import PersonalDataI from "./PersonalDataI";
|
|
3
4
|
export default interface DeliveryDetailsI {
|
|
4
5
|
id: number;
|
|
5
6
|
personalData: PersonalDataI | null;
|
|
6
7
|
address: AddressI | null;
|
|
7
|
-
|
|
8
|
+
deliveryMethod: DeliveryMethodI | null;
|
|
8
9
|
}
|
package/dist/types/ProductI.d.ts
CHANGED
package/dist/types/StatusI.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import ParameterType from "../../types/parameters/ParameterType";
|
|
2
2
|
export default class ParameterFilterSystem {
|
|
3
3
|
static filter(parameter, parameterFilter) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
if (parameterFilter.filter && typeof parameterFilter.filter === 'function') {
|
|
5
|
+
switch (parameterFilter.type) {
|
|
6
|
+
case ParameterType.string: return parameterFilter.filter(parameter);
|
|
7
|
+
case ParameterType.arrayString:
|
|
8
|
+
return parameter.map((stringParameter) => parameterFilter.filter(stringParameter));
|
|
9
|
+
default: return parameter;
|
|
10
|
+
}
|
|
9
11
|
}
|
|
12
|
+
else
|
|
13
|
+
return parameter;
|
|
10
14
|
}
|
|
11
15
|
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|