@dascompany/product 4.2.8 → 4.2.10

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/index.d.ts CHANGED
@@ -76,4 +76,5 @@ import MarketPlacesReader from "./reader/MarketPlacesReader";
76
76
  import PriceConverter from "./utils/PriceConverter";
77
77
  import createQueryOptionsForId from "./utils/createQueryOptionsForId";
78
78
  import CilentAccountExistWithThisEmail from "./lib/errors/CilentAccountExistWithThisEmail";
79
- export { Client, ClientAccountRepo, ClientAccountReader, AccountDeliveryDetailsReader, AccountCompanyDetailsReader, AccountCart, AccountCartReader, 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, MarketPlacesReader, PriceConverter, createQueryOptionsForId, CilentAccountExistWithThisEmail };
79
+ import MarketPlaceI from "./types/MarketPlaceI";
80
+ export { Client, ClientAccountRepo, ClientAccountReader, AccountDeliveryDetailsReader, AccountCompanyDetailsReader, AccountCart, AccountCartReader, 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, MarketPlacesReader, PriceConverter, createQueryOptionsForId, CilentAccountExistWithThisEmail, MarketPlaceI };
@@ -1,13 +1,8 @@
1
1
  import { QueryOptions } from "@dascompany/database";
2
- type MarketData = {
3
- id: string;
4
- country: string;
5
- vatRate: string;
6
- };
2
+ import MarketPlaceI from "../types/MarketPlaceI";
7
3
  export default class MarketPlacesReader {
8
- static get(queryOptions: QueryOptions): Promise<MarketData>;
9
- static getAll(queryOptions: QueryOptions): Promise<MarketData[]>;
4
+ static get(queryOptions: QueryOptions): Promise<MarketPlaceI>;
5
+ static getAll(queryOptions: QueryOptions): Promise<MarketPlaceI[]>;
10
6
  private static correctMarkets;
11
7
  private static correctMarket;
12
8
  }
13
- export {};
@@ -21,7 +21,7 @@ export default class MarketPlacesReader {
21
21
  const correctMarket = {
22
22
  id: marketRow.id,
23
23
  country: marketRow.country,
24
- vatRate: marketRow.vat_rate,
24
+ vatRate: Number(marketRow.vat_rate)
25
25
  };
26
26
  return correctMarket;
27
27
  }
@@ -1,8 +1,8 @@
1
1
  import { QueryOptions } from "@dascompany/database";
2
2
  import ProductI from "../types/ProductI";
3
3
  export default class ProductReader {
4
- static get(queryOption: QueryOptions): Promise<ProductI>;
5
- static getAll(queryOption: QueryOptions): Promise<ProductI[]>;
4
+ static get(queryOption: QueryOptions, vat: number): Promise<ProductI>;
5
+ static getAll(queryOption: QueryOptions, vat: number): Promise<ProductI[]>;
6
6
  static getId(queryOptions: QueryOptions): Promise<string>;
7
7
  static getQuantity(queryOptions: QueryOptions): Promise<number>;
8
8
  static getMaxPrice(queryOptions: QueryOptions): Promise<number>;
@@ -5,18 +5,18 @@ import FileConnectionTypeE from "../types/FileConnectionTypeE";
5
5
  import PriceConverter from "../utils/PriceConverter";
6
6
  import createQueryOptionsForId from "../utils/createQueryOptionsForId";
7
7
  export default class ProductReader {
8
- static async get(queryOption) {
8
+ static async get(queryOption, vat) {
9
9
  const productRow = await DatabaseConnection.getInstance().products.select(queryOption);
10
10
  const queryOptionsFiles = new QueryOptions();
11
11
  queryOptionsFiles.setWhere([{ name: 'connection_id', type: ParameterType.bigint, value: productRow.id }, { name: 'connection_type', type: ParameterType.string, value: FileConnectionTypeE.product }]);
12
12
  queryOptionsFiles.setOrderBy([{ key: 'sequence', order: 'asc' }]);
13
13
  const files = await FilesReader.getForConnection(queryOptionsFiles);
14
- const product = await this.correctProduct(productRow);
14
+ const product = await this.correctProduct(productRow, vat);
15
15
  return { ...product, files };
16
16
  }
17
- static async getAll(queryOption) {
17
+ static async getAll(queryOption, vat) {
18
18
  const products = await DatabaseConnection.getInstance().products.selectAll(queryOption);
19
- return this.correctProducts(products);
19
+ return this.correctProducts(products, vat);
20
20
  }
21
21
  static async getId(queryOptions) {
22
22
  return await DatabaseConnection.getInstance().products.selectId(queryOptions);
@@ -29,15 +29,15 @@ export default class ProductReader {
29
29
  const price = await DatabaseConnection.getInstance().products.selectMaxPrice(queryOptions);
30
30
  return Number(price);
31
31
  }
32
- static async correctProducts(products) {
32
+ static async correctProducts(products, vat) {
33
33
  const correctProducts = [];
34
34
  for (let i = 0; i < products.length; i++) {
35
- const correctProduct = await this.correctProduct(products[i]);
35
+ const correctProduct = await this.correctProduct(products[i], vat);
36
36
  correctProducts.push(correctProduct);
37
37
  }
38
38
  return correctProducts;
39
39
  }
40
- static async correctProduct(product) {
40
+ static async correctProduct(product, vat) {
41
41
  const thumbnail = await FilesReader.get(createQueryOptionsForId(product.file_id));
42
42
  return {
43
43
  id: product.id,
@@ -48,8 +48,8 @@ export default class ProductReader {
48
48
  subtitle: product.subtitle,
49
49
  description: product.description,
50
50
  netPrice: product.net_price,
51
+ promotionalGrossPrice: PriceConverter.netToGrossPrice(product.promotional_net_price, vat),
51
52
  promotionalNetPrice: product.promotional_net_price,
52
- vat: product.vat,
53
53
  color: product.color,
54
54
  quantity: product.quantity,
55
55
  width: product.width,
@@ -58,7 +58,7 @@ export default class ProductReader {
58
58
  createdAt: product.created_at,
59
59
  deleted: product.deleted,
60
60
  thumbnail: thumbnail ? thumbnail : null,
61
- grossPrice: PriceConverter.netToGrossPrice(Number(product.net_price), Number(product.vat)),
61
+ grossPrice: PriceConverter.netToGrossPrice(Number(product.net_price), vat),
62
62
  jsonData: product.json_data
63
63
  };
64
64
  }
@@ -46,7 +46,7 @@ export default class Order extends StockObject {
46
46
  return this.zsiId;
47
47
  }
48
48
  getGrossPrice() {
49
- const vatPercentage = 23; //brak stawki vat dla zamówienia
49
+ const vatPercentage = this.vat ? this.vat : 23;
50
50
  return PriceConverter.netToGrossPrice(this.net_price, vatPercentage);
51
51
  }
52
52
  getClientId() {
@@ -0,0 +1,5 @@
1
+ export default interface MarketPlaceI {
2
+ id: string;
3
+ country: string;
4
+ vatRate: number;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dascompany/product",
3
- "version": "4.2.8",
3
+ "version": "4.2.10",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "vitest",