@dascompany/product 3.0.1 → 3.0.3
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 +4 -4
- package/dist/reader/ClientAccountReader.js +2 -2
- package/dist/reader/CompanyDetailsReader.js +5 -1
- package/dist/reader/PersonalDataReader.js +1 -9
- package/dist/repo/CompanyDetailsRepo.js +1 -1
- package/dist/repo/PersonalDataRepo.js +1 -1
- package/dist/stockObjects/CompanyDetails.d.ts +4 -3
- package/dist/stockObjects/CompanyDetails.js +10 -10
- package/dist/stockObjects/PersonalData.d.ts +1 -11
- package/dist/stockObjects/PersonalData.js +2 -33
- package/dist/tables/personalInformation/CompanyDetailsTable.js +1 -0
- package/dist/tables/personalInformation/PersonalDataTable.js +0 -1
- package/dist/types/CompanyDetailsI.d.ts +2 -0
- package/dist/types/PersonalDataI.d.ts +0 -3
- package/dist/types/rows/CompanyDetailsRow.d.ts +1 -0
- package/dist/types/rows/PersonalDataRow.d.ts +0 -1
- package/package.json +1 -1
- package/dist/mappers/AccountAddressMapper.d.ts +0 -9
- package/dist/mappers/AccountAddressMapper.js +0 -19
- package/dist/reader/AccountAddressesReader.d.ts +0 -7
- package/dist/reader/AccountAddressesReader.js +0 -26
- package/dist/repo/AccountAddressesRepo.d.ts +0 -6
- package/dist/repo/AccountAddressesRepo.js +0 -13
- package/dist/repo/OrderStatusRepo.d.ts +0 -8
- package/dist/repo/OrderStatusRepo.js +0 -25
- package/dist/stockObjects/AccountAddress.d.ts +0 -11
- package/dist/stockObjects/AccountAddress.js +0 -26
- package/dist/tables/clients/AccountAddressesTable.d.ts +0 -12
- package/dist/tables/clients/AccountAddressesTable.js +0 -41
- package/dist/types/AccountAddressesI.d.ts +0 -6
- package/dist/types/AccountAddressesI.js +0 -1
- package/dist/types/rows/AccountAddressesRow.d.ts +0 -5
- package/dist/types/rows/AccountAddressesRow.js +0 -1
- package/dist/utils/calculateNetToGrossPrice.d.ts +0 -1
- package/dist/utils/calculateNetToGrossPrice.js +0 -7
package/dist/SQL.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"accounts": {
|
|
12
12
|
"select": "SELECT * FROM clients.accounts",
|
|
13
13
|
"selectId": "SELECT id FROM clients.accounts ",
|
|
14
|
-
"insert": "INSERT INTO clients.accounts( id, email, activated,
|
|
15
|
-
"update": "UPDATE clients.accounts SET activated = $activated::BOOL, deleted = $deleted::BOOL,
|
|
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",
|
|
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)"
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
},
|
|
54
54
|
"personalData": {
|
|
55
55
|
"select": "SELECT * FROM personal_information.personal_data",
|
|
56
|
-
"insert": "INSERT INTO personal_information.personal_data (id, first_name, last_name, email, phone_number
|
|
57
|
-
"update": "UPDATE personal_information.personal_data SET email = $email::TEXT, first_name = $first_name::TEXT, last_name= $last_name::TEXT, phone_number = $phone_number::TEXT
|
|
56
|
+
"insert": "INSERT INTO personal_information.personal_data (id, first_name, last_name, email, phone_number) VALUES ($id::BIGINT, $first_name::TEXT, $last_name::TEXT, $email::TEXT, $phone_number::TEXT)",
|
|
57
|
+
"update": "UPDATE personal_information.personal_data SET email = $email::TEXT, first_name = $first_name::TEXT, last_name= $last_name::TEXT, phone_number = $phone_number::TEXT WHERE id = $id::BIGINT",
|
|
58
58
|
"selectNextId": "SELECT nextval('personal_information.personal_data_id'::regclass)"
|
|
59
59
|
},
|
|
60
60
|
"companyDetails": {
|
|
@@ -31,9 +31,9 @@ export default class ClientAccountReader {
|
|
|
31
31
|
createdAt: client.created_at,
|
|
32
32
|
activated: client.activated,
|
|
33
33
|
deleted: client.deleted,
|
|
34
|
-
personalDataId: client.
|
|
34
|
+
personalDataId: client.personal_data_id,
|
|
35
35
|
deliveryDetailsId: client.delivery_details_id,
|
|
36
|
-
companyDetailsId: client.
|
|
36
|
+
companyDetailsId: client.company_details_id,
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
|
+
import AddressesReader from "./AddressesReader";
|
|
3
|
+
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
2
4
|
export default class CompanyDetailsReader {
|
|
3
5
|
static async get(queryOptions) {
|
|
4
6
|
const companyDetails = await DatabaseConnection.getInstance().companyDetails.select(queryOptions);
|
|
7
|
+
const address = await AddressesReader.get(createQueryOptionsForId(companyDetails.address_id));
|
|
5
8
|
if (companyDetails)
|
|
6
9
|
return {
|
|
7
10
|
id: companyDetails.id,
|
|
8
11
|
name: companyDetails.name,
|
|
9
|
-
taxNumber: companyDetails.tax_number
|
|
12
|
+
taxNumber: companyDetails.tax_number,
|
|
13
|
+
address
|
|
10
14
|
};
|
|
11
15
|
else
|
|
12
16
|
throw Error(`no companyDetails found with queryOptions: ${queryOptions}`);
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import correctPhoneNumber from "../utils/correctPhoneNumber";
|
|
3
|
-
import CompanyDetailsReader from "./CompanyDetailsReader";
|
|
4
|
-
import createQueryOptionsForId from "../utils/createQueryOptionsForId";
|
|
5
3
|
export default class PersonalDataReader {
|
|
6
4
|
static async get(queryOptions) {
|
|
7
5
|
const personalDataRow = await DatabaseConnection.getInstance().personalData.select(queryOptions);
|
|
8
6
|
const personalData = this.correctPersonalData(personalDataRow);
|
|
9
|
-
if (personalDataRow.company_details_id) {
|
|
10
|
-
personalData.companyDetails = await CompanyDetailsReader.get(createQueryOptionsForId(personalDataRow.company_details_id));
|
|
11
|
-
personalData.isCompany = true;
|
|
12
|
-
}
|
|
13
7
|
return personalData;
|
|
14
8
|
}
|
|
15
9
|
static correctPersonalData(personalDataRow) {
|
|
@@ -19,9 +13,7 @@ export default class PersonalDataReader {
|
|
|
19
13
|
firstName: personalDataRow.first_name,
|
|
20
14
|
lastName: personalDataRow.last_name,
|
|
21
15
|
email: personalDataRow.email,
|
|
22
|
-
phoneNumber
|
|
23
|
-
companyDetails: null,
|
|
24
|
-
isCompany: false
|
|
16
|
+
phoneNumber
|
|
25
17
|
};
|
|
26
18
|
}
|
|
27
19
|
}
|
|
@@ -6,7 +6,7 @@ export default class CompanyDetailsRepo {
|
|
|
6
6
|
return this.createCompanyDetailsFromRow(companyDetailsRow);
|
|
7
7
|
}
|
|
8
8
|
static createCompanyDetailsFromRow(companyDetailsRow) {
|
|
9
|
-
const companyDetails = new CompanyDetails(companyDetailsRow.name, companyDetailsRow.tax_number);
|
|
9
|
+
const companyDetails = new CompanyDetails(companyDetailsRow.name, companyDetailsRow.tax_number, companyDetailsRow.address_id);
|
|
10
10
|
companyDetails.setId(companyDetailsRow.id);
|
|
11
11
|
return companyDetails;
|
|
12
12
|
}
|
|
@@ -8,7 +8,7 @@ export default class PersonalDataRepo {
|
|
|
8
8
|
}
|
|
9
9
|
static createPersonalDataFromRow(dataRow) {
|
|
10
10
|
const phoneNumber = correctPhoneNumber(dataRow.phone_number);
|
|
11
|
-
const personalData = new PersonalData(dataRow.email, dataRow.first_name, dataRow.last_name, phoneNumber
|
|
11
|
+
const personalData = new PersonalData(dataRow.email, dataRow.first_name, dataRow.last_name, phoneNumber);
|
|
12
12
|
personalData.setId(dataRow.id);
|
|
13
13
|
return personalData;
|
|
14
14
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { StockObject, StockObjectMapper } from "@dascompany/database";
|
|
2
|
-
import CompanyDetailsI from "../types/CompanyDetailsI";
|
|
3
2
|
export default class CompanyDetails extends StockObject {
|
|
4
3
|
private name;
|
|
5
4
|
private taxNumber;
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
private addressId;
|
|
6
|
+
constructor(name: string, taxNumber: string, addressId: number);
|
|
8
7
|
getName(): string;
|
|
9
8
|
getTaxNumber(): string;
|
|
9
|
+
getAddressId(): number;
|
|
10
|
+
setAddressId(addressId: number): void;
|
|
10
11
|
setName(name: string): void;
|
|
11
12
|
setTaxNumber(taxNumber: string): void;
|
|
12
13
|
protected getMapper(): StockObjectMapper;
|
|
@@ -3,18 +3,12 @@ import CompanyDetailsMapper from "../mappers/CompanyDetailsMapper";
|
|
|
3
3
|
export default class CompanyDetails extends StockObject {
|
|
4
4
|
name;
|
|
5
5
|
taxNumber;
|
|
6
|
-
|
|
6
|
+
addressId;
|
|
7
|
+
constructor(name, taxNumber, addressId) {
|
|
7
8
|
super();
|
|
8
9
|
this.name = name;
|
|
9
|
-
this.taxNumber = taxNumber
|
|
10
|
-
|
|
11
|
-
getData() {
|
|
12
|
-
const id = this.getId();
|
|
13
|
-
return {
|
|
14
|
-
id,
|
|
15
|
-
name: this.name,
|
|
16
|
-
taxNumber: this.taxNumber
|
|
17
|
-
};
|
|
10
|
+
this.taxNumber = taxNumber,
|
|
11
|
+
this.addressId = addressId;
|
|
18
12
|
}
|
|
19
13
|
getName() {
|
|
20
14
|
return this.name;
|
|
@@ -22,6 +16,12 @@ export default class CompanyDetails extends StockObject {
|
|
|
22
16
|
getTaxNumber() {
|
|
23
17
|
return this.taxNumber;
|
|
24
18
|
}
|
|
19
|
+
getAddressId() {
|
|
20
|
+
return this.addressId;
|
|
21
|
+
}
|
|
22
|
+
setAddressId(addressId) {
|
|
23
|
+
this.addressId = addressId;
|
|
24
|
+
}
|
|
25
25
|
setName(name) {
|
|
26
26
|
this.name = name;
|
|
27
27
|
}
|
|
@@ -1,34 +1,24 @@
|
|
|
1
1
|
import { StockObject, StockObjectMapper } from "@dascompany/database";
|
|
2
|
-
import CompanyDetails from "./CompanyDetails";
|
|
3
|
-
import CompanyDetailsI from "../types/CompanyDetailsI";
|
|
4
2
|
export default class PersonalData extends StockObject {
|
|
5
3
|
private email;
|
|
6
4
|
private firstName;
|
|
7
5
|
private lastName;
|
|
8
6
|
private phoneNumber;
|
|
9
|
-
|
|
10
|
-
private companyDetails;
|
|
11
|
-
constructor(email: string, firstName: string, lastName: string, phoneNumber: string, companyDetailsId?: number | null);
|
|
7
|
+
constructor(email: string, firstName: string, lastName: string, phoneNumber: string);
|
|
12
8
|
getData(): Promise<{
|
|
13
9
|
email: string;
|
|
14
10
|
firstName: string;
|
|
15
11
|
lastName: string;
|
|
16
12
|
phoneNumber: string;
|
|
17
|
-
companyDetails: CompanyDetailsI | null;
|
|
18
13
|
}>;
|
|
19
|
-
getCompanyDetailsData(): Promise<CompanyDetailsI | null>;
|
|
20
|
-
getCompanyDetails(): Promise<CompanyDetails | null>;
|
|
21
|
-
isCompany(): boolean;
|
|
22
14
|
getEmail(): string;
|
|
23
15
|
getFirstName(): string;
|
|
24
16
|
getLastName(): string;
|
|
25
17
|
getName(): string;
|
|
26
18
|
getPhoneNumber(): string;
|
|
27
|
-
getCompanyDetailsId(): number | null;
|
|
28
19
|
setEmail(email: string): void;
|
|
29
20
|
setFirstName(firstName: string): void;
|
|
30
21
|
setLastName(lastName: string): void;
|
|
31
22
|
setPhoneNumber(phoneNumber: string): void;
|
|
32
|
-
setCompanyDetailsId(companyDetailsId: number | null): void;
|
|
33
23
|
protected getMapper(): StockObjectMapper;
|
|
34
24
|
}
|
|
@@ -1,50 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StockObject } from "@dascompany/database";
|
|
2
2
|
import PersonalDataMapper from "../mappers/PersonalDataMapper";
|
|
3
|
-
import CompanyDetailsRepo from "../repo/CompanyDetailsRepo";
|
|
4
3
|
export default class PersonalData extends StockObject {
|
|
5
4
|
email;
|
|
6
5
|
firstName;
|
|
7
6
|
lastName;
|
|
8
7
|
phoneNumber;
|
|
9
|
-
|
|
10
|
-
companyDetails;
|
|
11
|
-
constructor(email, firstName, lastName, phoneNumber, companyDetailsId = null) {
|
|
8
|
+
constructor(email, firstName, lastName, phoneNumber) {
|
|
12
9
|
super();
|
|
13
10
|
this.email = email;
|
|
14
11
|
this.firstName = firstName;
|
|
15
12
|
this.lastName = lastName;
|
|
16
13
|
this.phoneNumber = phoneNumber;
|
|
17
|
-
this.companyDetailsId = companyDetailsId;
|
|
18
|
-
this.companyDetails = null;
|
|
19
14
|
}
|
|
20
15
|
async getData() {
|
|
21
|
-
const companyDetails = await this.getCompanyDetailsData();
|
|
22
16
|
return {
|
|
23
17
|
email: this.email,
|
|
24
18
|
firstName: this.firstName,
|
|
25
19
|
lastName: this.lastName,
|
|
26
20
|
phoneNumber: this.phoneNumber,
|
|
27
|
-
companyDetails,
|
|
28
21
|
};
|
|
29
22
|
}
|
|
30
|
-
async getCompanyDetailsData() {
|
|
31
|
-
let companyDetailsData = null;
|
|
32
|
-
await this.getCompanyDetails();
|
|
33
|
-
if (this.companyDetails)
|
|
34
|
-
companyDetailsData = this.companyDetails.getData();
|
|
35
|
-
return companyDetailsData;
|
|
36
|
-
}
|
|
37
|
-
async getCompanyDetails() {
|
|
38
|
-
if (this.companyDetailsId && !this.companyDetails) {
|
|
39
|
-
const queryOptions = new QueryOptions();
|
|
40
|
-
queryOptions.setWhere([{ name: 'id', type: ParameterType.bigint, value: this.companyDetailsId }]);
|
|
41
|
-
this.companyDetails = await CompanyDetailsRepo.get(queryOptions);
|
|
42
|
-
}
|
|
43
|
-
return this.companyDetails;
|
|
44
|
-
}
|
|
45
|
-
isCompany() {
|
|
46
|
-
return !!this.companyDetailsId;
|
|
47
|
-
}
|
|
48
23
|
getEmail() {
|
|
49
24
|
return this.email;
|
|
50
25
|
}
|
|
@@ -60,9 +35,6 @@ export default class PersonalData extends StockObject {
|
|
|
60
35
|
getPhoneNumber() {
|
|
61
36
|
return this.phoneNumber;
|
|
62
37
|
}
|
|
63
|
-
getCompanyDetailsId() {
|
|
64
|
-
return this.companyDetailsId;
|
|
65
|
-
}
|
|
66
38
|
setEmail(email) {
|
|
67
39
|
this.email = email;
|
|
68
40
|
}
|
|
@@ -75,9 +47,6 @@ export default class PersonalData extends StockObject {
|
|
|
75
47
|
setPhoneNumber(phoneNumber) {
|
|
76
48
|
this.phoneNumber = phoneNumber;
|
|
77
49
|
}
|
|
78
|
-
setCompanyDetailsId(companyDetailsId) {
|
|
79
|
-
this.companyDetailsId = companyDetailsId;
|
|
80
|
-
}
|
|
81
50
|
getMapper() {
|
|
82
51
|
return new PersonalDataMapper(this);
|
|
83
52
|
}
|
|
@@ -33,5 +33,6 @@ export default class CompanyDetailsTable extends Table {
|
|
|
33
33
|
bindParameters(query, companyDetails) {
|
|
34
34
|
query.bindParameter('name', companyDetails.getName());
|
|
35
35
|
query.bindParameter('tax_number', companyDetails.getTaxNumber());
|
|
36
|
+
query.bindParameter('address_id', companyDetails.getAddressId());
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -31,6 +31,5 @@ export default class PersonalDataTable extends Table {
|
|
|
31
31
|
query.bindParameter('first_name', personalData.getFirstName());
|
|
32
32
|
query.bindParameter('last_name', personalData.getLastName());
|
|
33
33
|
query.bindParameter('phone_number', personalData.getPhoneNumber());
|
|
34
|
-
query.bindParameter('company_details_id', personalData.getCompanyDetailsId());
|
|
35
34
|
}
|
|
36
35
|
}
|
package/package.json
CHANGED
|
@@ -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 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -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
|
-
}
|