@dascompany/product 3.0.8 → 3.1.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 CHANGED
@@ -71,8 +71,8 @@
71
71
  },
72
72
  "orders": {
73
73
  "select": "SELECT * FROM orders.orders",
74
- "insert": "INSERT INTO orders.orders( id, email, price, client_id, personal_data_id_id, delivery_details_id, invoice_details_id, payment_details_id ) VALUES ($order_id::BIGINT, $email::TEXT, $price::DOUBLE PRECISION, $client_id::BIGINT, $personal_data_id_id::BIGINT, $delivery_details_id::BIGINT , $invoice_details_id::BIGINT, $payment_details_id::BIGINT )",
75
- "update": "UPDATE orders.orders SET price = $price::DOUBLE PRECISION, personal_data_id_id = $personal_data_id_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",
74
+ "insert": "INSERT INTO orders.orders( id, email, price, client_id, delivery_details_id, company_details_id, payment_details_id ) VALUES ($order_id::BIGINT, $email::TEXT, $price::DOUBLE PRECISION, $client_id::BIGINT, $delivery_details_id::BIGINT , $company_details_id::BIGINT, $payment_details_id::BIGINT )",
75
+ "update": "UPDATE orders.orders SET price = $price::DOUBLE PRECISION, delivery_details_id = $delivery_details_id::BIGINT, company_details_id = $company_details_id::BIGINT, payment_details_id = $payment_details_id::BIGINT, zsi_id = $zsi_id::BIGINT WHERE id = $id::BIGINT",
76
76
  "count": "SELECT COUNT (*) AS TOTAL_ROWS FROM orders.orders",
77
77
  "selectNextId": "SELECT nextval('orders.orders_id'::regclass)"
78
78
  },
