@dascompany/product 3.0.3 → 3.0.5

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.
Files changed (33) hide show
  1. package/dist/DatabaseConnection.d.ts +0 -2
  2. package/dist/DatabaseConnection.js +0 -6
  3. package/dist/SQL.json +3 -9
  4. package/dist/index.d.ts +1 -5
  5. package/dist/index.js +1 -4
  6. package/dist/mappers/AccountAddressMapper.d.ts +9 -0
  7. package/dist/mappers/AccountAddressMapper.js +19 -0
  8. package/dist/reader/AccountAddressesReader.d.ts +7 -0
  9. package/dist/reader/AccountAddressesReader.js +26 -0
  10. package/dist/reader/OrderReader.js +1 -1
  11. package/dist/repo/AccountAddressesRepo.d.ts +6 -0
  12. package/dist/repo/AccountAddressesRepo.js +13 -0
  13. package/dist/repo/OrderRepo.js +1 -1
  14. package/dist/repo/OrderStatusRepo.d.ts +8 -0
  15. package/dist/repo/OrderStatusRepo.js +25 -0
  16. package/dist/stockObjects/AccountAddress.d.ts +11 -0
  17. package/dist/stockObjects/AccountAddress.js +26 -0
  18. package/dist/stockObjects/Order.d.ts +6 -6
  19. package/dist/stockObjects/Order.js +9 -9
  20. package/dist/tables/TableNames.d.ts +0 -1
  21. package/dist/tables/TableNames.js +0 -1
  22. package/dist/tables/clients/AccountAddressesTable.d.ts +12 -0
  23. package/dist/tables/clients/AccountAddressesTable.js +41 -0
  24. package/dist/tables/orders/OrdersTable.js +2 -2
  25. package/dist/types/AccountAddressesI.d.ts +6 -0
  26. package/dist/types/AccountAddressesI.js +1 -0
  27. package/dist/types/OrderI.d.ts +1 -1
  28. package/dist/types/rows/AccountAddressesRow.d.ts +5 -0
  29. package/dist/types/rows/AccountAddressesRow.js +1 -0
  30. package/dist/types/rows/OrderRow.d.ts +1 -1
  31. package/dist/utils/calculateNetToGrossPrice.d.ts +1 -0
  32. package/dist/utils/calculateNetToGrossPrice.js +7 -0
  33. package/package.json +1 -1
@@ -8,7 +8,6 @@ import ClientAccountsTable from './tables/clients/ClientAccountsTable';
8
8
  import PersonalDataTable from './tables/personalInformation/PersonalDataTable';
9
9
  import OrdersProductsTable from './tables/orders/OrdersProductsTable';
10
10
  import CompanyDetailsTable from './tables/personalInformation/CompanyDetailsTable';
11
- import ContactDetailsTable from './tables/personalInformation/ContactDetailsTable';
12
11
  import DeliveryDetailsTable from './tables/personalInformation/DeliveryDetailsTable';
13
12
  import InvoiceDetailsTable from './tables/personalInformation/InvoiceDetailsTable';
14
13
  import DeliveryMethodsTable from './tables/settings/DeliveryMethodsTable';
