@dascompany/database 0.0.5 → 0.0.7
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 +12 -5
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/mappers/ProductMapper.js +3 -1
- package/dist/reader/CompanyDataReader.js +1 -1
- package/dist/reader/FilesReader.d.ts +2 -2
- package/dist/reader/OrderProductsReader.d.ts +5 -1
- package/dist/reader/OrderProductsReader.js +42 -0
- package/dist/reader/OrderReader.d.ts +6 -0
- package/dist/reader/OrderReader.js +14 -0
- package/dist/reader/ProductReader.d.ts +2 -1
- package/dist/reader/ProductReader.js +21 -13
- package/dist/repo/FilesRepo.d.ts +2 -2
- package/dist/repo/OrderProductsRepo.d.ts +7 -0
- package/dist/repo/OrderProductsRepo.js +37 -0
- package/dist/repo/OrderStatusRepo.d.ts +7 -0
- package/dist/repo/OrderStatusRepo.js +27 -0
- package/dist/repo/ProductRepo.js +1 -0
- package/dist/stockObjects/Order.d.ts +1 -0
- package/dist/stockObjects/Order.js +9 -0
- package/dist/stockObjects/OrderProduct.d.ts +1 -1
- package/dist/stockObjects/OrderProduct.js +2 -2
- package/dist/stockObjects/Product.js +2 -2
- package/dist/stockObjects/Status.d.ts +13 -5
- package/dist/stockObjects/Status.js +25 -9
- package/dist/tables/files/FileConnectionsTable.d.ts +2 -2
- package/dist/tables/files/FilesTable.d.ts +2 -2
- package/dist/tables/orders/OrdersProductsTable.d.ts +7 -1
- package/dist/tables/orders/OrdersProductsTable.js +35 -6
- package/dist/tables/orders/OrdersTable.d.ts +3 -0
- package/dist/tables/orders/OrdersTable.js +10 -0
- package/dist/tables/orders/StatusesTable.d.ts +1 -0
- package/dist/tables/orders/StatusesTable.js +6 -0
- package/dist/types/CompanyDataI.d.ts +1 -1
- package/dist/types/FileConnectionTypeE.d.ts +4 -0
- package/dist/types/FileConnectionTypeE.js +5 -0
- package/dist/types/OrderProductI.d.ts +11 -5
- package/dist/types/ProductI.d.ts +1 -0
- package/dist/types/StatusI.d.ts +5 -0
- package/dist/types/StatusI.js +1 -0
- package/dist/types/rows/OrderRow.d.ts +3 -0
- package/dist/types/rows/StatusRow.d.ts +2 -1
- package/package.json +1 -1
- package/dist/types/FileConnectionE.d.ts +0 -4
- package/dist/types/FileConnectionE.js +0 -5
package/dist/SQL.json
CHANGED
|
@@ -69,24 +69,31 @@
|
|
|
69
69
|
"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
70
|
"delete": "UPDATE products SET deleted = true WHERE id = $id::BIGINT",
|
|
71
71
|
"restore": "UPDATE products SET deleted = false WHERE id = $id::BIGINT",
|
|
72
|
-
"selectForSku": "SELECT
|
|
72
|
+
"selectForSku": "SELECT * FROM products WHERE LOWER( sku ) = LOWER($sku::TEXT)",
|
|
73
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
74
|
"selectNextId": "SELECT nextval('product_id'::regclass)",
|
|
75
75
|
"count": "SELECT COUNT(*) AS total_rows FROM products WHERE deleted = false $PARAMS"
|
|
76
76
|
},
|
|
77
77
|
"orders": {
|
|
78
|
+
"selectAll": "SELECT id, email, price, client_id, contact_details_id, delivery_details_id, invoice_details_id, payment_details_id, zsi_id FROM orders.orders",
|
|
78
79
|
"select": "SELECT id, email, price, client_id, contact_details_id, delivery_details_id, invoice_details_id, payment_details_id, zsi_id FROM orders.orders WHERE id = $id::BIGINT",
|
|
79
80
|
"selectForClient": "SELECT id, email, price, client_id, contact_details_id, delivery_details_id, invoice_details_id, payment_details_id FROM orders.orders WHERE client_id = $client_id::BIGINT ORDER BY id DESC",
|
|
80
81
|
"insert": "INSERT INTO orders.orders( id, email, price, client_id, contact_details_id, delivery_details_id, invoice_details_id, payment_details_id ) VALUES ($order_id::BIGINT, $email::TEXT, $price::DOUBLE PRECISION, $client_id::BIGINT, $contact_details_id::BIGINT, $delivery_details_id::BIGINT , $invoice_details_id::BIGINT, $payment_details_id::BIGINT )",
|
|
81
82
|
"update": "UPDATE orders.orders SET price = $price::DOUBLE PRECISION, contact_details_id = $contact_details_id::BIGINT, delivery_details_id = $delivery_details_id::BIGINT, invoice_details_id = $invoice_details_id::BIGINT, payment_details_id = $payment_details_id::BIGINT, zsi_id = $zsi_id::BIGINT WHERE id = $id::BIGINT",
|
|
82
|
-
"selectNextId": "SELECT nextval('orders.orders_id'::regclass)"
|
|
83
|
+
"selectNextId": "SELECT nextval('orders.orders_id'::regclass)",
|
|
84
|
+
"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"
|
|
83
85
|
},
|
|
84
86
|
"ordersProducts": {
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
87
|
+
"selectProducts": "SELECT op.id, order_id, product_id, title, sku, 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",
|
|
88
|
+
"select": "SELECT id, order_id, product_id, in_order FROM orders.orders_products WHERE order_id = $order_id::BIGINT AND in_order = true",
|
|
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",
|
|
91
|
+
"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
|
+
"selectNextId": "SELECT nextval('orders.orders_products_id'::regclass)",
|
|
93
|
+
"delete": "UPDATE orders.orders_products SET in_order = false WHERE id = $id::BIGINT"
|
|
88
94
|
},
|
|
89
95
|
"statuses": {
|
|
96
|
+
"selectLatest": "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",
|
|
90
97
|
"selectForOrder": "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 LIMIT 1",
|
|
91
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",
|
|
92
99
|
"insert": "INSERT INTO orders.statuses( id, type, order_id, user_id ) VALUES ($id::BIGINT, $type::BIGINT, $order_id::BIGINT, $user_id::BIGINT)",
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import OrderProductsReader from "./reader/OrderProductsReader";
|
|
|
10
10
|
import OrderReader from "./reader/OrderReader";
|
|
11
11
|
import FilesReader from './reader/FilesReader';
|
|
12
12
|
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
13
|
+
import OrderStatusRepo from "./repo/OrderStatusRepo";
|
|
13
14
|
import PaymentDetailsReader from "./reader/payment/PaymentDetailsReader";
|
|
14
15
|
import PaymentMethodReader from "./reader/payment/PaymentMethodReader";
|
|
15
16
|
import PaymentStatusesReader from "./reader/payment/PaymentStatusesReader";
|
|
@@ -46,7 +47,6 @@ import AdminRepo from './repo/AdminRepo';
|
|
|
46
47
|
import TableConnection from './TableConnection';
|
|
47
48
|
import ParameterType from './types/parameters/ParameterType';
|
|
48
49
|
import DeliveryStatusReader from './reader/DeliveryStatusReader';
|
|
49
|
-
import FileConnectionE from './types/FileConnectionE';
|
|
50
50
|
import ConnectorE from './types/ConnectorE';
|
|
51
51
|
import ParameterI from './types/ParameterI';
|
|
52
52
|
import QueryOptionsI from './types/QueryOptionsI';
|
|
@@ -62,4 +62,8 @@ import FileConnectionsRepo from "./repo/FileConnectionsRepo";
|
|
|
62
62
|
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
63
63
|
import OrderByI from "./utils/OrderByI";
|
|
64
64
|
import FilesRepo from './repo/FilesRepo';
|
|
65
|
-
|
|
65
|
+
import File from './stockObjects/File';
|
|
66
|
+
import QueryOptions from './query/QueryOptions';
|
|
67
|
+
import OrderProductsRepo from "./repo/OrderProductsRepo";
|
|
68
|
+
import FileConnectionTypeE from './types/FileConnectionTypeE';
|
|
69
|
+
export { TableConnection, DatabaseConnection, File, OrderByI, ParameterType, ConnectorE, FileConnectionTypeE, PaymentStatusE, Parameters, ParameterI, QueryOptions, QueryOptionsI, ResultLimitationI, OrderProductI, ParameterFilter, PaymentDetailsReader, FilesReader, PaymentMethodReader, DeliveryStatusReader, PaymentStatusesReader, AddressesReader, ClientAccountReader, CompanyDetailsReader, ContactDetailsReader, DeliveryDetailsReader, DeliveryMethodReader, InvoiceDetailsReader, OrderProductsReader, OrderReader, OrderStatusReader, PersonalDataReader, ProductReader, StatusTypesReader, FileConnectionsReader, CompanyDataReader, DeliveryMethodRepo, AdminRepo, PaymentDetailsRepo, AddressesRepo, ClientAccountRepo, CompanyDetailsRepo, ContactDetailsRepo, DeliveryDetailsRepo, CompanyDataRepo, InvoiceDetailsRepo, OrderRepo, PersonalDataRepo, PaymentMethodRepo, ProductRepo, FileConnectionsRepo, FilesRepo, OrderProductsRepo, OrderStatusRepo, Address, Admin, Client, CompanyDetails, ContactDetails, DeliveryDetails, InvoiceDetails, DeliveryStatus, Order, OrderProduct, PaymentDetails, PaymentStatus, PersonalData, Product, Status, };
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import OrderProductsReader from "./reader/OrderProductsReader";
|
|
|
10
10
|
import OrderReader from "./reader/OrderReader";
|
|
11
11
|
import FilesReader from './reader/FilesReader';
|
|
12
12
|
import OrderStatusReader from "./reader/OrderStatusReader";
|
|
13
|
+
import OrderStatusRepo from "./repo/OrderStatusRepo";
|
|
13
14
|
import PaymentDetailsReader from "./reader/payment/PaymentDetailsReader";
|
|
14
15
|
import PaymentMethodReader from "./reader/payment/PaymentMethodReader";
|
|
15
16
|
import PaymentStatusesReader from "./reader/payment/PaymentStatusesReader";
|
|
@@ -46,7 +47,6 @@ import AdminRepo from './repo/AdminRepo';
|
|
|
46
47
|
import TableConnection from './TableConnection';
|
|
47
48
|
import ParameterType from './types/parameters/ParameterType';
|
|
48
49
|
import DeliveryStatusReader from './reader/DeliveryStatusReader';
|
|
49
|
-
import FileConnectionE from './types/FileConnectionE';
|
|
50
50
|
import ConnectorE from './types/ConnectorE';
|
|
51
51
|
import PaymentStatusE from './types/PaymentStatusE';
|
|
52
52
|
import Parameters from './utils/Parameters';
|
|
@@ -56,4 +56,8 @@ import FileConnectionsReader from "./reader/FileConnectionsReader";
|
|
|
56
56
|
import FileConnectionsRepo from "./repo/FileConnectionsRepo";
|
|
57
57
|
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
58
58
|
import FilesRepo from './repo/FilesRepo';
|
|
59
|
-
|
|
59
|
+
import File from './stockObjects/File';
|
|
60
|
+
import QueryOptions from './query/QueryOptions';
|
|
61
|
+
import OrderProductsRepo from "./repo/OrderProductsRepo";
|
|
62
|
+
import FileConnectionTypeE from './types/FileConnectionTypeE';
|
|
63
|
+
export { TableConnection, DatabaseConnection, File, ParameterType, ConnectorE, FileConnectionTypeE, PaymentStatusE, Parameters, QueryOptions, PaymentDetailsReader, FilesReader, PaymentMethodReader, DeliveryStatusReader, PaymentStatusesReader, AddressesReader, ClientAccountReader, CompanyDetailsReader, ContactDetailsReader, DeliveryDetailsReader, DeliveryMethodReader, InvoiceDetailsReader, OrderProductsReader, OrderReader, OrderStatusReader, PersonalDataReader, ProductReader, StatusTypesReader, FileConnectionsReader, CompanyDataReader, DeliveryMethodRepo, AdminRepo, PaymentDetailsRepo, AddressesRepo, ClientAccountRepo, CompanyDetailsRepo, ContactDetailsRepo, DeliveryDetailsRepo, CompanyDataRepo, InvoiceDetailsRepo, OrderRepo, PersonalDataRepo, PaymentMethodRepo, ProductRepo, FileConnectionsRepo, FilesRepo, OrderProductsRepo, OrderStatusRepo, Address, Admin, Client, CompanyDetails, ContactDetails, DeliveryDetails, InvoiceDetails, DeliveryStatus, Order, OrderProduct, PaymentDetails, PaymentStatus, PersonalData, Product, Status, };
|
|
@@ -13,6 +13,8 @@ export default class ProductMapper {
|
|
|
13
13
|
await this.productTable.insert(this.product);
|
|
14
14
|
}
|
|
15
15
|
async delete() {
|
|
16
|
-
|
|
16
|
+
const id = this.product.getId();
|
|
17
|
+
if (id)
|
|
18
|
+
await this.productTable.delete(id);
|
|
17
19
|
}
|
|
18
20
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import FileConnectionTypeE from "../types/FileConnectionTypeE";
|
|
2
2
|
import FileI from "../types/FileI";
|
|
3
3
|
import QueryOptionsI from "../types/QueryOptionsI";
|
|
4
4
|
export default class FilesReader {
|
|
@@ -6,7 +6,7 @@ export default class FilesReader {
|
|
|
6
6
|
static getAll(queryOptions: QueryOptionsI): Promise<FileI[]>;
|
|
7
7
|
static isExist(queryOptions: QueryOptionsI): Promise<number>;
|
|
8
8
|
static getQuantity(queryOptions: any): Promise<number>;
|
|
9
|
-
static getForConnection(connectionType:
|
|
9
|
+
static getForConnection(connectionType: FileConnectionTypeE, connectionId: number): Promise<FileI[]>;
|
|
10
10
|
private static correctFiles;
|
|
11
11
|
private static correctFile;
|
|
12
12
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import OrderProductI from "../types/OrderProductI";
|
|
2
2
|
export default class OrderProductsReader {
|
|
3
|
-
static getForOrder(orderId: number): Promise<
|
|
3
|
+
static getForOrder(orderId: number): Promise<any[]>;
|
|
4
4
|
static getAll(orderId: number): Promise<OrderProductI[]>;
|
|
5
5
|
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;
|
|
6
10
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import ConnectorE from "../types/ConnectorE";
|
|
3
|
+
import ParameterType from "../types/parameters/ParameterType";
|
|
2
4
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
3
5
|
import FilesReader from "./FilesReader";
|
|
4
6
|
import ProductReader from "./ProductReader";
|
|
@@ -47,4 +49,44 @@ export default class OrderProductsReader {
|
|
|
47
49
|
};
|
|
48
50
|
return correctProduct;
|
|
49
51
|
}
|
|
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
|
+
}
|
|
50
92
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import OrderI from "../types/OrderI";
|
|
2
|
+
import QueryOptionsI from "../types/QueryOptionsI";
|
|
2
3
|
export default class OrderReader {
|
|
3
4
|
static get(orderId: number): Promise<OrderI>;
|
|
4
5
|
static getForClient(clientAccountId: number): Promise<OrderI[]>;
|
|
6
|
+
static getAll(queryOptions: QueryOptionsI): Promise<{
|
|
7
|
+
orders: OrderI[];
|
|
8
|
+
quantity: number;
|
|
9
|
+
}>;
|
|
10
|
+
private static correctOrders;
|
|
5
11
|
private static correctOrder;
|
|
6
12
|
}
|
|
@@ -19,6 +19,20 @@ export default class OrderReader {
|
|
|
19
19
|
}
|
|
20
20
|
return correctOrders;
|
|
21
21
|
}
|
|
22
|
+
static async getAll(queryOptions) {
|
|
23
|
+
const connection = DatabaseConnection.get();
|
|
24
|
+
const orders = await connection.orders.selectAll(queryOptions);
|
|
25
|
+
const quantity = await connection.orders.count(queryOptions);
|
|
26
|
+
return { orders: this.correctOrders(orders), quantity };
|
|
27
|
+
}
|
|
28
|
+
static correctOrders(orderRows) {
|
|
29
|
+
const orders = [];
|
|
30
|
+
for (let i = 0; i < orderRows.length; i++) {
|
|
31
|
+
const order = this.correctOrder(orderRows[i]);
|
|
32
|
+
orders.push(order);
|
|
33
|
+
}
|
|
34
|
+
return orders;
|
|
35
|
+
}
|
|
22
36
|
static correctOrder(order) {
|
|
23
37
|
const correctOrder = {
|
|
24
38
|
id: order.id,
|
|
@@ -2,10 +2,11 @@ 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>;
|
|
5
6
|
static getForUrl(productUrl: string): Promise<ProductI>;
|
|
6
|
-
static getListForOrder(): Promise<any>;
|
|
7
7
|
static getAll(queryOptions: QueryOptionsI): Promise<ProductI[]>;
|
|
8
8
|
static getQuantity(queryOptions: QueryOptionsI): Promise<number>;
|
|
9
|
+
static getListForOrder(): Promise<any>;
|
|
9
10
|
private static correctProducts;
|
|
10
11
|
private static correctProduct;
|
|
11
12
|
private static correctProductForOrderList;
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import FileConnectionTypeE from "../types/FileConnectionTypeE";
|
|
2
3
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
3
4
|
import FilesReader from "./FilesReader";
|
|
4
5
|
export default class ProductReader {
|
|
5
6
|
static async get(productId) {
|
|
6
7
|
const connection = DatabaseConnection.get();
|
|
7
8
|
const product = await connection.products.select(productId);
|
|
8
|
-
|
|
9
|
+
const thumbnail = await FilesReader.get(product.file_id);
|
|
10
|
+
const files = await FilesReader.getForConnection(FileConnectionTypeE.product, product.id);
|
|
11
|
+
return this.correctProduct(product, thumbnail, files);
|
|
12
|
+
}
|
|
13
|
+
static async getIdForSku(productSku) {
|
|
14
|
+
const connection = DatabaseConnection.get();
|
|
15
|
+
return await connection.products.selectIdForSku(productSku);
|
|
9
16
|
}
|
|
10
17
|
static async getForUrl(productUrl) {
|
|
11
18
|
const connection = DatabaseConnection.get();
|
|
12
19
|
const product = await connection.products.selectForUrl(productUrl);
|
|
13
20
|
return this.correctProduct(product);
|
|
14
21
|
}
|
|
22
|
+
static async getAll(queryOptions) {
|
|
23
|
+
const connection = DatabaseConnection.get();
|
|
24
|
+
const products = await connection.products.selectAll(queryOptions);
|
|
25
|
+
return this.correctProducts(products);
|
|
26
|
+
}
|
|
27
|
+
static async getQuantity(queryOptions) {
|
|
28
|
+
const connection = DatabaseConnection.get();
|
|
29
|
+
const quantity = await connection.products.count(queryOptions);
|
|
30
|
+
return quantity;
|
|
31
|
+
}
|
|
15
32
|
static async getListForOrder() {
|
|
16
33
|
const connection = DatabaseConnection.get();
|
|
17
34
|
let correctProducts = [];
|
|
@@ -23,16 +40,6 @@ export default class ProductReader {
|
|
|
23
40
|
}
|
|
24
41
|
return correctProducts;
|
|
25
42
|
}
|
|
26
|
-
static async getAll(queryOptions) {
|
|
27
|
-
const connection = DatabaseConnection.get();
|
|
28
|
-
const products = await connection.products.selectAll(queryOptions);
|
|
29
|
-
return this.correctProducts(products);
|
|
30
|
-
}
|
|
31
|
-
static async getQuantity(queryOptions) {
|
|
32
|
-
const connection = DatabaseConnection.get();
|
|
33
|
-
const quantity = await connection.products.count(queryOptions);
|
|
34
|
-
return quantity;
|
|
35
|
-
}
|
|
36
43
|
static correctProducts(products) {
|
|
37
44
|
const correctProducts = [];
|
|
38
45
|
for (let i = 0; i < products.length; i++) {
|
|
@@ -41,7 +48,7 @@ export default class ProductReader {
|
|
|
41
48
|
}
|
|
42
49
|
return correctProducts;
|
|
43
50
|
}
|
|
44
|
-
static correctProduct(product) {
|
|
51
|
+
static correctProduct(product, thumbnail, files) {
|
|
45
52
|
return {
|
|
46
53
|
id: product.id,
|
|
47
54
|
sku: product.sku,
|
|
@@ -55,9 +62,10 @@ export default class ProductReader {
|
|
|
55
62
|
width: product.width,
|
|
56
63
|
height: product.height,
|
|
57
64
|
length: product.length,
|
|
58
|
-
fileId: product.file_id,
|
|
59
65
|
createdAt: product.created_at,
|
|
60
66
|
deleted: product.deleted,
|
|
67
|
+
thumbnail: thumbnail ? thumbnail : null,
|
|
68
|
+
files: files,
|
|
61
69
|
grossPrice: calculateNetToGrossPrice(product.net_price, product.vat)
|
|
62
70
|
};
|
|
63
71
|
}
|
package/dist/repo/FilesRepo.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import FileConnectionTypeE from "../types/FileConnectionTypeE";
|
|
2
2
|
export default class FilesRepo {
|
|
3
3
|
static get(fileId: number): Promise<any>;
|
|
4
|
-
static getAllForConnection(connectionType:
|
|
4
|
+
static getAllForConnection(connectionType: FileConnectionTypeE, connectionId: number): Promise<any>;
|
|
5
5
|
private static createFilesFromRows;
|
|
6
6
|
private static createFileFromRow;
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import OrderProduct from "../stockObjects/OrderProduct";
|
|
2
|
+
export default class OrderProductsRepo {
|
|
3
|
+
static getAllActiveForOrderId(orderId: number): Promise<OrderProduct[]>;
|
|
4
|
+
static getAllForIds(orderProductsIds: number[]): Promise<OrderProduct[]>;
|
|
5
|
+
private static createOrdersProductsFromRows;
|
|
6
|
+
private static createOrdersProductFromRow;
|
|
7
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import OrderProduct from "../stockObjects/OrderProduct";
|
|
3
|
+
import ConnectorE from "../types/ConnectorE";
|
|
4
|
+
import ParameterType from "../types/parameters/ParameterType";
|
|
5
|
+
export default class OrderProductsRepo {
|
|
6
|
+
static async getAllActiveForOrderId(orderId) {
|
|
7
|
+
const connection = DatabaseConnection.get();
|
|
8
|
+
const orderProducts = await connection.ordersProducts.selectAll(orderId);
|
|
9
|
+
return this.createOrdersProductsFromRows(orderProducts);
|
|
10
|
+
}
|
|
11
|
+
static async getAllForIds(orderProductsIds) {
|
|
12
|
+
const connection = DatabaseConnection.get();
|
|
13
|
+
const queryOptions = {
|
|
14
|
+
where: {
|
|
15
|
+
connector: ConnectorE.and,
|
|
16
|
+
parameters: [
|
|
17
|
+
{ name: 'id', type: ParameterType.arrayBigint, value: orderProductsIds },
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const orderProducts = await connection.ordersProducts.selectAllForIds(queryOptions);
|
|
22
|
+
return this.createOrdersProductsFromRows(orderProducts);
|
|
23
|
+
}
|
|
24
|
+
static async createOrdersProductsFromRows(dataRows) {
|
|
25
|
+
const products = [];
|
|
26
|
+
for (const dataRow of dataRows) {
|
|
27
|
+
const product = await this.createOrdersProductFromRow(dataRow);
|
|
28
|
+
products.push(product);
|
|
29
|
+
}
|
|
30
|
+
return products;
|
|
31
|
+
}
|
|
32
|
+
static async createOrdersProductFromRow(dataRow) {
|
|
33
|
+
const orderProduct = new OrderProduct(dataRow.order_id, dataRow.product_id, dataRow.net_price, dataRow.in_order);
|
|
34
|
+
orderProduct.setId(dataRow.id);
|
|
35
|
+
return orderProduct;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Status from "../stockObjects/Status";
|
|
2
|
+
export default class OrderStatusRepo {
|
|
3
|
+
static get(orderId: number): Promise<Status>;
|
|
4
|
+
static getAll(orderId: number): Promise<Status[]>;
|
|
5
|
+
private static createStatusesFromRows;
|
|
6
|
+
private static createStatusFromRow;
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import Status from "../stockObjects/Status";
|
|
3
|
+
export default class OrderStatusRepo {
|
|
4
|
+
static async get(orderId) {
|
|
5
|
+
const connection = DatabaseConnection.get();
|
|
6
|
+
const status = await connection.statuses.selectLatest(orderId);
|
|
7
|
+
return this.createStatusFromRow(status);
|
|
8
|
+
}
|
|
9
|
+
static async getAll(orderId) {
|
|
10
|
+
const connection = DatabaseConnection.get();
|
|
11
|
+
const statuses = await connection.statuses.selectAllForOrder(orderId);
|
|
12
|
+
return this.createStatusesFromRows(statuses);
|
|
13
|
+
}
|
|
14
|
+
static async createStatusesFromRows(dataRows) {
|
|
15
|
+
const statuses = [];
|
|
16
|
+
for (const dataRow of dataRows) {
|
|
17
|
+
const status = await this.createStatusFromRow(dataRow);
|
|
18
|
+
statuses.push(status);
|
|
19
|
+
}
|
|
20
|
+
return statuses;
|
|
21
|
+
}
|
|
22
|
+
static async createStatusFromRow(dataRow) {
|
|
23
|
+
const status = new Status(dataRow.order_id, dataRow.user_id, dataRow.type_id, dataRow.type_name, dataRow.created_at);
|
|
24
|
+
status.setId(dataRow.id);
|
|
25
|
+
return status;
|
|
26
|
+
}
|
|
27
|
+
}
|
package/dist/repo/ProductRepo.js
CHANGED
|
@@ -9,6 +9,7 @@ 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);
|
|
12
13
|
return this.createProductFromRow(product);
|
|
13
14
|
}
|
|
14
15
|
static createProductFromRow(productRow) {
|
|
@@ -36,5 +36,6 @@ export default class Order extends StockObject {
|
|
|
36
36
|
setInvoiceDetailsId(invoiceDetailsId: number): void;
|
|
37
37
|
setPaymentDetailsId(paymentDetailsId: number): void;
|
|
38
38
|
setZsiId(zsiId: number): void;
|
|
39
|
+
calculateAndUpdatePrice(): Promise<void>;
|
|
39
40
|
protected getMapper(): StockObjectMapper;
|
|
40
41
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import OrderMapper from "../mappers/OrderMapper";
|
|
2
|
+
import OrderProductsRepo from "../repo/OrderProductsRepo";
|
|
2
3
|
import StockObject from "../types/StockObject";
|
|
3
4
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
4
5
|
export default class Order extends StockObject {
|
|
@@ -82,6 +83,14 @@ export default class Order extends StockObject {
|
|
|
82
83
|
setZsiId(zsiId) {
|
|
83
84
|
this.zsiId = zsiId;
|
|
84
85
|
}
|
|
86
|
+
async calculateAndUpdatePrice() {
|
|
87
|
+
let totalPrice = 0;
|
|
88
|
+
const orderProducts = await OrderProductsRepo.getAllActiveForOrderId(this.getId());
|
|
89
|
+
for (const product of orderProducts) {
|
|
90
|
+
totalPrice += product.getNetPrice();
|
|
91
|
+
}
|
|
92
|
+
this.setPrice(totalPrice);
|
|
93
|
+
}
|
|
85
94
|
getMapper() {
|
|
86
95
|
return new OrderMapper(this);
|
|
87
96
|
}
|
|
@@ -5,7 +5,7 @@ export default class OrderProduct extends StockObject {
|
|
|
5
5
|
private productId;
|
|
6
6
|
private netPrice;
|
|
7
7
|
private inOrder;
|
|
8
|
-
constructor(orderId: number, productId: number, netPrice: number);
|
|
8
|
+
constructor(orderId: number, productId: number, netPrice: number, inOrder: boolean);
|
|
9
9
|
getOrderId(): number;
|
|
10
10
|
getProductId(): number;
|
|
11
11
|
getNetPrice(): number;
|
|
@@ -5,12 +5,12 @@ export default class OrderProduct extends StockObject {
|
|
|
5
5
|
productId;
|
|
6
6
|
netPrice;
|
|
7
7
|
inOrder;
|
|
8
|
-
constructor(orderId, productId, netPrice) {
|
|
8
|
+
constructor(orderId, productId, netPrice, inOrder) {
|
|
9
9
|
super();
|
|
10
10
|
this.orderId = orderId;
|
|
11
11
|
this.productId = productId;
|
|
12
12
|
this.netPrice = netPrice;
|
|
13
|
-
this.inOrder =
|
|
13
|
+
this.inOrder = inOrder;
|
|
14
14
|
}
|
|
15
15
|
getOrderId() {
|
|
16
16
|
return this.orderId;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ProductMapper from "../mappers/ProductMapper";
|
|
2
2
|
import FilesReader from "../reader/FilesReader";
|
|
3
|
-
import
|
|
3
|
+
import FileConnectionTypeE from "../types/FileConnectionTypeE";
|
|
4
4
|
import StockObject from "../types/StockObject";
|
|
5
5
|
import calculateNetToGrossPrice from "../utils/calculateNetToGrossPrice";
|
|
6
6
|
export default class Product extends StockObject {
|
|
@@ -90,7 +90,7 @@ export default class Product extends StockObject {
|
|
|
90
90
|
if (!this.files) {
|
|
91
91
|
const id = this.getId();
|
|
92
92
|
if (id) {
|
|
93
|
-
const files = await FilesReader.getForConnection(
|
|
93
|
+
const files = await FilesReader.getForConnection(FileConnectionTypeE.product, id);
|
|
94
94
|
this.files = files;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -3,13 +3,21 @@ import StockObjectMapper from "../types/StockObjectMapper";
|
|
|
3
3
|
export default class Status extends StockObject {
|
|
4
4
|
private orderId;
|
|
5
5
|
private userId;
|
|
6
|
-
private
|
|
7
|
-
|
|
6
|
+
private typeId;
|
|
7
|
+
private typeName;
|
|
8
|
+
private createdAt;
|
|
9
|
+
constructor(orderId: number, userId: number, typeId: number, typeName?: string | null, createdAt?: string | null);
|
|
8
10
|
getOrderId(): number;
|
|
11
|
+
getCreatedAt(): string | null;
|
|
9
12
|
getUserId(): number;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
getTypeId(): number;
|
|
14
|
+
getType(): {
|
|
15
|
+
id: number;
|
|
16
|
+
name: string | null;
|
|
17
|
+
};
|
|
13
18
|
setOrderId(orderId: number): void;
|
|
19
|
+
setCreatedAt(createdAt: string): void;
|
|
20
|
+
setUserId(userId: number): void;
|
|
21
|
+
setTypeId(typeId: number): void;
|
|
14
22
|
protected getMapper(): StockObjectMapper;
|
|
15
23
|
}
|
|
@@ -3,30 +3,46 @@ import StockObject from "../types/StockObject";
|
|
|
3
3
|
export default class Status extends StockObject {
|
|
4
4
|
orderId;
|
|
5
5
|
userId;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
typeId;
|
|
7
|
+
typeName;
|
|
8
|
+
createdAt;
|
|
9
|
+
constructor(orderId, userId, typeId, typeName = null, createdAt = null) {
|
|
8
10
|
super();
|
|
9
11
|
this.orderId = orderId;
|
|
10
12
|
this.userId = userId;
|
|
11
|
-
this.
|
|
13
|
+
this.typeId = typeId;
|
|
14
|
+
this.typeName = typeName;
|
|
15
|
+
this.createdAt = createdAt;
|
|
12
16
|
}
|
|
13
17
|
getOrderId() {
|
|
14
18
|
return this.orderId;
|
|
15
19
|
}
|
|
20
|
+
getCreatedAt() {
|
|
21
|
+
return this.createdAt;
|
|
22
|
+
}
|
|
16
23
|
getUserId() {
|
|
17
24
|
return this.userId;
|
|
18
25
|
}
|
|
26
|
+
getTypeId() {
|
|
27
|
+
return this.typeId;
|
|
28
|
+
}
|
|
19
29
|
getType() {
|
|
20
|
-
return
|
|
30
|
+
return {
|
|
31
|
+
id: this.typeId,
|
|
32
|
+
name: this.typeName
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
setOrderId(orderId) {
|
|
36
|
+
this.orderId = orderId;
|
|
37
|
+
}
|
|
38
|
+
setCreatedAt(createdAt) {
|
|
39
|
+
this.createdAt = createdAt;
|
|
21
40
|
}
|
|
22
41
|
setUserId(userId) {
|
|
23
42
|
this.userId = userId;
|
|
24
43
|
}
|
|
25
|
-
|
|
26
|
-
this.
|
|
27
|
-
}
|
|
28
|
-
setOrderId(orderId) {
|
|
29
|
-
this.orderId = orderId;
|
|
44
|
+
setTypeId(typeId) {
|
|
45
|
+
this.typeId = typeId;
|
|
30
46
|
}
|
|
31
47
|
getMapper() {
|
|
32
48
|
return new StatusMapper(this);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Table from '../../Table';
|
|
2
|
-
import
|
|
2
|
+
import FileConnectionTypeE from '../../types/FileConnectionTypeE';
|
|
3
3
|
import FileConnection from '../../stockObjects/FileConnection';
|
|
4
4
|
import FileConnectionRow from '../../types/rows/FileConnectionRow';
|
|
5
5
|
export default class FileConnectionsTable extends Table {
|
|
6
|
-
select(connectionType:
|
|
6
|
+
select(connectionType: FileConnectionTypeE, connection_id: number): Promise<any[]>;
|
|
7
7
|
selectForFileId(fileId: number): Promise<FileConnectionRow[]>;
|
|
8
8
|
insert(fileConnection: FileConnection): Promise<void>;
|
|
9
9
|
delete(fileId: number): Promise<boolean>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import Table from '../../Table';
|
|
2
2
|
import FileRow from '../../types/rows/FileRow';
|
|
3
|
-
import
|
|
3
|
+
import FileConnectionTypeE from '../../types/FileConnectionTypeE';
|
|
4
4
|
import QueryOptionsI from '../../types/QueryOptionsI';
|
|
5
5
|
import File from '../../stockObjects/File';
|
|
6
6
|
export default class FilesTable extends Table {
|
|
7
7
|
selectId(queryOptions: QueryOptionsI): Promise<number>;
|
|
8
8
|
selectAll(queryOptions: QueryOptionsI): Promise<FileRow[]>;
|
|
9
9
|
select(fileId: number): Promise<FileRow>;
|
|
10
|
-
selectForConnection(connectionType:
|
|
10
|
+
selectForConnection(connectionType: FileConnectionTypeE, connectionId: number): Promise<FileRow[]>;
|
|
11
11
|
insert(file: File): Promise<boolean>;
|
|
12
12
|
update(fileData: File): Promise<boolean>;
|
|
13
13
|
count(queryOptions: QueryOptionsI): Promise<number>;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import Table from '../../Table';
|
|
2
2
|
import OrderProductRow from '../../types/rows/OrderProductRow';
|
|
3
3
|
import OrderProduct from '../../stockObjects/OrderProduct';
|
|
4
|
+
import QueryOptionsI from '../../types/QueryOptionsI';
|
|
4
5
|
export default class OrdersProductsTable extends Table {
|
|
5
6
|
selectAll(orderId: number): Promise<OrderProductRow[]>;
|
|
6
|
-
|
|
7
|
+
getAllActiveForOrderId(orderId: number): Promise<OrderProduct[]>;
|
|
8
|
+
selectProducts(orderId: number): Promise<OrderProductRow[]>;
|
|
9
|
+
selectAllForIds(queryOprions: QueryOptionsI): Promise<OrderProduct[]>;
|
|
10
|
+
delete(orderProduct: OrderProduct): Promise<boolean>;
|
|
11
|
+
private bindParams;
|
|
12
|
+
insert(orderProduct: OrderProduct): Promise<boolean>;
|
|
7
13
|
private selectNextId;
|
|
8
14
|
}
|
|
@@ -2,20 +2,49 @@ import Table from '../../Table';
|
|
|
2
2
|
import * as SQL from '../../SQL.json';
|
|
3
3
|
export default class OrdersProductsTable extends Table {
|
|
4
4
|
async selectAll(orderId) {
|
|
5
|
-
const query = this.createQuery(SQL.ordersProducts.
|
|
5
|
+
const query = this.createQuery(SQL.ordersProducts.getAllActiveForOrderId);
|
|
6
6
|
query.bindParameter('order_id', orderId);
|
|
7
|
-
const
|
|
8
|
-
return
|
|
7
|
+
const result = await query.execute();
|
|
8
|
+
return result.getRows();
|
|
9
9
|
}
|
|
10
|
-
async
|
|
11
|
-
const
|
|
12
|
-
|
|
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);
|
|
18
|
+
query.bindParameter('order_id', orderId);
|
|
19
|
+
const result = await query.execute();
|
|
20
|
+
return result.getRows();
|
|
21
|
+
}
|
|
22
|
+
async selectAllForIds(queryOprions) {
|
|
23
|
+
const query = this.createQuery(SQL.ordersProducts.selectAll, queryOprions);
|
|
24
|
+
const result = await query.execute();
|
|
25
|
+
return result.getRows();
|
|
26
|
+
}
|
|
27
|
+
async delete(orderProduct) {
|
|
28
|
+
const query = this.createQuery(SQL.ordersProducts.delete);
|
|
29
|
+
const id = orderProduct.getId();
|
|
13
30
|
query.bindParameter('id', id);
|
|
31
|
+
await query.execute();
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
bindParams(query, orderProduct) {
|
|
14
35
|
query.bindParameter('order_id', orderProduct.getOrderId());
|
|
15
36
|
query.bindParameter('product_id', orderProduct.getProductId());
|
|
16
37
|
query.bindParameter('net_price', orderProduct.getNetPrice());
|
|
38
|
+
query.bindParameter('in_order', orderProduct.getInOrder());
|
|
39
|
+
}
|
|
40
|
+
async insert(orderProduct) {
|
|
41
|
+
const query = this.createQuery(SQL.ordersProducts.insert);
|
|
42
|
+
const id = await this.selectNextId();
|
|
43
|
+
query.bindParameter('id', id);
|
|
44
|
+
this.bindParams(query, orderProduct);
|
|
17
45
|
await query.execute();
|
|
18
46
|
orderProduct.setId(id);
|
|
47
|
+
return true;
|
|
19
48
|
}
|
|
20
49
|
async selectNextId() {
|
|
21
50
|
const query = this.createQuery(SQL.ordersProducts.selectNextId);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import Table from '../../Table';
|
|
2
2
|
import OrderRow from '../../types/rows/OrderRow';
|
|
3
3
|
import Order from '../../stockObjects/Order';
|
|
4
|
+
import QueryOptionsI from '../../types/QueryOptionsI';
|
|
4
5
|
export default class OrdersTable extends Table {
|
|
5
6
|
select(orderId: number): Promise<OrderRow>;
|
|
6
7
|
selectForClient(clientId: number): Promise<OrderRow[]>;
|
|
8
|
+
selectAll(queryOption: QueryOptionsI): Promise<OrderRow[]>;
|
|
9
|
+
count(queryOptions?: QueryOptionsI): Promise<number>;
|
|
7
10
|
insert(order: Order): Promise<void>;
|
|
8
11
|
update(order: Order): Promise<void>;
|
|
9
12
|
private bindParameters;
|
|
@@ -13,6 +13,16 @@ export default class OrdersTable extends Table {
|
|
|
13
13
|
const result = await query.execute();
|
|
14
14
|
return result.getRows();
|
|
15
15
|
}
|
|
16
|
+
async selectAll(queryOption) {
|
|
17
|
+
const query = this.createQuery(SQL.orders.selectAll, queryOption);
|
|
18
|
+
const result = await query.execute();
|
|
19
|
+
return result.getRows();
|
|
20
|
+
}
|
|
21
|
+
async count(queryOptions) {
|
|
22
|
+
const query = this.createQuery(SQL.orders.count, queryOptions);
|
|
23
|
+
const result = await query.execute();
|
|
24
|
+
return result.getValue();
|
|
25
|
+
}
|
|
16
26
|
async insert(order) {
|
|
17
27
|
const orderId = await this.selectNextId();
|
|
18
28
|
const query = this.createQuery(SQL.orders.insert);
|
|
@@ -3,6 +3,7 @@ import Status from '../../stockObjects/Status';
|
|
|
3
3
|
import StatusRow from '../../types/rows/StatusRow';
|
|
4
4
|
export default class StatusesTable extends Table {
|
|
5
5
|
selectForOrder(orderId: number): Promise<StatusRow>;
|
|
6
|
+
selectLatest(orderId: number): Promise<StatusRow>;
|
|
6
7
|
selectAllForOrder(orderId: number): Promise<StatusRow[]>;
|
|
7
8
|
insert(status: Status): Promise<void>;
|
|
8
9
|
private bindParameters;
|
|
@@ -7,6 +7,12 @@ export default class StatusesTable extends Table {
|
|
|
7
7
|
const result = await query.execute();
|
|
8
8
|
return result.getRow();
|
|
9
9
|
}
|
|
10
|
+
async selectLatest(orderId) {
|
|
11
|
+
const query = this.createQuery(SQL.statuses.selectLatest);
|
|
12
|
+
query.bindParameter('order_id', orderId);
|
|
13
|
+
const result = await query.execute();
|
|
14
|
+
return result.getRow();
|
|
15
|
+
}
|
|
10
16
|
async selectAllForOrder(orderId) {
|
|
11
17
|
const query = this.createQuery(SQL.statuses.selectAllForOrder);
|
|
12
18
|
query.bindParameter('order_id', orderId);
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import FileI from "./FileI";
|
|
2
2
|
export default interface OrderProductI {
|
|
3
|
-
orderProductId: number;
|
|
4
3
|
id: number;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
productId: number;
|
|
5
|
+
orderId: number;
|
|
6
|
+
product: {
|
|
7
|
+
id: number;
|
|
8
|
+
sku: string;
|
|
9
|
+
title: string;
|
|
10
|
+
netPrice: number;
|
|
11
|
+
grossPrice: number;
|
|
12
|
+
vat: number;
|
|
13
|
+
file: FileI;
|
|
14
|
+
};
|
|
9
15
|
}
|
package/dist/types/ProductI.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED