@dascompany/product 4.0.7 → 4.0.9
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 +1 -2
- package/dist/index.js +1 -2
- package/dist/reader/AccountCartReader.d.ts +1 -1
- package/dist/reader/AccountCartReader.js +2 -2
- package/dist/reader/ProductReader.js +8 -3
- package/dist/tables/clients/AccountCartTable.d.ts +1 -1
- package/dist/tables/clients/AccountCartTable.js +3 -2
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
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";
|
|
5
4
|
import AccountDeliveryDetailsReader from "./reader/AccountDeliveryDetailsReader";
|
|
6
5
|
import AccountCompanyDetailsReader from "./reader/AccountCompanyDetailsReader";
|
|
7
6
|
import Admin from "./stockObjects/Admin";
|
|
@@ -73,4 +72,4 @@ import CompanyDataReader from "./reader/CompanyDataReader";
|
|
|
73
72
|
import CompanyDataI from "./types/CompanyDataI";
|
|
74
73
|
import PriceConverter from "./utils/PriceConverter";
|
|
75
74
|
import createQueryOptionsForId from "./utils/createQueryOptionsForId";
|
|
76
|
-
export { Client, ClientAccountRepo, ClientAccountReader,
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
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";
|
|
5
4
|
import AccountDeliveryDetailsReader from "./reader/AccountDeliveryDetailsReader";
|
|
6
5
|
import AccountCompanyDetailsReader from "./reader/AccountCompanyDetailsReader";
|
|
7
6
|
import Admin from "./stockObjects/Admin";
|
|
@@ -61,4 +60,4 @@ import CompanyDataRepo from "./repo/CompanyDataRepo";
|
|
|
61
60
|
import CompanyDataReader from "./reader/CompanyDataReader";
|
|
62
61
|
import PriceConverter from "./utils/PriceConverter";
|
|
63
62
|
import createQueryOptionsForId from "./utils/createQueryOptionsForId";
|
|
64
|
-
export { Client, ClientAccountRepo, ClientAccountReader,
|
|
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 };
|
|
@@ -2,8 +2,8 @@ import DatabaseConnection from "../DatabaseConnection";
|
|
|
2
2
|
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
3
3
|
import ProductReader from "./ProductReader";
|
|
4
4
|
export default class AccountCartReader {
|
|
5
|
-
static async getAll(accountId) {
|
|
6
|
-
const accountCart = await DatabaseConnection.getInstance().accountCart.selectAll(accountId);
|
|
5
|
+
static async getAll(accountId, productId) {
|
|
6
|
+
const accountCart = await DatabaseConnection.getInstance().accountCart.selectAll(accountId, productId);
|
|
7
7
|
return this.correctAccountCart(accountCart);
|
|
8
8
|
}
|
|
9
9
|
static async correctAccountCart(accountCart) {
|
|
@@ -39,6 +39,10 @@ export default class ProductReader {
|
|
|
39
39
|
}
|
|
40
40
|
static async correctProduct(product) {
|
|
41
41
|
const thumbnail = await FilesReader.get(createQueryOptionsForId(product.file_id));
|
|
42
|
+
const netPrice = PriceConverter.priceToPenny(product.net_price);
|
|
43
|
+
const promotionalNetPrice = product.promotional_net_price ? PriceConverter.priceToPenny(product.promotional_net_price) : null;
|
|
44
|
+
const grossPrice = PriceConverter.netToGrossPrice(Number(product.net_price), Number(product.vat));
|
|
45
|
+
const promotionalGrossPrice = product.promotional_net_price ? PriceConverter.netToGrossPrice(Number(product.promotional_net_price), Number(product.vat)) : null;
|
|
42
46
|
return {
|
|
43
47
|
id: product.id,
|
|
44
48
|
sku: product.sku,
|
|
@@ -47,8 +51,8 @@ export default class ProductReader {
|
|
|
47
51
|
title: product.title,
|
|
48
52
|
subtitle: product.subtitle,
|
|
49
53
|
description: product.description,
|
|
50
|
-
netPrice
|
|
51
|
-
promotionalNetPrice
|
|
54
|
+
netPrice,
|
|
55
|
+
promotionalNetPrice,
|
|
52
56
|
vat: product.vat,
|
|
53
57
|
color: product.color,
|
|
54
58
|
quantity: product.quantity,
|
|
@@ -58,7 +62,8 @@ export default class ProductReader {
|
|
|
58
62
|
createdAt: product.created_at,
|
|
59
63
|
deleted: product.deleted,
|
|
60
64
|
thumbnail: thumbnail ? thumbnail : null,
|
|
61
|
-
grossPrice
|
|
65
|
+
grossPrice,
|
|
66
|
+
promotionalGrossPrice,
|
|
62
67
|
jsonData: product.json_data
|
|
63
68
|
};
|
|
64
69
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Table } from '@dascompany/database';
|
|
2
2
|
import AccountCartRow from '../../types/rows/AccountCartRow';
|
|
3
3
|
export default class AccountCartTable extends Table {
|
|
4
|
-
selectAll(accountId: string): Promise<AccountCartRow[]>;
|
|
4
|
+
selectAll(accountId: string, productId: string): Promise<AccountCartRow[]>;
|
|
5
5
|
delete(accountId: string, productId: string): Promise<void>;
|
|
6
6
|
insert(accountId: string, productId: string): Promise<void>;
|
|
7
7
|
private bindParams;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Table } from '@dascompany/database';
|
|
2
2
|
import * as SQL from '../../SQL.json';
|
|
3
3
|
export default class AccountCartTable extends Table {
|
|
4
|
-
async selectAll(accountId) {
|
|
4
|
+
async selectAll(accountId, productId) {
|
|
5
5
|
const query = this.createQuery(SQL.accountCart.select);
|
|
6
|
-
|
|
6
|
+
this.bindParams(query, accountId, productId);
|
|
7
7
|
const result = await query.execute();
|
|
8
8
|
return result.getRows();
|
|
9
9
|
}
|
|
@@ -18,6 +18,7 @@ export default class AccountCartTable extends Table {
|
|
|
18
18
|
await query.execute();
|
|
19
19
|
}
|
|
20
20
|
bindParams(query, accountId, productId) {
|
|
21
|
+
console.log(query, accountId, productId);
|
|
21
22
|
query.bindParameter('account_id', accountId);
|
|
22
23
|
query.bindParameter('product_id', productId);
|
|
23
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dascompany/product",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.9",
|
|
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.
|
|
23
|
+
"@dascompany/database": "^4.0.6",
|
|
24
24
|
"@types/pg": "^8.11.11",
|
|
25
25
|
"pg": "^8.13.3"
|
|
26
26
|
}
|