@dascompany/product 3.5.5 → 3.6.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
@@ -58,8 +58,8 @@
58
58
  "products": {
59
59
  "select": "SELECT * FROM products",
60
60
  "selectId": "SELECT id FROM products",
61
- "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)",
62
- "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",
61
+ "insert": "INSERT INTO products( id, sku, article_number, url, title, description, net_price, promotional_net_price, vat, color, quantity, width, length, height, file_id, json_data, deleted) VALUES ($id::BIGINT, $sku::TEXT, $article_number::TEXT, $url::TEXT, $title::TEXT, $description::TEXT, $net_price::DOUBLE PRECISION, $promotional_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)",
62
+ "update": "UPDATE products SET url = $url::TEXT, title = $title::TEXT, description = $description::TEXT , net_price = $net_price::DOUBLE PRECISION, promotional_net_price = $promotional_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",
63
63
  "delete": "UPDATE products SET deleted = true WHERE id = $id::BIGINT",
64
64
  "maxPrice": "SELECT MAX(net_price) FROM products",
65
65
  "count": "SELECT COUNT(*) AS total_rows FROM products",
@@ -42,10 +42,12 @@ export default class ProductReader {
42
42
  return {
43
43
  id: product.id,
44
44
  sku: product.sku,
45
+ articleNumber: product.article_number,
45
46
  url: product.url,
46
47
  title: product.title,
47
48
  description: product.description,
48
49
  netPrice: Number(product.net_price),
50
+ promotionalNetPrice: Number(product.promotional_net_price),
49
51
  vat: Number(product.vat),
50
52
  color: product.color,
51
53
  quantity: Number(product.quantity),
@@ -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.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.article_number, productRow.title, productRow.description, productRow.net_price, productRow.promotional_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,9 +3,11 @@ import FileI from "../types/FileI";
3
3
  export default class Product extends StockObject {
4
4
  private sku;
5
5
  private url;
6
+ private articleNumber;
6
7
  private title;
7
8
  private description;
8
9
  private netPrice;
10
+ private promotionalNetPrice;
9
11
  private vat;
10
12
  private color;
11
13
  private quantity;
@@ -18,12 +20,14 @@ export default class Product extends StockObject {
18
20
  private file;
19
21
  private jsonData;
20
22
  private files;
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
+ constructor(sku: string, url: string, articleNumber: string, title: string, description: string, netPrice: number, promotionalNetPrice: number | null, vat: number, color: string, quantity: number, width: number, length: number, height: number, fileId: number, jsonData: any, deleted?: boolean);
22
24
  getSku(): string;
23
25
  getUrl(): string;
26
+ getArticleNumber(): string;
24
27
  getTitle(): string;
25
28
  getDescription(): string;
26
29
  getNetPrice(): number;
30
+ getPromotionalNetPrice(): number | null;
27
31
  getGrossPrice(): number;
28
32
  getVat(): number;
29
33
  getColor(): string;
@@ -6,9 +6,11 @@ import PriceConverter from "../utils/PriceConverter";
6
6
  export default class Product extends StockObject {
7
7
  sku;
8
8
  url;
9
+ articleNumber;
9
10
  title;
10
11
  description;
11
12
  netPrice;
13
+ promotionalNetPrice;
12
14
  vat;
13
15
  color;
14
16
  quantity;
@@ -21,13 +23,15 @@ export default class Product extends StockObject {
21
23
  file;
22
24
  jsonData;
23
25
  files;
24
- constructor(sku, url, title, description, netPrice, vat, color, quantity, width, length, height, fileId, jsonData, deleted = false) {
26
+ constructor(sku, url, articleNumber, title, description, netPrice, promotionalNetPrice, vat, color, quantity, width, length, height, fileId, jsonData, deleted = false) {
25
27
  super();
26
28
  this.sku = sku;
27
29
  this.url = url;
30
+ this.articleNumber = articleNumber;
28
31
  this.title = title;
29
32
  this.description = description;
30
33
  this.netPrice = netPrice;
34
+ this.promotionalNetPrice = promotionalNetPrice;
31
35
  this.vat = vat;
32
36
  this.color = color;
33
37
  this.quantity = quantity;
@@ -47,6 +51,9 @@ export default class Product extends StockObject {
47
51
  getUrl() {
48
52
  return this.url;
49
53
  }
54
+ getArticleNumber() {
55
+ return this.url;
56
+ }
50
57
  getTitle() {
51
58
  return this.title;
52
59
  }
@@ -54,10 +61,13 @@ export default class Product extends StockObject {
54
61
  return this.description;
55
62
  }
56
63
  getNetPrice() {
57
- return PriceConverter.netToGrossPrice(this.netPrice, this.vat);
64
+ return this.netPrice;
65
+ }
66
+ getPromotionalNetPrice() {
67
+ return this.promotionalNetPrice;
58
68
  }
59
69
  getGrossPrice() {
60
- return this.netPrice;
70
+ return PriceConverter.netToGrossPrice(this.netPrice, this.vat);
61
71
  }
62
72
  getVat() {
63
73
  return this.vat;
@@ -32,6 +32,7 @@ export default class FilesTable extends Table {
32
32
  }
33
33
  async update(fileData) {
34
34
  const query = this.createQuery(SQL.files.update);
35
+ query.bindParameter('id', fileData.getId());
35
36
  this.bindParameters(query, fileData);
36
37
  await query.execute();
37
38
  return true;
@@ -65,9 +65,11 @@ export default class ProductsTable extends Table {
65
65
  bindParameters(query, product) {
66
66
  query.bindParameter('sku', product.getSku());
67
67
  query.bindParameter('url', product.getUrl());
68
+ query.bindParameter('article_number', product.getArticleNumber());
68
69
  query.bindParameter('title', product.getTitle());
69
70
  query.bindParameter('description', product.getDescription());
70
71
  query.bindParameter('net_price', product.getNetPrice());
72
+ query.bindParameter('promotional_net_price', product.getPromotionalNetPrice());
71
73
  query.bindParameter('vat', product.getVat());
72
74
  query.bindParameter('color', product.getColor());
73
75
  query.bindParameter('quantity', product.getQuantity());
@@ -2,10 +2,12 @@ import type FileI from "./FileI";
2
2
  export default interface ProductI {
3
3
  id: string;
4
4
  sku: string;
5
+ articleNumber: string;
5
6
  url: string;
6
7
  title: string;
7
8
  description: string;
8
9
  netPrice: number;
10
+ promotionalNetPrice: number;
9
11
  installationPrice: number;
10
12
  grossPrice: number;
11
13
  vat: number;
@@ -2,5 +2,5 @@ export default interface FileConnectionRow {
2
2
  file_id: string;
3
3
  connection_type: string;
4
4
  connection_id: string;
5
- sequence: string;
5
+ sequence: number;
6
6
  }
@@ -3,7 +3,7 @@ export default interface FileRow {
3
3
  name: string;
4
4
  orginal_name: string;
5
5
  catalog: string;
6
- size_kb: string;
6
+ size_kb: number;
7
7
  type: string;
8
8
  created_at: string;
9
9
  }
@@ -1,11 +1,13 @@
1
1
  export default interface ProductRow {
2
2
  id: string;
3
3
  sku: string;
4
+ article_number: string;
4
5
  url: string;
5
6
  title: string;
6
7
  description: string;
7
8
  file_id: string;
8
9
  net_price: number;
10
+ promotional_net_price: number;
9
11
  vat: number;
10
12
  color: string;
11
13
  quantity: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dascompany/product",
3
- "version": "3.5.5",
3
+ "version": "3.6.0",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "vitest",
@@ -1,7 +0,0 @@
1
- import AddressI from "./AddressI";
2
- export default interface AccountDeliveryDetailsI {
3
- id: number;
4
- accountId: number;
5
- address: AddressI;
6
- personalData: number;
7
- }
@@ -1 +0,0 @@
1
- export {};