@@ -42,7 +41,6 @@ export default class DatabaseConnection {
42
41
  get companyDetails(): CompanyDetailsTable;
43
42
  get personalData(): PersonalDataTable;
44
43
  get ordersProducts(): OrdersProductsTable;
45
- get contactDetails(): ContactDetailsTable;
46
44
  get deliveryDetails(): DeliveryDetailsTable;
47
45
  get invoiceDetails(): InvoiceDetailsTable;
48
46
  get deliveryMethods(): DeliveryMethodsTable;
@@ -10,7 +10,6 @@ import ClientAccountsTable from './tables/clients/ClientAccountsTable';
10
10
  import PersonalDataTable from './tables/personalInformation/PersonalDataTable';
11
11
  import OrdersProductsTable from './tables/orders/OrdersProductsTable';
12
12
  import CompanyDetailsTable from './tables/personalInformation/CompanyDetailsTable';
13
- import ContactDetailsTable from './tables/personalInformation/ContactDetailsTable';
14
13
  import DeliveryDetailsTable from './tables/personalInformation/DeliveryDetailsTable';
15
14
  import InvoiceDetailsTable from './tables/personalInformation/InvoiceDetailsTable';
16
15
  import DeliveryMethodsTable from './tables/settings/DeliveryMethodsTable';
@@ -102,11 +101,6 @@ export default class DatabaseConnection {
102
101
  this.tables.set(TableNames.ordersProducts, new OrdersProductsTable(this.connection));
103
102
  return this.tables.get(TableNames.ordersProducts);
104
103
  }
105
- get contactDetails() {
106
- if (!this.tables.get(TableNames.contactDetails))
107
- this.tables.set(TableNames.contactDetails, new ContactDetailsTable(this.connection));
108
- return this.tables.get(TableNames.contactDetails);
109
- }
110
104
  get deliveryDetails() {
111
105
  if (!this.tables.get(TableNames.deliveryDetails))
112
106
  this.tables.set(TableNames.deliveryDetails, new DeliveryDetailsTable(this.connection));
package/dist/SQL.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "select": "SELECT * FROM clients.accounts",
13
13
  "selectId": "SELECT id FROM clients.accounts ",
14
14
  "insert": "INSERT INTO clients.accounts( id, email, activated, personal_data_id) VALUES ($id::BIGINT, LOWER($email::TEXT), $activated::BOOL, $personal_data_id::BIGINT)",
15
- "update": "UPDATE clients.accounts SET activated = $activated::BOOL, deleted = $deleted::BOOL, personal_data_id = $personal_details_id::BIGINT, delivery_details_id = $delivery_details_id::BIGINT, company_details_id = $company_details_id::BIGINT WHERE id = $id::BIGINT",
15
+ "update": "UPDATE clients.accounts SET activated = $activated::BOOL, deleted = $deleted::BOOL, personal_data_id = $personal_data_id::BIGINT, delivery_details_id = $delivery_details_id::BIGINT, company_details_id = $company_details_id::BIGINT WHERE id = $id::BIGINT",
16
16
  "delete": "DELETE FROM clients.accounts WHERE id = $account_id::BIGINT",
17
17
  "count": "SELECT COUNT(*) AS total_rows FROM clients.accounts",
18
18
  "selectNextId": "SELECT nextval('clients.accounts_id'::regclass)"
@@ -27,12 +27,6 @@
27
27
  "insert": "INSERT INTO clients.account_company_details(account_id, company_details_id) VALUES ($account_id::BIGINT, $company_details_id::BIGINT)",
28
28
  "delete": "DELETE FROM clients.account_company_details"
29
29
  },
30
- "contactDetails": {
31
- "select": "SELECT * FROM personal_information.contact_details",
32
- "insert": "INSERT INTO personal_information.contact_details(id, personal_data_id, address_id) VALUES ($id::BIGINT, $personal_data_id::BIGINT, $address_id::BIGINT)",
33
- "update": "UPDATE personal_information.contact_details SET personal_data_id = $personal_data_id::BIGINT, address_id = $address_id::BIGINT WHERE id = $id::BIGINT",
34
- "selectNextId": "SELECT nextval('personal_information.contact_details_id'::regclass)"
35
- },
36
30
  "deliveryDetails": {
37
31
  "select": "SELECT * FROM personal_information.delivery_details",
38
32
  "insert": "INSERT INTO personal_information.delivery_details(id, personal_data_id, address_id, delivery_method_id) VALUES ($id::BIGINT, $personal_data_id::BIGINT, $address_id::BIGINT, $delivery_method_id::BIGINT)",
@@ -76,8 +70,8 @@
76
70
  },
77
71
  "orders": {
78
72
  "select": "SELECT * FROM orders.orders",
79
- "insert": "INSERT INTO orders.orders( id, email, price, client_id, contact_details_id, delivery_details_id, invoice_details_id, payment_details_id ) VALUES ($order_id::BIGINT, $email::TEXT, $price::DOUBLE PRECISION, $client_id::BIGINT, $contact_details_id::BIGINT, $delivery_details_id::BIGINT , $invoice_details_id::BIGINT, $payment_details_id::BIGINT )",
80
- "update": "UPDATE orders.orders SET price = $price::DOUBLE PRECISION, contact_details_id = $contact_details_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",
73
+ "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 )",
74
+ "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",
81
75
  "count": "SELECT COUNT (*) AS TOTAL_ROWS FROM orders.orders",
82
76
  "selectNextId": "SELECT nextval('orders.orders_id'::regclass)"
83
77
  },
package/dist/index.d.ts CHANGED
@@ -18,10 +18,6 @@ import CompanyDetails from "./stockObjects/CompanyDetails";
18
18
  import CompanyDetailsRepo from "./repo/CompanyDetailsRepo";
19
19
  import CompanyDetailsReader from "./reader/CompanyDetailsReader";
20
20
  import CompanyDetailsI from "./types/CompanyDetailsI";
21
- import ContactDetails from "./stockObjects/ContactDetails";
22
- import ContactDetailsRepo from "./repo/ContactDetailsRepo";
23
- import ContactDetailsReader from "./reader/ContactDetailsReader";
24
- import ContactDetailsI from "./types/ContactDetailsI";
25
21
  import DeliveryDetails from "./stockObjects/DeliveryDetails";
26
22
  import DeliveryDetailsRepo from "./repo/DeliveryDetailsRepo";
27
23
  import DeliveryDetailsReader from "./reader/DeliveryDetailsReader";
@@ -80,4 +76,4 @@ import CompanyDataReader from "./reader/CompanyDataReader";
80
76
  import CompanyDataI from "./types/CompanyDataI";
81
77
  import PriceConverter from "./utils/PriceConverter";
82
78
  import createQueryOptionsForId from "./utils/createQueryOptionsForId";
83
- export { Client, ClientAccountRepo, ClientAccountReader, AccountDeliveryDetailsReader, AccountCompanyDetailsReader, Admin, AdminRepo, AdminReader, Address, AddressI, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, PersonalDataI, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, CompanyDetailsI, ContactDetails, ContactDetailsRepo, ContactDetailsReader, ContactDetailsI, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryDetailsI, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryMethodI, DeliveryMethodTypeE, DeliveryStatus, DeliveryStatusReader, DeliveryStatusTypeE, InvoiceDetails, InvoiceDetailsRepo, InvoiceDetailsReader, InvoiceDetailsI, 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 };
79
+ 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, InvoiceDetails, InvoiceDetailsRepo, InvoiceDetailsReader, InvoiceDetailsI, 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
@@ -15,9 +15,6 @@ import PersonalDataReader from "./reader/PersonalDataReader";
15
15
  import CompanyDetails from "./stockObjects/CompanyDetails";
16
16
  import CompanyDetailsRepo from "./repo/CompanyDetailsRepo";
17
17
  import CompanyDetailsReader from "./reader/CompanyDetailsReader";
18
- import ContactDetails from "./stockObjects/ContactDetails";
19
- import ContactDetailsRepo from "./repo/ContactDetailsRepo";
20
- import ContactDetailsReader from "./reader/ContactDetailsReader";
21
18
  import DeliveryDetails from "./stockObjects/DeliveryDetails";
22
19
  import DeliveryDetailsRepo from "./repo/DeliveryDetailsRepo";
23
20
  import DeliveryDetailsReader from "./reader/DeliveryDetailsReader";
@@ -66,4 +63,4 @@ import CompanyDataRepo from "./repo/CompanyDataRepo";
66
63
  import CompanyDataReader from "./reader/CompanyDataReader";
67
64
  import PriceConverter from "./utils/PriceConverter";
68
65
  import createQueryOptionsForId from "./utils/createQueryOptionsForId";
69
- export { Client, ClientAccountRepo, ClientAccountReader, AccountDeliveryDetailsReader, AccountCompanyDetailsReader, Admin, AdminRepo, AdminReader, Address, AddressesRepo, AddressesReader, PersonalData, PersonalDataRepo, PersonalDataReader, CompanyDetails, CompanyDetailsRepo, CompanyDetailsReader, ContactDetails, ContactDetailsRepo, ContactDetailsReader, DeliveryDetails, DeliveryDetailsRepo, DeliveryDetailsReader, DeliveryMethods, DeliveryMethodRepo, DeliveryMethodReader, DeliveryMethodTypeE, DeliveryStatus, DeliveryStatusReader, DeliveryStatusTypeE, InvoiceDetails, InvoiceDetailsRepo, InvoiceDetailsReader, 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 };
66
+ 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, InvoiceDetails, InvoiceDetailsRepo, InvoiceDetailsReader, 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,9 @@
1
+ import { StockObjectMapper } from "@dascompany/database";
2
+ import AccountAddress from "../stockObjects/AccountAddress";
3
+ export default class AccountAddressMapper implements StockObjectMapper {
4
+ private accountAddress;
5
+ private accountAddressessTable;
6
+ constructor(accountAddress: AccountAddress);
7
+ save(): Promise<void>;
8
+ delete(): Promise<void>;
9
+ }
@@ -0,0 +1,19 @@
1
+ import DatabaseConnection from "../DatabaseConnection";
2
+ export default class AccountAddressMapper {
3
+ accountAddress;
4
+ accountAddressessTable;
5
+ constructor(accountAddress) {
6
+ this.accountAddressessTable = DatabaseConnection.getInstance().accountAddresses;
7
+ this.accountAddress = accountAddress;
8
+ }
9
+ async save() {
10
+ await this.accountAddressessTable.insert(this.accountAddress);
11
+ }
12
+ async delete() {
13
+ const accountAddressId = this.accountAddress.getId();
14
+ if (accountAddressId)
15
+ await this.accountAddressessTable.delete(accountAddressId);
16
+ else
17
+ throw new Error('Can`t remove the order and product connection without providing its ID');
18
+ }
19
+ }
@@ -0,0 +1,7 @@
1
+ import { QueryOptions } from "@dascompany/database";
2
+ import AccountAddressesI from "../types/AccountAddressesI";
3
+ export default class AccountAddressesReader {
4
+ static getAll(queryOptions?: QueryOptions): Promise<AccountAddressesI[]>;
5
+ private static correctAccountAddresses;
6
+ private static correctAccountAddress;
7
+ }
@@ -0,0 +1,26 @@
1
+ import DatabaseConnection from "../DatabaseConnection";
2
+ import AddressesReader from "./AddressesReader";
3
+ import createQueryOptionsForId from "../utils/createQueryOptionsForId";
4
+ export default class AccountAddressesReader {
5
+ static async getAll(queryOptions) {
6
+ const accountAddresses = await DatabaseConnection.getInstance().accountAddresses.selectAll(queryOptions);
7
+ return this.correctAccountAddresses(accountAddresses);
8
+ }
9
+ static async correctAccountAddresses(accountAddresses) {
10
+ const correctAccountAddresses = [];
11
+ for (let i = 0; i < accountAddresses.length; i++) {
12
+ const correctAccountAddress = await this.correctAccountAddress(accountAddresses[i]);
13
+ correctAccountAddresses.push(correctAccountAddress);
14
+ }
15
+ return correctAccountAddresses;
16
+ }
17
+ static async correctAccountAddress(accountAddress) {
18
+ const address = await AddressesReader.get(createQueryOptionsForId(accountAddress.address_id));
19
+ const correctAddress = {
20
+ id: accountAddress.id,
21
+ accountId: accountAddress.account_id,
22
+ address: address
23
+ };
24
+ return correctAddress;
25
+ }
26
+ }
@@ -42,7 +42,7 @@ export default class OrderReader {
42
42
  price: order.price,
43
43
  createdAt: order.created_at,
44
44
  clientId: order.client_id,
45
- contactDetailsId: order.contact_details_id,
45
+ personalDataId: order.personal_data_id,
46
46
  deliveryDetailsId: order.delivery_details_id,
47
47
  invoiceDetailsId: order.invoice_details_id,
48
48
  paymentDetailsId: order.payment_details_id,
@@ -0,0 +1,6 @@
1
+ import { QueryOptions } from "@dascompany/database";
2
+ import AccountAddress from "../stockObjects/AccountAddress";
3
+ export default class AccountAddressesRepo {
4
+ static get(queryOptions: QueryOptions): Promise<AccountAddress>;
5
+ private static createAccountAddressFromRow;
6
+ }
@@ -0,0 +1,13 @@
1
+ import DatabaseConnection from "../DatabaseConnection";
2
+ import AccountAddress from "../stockObjects/AccountAddress";
3
+ export default class AccountAddressesRepo {
4
+ static async get(queryOptions) {
5
+ const accountAddress = await DatabaseConnection.getInstance().accountAddresses.select(queryOptions);
6
+ return this.createAccountAddressFromRow(accountAddress);
7
+ }
8
+ static async createAccountAddressFromRow(dataRow) {
9
+ const accountAddress = new AccountAddress(dataRow.account_id, dataRow.address_id);
10
+ accountAddress.setId(dataRow.id);
11
+ return accountAddress;
12
+ }
13
+ }
@@ -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.contact_details_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.personal_data_id, orderData.delivery_details_id, orderData.invoice_details_id, orderData.payment_details_id);
10
10
  order.setId(orderData.id);
11
11
  return order;
12
12
  }
