@dascompany/product 3.0.8 → 3.1.1

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
@@ -62,8 +62,8 @@
62
62
  "products": {
63
63
  "select": "SELECT * FROM products",
64
64
  "selectId": "SELECT id FROM products",
65
- "insert": "INSERT INTO products( id, sku, url, title, description, net_price, installation_price, vat, color, quantity, width, length, height, file_id, json_data, deleted) VALUES ($id::BIGINT, $sku::TEXT, $url::TEXT, $title::TEXT, $description::TEXT, $net_price::DOUBLE PRECISION, $installation_price::DOUBLE PRECISION, $vat::INT, $color::TEXT, $quantity::INT, $width::INT, $length::INT, $height::DOUBLE PRECISION,$file_id::BIGINT , $json_data::JSON, false::BOOL)",
66
- "update": "UPDATE products SET url = $url::TEXT, title = $title::TEXT, description = $description::TEXT , net_price = $net_price::DOUBLE PRECISION, installation_price = $installation_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, json_data = $json_data::JSON WHERE id = $id::BIGINT",
65
+ "insert": "INSERT INTO products( id, sku, url, title, description, net_price, vat, color, quantity, width, length, height, file_id, json_data, 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 , $json_data::JSON, false::BOOL)",
66
+ "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, json_data = $json_data::JSON WHERE id = $id::BIGINT",
67
67
  "delete": "UPDATE products SET deleted = true WHERE id = $id::BIGINT",
68
68
  "maxPrice": "SELECT MAX(net_price) FROM products",
69
69
  "count": "SELECT COUNT(*) AS total_rows FROM products",
@@ -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) {
@@ -46,7 +48,6 @@ export default class ProductReader {
46
48
  title: product.title,
47
49
  description: product.description,
48
50
  netPrice: product.net_price,
49
- installationPrice: product.installation_price,
50
51
  vat: product.vat,
51
52
  color: product.color,
52
53
  quantity: product.quantity,
@@ -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
  }
@@ -6,7 +6,7 @@ export default class ProductRepo {
6
6
  return this.createProductFromRow(product);
7
7
  }
8
8
  static createProductFromRow(productRow) {
9
- const product = new Product(productRow.sku, productRow.url, productRow.title, productRow.description, productRow.net_price, productRow.installation_price, productRow.vat, productRow.color, productRow.quantity, productRow.width, productRow.length, productRow.height, productRow.file_id, productRow.deleted);
9
+ const product = new Product(productRow.sku, productRow.url, productRow.title, productRow.description, productRow.net_price, productRow.vat, productRow.color, productRow.quantity, productRow.width, productRow.length, productRow.height, productRow.file_id, productRow.deleted);
10
10
  product.setId(productRow.id);
11
11
  product.setCreatedAt(productRow.created_at);
12
12
  return product;
@@ -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;
@@ -6,7 +6,6 @@ export default class Product extends StockObject {
6
6
  private title;
7
7
  private description;
8
8
  private netPrice;
9
- private installationPrice;
10
9
  private vat;
11
10
  private color;
12
11
  private quantity;
@@ -19,13 +18,12 @@ export default class Product extends StockObject {
19
18
  private file;
20
19
  private jsonData;
21
20
  private files;
22
- constructor(sku: string, url: string, title: string, description: string, netPrice: number, installationPrice: number, vat: number, color: string, quantity: number, width: number, length: number, height: number, fileId: number, jsonData: any, deleted?: boolean);
21
+ constructor(sku: string, url: string, title: string, description: string, netPrice: number, vat: number, color: string, quantity: number, width: number, length: number, height: number, fileId: number, jsonData: any, deleted?: boolean);
23
22
  getSku(): string;
24
23
  getUrl(): string;
25
24
  getTitle(): string;
26
25
  getDescription(): string;
27
26
  getNetPrice(): number;
28
- getInstallationPrice(): number;
29
27
  getGrossPrice(): number;
30
28
  getVat(): number;
31
29
  getColor(): string;
@@ -45,7 +43,6 @@ export default class Product extends StockObject {
45
43
  title: string;
46
44
  description: string;
47
45
  netPrice: number;
48
- installationPrice: number;
49
46
  vat: number;
50
47
  color: string;
51
48
  quantity: number;
@@ -62,7 +59,6 @@ export default class Product extends StockObject {
62
59
  setTitle(title: string): string;
63
60
  setDescription(description: string): string;
64
61
  setNetPrice(netPrice: number): number;
65
- setInstallationPrice(installationPrice: number): number;
66
62
  setVat(vat: number): number;
67
63
  setColor(color: string): string;
68
64
  setQuantity(quantity: number): number;
@@ -9,7 +9,6 @@ export default class Product extends StockObject {
9
9
  title;
10
10
  description;
11
11
  netPrice;
12
- installationPrice;
13
12
  vat;
14
13
  color;
15
14
  quantity;
@@ -22,14 +21,13 @@ export default class Product extends StockObject {
22
21
  file;
23
22
  jsonData;
24
23
  files;
25
- constructor(sku, url, title, description, netPrice, installationPrice, vat, color, quantity, width, length, height, fileId, jsonData, deleted = false) {
24
+ constructor(sku, url, title, description, netPrice, vat, color, quantity, width, length, height, fileId, jsonData, deleted = false) {
26
25
  super();
27
26
  this.sku = sku;
28
27
  this.url = url;
29
28
  this.title = title;
30
29
  this.description = description;
31
30
  this.netPrice = netPrice;
32
- this.installationPrice = installationPrice;
33
31
  this.vat = vat;
34
32
  this.color = color;
35
33
  this.quantity = quantity;
@@ -58,9 +56,6 @@ export default class Product extends StockObject {
58
56
  getNetPrice() {
59
57
  return PriceConverter.netToGrossPrice(this.netPrice, this.vat);
60
58
  }
61
- getInstallationPrice() {
62
- return this.installationPrice;
63
- }
64
59
  getGrossPrice() {
65
60
  return this.netPrice;
66
61
  }
@@ -119,7 +114,6 @@ export default class Product extends StockObject {
119
114
  title: this.title,
120
115
  description: this.description,
121
116
  netPrice: this.netPrice,
122
- installationPrice: this.installationPrice,
123
117
  vat: this.vat,
124
118
  color: this.color,
125
119
  quantity: this.quantity,
@@ -149,9 +143,6 @@ export default class Product extends StockObject {
149
143
  setNetPrice(netPrice) {
150
144
  return this.netPrice = netPrice;
151
145
  }
152
- setInstallationPrice(installationPrice) {
153
- return this.installationPrice = installationPrice;
154
- }
155
146
  setVat(vat) {
156
147
  return this.vat = vat;
157
148
  }
@@ -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() {
@@ -68,7 +68,6 @@ export default class ProductsTable extends Table {
68
68
  query.bindParameter('title', product.getTitle());
69
69
  query.bindParameter('description', product.getDescription());
70
70
  query.bindParameter('net_price', product.getNetPrice());
71
- query.bindParameter('installation_price', product.getInstallationPrice());
72
71
  query.bindParameter('vat', product.getVat());
73
72
  query.bindParameter('color', product.getColor());
74
73
  query.bindParameter('quantity', product.getQuantity());
@@ -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;
@@ -6,7 +6,6 @@ export default interface ProductRow {
6
6
  description: string;
7
7
  file_id: number;
8
8
  net_price: number;
9
- installation_price: number;
10
9
  vat: number;
11
10
  color: string;
12
11
  quantity: 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.1",
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
  }