@dascompany/product 2.1.11 → 2.1.13
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 +1 -1
- package/dist/mappers/OrderProductMapper.js +5 -1
- package/dist/reader/StatusTypesReader.d.ts +3 -1
- package/dist/reader/StatusTypesReader.js +6 -2
- package/dist/stockObjects/Order.js +1 -1
- package/dist/tables/orders/OrdersProductsTable.d.ts +1 -1
- package/dist/tables/orders/OrdersProductsTable.js +1 -2
- package/dist/tables/orders/StatusTypesTable.d.ts +3 -2
- package/dist/tables/orders/StatusTypesTable.js +7 -2
- package/package.json +1 -1
package/dist/SQL.json
CHANGED
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"delete": "UPDATE orders.orders_products SET in_order = false WHERE id = $id::BIGINT"
|
|
79
79
|
},
|
|
80
80
|
"statuses": {
|
|
81
|
-
"select": "SELECT
|
|
81
|
+
"select": "SELECT * FROM orders.statuses",
|
|
82
82
|
"insert": "INSERT INTO orders.statuses( id, type, order_id, user_id ) VALUES ($id::BIGINT, $type::BIGINT, $order_id::BIGINT, $user_id::BIGINT)",
|
|
83
83
|
"selectNextId": "SELECT nextval('orders.statuses_id'::regclass)"
|
|
84
84
|
},
|
|
@@ -10,6 +10,10 @@ export default class OrderProductMapper {
|
|
|
10
10
|
await this.orderProductsTable.insert(this.orderProduct);
|
|
11
11
|
}
|
|
12
12
|
async delete() {
|
|
13
|
-
|
|
13
|
+
const orderId = this.orderProduct.getId();
|
|
14
|
+
if (orderId)
|
|
15
|
+
await this.orderProductsTable.delete(orderId);
|
|
16
|
+
else
|
|
17
|
+
throw new Error('Can`t remove the order and product connection without providing its ID');
|
|
14
18
|
}
|
|
15
19
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
export default class StatusTypesReader {
|
|
3
|
-
static async get() {
|
|
4
|
-
const statusTypes = await DatabaseConnection.getInstance().statusTypes.select();
|
|
3
|
+
static async get(queryOptions) {
|
|
4
|
+
const statusTypes = await DatabaseConnection.getInstance().statusTypes.select(queryOptions);
|
|
5
|
+
return statusTypes;
|
|
6
|
+
}
|
|
7
|
+
static async getAll(queryOptions) {
|
|
8
|
+
const statusTypes = await DatabaseConnection.getInstance().statusTypes.selectAll(queryOptions);
|
|
5
9
|
return statusTypes;
|
|
6
10
|
}
|
|
7
11
|
}
|
|
@@ -88,7 +88,7 @@ export default class Order extends StockObject {
|
|
|
88
88
|
if (id) {
|
|
89
89
|
let totalPrice = 0;
|
|
90
90
|
const queryOptions = new QueryOptions();
|
|
91
|
-
queryOptions.setWhere([{ name: 'id', type: ParameterType.bigint, value: id }]);
|
|
91
|
+
queryOptions.setWhere([{ name: 'op.id', type: ParameterType.bigint, value: id }]);
|
|
92
92
|
const orderProducts = await OrderProductsRepo.getAll(queryOptions);
|
|
93
93
|
for (const product of orderProducts) {
|
|
94
94
|
totalPrice += product.getNetPrice();
|
|
@@ -4,7 +4,7 @@ import OrderProduct from '../../stockObjects/OrderProduct';
|
|
|
4
4
|
export default class OrdersProductsTable extends Table {
|
|
5
5
|
selectAll(queryOptions?: QueryOptions): Promise<OrderProductRow[]>;
|
|
6
6
|
insert(orderProduct: OrderProduct): Promise<boolean>;
|
|
7
|
-
delete(
|
|
7
|
+
delete(id: number): Promise<boolean>;
|
|
8
8
|
private selectNextId;
|
|
9
9
|
private bindParams;
|
|
10
10
|
}
|
|
@@ -15,9 +15,8 @@ export default class OrdersProductsTable extends Table {
|
|
|
15
15
|
orderProduct.setId(id);
|
|
16
16
|
return true;
|
|
17
17
|
}
|
|
18
|
-
async delete(
|
|
18
|
+
async delete(id) {
|
|
19
19
|
const query = this.createQuery(SQL.ordersProducts.delete);
|
|
20
|
-
const id = orderProduct.getId();
|
|
21
20
|
query.bindParameter('id', id);
|
|
22
21
|
await query.execute();
|
|
23
22
|
return true;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Table } from '@dascompany/database';
|
|
1
|
+
import { QueryOptions, Table } from '@dascompany/database';
|
|
2
2
|
export default class StatusTypesTable extends Table {
|
|
3
|
-
select(): Promise<any[]>;
|
|
3
|
+
select(queryOptions: QueryOptions): Promise<any[]>;
|
|
4
|
+
selectAll(queryOptions?: QueryOptions): Promise<any[]>;
|
|
4
5
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { Table } from '@dascompany/database';
|
|
2
2
|
import * as SQL from '../../SQL.json';
|
|
3
3
|
export default class StatusTypesTable extends Table {
|
|
4
|
-
async select() {
|
|
5
|
-
const query = this.createQuery(SQL.statusTypes.select);
|
|
4
|
+
async select(queryOptions) {
|
|
5
|
+
const query = this.createQuery(SQL.statusTypes.select, queryOptions);
|
|
6
|
+
const result = await query.execute();
|
|
7
|
+
return result.getRow();
|
|
8
|
+
}
|
|
9
|
+
async selectAll(queryOptions) {
|
|
10
|
+
const query = this.createQuery(SQL.statusTypes.select, queryOptions);
|
|
6
11
|
const result = await query.execute();
|
|
7
12
|
return result.getRows();
|
|
8
13
|
}
|