@@ -0,0 +1,8 @@
1
+ import { QueryOptions } from "@dascompany/database";
2
+ import Status from "../stockObjects/Status";
3
+ export default class OrderStatusRepo {
4
+ static get(queryOptions: QueryOptions): Promise<Status>;
5
+ static getAll(queryOptions?: QueryOptions): Promise<Status[]>;
6
+ private static createStatusesFromRows;
7
+ private static createStatusFromRow;
8
+ }
@@ -0,0 +1,25 @@
1
+ import DatabaseConnection from "../DatabaseConnection";
2
+ import Status from "../stockObjects/Status";
3
+ export default class OrderStatusRepo {
4
+ static async get(queryOptions) {
5
+ const status = await DatabaseConnection.getInstance().statuses.select(queryOptions);
6
+ return this.createStatusFromRow(status);
7
+ }
8
+ static async getAll(queryOptions) {
9
+ const statuses = await DatabaseConnection.getInstance().statuses.selectAll(queryOptions);
10
+ return this.createStatusesFromRows(statuses);
11
+ }
12
+ static async createStatusesFromRows(dataRows) {
13
+ const statuses = [];
14
+ for (const dataRow of dataRows) {
15
+ const status = await this.createStatusFromRow(dataRow);
16
+ statuses.push(status);
17
+ }
18
+ return statuses;
19
+ }
20
+ static async createStatusFromRow(dataRow) {
21
+ const status = new Status(dataRow.order_id, dataRow.user_id, dataRow.type, dataRow.created_at);
22
+ status.setId(dataRow.id);
23
+ return status;
24
+ }
25
+ }
@@ -0,0 +1,11 @@
1
+ import { StockObject, StockObjectMapper } from "@dascompany/database";
2
+ export default class AccountAddress extends StockObject {
3
+ private accountId;
4
+ private addressId;
5
+ constructor(accountId: number, addressId: number);
6
+ getAccountId(): number;
7
+ getAddressId(): number;
8
+ setAccountId(accountId: number): void;
9
+ setAddressId(addressId: number): void;
10
+ protected getMapper(): StockObjectMapper;
11
+ }
@@ -0,0 +1,26 @@
1
+ import { StockObject } from "@dascompany/database";
2
+ import AccountAddressMapper from "../mappers/AccountAddressMapper";
3
+ export default class AccountAddress extends StockObject {
4
+ accountId;
5
+ addressId;
6
+ constructor(accountId, addressId) {
7
+ super();
8
+ this.accountId = accountId;
9
+ this.addressId = addressId;
10
+ }
11
+ getAccountId() {
12
+ return this.accountId;
13
+ }
14
+ getAddressId() {
15
+ return this.addressId;
16
+ }
17
+ setAccountId(accountId) {
18
+ this.accountId = accountId;
19
+ }
20
+ setAddressId(addressId) {
21
+ this.addressId = addressId;
22
+ }
23
+ getMapper() {
24
+ return new AccountAddressMapper(this);
25
+ }
26
+ }
@@ -3,18 +3,18 @@ export default class Order extends StockObject {
3
3
  private email;
4
4
  private price;
5
5
  private clientId;
6
- private contactDetailsId;
6
+ private personalDataId;
7
7
  private deliveryDetailsId;
8
8
  private invoiceDetailsId;
9
9
  private paymentDetailsId;
10
10
  private zsiId;
11
- constructor(email: string, price: number, clientId: number | null, contactDetailsId: number, deliveryDetailsId: number, invoiceDetailsId?: number | null, paymentDetailsId?: number | null);
11
+ constructor(email: string, price: number, clientId: number | null, personalDataId: number, deliveryDetailsId: number, invoiceDetailsId?: number | null, paymentDetailsId?: number | null);
12
12
  getData(): Promise<{
13
13
  id: number | null;
14
14
  email: string;
15
15
  price: number;
16
16
  clientId: number | null;
17
- contactDetailsId: number | null;
17
+ personalDataId: number | null;
18
18
  deliveryDetailsId: number | null;
19
19
  invoiceDetailsId: number | null;
20
20
  paymentDetailsId: number | null;
@@ -23,14 +23,14 @@ export default class Order extends StockObject {
23
23
  getPrice(): number;
24
24
  getZsiId(): number | null;
25
25
  getGrossPrice(): number;
26
- getclientId(): number | null;
27
- getContactDetailsId(): number | null;
26
+ getClientId(): number | null;
27
+ getPersonalDataId(): number | null;
28
28
  getDeliveryDetailsId(): number | null;
29
29
  getInvoiceDetailsId(): number | null;
30
30
  getPaymentDetailsId(): number | null;
31
31
  setPrice(price: number): void;
32
32
  setclientId(clientId: number): void;
33
- setContactDetailsId(contactDetailsId: number): void;
33
+ setPersonalDataId(personalDataId: number): void;
34
34
  setDeliveryDetailsId(deliveryDetailsId: number): void;
35
35
  setInvoiceDetailsId(invoiceDetailsId: number): void;
36
36
  setPaymentDetailsId(paymentDetailsId: number): void;
@@ -6,17 +6,17 @@ export default class Order extends StockObject {
6
6
  email;
7
7
  price;
8
8
  clientId;
9
- contactDetailsId;
9
+ personalDataId;
10
10
  deliveryDetailsId;
11
11
  invoiceDetailsId;
12
12
  paymentDetailsId;
13
13
  zsiId;
14
- constructor(email, price, clientId, contactDetailsId, deliveryDetailsId, invoiceDetailsId = null, paymentDetailsId = null) {
14
+ constructor(email, price, clientId, personalDataId, deliveryDetailsId, invoiceDetailsId = null, paymentDetailsId = null) {
15
15
  super();
16
16
  this.email = email;
17
17
  this.price = price;
18
18
  this.clientId = clientId;
19
- this.contactDetailsId = contactDetailsId;
19
+ this.personalDataId = personalDataId;
20
20
  this.deliveryDetailsId = deliveryDetailsId;
21
21
  this.invoiceDetailsId = invoiceDetailsId;
22
22
  this.paymentDetailsId = paymentDetailsId;
@@ -28,7 +28,7 @@ export default class Order extends StockObject {
28
28
  email: this.email,
29
29
  price: this.price,
30
30
  clientId: this.clientId,
31
- contactDetailsId: this.contactDetailsId,
31
+ personalDataId: this.personalDataId,
32
32
  deliveryDetailsId: this.deliveryDetailsId,
33
33
  invoiceDetailsId: this.invoiceDetailsId,
34
34
  paymentDetailsId: this.paymentDetailsId,
@@ -47,11 +47,11 @@ export default class Order extends StockObject {
47
47
  const vatPercentage = 23; //brak stawki vat dla zamówienia
48
48
  return PriceConverter.netToGrossPrice(this.price, vatPercentage);
49
49
  }
50
- getclientId() {
50
+ getClientId() {
51
51
  return this.clientId;
52
52
  }
53
- getContactDetailsId() {
54
- return this.contactDetailsId;
53
+ getPersonalDataId() {
54
+ return this.personalDataId;
55
55
  }
56
56
  getDeliveryDetailsId() {
57
57
  return this.deliveryDetailsId;
@@ -68,8 +68,8 @@ export default class Order extends StockObject {
68
68
  setclientId(clientId) {
69
69
  this.clientId = clientId;
70
70
  }
71
- setContactDetailsId(contactDetailsId) {
72
- this.contactDetailsId = contactDetailsId;
71
+ setPersonalDataId(personalDataId) {
72
+ this.personalDataId = personalDataId;
73
73
  }
74
74
  setDeliveryDetailsId(deliveryDetailsId) {
75
75
  this.deliveryDetailsId = deliveryDetailsId;
@@ -14,7 +14,6 @@ declare enum TableNames {
14
14
  statusTypes = "statusTypesTable",
15
15
  addresses = "addressesTable",
16
16
  companyDetails = "companyDetailsTable",
17
- contactDetails = "contactDetailsTable",
18
17
  deliveryDetails = "deliveryDetailsTable",
19
18
  deliveryStatuses = "deliveryStatusesTable",
20
19
  deliveryStatusTypes = "deliveryStatusTypesTable",
@@ -15,7 +15,6 @@ var TableNames;
15
15
  TableNames["statusTypes"] = "statusTypesTable";
16
16
  TableNames["addresses"] = "addressesTable";
17
17
  TableNames["companyDetails"] = "companyDetailsTable";
18
- TableNames["contactDetails"] = "contactDetailsTable";
19
18
  TableNames["deliveryDetails"] = "deliveryDetailsTable";
20
19
  TableNames["deliveryStatuses"] = "deliveryStatusesTable";
21
20
  TableNames["deliveryStatusTypes"] = "deliveryStatusTypesTable";
@@ -0,0 +1,12 @@
1
+ import { QueryOptions, Table } from '@dascompany/database';
2
+ import AccountAddressesRow from '../../types/rows/AccountAddressesRow';
3
+ import AccountAddress from '../../stockObjects/AccountAddress';
4
+ export default class AccountAddressesTable extends Table {
5
+ select(queryOptions: QueryOptions): Promise<AccountAddressesRow>;
6
+ selectAll(queryOptions?: QueryOptions): Promise<AccountAddressesRow[]>;
7
+ selectId(queryOptions: QueryOptions): Promise<number | null>;
8
+ delete(id: number): Promise<number>;
9
+ private bindParameters;
10
+ insert(AccountAddresses: AccountAddress): Promise<void>;
11
+ private selectNextId;
12
+ }
@@ -0,0 +1,41 @@
1
+ import { Table } from '@dascompany/database';
2
+ import * as SQL from '../../SQL.json';
3
+ export default class AccountAddressesTable extends Table {
4
+ async select(queryOptions) {
5
+ const query = this.createQuery(SQL.accountAddresses.select, queryOptions);
6
+ const result = await query.execute();
7
+ return result.getRow();
8
+ }
9
+ async selectAll(queryOptions) {
10
+ const query = this.createQuery(SQL.accountAddresses.select, queryOptions);
11
+ const result = await query.execute();
12
+ return result.getRows();
13
+ }
14
+ async selectId(queryOptions) {
15
+ const query = this.createQuery(SQL.accountAddresses.selectId, queryOptions);
16
+ const result = await query.execute();
17
+ return result.getValue();
18
+ }
19
+ async delete(id) {
20
+ const query = this.createQuery(SQL.accountAddresses.delete);
21
+ query.bindParameter('id', id);
22
+ const result = await query.execute();
23
+ return result.getRowCount();
24
+ }
25
+ bindParameters(query, AccountAddresses) {
26
+ query.bindParameter('account_id', AccountAddresses.getAccountId());
27
+ query.bindParameter('address_id', AccountAddresses.getAddressId());
28
+ }
29
+ async insert(AccountAddresses) {
30
+ const id = await this.selectNextId();
31
+ const query = this.createQuery(SQL.accountAddresses.insert);
32
+ this.bindParameters(query, AccountAddresses);
33
+ await query.execute();
34
+ AccountAddresses.setId(id);
35
+ }
36
+ async selectNextId() {
37
+ const query = this.createQuery(SQL.accountAddresses.selectNextId);
38
+ const result = await query.execute();
39
+ return result.getValue();
40
+ }
41
+ }
@@ -36,11 +36,11 @@ export default class OrdersTable extends Table {
36
36
  bindParameters(query, order) {
37
37
  query.bindParameter('email', order.getEmail());
38
38
  query.bindParameter('price', order.getPrice());
39
- query.bindParameter('client_id', order.getclientId());
39
+ query.bindParameter('client_id', order.getClientId());
40
40
  this.bindDetailsParameters(query, order);
41
41
  }
42
42
  bindDetailsParameters(query, order) {
43
- query.bindParameter('contact_details_id', order.getContactDetailsId());
43
+ query.bindParameter('personal_data_id', order.getPersonalDataId());
44
44
  query.bindParameter('delivery_details_id', order.getDeliveryDetailsId());
45
45
  query.bindParameter('invoice_details_id', order.getInvoiceDetailsId());
46
46
  query.bindParameter('payment_details_id', order.getPaymentDetailsId());
@@ -0,0 +1,6 @@
1
+ import AddressI from "./AddressI";
2
+ export default interface AccountAddressesI {
3
+ id: number;
4
+ accountId: number;
5
+ address: AddressI;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -5,7 +5,7 @@ export default interface OrderI {
5
5
  price: number;
6
6
  createdAt: string;
7
7
  clientId: number;
8
- contactDetailsId: number;
8
+ personalDataId: number;
9
9
  deliveryDetailsId: number;
10
10
  invoiceDetailsId: number;
11
11
  paymentDetailsId: number;
@@ -0,0 +1,5 @@
1
+ export default interface AccountAddressesRow {
2
+ id: number;
3
+ account_id: number;
4
+ address_id: number;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -4,7 +4,7 @@ export default interface OrderRow {
4
4
  price: number;
5
5
  created_at: string;
6
6
  client_id: number;
7
- contact_details_id: number;
7
+ personal_data_id: number;
8
8
  delivery_details_id: number;
9
9
  invoice_details_id: number;
10
10
  payment_details_id: number;
@@ -0,0 +1 @@
1
+ export default function calculateNetToGrossPrice(netPrice: number, vatPercentage: number): number;
@@ -0,0 +1,7 @@
1
+ export default function calculateNetToGrossPrice(netPrice, vatPercentage) {
2
+ const netPriceInPenny = Math.round(netPrice * 100);
3
+ const vatPriceInPenny = Math.round((netPriceInPenny * vatPercentage) / 100);
4
+ const grossPriceInPenny = netPriceInPenny + vatPriceInPenny;
5
+ const grossPrice = (grossPriceInPenny / 100).toFixed(2);
6
+ return Number(grossPrice);
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dascompany/product",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "vitest",