@dascompany/product 2.1.11 → 2.1.12

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.
@@ -10,6 +10,10 @@ export default class OrderProductMapper {
10
10
  await this.orderProductsTable.insert(this.orderProduct);
11
11
  }
12
12
  async delete() {
13
- throw Error('NOT IMPLEMENTED');
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
  }
@@ -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(orderProduct: OrderProduct): Promise<boolean>;
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(orderProduct) {
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dascompany/product",
3
- "version": "2.1.11",
3
+ "version": "2.1.12",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "vitest",