@dascompany/product 4.0.5 → 4.0.6

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.
@@ -21,6 +21,7 @@ import FileConnectionsTable from './tables/files/FileConnectionsTable';
21
21
  import AdminAccountsTable from './tables/public/AdminAccountsTable';
22
22
  import AccountCompanyDetailsTable from './tables/clients/AccountCompanyDetailsTable';
23
23
  import AccountDeliveryDetailsTable from './tables/clients/AccountDeliveryDetailsTable';
24
+ import AccountCartTable from './tables/clients/AccountCartTable';
24
25
  export default class DatabaseConnection {
25
26
  static instance: DatabaseConnection;
26
27
  private tables;
@@ -35,6 +36,7 @@ export default class DatabaseConnection {
35
36
  get addresses(): AddressesTable;
36
37
  get clientAccounts(): ClientAccountsTable;
37
38
  get accountCompanyDetails(): AccountCompanyDetailsTable;
39
+ get accountCart(): AccountCartTable;
38
40
  get accountDeliveryDetails(): AccountDeliveryDetailsTable;
39
41
  get adminAccounts(): AdminAccountsTable;
40
42
  get companyDetails(): CompanyDetailsTable;
@@ -23,6 +23,7 @@ import FileConnectionsTable from './tables/files/FileConnectionsTable';
23
23
  import AdminAccountsTable from './tables/public/AdminAccountsTable';
24
24
  import AccountCompanyDetailsTable from './tables/clients/AccountCompanyDetailsTable';
25
25
  import AccountDeliveryDetailsTable from './tables/clients/AccountDeliveryDetailsTable';
26
+ import AccountCartTable from './tables/clients/AccountCartTable';
26
27
  export default class DatabaseConnection {
27
28
  static instance;
28
29
  tables = new Map();
@@ -75,6 +76,11 @@ export default class DatabaseConnection {
75
76
  this.tables.set(TableNames.accountCompanyDetails, new AccountCompanyDetailsTable(this.connection));
76
77
  return this.tables.get(TableNames.accountCompanyDetails);
77
78
  }
79
+ get accountCart() {
80
+ if (!this.tables.get(TableNames.accountCart))
81
+ this.tables.set(TableNames.accountCart, new AccountCartTable(this.connection));
82
+ return this.tables.get(TableNames.accountCart);
83
+ }
78
84
  get accountDeliveryDetails() {
79
85
  if (!this.tables.get(TableNames.accountDeliveryDetails))
80
86
  this.tables.set(TableNames.accountDeliveryDetails, new AccountDeliveryDetailsTable(this.connection));
package/dist/SQL.json CHANGED
@@ -17,6 +17,11 @@
17
17
  "count": "SELECT COUNT(*) AS total_rows FROM clients.accounts",
18
18
  "selectNextId": "SELECT nextval('clients.accounts_id'::regclass)"
19
19
  },
20
+ "accountCart": {
21
+ "select": "SELECT * FROM clients.account_cart WHERE account_id = $account_id::BIGINT AND product_id = $product_id::BIGINT",
22
+ "insert": "INSERT INTO clients.account_cart(account_id, product_id) VALUES ($account_id::BIGINT, $product_id::BIGINT)",
23
+ "delete": "DELETE FROM clients.account_cart WHERE product_id = $product_id::BIGINT AND account_id = $account_id::BIGINT"
24
+ },
20
25
  "accountDeliveryDetails": {
21
26
  "select": "SELECT * FROM clients.account_delivery_details WHERE account_id = $account_id::BIGINT",
22
27
  "insert": "INSERT INTO clients.account_delivery_details(account_id, delivery_details_id) VALUES ($account_id::BIGINT, $delivery_details_id::BIGINT)",
@@ -58,8 +63,8 @@
58
63
  "products": {
59
64
  "select": "SELECT * FROM products",
60
65
  "selectId": "SELECT id FROM products",
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, article_number = $article_number::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",
66
+ "insert": "INSERT INTO products( id, sku, article_number, url, title, subtitle, 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, subtitle::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)",
67
+ "update": "UPDATE products SET url = $url::TEXT, article_number = $article_number::TEXT, title = $title::TEXT, subtitle = $subtitle::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
68
  "delete": "UPDATE products SET deleted = true WHERE id = $id::BIGINT",
64
69
  "maxPrice": "SELECT MAX(net_price) FROM products",
65
70
  "count": "SELECT COUNT(*) AS total_rows FROM products",
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import Client from "./stockObjects/Client";
2
2
  import ClientAccountRepo from "./repo/ClientAccountRepo";
3
3
  import ClientAccountReader from "./reader/ClientAccountReader";
4
+ import AccountCartReader from "./reader/AccountCartReader";
4
5
  import AccountDeliveryDetailsReader from "./reader/AccountDeliveryDetailsReader";
5
6
  import AccountCompanyDetailsReader from "./reader/AccountCompanyDetailsReader";
6
7
  import Admin from "./stockObjects/Admin";
@@ -72,4 +73,4 @@ import CompanyDataReader from "./reader/CompanyDataReader";
72
73
  import CompanyDataI from "./types/CompanyDataI";
73
74
  import PriceConverter from "./utils/PriceConverter";
74
75
  import createQueryOptionsForId from "./utils/createQueryOptionsForId";
75
- export { Client, ClientAccountRepo, ClientAccountReader, AccountDeliveryDetailsReader, AccountCompanyDetailsReader, Admin, AdminRepo, AdminReader, Address, AddressI, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, PersonalDataI, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, CompanyDetailsI, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryDetailsI, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryMethodI, DeliveryMethodTypeE, DeliveryStatus, DeliveryStatusReader, DeliveryStatusTypeE, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentDetailsI, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentMethodI, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, OrderProductI, Status, OrderStatusReader, StatusI, OrderStatusTypeE, StatusTypesReader, ProductI, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileI, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, CompanyDataI, PriceConverter, createQueryOptionsForId };
76
+ export { Client, ClientAccountRepo, ClientAccountReader, AccountCartReader, AccountDeliveryDetailsReader, AccountCompanyDetailsReader, Admin, AdminRepo, AdminReader, Address, AddressI, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, PersonalDataI, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, CompanyDetailsI, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryDetailsI, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryMethodI, DeliveryMethodTypeE, DeliveryStatus, DeliveryStatusReader, DeliveryStatusTypeE, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentDetailsI, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentMethodI, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, OrderProductI, Status, OrderStatusReader, StatusI, OrderStatusTypeE, StatusTypesReader, ProductI, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileI, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, CompanyDataI, PriceConverter, createQueryOptionsForId };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import Client from "./stockObjects/Client";
2
2
  import ClientAccountRepo from "./repo/ClientAccountRepo";
3
3
  import ClientAccountReader from "./reader/ClientAccountReader";
4
+ import AccountCartReader from "./reader/AccountCartReader";
4
5
  import AccountDeliveryDetailsReader from "./reader/AccountDeliveryDetailsReader";
5
6
  import AccountCompanyDetailsReader from "./reader/AccountCompanyDetailsReader";
6
7
  import Admin from "./stockObjects/Admin";
@@ -60,4 +61,4 @@ import CompanyDataRepo from "./repo/CompanyDataRepo";
60
61
  import CompanyDataReader from "./reader/CompanyDataReader";
61
62
  import PriceConverter from "./utils/PriceConverter";
62
63
  import createQueryOptionsForId from "./utils/createQueryOptionsForId";
63
- export { Client, ClientAccountRepo, ClientAccountReader, AccountDeliveryDetailsReader, AccountCompanyDetailsReader, Admin, AdminRepo, AdminReader, Address, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryMethodTypeE, DeliveryStatus, DeliveryStatusReader, DeliveryStatusTypeE, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, Status, OrderStatusReader, OrderStatusTypeE, StatusTypesReader, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, PriceConverter, createQueryOptionsForId };
64
+ export { Client, ClientAccountRepo, ClientAccountReader, AccountCartReader, AccountDeliveryDetailsReader, AccountCompanyDetailsReader, Admin, AdminRepo, AdminReader, Address, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryMethodTypeE, DeliveryStatus, DeliveryStatusReader, DeliveryStatusTypeE, PaymentDetails, PaymentDetailsRepo, PaymentDetailsReader, PaymentMethods, PaymentMethodRepo, PaymentMethodReader, PaymentMethodE, PaymentStatus, PaymentStatusesReader, PaymentStatusE, Order, OrderRepo, OrderReader, OrderProduct, OrderProductsRepo, OrderProductsReader, Status, OrderStatusReader, OrderStatusTypeE, StatusTypesReader, Product, ProductRepo, ProductReader, File, FilesRepo, FilesReader, FileConnection, FileConnectionsRepo, FileConnectionsReader, FileConnectionTypeE, CompanyData, CompanyDataRepo, CompanyDataReader, PriceConverter, createQueryOptionsForId };
@@ -0,0 +1,5 @@
1
+ import ProductI from "../types/ProductI";
2
+ export default class AccountCartReader {
3
+ static getAll(accountId: string, productId: string): Promise<ProductI[]>;
4
+ private static correctAccountCart;
5
+ }
@@ -0,0 +1,17 @@
1
+ import DatabaseConnection from "../DatabaseConnection";
2
+ import createQueryOptionsForId from "../utils/createQueryOptionsForId";
3
+ import ProductReader from "./ProductReader";
4
+ export default class AccountCartReader {
5
+ static async getAll(accountId, productId) {
6
+ const accountCart = await DatabaseConnection.getInstance().accountCart.selectAll(accountId, productId);
7
+ return this.correctAccountCart(accountCart);
8
+ }
9
+ static async correctAccountCart(accountCart) {
10
+ const correctAccountCart = [];
11
+ for (let i = 0; i < accountCart.length; i++) {
12
+ const product = await ProductReader.get(createQueryOptionsForId(accountCart[i].product_id));
13
+ correctAccountCart.push(product);
14
+ }
15
+ return correctAccountCart;
16
+ }
17
+ }
@@ -23,11 +23,11 @@ export default class OrderProductsReader {
23
23
  productId: orderProduct.product_id,
24
24
  sku: orderProduct.sku,
25
25
  title: orderProduct.title,
26
- netPrice: Number(orderProduct.net_price),
26
+ netPrice: PriceConverter.priceToPenny(orderProduct.net_price),
27
27
  installation: orderProduct.installation_price ? true : false,
28
- installationPrice: Number(orderProduct.installation_price),
28
+ installationPrice: PriceConverter.priceToPenny(orderProduct.installation_price),
29
29
  grossPrice: PriceConverter.netToGrossPrice(Number(orderProduct.net_price), Number(orderProduct.vat)),
30
- vat: Number(orderProduct.vat),
30
+ vat: orderProduct.vat,
31
31
  thumbnail,
32
32
  };
33
33
  return correctProduct;
@@ -1,6 +1,7 @@
1
1
  import { ParameterType, QueryOptions } from "@dascompany/database";
2
2
  import DatabaseConnection from "../DatabaseConnection";
3
3
  import OrderStatusReader from "./OrderStatusReader";
4
+ import PriceConverter from "../utils/PriceConverter";
4
5
  export default class OrderReader {
5
6
  static async get(queryOptions) {
6
7
  const orderData = await DatabaseConnection.getInstance().orders.select(queryOptions);
@@ -39,7 +40,7 @@ export default class OrderReader {
39
40
  const correctOrder = {
40
41
  id: order.id,
41
42
  email: order.email,
42
- price: Number(order.price),
43
+ price: PriceConverter.priceToPenny(order.price),
43
44
  createdAt: order.created_at,
44
45
  clientId: order.client_id,
45
46
  deliveryDetailsId: order.delivery_details_id,
@@ -45,12 +45,13 @@ export default class ProductReader {
45
45
  articleNumber: product.article_number,
46
46
  url: product.url,
47
47
  title: product.title,
48
+ subtitle: product.subtitle,
48
49
  description: product.description,
49
- netPrice: Number(product.net_price),
50
- promotionalNetPrice: Number(product.promotional_net_price),
51
- vat: Number(product.vat),
50
+ netPrice: PriceConverter.priceToPenny(product.net_price),
51
+ promotionalNetPrice: PriceConverter.priceToPenny(product.promotional_net_price),
52
+ vat: product.vat,
52
53
  color: product.color,
53
- quantity: Number(product.quantity),
54
+ quantity: product.quantity,
54
55
  width: product.width,
55
56
  height: product.height,
56
57
  length: product.length,
@@ -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.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);
9
+ const product = new Product(productRow.sku, productRow.url, productRow.article_number, productRow.title, productRow.subtitle, 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;
@@ -8,7 +8,7 @@ export default class Address extends StockObject {
8
8
  private apartmentNumber;
9
9
  constructor(country: string, city: string, street: string, postalCode: string, houseNumber: string, apartmentNumber?: string | null);
10
10
  getData(): {
11
- id: number | null;
11
+ id: string | null;
12
12
  country: string;
13
13
  city: string;
14
14
  street: string;
@@ -10,7 +10,7 @@ export default class Order extends StockObject {
10
10
  private zsiId;
11
11
  constructor(email: string, price: number, clientId: string | null, deliveryDetailsId: string, companyDetailsId?: string | null, paymentDetailsId?: string | null, invoice?: boolean);
12
12
  getData(): Promise<{
13
- id: number | null;
13
+ id: string | null;
14
14
  email: string;
15
15
  price: number;
16
16
  invoice: boolean;
@@ -5,6 +5,7 @@ export default class Product extends StockObject {
5
5
  private url;
6
6
  private articleNumber;
7
7
  private title;
8
+ private subtitle;
8
9
  private description;
9
10
  private netPrice;
10
11
  private promotionalNetPrice;
@@ -20,11 +21,12 @@ export default class Product extends StockObject {
20
21
  private file;
21
22
  private jsonData;
22
23
  private files;
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);
24
+ constructor(sku: string, url: string, articleNumber: string, title: string, subtitle: 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);
24
25
  getSku(): string;
25
26
  getUrl(): string;
26
27
  getArticleNumber(): string;
27
28
  getTitle(): string;
29
+ getSubtitle(): string;
28
30
  getDescription(): string;
29
31
  getNetPrice(): number;
30
32
  getPromotionalNetPrice(): number | null;
@@ -41,7 +43,7 @@ export default class Product extends StockObject {
41
43
  getFile(): Promise<FileI | null>;
42
44
  getFiles(): Promise<FileI[] | null>;
43
45
  getData(): {
44
- id: number | null;
46
+ id: string | null;
45
47
  sku: string;
46
48
  url: string;
47
49
  title: string;
@@ -62,6 +64,7 @@ export default class Product extends StockObject {
62
64
  setUrl(url: string): string;
63
65
  setArticleNumber(articleNumber: string): string;
64
66
  setTitle(title: string): string;
67
+ setSubtitle(subtitle: string): string;
65
68
  setDescription(description: string): string;
66
69
  setNetPrice(netPrice: number): number;
67
70
  setPromotionalNetPrice(promotionalNetPrice: number | null): number | null;
@@ -8,6 +8,7 @@ export default class Product extends StockObject {
8
8
  url;
9
9
  articleNumber;
10
10
  title;
11
+ subtitle;
11
12
  description;
12
13
  netPrice;
13
14
  promotionalNetPrice;
@@ -23,12 +24,13 @@ export default class Product extends StockObject {
23
24
  file;
24
25
  jsonData;
25
26
  files;
26
- constructor(sku, url, articleNumber, title, description, netPrice, promotionalNetPrice, vat, color, quantity, width, length, height, fileId, jsonData, deleted = false) {
27
+ constructor(sku, url, articleNumber, title, subtitle, description, netPrice, promotionalNetPrice, vat, color, quantity, width, length, height, fileId, jsonData, deleted = false) {
27
28
  super();
28
29
  this.sku = sku;
29
30
  this.url = url;
30
31
  this.articleNumber = articleNumber;
31
32
  this.title = title;
33
+ this.subtitle = subtitle;
32
34
  this.description = description;
33
35
  this.netPrice = netPrice;
34
36
  this.promotionalNetPrice = promotionalNetPrice;
@@ -57,6 +59,9 @@ export default class Product extends StockObject {
57
59
  getTitle() {
58
60
  return this.title;
59
61
  }
62
+ getSubtitle() {
63
+ return this.subtitle;
64
+ }
60
65
  getDescription() {
61
66
  return this.description;
62
67
  }
@@ -150,6 +155,9 @@ export default class Product extends StockObject {
150
155
  setTitle(title) {
151
156
  return this.title = title;
152
157
  }
158
+ setSubtitle(subtitle) {
159
+ return this.subtitle = subtitle;
160
+ }
153
161
  setDescription(description) {
154
162
  return this.description = description;
155
163
  }
@@ -2,6 +2,7 @@ declare enum TableNames {
2
2
  adminAccounts = "adminAccountsTable",
3
3
  clientAccounts = "clientAccountsTable",
4
4
  accountDeliveryDetails = "accountDeliveryDetailsTable",
5
+ accountCart = "accountCartTable",
5
6
  accountCompanyDetails = "accountCompanyDetailsTable",
6
7
  fileConnections = "fileConnectionsTable",
7
8
  files = "filesTable",
@@ -3,6 +3,7 @@ var TableNames;
3
3
  TableNames["adminAccounts"] = "adminAccountsTable";
4
4
  TableNames["clientAccounts"] = "clientAccountsTable";
5
5
  TableNames["accountDeliveryDetails"] = "accountDeliveryDetailsTable";
6
+ TableNames["accountCart"] = "accountCartTable";
6
7
  TableNames["accountCompanyDetails"] = "accountCompanyDetailsTable";
7
8
  TableNames["fileConnections"] = "fileConnectionsTable";
8
9
  TableNames["files"] = "filesTable";
@@ -0,0 +1,8 @@
1
+ import { Table } from '@dascompany/database';
2
+ import AccountCartRow from '../../types/rows/AccountCartRow';
3
+ export default class AccountCartTable extends Table {
4
+ selectAll(accountId: string, productId: string): Promise<AccountCartRow[]>;
5
+ delete(accountId: string, productId: string): Promise<void>;
6
+ insert(accountId: string, productId: string): Promise<void>;
7
+ private bindParams;
8
+ }
@@ -0,0 +1,25 @@
1
+ import { Table } from '@dascompany/database';
2
+ import * as SQL from '../../SQL.json';
3
+ export default class AccountCartTable extends Table {
4
+ async selectAll(accountId, productId) {
5
+ const query = this.createQuery(SQL.accountCart.select);
6
+ this.bindParams(query, accountId, productId);
7
+ const result = await query.execute();
8
+ return result.getRows();
9
+ }
10
+ async delete(accountId, productId) {
11
+ const query = this.createQuery(SQL.accountCart.delete);
12
+ this.bindParams(query, accountId, productId);
13
+ await query.execute();
14
+ }
15
+ async insert(accountId, productId) {
16
+ const query = this.createQuery(SQL.accountCart.insert);
17
+ this.bindParams(query, accountId, productId);
18
+ await query.execute();
19
+ }
20
+ bindParams(query, accountId, productId) {
21
+ console.log(query, accountId, productId);
22
+ query.bindParameter('account_id', accountId);
23
+ query.bindParameter('product_id', productId);
24
+ }
25
+ }
@@ -67,6 +67,7 @@ export default class ProductsTable extends Table {
67
67
  query.bindParameter('url', product.getUrl());
68
68
  query.bindParameter('article_number', product.getArticleNumber());
69
69
  query.bindParameter('title', product.getTitle());
70
+ query.bindParameter('subtitle', product.getSubtitle());
70
71
  query.bindParameter('description', product.getDescription());
71
72
  query.bindParameter('net_price', product.getNetPrice());
72
73
  query.bindParameter('promotional_net_price', product.getPromotionalNetPrice());
@@ -0,0 +1,4 @@
1
+ export default interface AccountCartRow {
2
+ account_id: string;
3
+ product_id: string;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -2,10 +2,10 @@ export default interface OrderProductRow {
2
2
  id: string;
3
3
  order_id: string;
4
4
  product_id: string;
5
- net_price: string;
6
- installation_price: string;
5
+ net_price: number;
6
+ installation_price: number;
7
7
  title: string;
8
8
  sku: string;
9
- vat: string;
9
+ vat: number;
10
10
  file_id: string;
11
11
  }
@@ -4,6 +4,7 @@ export default interface ProductRow {
4
4
  article_number: string;
5
5
  url: string;
6
6
  title: string;
7
+ subtitle: string;
7
8
  description: string;
8
9
  file_id: string;
9
10
  net_price: number;
@@ -0,0 +1,4 @@
1
+ export default class AccountCart {
2
+ static delete(accountId: string, productId: string): Promise<boolean>;
3
+ static insert(accountId: string, productId: string): Promise<boolean>;
4
+ }
@@ -0,0 +1,11 @@
1
+ import DatabaseConnection from "../DatabaseConnection";
2
+ export default class AccountCart {
3
+ static async delete(accountId, productId) {
4
+ await DatabaseConnection.getInstance().accountCart.delete(accountId, productId);
5
+ return true;
6
+ }
7
+ static async insert(accountId, productId) {
8
+ await DatabaseConnection.getInstance().accountCart.insert(accountId, productId);
9
+ return true;
10
+ }
11
+ }
@@ -1,4 +1,5 @@
1
1
  export default class PriceConverter {
2
2
  static netToGrossPrice(netPrice: number, vatPercentage?: number): number;
3
- static grossToNetPrice(grossPrice: number, vatPercentage?: number): number;
3
+ static grossToNetPrice(grossPrice: number, vatPercentage?: number): string;
4
+ static priceToPenny(price: number): number;
4
5
  }
@@ -3,12 +3,14 @@ export default class PriceConverter {
3
3
  const netPriceInPenny = Math.round(netPrice * 100);
4
4
  const vatPriceInPenny = Math.round((netPriceInPenny * vatPercentage) / 100);
5
5
  const grossPriceInPenny = netPriceInPenny + vatPriceInPenny;
6
- const grossPrice = (grossPriceInPenny / 100).toFixed(2);
7
- return Number(grossPrice);
6
+ return grossPriceInPenny;
8
7
  }
9
8
  static grossToNetPrice(grossPrice, vatPercentage = 23) {
10
9
  const grossPriceInPenny = Math.round(grossPrice * 100);
11
10
  const netPrice = ((grossPriceInPenny / (vatPercentage / 100 + 1)) / 100).toFixed(2);
12
- return Number(netPrice);
11
+ return netPrice;
12
+ }
13
+ static priceToPenny(price) {
14
+ return Math.round(price * 100);
13
15
  }
14
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dascompany/product",
3
- "version": "4.0.5",
3
+ "version": "4.0.6",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "vitest",
@@ -20,7 +20,7 @@
20
20
  "vitest": "^3.0.6"
21
21
  },
22
22
  "peerDependencies": {
23
- "@dascompany/database": "4.0.8",
23
+ "@dascompany/database": "^4.0.9",
24
24
  "@types/pg": "^8.11.11",
25
25
  "pg": "^8.13.3"
26
26
  }