@dascompany/product 3.1.2 → 3.1.4

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
@@ -54,8 +54,8 @@
54
54
  },
55
55
  "companyDetails": {
56
56
  "select": "SELECT * FROM personal_information.company_details",
57
- "insert": "INSERT INTO personal_information.company_details( id, name, tax_number ) VALUES ($id::BIGINT, $name::TEXT, $tax_number::TEXT )",
58
- "update": "UPDATE personal_information.company_details SET name = $name::TEXT, tax_number = $tax_number::TEXT WHERE id = $id::BIGINT",
57
+ "insert": "INSERT INTO personal_information.company_details( id, name, tax_number, address_id ) VALUES ($id::BIGINT, $name::TEXT, $tax_number::TEXT, $address_id::BIGINT )",
58
+ "update": "UPDATE personal_information.company_details SET name = $name::TEXT, tax_number = $tax_number::TEXT, address_id = $address_id::BIGINT WHERE id = $id::BIGINT",
59
59
  "delete": "DELETE FROM personal_information.company_details WHERE id = $id::BIGINT",
60
60
  "selectNextId": "SELECT nextval('personal_information.company_details_id'::regclass)"
61
61
  },
@@ -23,12 +23,12 @@ export default class Order extends StockObject {
23
23
  getGrossPrice(): number;
24
24
  getClientId(): number | null;
25
25
  getDeliveryDetailsId(): number | null;
26
- getInvoiceDetailsId(): number | null;
26
+ getCompanyDetailsId(): number | null;
27
27
  getPaymentDetailsId(): number | null;
28
28
  setPrice(price: number): void;
29
29
  setclientId(clientId: number): void;
30
30
  setDeliveryDetailsId(deliveryDetailsId: number): void;
31
- setInvoiceDetailsId(companyDetailsId: number): void;
31
+ setCompanyDetailsId(companyDetailsId: number): void;
32
32
  setPaymentDetailsId(paymentDetailsId: number): void;
33
33
  setZsiId(zsiId: number): void;
34
34
  calculateAndUpdatePrice(): Promise<void>;
@@ -50,7 +50,7 @@ export default class Order extends StockObject {
50
50
  getDeliveryDetailsId() {
51
51
  return this.deliveryDetailsId;
52
52
  }
53
- getInvoiceDetailsId() {
53
+ getCompanyDetailsId() {
54
54
  return this.companyDetailsId;
55
55
  }
56
56
  getPaymentDetailsId() {
@@ -65,7 +65,7 @@ export default class Order extends StockObject {
65
65
  setDeliveryDetailsId(deliveryDetailsId) {
66
66
  this.deliveryDetailsId = deliveryDetailsId;
67
67
  }
68
- setInvoiceDetailsId(companyDetailsId) {
68
+ setCompanyDetailsId(companyDetailsId) {
69
69
  this.companyDetailsId = companyDetailsId;
70
70
  }
71
71
  setPaymentDetailsId(paymentDetailsId) {
@@ -41,7 +41,7 @@ export default class OrdersTable extends Table {
41
41
  }
42
42
  bindDetailsParameters(query, order) {
43
43
  query.bindParameter('delivery_details_id', order.getDeliveryDetailsId());
44
- query.bindParameter('company_details_id', order.getInvoiceDetailsId());
44
+ query.bindParameter('company_details_id', order.getCompanyDetailsId());
45
45
  query.bindParameter('payment_details_id', order.getPaymentDetailsId());
46
46
  }
47
47
  async selectNextId() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dascompany/product",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "vitest",
@@ -21,7 +21,6 @@
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@dascompany/database": "^3.0.2",
24
- "@dascompany/zsi": "^2.0.1",
25
24
  "@types/pg": "^8.11.11",
26
25
  "pg": "^8.13.3"
27
26
  }
@@ -1,9 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
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
- }
@@ -1,26 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
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
- }
@@ -1,13 +0,0 @@
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
- }
@@ -1,8 +0,0 @@
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
- }
@@ -1,25 +0,0 @@
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
- }
@@ -1,11 +0,0 @@
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
- }
@@ -1,26 +0,0 @@
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
- }
@@ -1,12 +0,0 @@
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
- }
@@ -1,41 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- import AddressI from "./AddressI";
2
- export default interface AccountAddressesI {
3
- id: number;
4
- accountId: number;
5
- address: AddressI;
6
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- export default interface AccountAddressesRow {
2
- id: number;
3
- account_id: number;
4
- address_id: number;
5
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export default function calculateNetToGrossPrice(netPrice: number, vatPercentage: number): number;
@@ -1,7 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- import ProductI from "../types/ProductI";
2
- export default function getTentInstallationPrice(productData: ProductI): Promise<number>;
@@ -1,14 +0,0 @@
1
- import { TentInstallation } from "@dascompany/zsi";
2
- export default async function getTentInstallationPrice(productData) {
3
- const constructionSplit = productData.jsonData.construction.type.split(' ');
4
- const tentData = {
5
- construction: constructionSplit[0],
6
- reinforcement: constructionSplit[1].toUpperCase() === 'POLAR',
7
- fireResistant: (productData.jsonData.cover.type === 'PVC - 600g' || productData.jsonData.cover.type === 'PVC - 620g'),
8
- width: productData.width,
9
- length: productData.length,
10
- height: productData.height
11
- };
12
- const installationPrice = await TentInstallation.getPrice(tentData);
13
- return installationPrice;
14
- }