@@ -42,9 +42,8 @@ export default class OrderReader {
42
42
  price: order.price,
43
43
  createdAt: order.created_at,
44
44
  clientId: order.client_id,
45
- personalDataId: order.personal_data_id,
46
45
  deliveryDetailsId: order.delivery_details_id,
47
- invoiceDetailsId: order.invoice_details_id,
46
+ companyDetailsId: order.company_details_id,
48
47
  paymentDetailsId: order.payment_details_id,
49
48
  zsiId: order.zsi_id,
50
49
  status
@@ -4,6 +4,7 @@ import DatabaseConnection from "../DatabaseConnection";
4
4
  import FileConnectionTypeE from "../types/FileConnectionTypeE";
5
5
  import PriceConverter from "../utils/PriceConverter";
6
6
  import createQueryOptionsForId from "../utils/createQueryOptionsForId";
7
+ import getTentInstallationPrice from "../utils/getTentInstallationPrice";
7
8
  export default class ProductReader {
8
9
  static async get(queryOption) {
9
10
  const productRow = await DatabaseConnection.getInstance().products.select(queryOption);
@@ -12,6 +13,7 @@ export default class ProductReader {
12
13
  queryOptionsFiles.setOrderBy([{ key: 'sequence', order: 'asc' }]);
13
14
  const files = await FilesReader.getForConnection(queryOptionsFiles);
14
15
  const product = await this.correctProduct(productRow);
16
+ product.installationPrice = await getTentInstallationPrice(product);
15
17
  return { ...product, files };
16
18
  }
17
19
  static async getAll(queryOption) {
@@ -6,7 +6,7 @@ export default class OrderRepo {
6
6
  return this.createOrderFromRow(orderData);
7
7
  }
8
8
  static createOrderFromRow(orderData) {
9
- const order = new Order(orderData.email, orderData.price, orderData.client_id, orderData.personal_data_id, orderData.delivery_details_id, orderData.invoice_details_id, orderData.payment_details_id);
9
+ const order = new Order(orderData.email, orderData.price, orderData.client_id, orderData.delivery_details_id, orderData.company_details_id, orderData.payment_details_id);
10
10
  order.setId(orderData.id);
11
11
  return order;
12
12
  }
@@ -3,20 +3,18 @@ export default class Order extends StockObject {
3
3
  private email;
4
4
  private price;
5
5
  private clientId;
6
- private personalDataId;
7
6
  private deliveryDetailsId;
8
- private invoiceDetailsId;
7
+ private companyDetailsId;
9
8
  private paymentDetailsId;
10
9
  private zsiId;
11
- constructor(email: string, price: number, clientId: number | null, personalDataId: number, deliveryDetailsId: number, invoiceDetailsId?: number | null, paymentDetailsId?: number | null);
10
+ constructor(email: string, price: number, clientId: number | null, deliveryDetailsId: number, companyDetailsId?: number | null, paymentDetailsId?: number | null);
12
11
  getData(): Promise<{
13
12
  id: number | null;
14
13
  email: string;
15
14
  price: number;
16
15
  clientId: number | null;
17
- personalDataId: number | null;
18
16
  deliveryDetailsId: number | null;
19
- invoiceDetailsId: number | null;
17
+ companyDetailsId: number | null;
20
18
  paymentDetailsId: number | null;
21
19
  }>;
22
20
  getEmail(): string;
@@ -24,15 +22,13 @@ export default class Order extends StockObject {
24
22
  getZsiId(): number | null;
25
23
  getGrossPrice(): number;
26
24
  getClientId(): number | null;
27
- getPersonalDataId(): number | null;
28
25
  getDeliveryDetailsId(): number | null;
29
26
  getInvoiceDetailsId(): number | null;
30
27
  getPaymentDetailsId(): number | null;
31
28
  setPrice(price: number): void;
32
29
  setclientId(clientId: number): void;
33
- setPersonalDataId(personalDataId: number): void;
34
30
  setDeliveryDetailsId(deliveryDetailsId: number): void;
35
- setInvoiceDetailsId(invoiceDetailsId: number): void;
31
+ setInvoiceDetailsId(companyDetailsId: number): void;
36
32
  setPaymentDetailsId(paymentDetailsId: number): void;
37
33
  setZsiId(zsiId: number): void;
38
34
  calculateAndUpdatePrice(): Promise<void>;
@@ -6,19 +6,17 @@ export default class Order extends StockObject {
6
6
  email;
7
7
  price;
8
8
  clientId;
9
- personalDataId;
10
9
  deliveryDetailsId;
11
- invoiceDetailsId;
10
+ companyDetailsId;
12
11
  paymentDetailsId;
13
12
  zsiId;
14
- constructor(email, price, clientId, personalDataId, deliveryDetailsId, invoiceDetailsId = null, paymentDetailsId = null) {
13
+ constructor(email, price, clientId, deliveryDetailsId, companyDetailsId = null, paymentDetailsId = null) {
15
14
  super();
16
15
  this.email = email;
17
16
  this.price = price;
18
17
  this.clientId = clientId;
19
- this.personalDataId = personalDataId;
20
18
  this.deliveryDetailsId = deliveryDetailsId;
21
- this.invoiceDetailsId = invoiceDetailsId;
19
+ this.companyDetailsId = companyDetailsId;
22
20
  this.paymentDetailsId = paymentDetailsId;
23
21
  this.zsiId = null;
24
22
  }
@@ -28,9 +26,8 @@ export default class Order extends StockObject {
28
26
  email: this.email,
29
27
  price: this.price,
30
28
  clientId: this.clientId,
31
- personalDataId: this.personalDataId,
32
29
  deliveryDetailsId: this.deliveryDetailsId,
33
- invoiceDetailsId: this.invoiceDetailsId,
30
+ companyDetailsId: this.companyDetailsId,
34
31
  paymentDetailsId: this.paymentDetailsId,
35
32
  };
36
33
  }
@@ -50,14 +47,11 @@ export default class Order extends StockObject {
50
47
  getClientId() {
51
48
  return this.clientId;
52
49
  }
53
- getPersonalDataId() {
54
- return this.personalDataId;
55
- }
56
50
  getDeliveryDetailsId() {
57
51
  return this.deliveryDetailsId;
58
52
  }
59
53
  getInvoiceDetailsId() {
60
- return this.invoiceDetailsId;
54
+ return this.companyDetailsId;
61
55
  }
62
56
  getPaymentDetailsId() {
63
57
  return this.paymentDetailsId;
@@ -68,14 +62,11 @@ export default class Order extends StockObject {
68
62
  setclientId(clientId) {
69
63
  this.clientId = clientId;
70
64
  }
71
- setPersonalDataId(personalDataId) {
72
- this.personalDataId = personalDataId;
73
- }
74
65
  setDeliveryDetailsId(deliveryDetailsId) {
75
66
  this.deliveryDetailsId = deliveryDetailsId;
76
67
  }
77
- setInvoiceDetailsId(invoiceDetailsId) {
78
- this.invoiceDetailsId = invoiceDetailsId;
68
+ setInvoiceDetailsId(companyDetailsId) {
69
+ this.companyDetailsId = companyDetailsId;
79
70
  }
80
71
  setPaymentDetailsId(paymentDetailsId) {
81
72
  this.paymentDetailsId = paymentDetailsId;
@@ -40,9 +40,8 @@ export default class OrdersTable extends Table {
40
40
  this.bindDetailsParameters(query, order);
41
41
  }
42
42
  bindDetailsParameters(query, order) {
43
- query.bindParameter('personal_data_id', order.getPersonalDataId());
44
43
  query.bindParameter('delivery_details_id', order.getDeliveryDetailsId());
45
- query.bindParameter('invoice_details_id', order.getInvoiceDetailsId());
44
+ query.bindParameter('company_details_id', order.getInvoiceDetailsId());
46
45
  query.bindParameter('payment_details_id', order.getPaymentDetailsId());
47
46
  }
48
47
  async selectNextId() {
@@ -5,9 +5,8 @@ export default interface OrderI {
5
5
  price: number;
6
6
  createdAt: string;
7
7
  clientId: number;
8
- personalDataId: number;
9
8
  deliveryDetailsId: number;
10
- invoiceDetailsId: number;
9
+ companyDetailsId: number;
11
10
  paymentDetailsId: number;
12
11
  zsiId: number;
13
12
  status: StatusI;
@@ -4,9 +4,8 @@ export default interface OrderRow {
4
4
  price: number;
5
5
  created_at: string;
6
6
  client_id: number;
7
- personal_data_id: number;
8
7
  delivery_details_id: number;
9
- invoice_details_id: number;
8
+ company_details_id: number;
10
9
  payment_details_id: number;
11
10
  zsi_id: number;
12
11
  status_id: number;
@@ -0,0 +1,2 @@
1
+ import ProductI from "../types/ProductI";
2
+ export default function getTentInstallationPrice(productData: ProductI): Promise<number>;
@@ -0,0 +1,14 @@
1
+ import { TentInstallation } from "@dascompany/zsi";
2
+ export default async function getTentInstallationPrice(productData) {
3
+ const constructionSplit = productData.jsonData.construction.type.split(' ');
4
+ const tentData = {
5
+ construction: constructionSplit[0],
6
+ reinforcement: constructionSplit[1].toUpperCase() === 'POLAR',
7
+ fireResistant: (productData.jsonData.cover.type === 'PVC - 600g' || productData.jsonData.cover.type === 'PVC - 620g'),
8
+ width: productData.width,
9
+ length: productData.length,
10
+ height: productData.height
11
+ };
12
+ const installationPrice = await TentInstallation.getPrice(tentData);
13
+ return installationPrice;
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dascompany/product",
3
- "version": "3.0.8",
3
+ "version": "3.1.0",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "vitest",
@@ -21,6 +21,7 @@
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@dascompany/database": "^3.0.2",
24
+ "@dascompany/zsi": "^2.0.1",
24
25
  "@types/pg": "^8.11.11",
25
26
  "pg": "^8.13.3"
26
27
  }