diff --git a/package.json b/package.json index dbb4c64..6beeda4 100644 --- a/package.json +++ b/package.json @@ -50,9 +50,9 @@ "formik": "^2.4.5", "framer-motion": "^11.0.20", "json-stringify-safe": "^5.0.1", - "react": "^18.2.69", + "react": "^18.2.0", "react-chartjs-2": "^5.2.0", - "react-dom": "^18.2.22", + "react-dom": "^18.2.0", "react-router-dom": "^6.22.3", "reflect-metadata": "^0.2.1", "sequelize": "^6.37.1", diff --git a/src/app/components/Portfolio/Report/ReportSummary.tsx b/src/app/components/Portfolio/Report/ReportSummary.tsx index ec66b79..807ba56 100644 --- a/src/app/components/Portfolio/Report/ReportSummary.tsx +++ b/src/app/components/Portfolio/Report/ReportSummary.tsx @@ -87,6 +87,15 @@ const ReportSummary: FunctionComponent = ({ ..._rest }): React.ReactNode +

Fees

+ + Total + + + + + + ); }; diff --git a/src/models/bond_statement.model.ts b/src/models/bond_statement.model.ts index edaa47b..17c5ab8 100644 --- a/src/models/bond_statement.model.ts +++ b/src/models/bond_statement.model.ts @@ -18,6 +18,9 @@ export class BondStatement extends Model< @BelongsTo(() => Statement, "id") public statement: Statement; + @Column({ type: DataType.STRING(2), field: "country" }) + declare country: string; + @Column({ type: DataType.FLOAT, field: "accruedInt" }) declare accruedInterests: number; diff --git a/src/models/interest_statement.model.ts b/src/models/interest_statement.model.ts index a0c54f5..9157acf 100644 --- a/src/models/interest_statement.model.ts +++ b/src/models/interest_statement.model.ts @@ -1,5 +1,5 @@ import { CreationOptional, InferAttributes, InferCreationAttributes } from "sequelize"; -import { BelongsTo, Model, Table } from "sequelize-typescript"; +import { BelongsTo, Column, DataType, Model, Table } from "sequelize-typescript"; import { Statement } from "."; @Table({ tableName: "interest_statement", timestamps: false, createdAt: false, updatedAt: false }) @@ -17,4 +17,7 @@ export class InterestStatement extends Model< @BelongsTo(() => Statement, "id") public statement: Statement; + + @Column({ type: DataType.STRING(2), field: "country" }) + declare country: string; } diff --git a/src/models/portfolio.model.ts b/src/models/portfolio.model.ts index 0076f20..9267449 100644 --- a/src/models/portfolio.model.ts +++ b/src/models/portfolio.model.ts @@ -39,6 +39,9 @@ export class Portfolio extends Model< @Column({ type: DataType.STRING(3), field: "base_currency" }) declare baseCurrency: string; + @Column({ type: DataType.STRING(2), field: "country" }) + declare country: string; + @Column({ type: DataType.FLOAT, field: "put_ratio", defaultValue: 0 }) declare putRatio?: number; diff --git a/src/routers/reports.types.ts b/src/routers/reports.types.ts index b215be1..3abe6d9 100644 --- a/src/routers/reports.types.ts +++ b/src/routers/reports.types.ts @@ -1,5 +1,6 @@ import { DividendStatementEntry, + FeeStatementEntry, InterestStatementEntry, TaxStatementEntry, WithHoldingStatementEntry, @@ -21,8 +22,8 @@ import { * Dididend Summary entry data transfered between frontend and backend */ export type DididendSummary = { - // year: number; - // month: number; + // year: number; + // month: number; country: string; grossAmountInBase: number; taxes: number; @@ -32,12 +33,22 @@ export type DididendSummary = { * Dididend Summary entry data transfered between frontend and backend */ export type InterestsSummary = { + // year: number; + // month: number; + // country: string; grossCredit: number; netDebit: number; withHolding: number; totalAmountInBase: number; }; +/** + * Fees summary + */ +export type FeesSummary = { + totalAmountInBase: number; +}; + /** * Report entry data transfered between frontend and backend */ @@ -49,4 +60,6 @@ export type ReportEntry = { dividendsDetails: (DividendStatementEntry | TaxStatementEntry)[]; interestsSummary: InterestsSummary; interestsDetails: (InterestStatementEntry | WithHoldingStatementEntry)[]; + feesSummary: FeesSummary; + feesDetails: FeeStatementEntry[]; }; diff --git a/src/routers/statements.utils.ts b/src/routers/statements.utils.ts index b03b0d9..8f667d6 100644 --- a/src/routers/statements.utils.ts +++ b/src/routers/statements.utils.ts @@ -166,11 +166,13 @@ export const prepareReport = (portfolio: Portfolio, year: number, month: number) dividendsDetails: [], interestsSummary: { totalAmountInBase: 0, grossCredit: 0, netDebit: 0, withHolding: 0 }, interestsDetails: [], + feesSummary: { totalAmountInBase: 0 }, + feesDetails: [], }; statements.forEach((statement) => { - // const date = statement.date.toString(); - // const year = parseInt(date.substring(0, 4)); - // const month = parseInt(date.substring(5, 7)); + // const date = statement.date.toString(); + // const year = parseInt(date.substring(0, 4)); + // const month = parseInt(date.substring(5, 7)); let entry: DididendSummary | undefined; switch (statement.statementType) { case StatementTypes.DividendStatement: @@ -205,6 +207,11 @@ export const prepareReport = (portfolio: Portfolio, year: number, month: number) report.interestsSummary.withHolding += statement.amount * statement.fxRateToBase; report.interestsDetails.push(statement); break; + + case StatementTypes.FeeStatement: + report.feesSummary.totalAmountInBase += statement.amount * statement.fxRateToBase; + report.feesDetails.push(statement); + break; } }); console.log(report.dividendsSummary); diff --git a/yarn.lock b/yarn.lock index 21e1380..dcdae82 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8808,7 +8808,7 @@ react-docgen@^7.0.0: resolve "^1.22.1" strip-indent "^4.0.0" -"react-dom@^16.8.0 || ^17.0.0 || ^18.0.0": +"react-dom@^16.8.0 || ^17.0.0 || ^18.0.0", react-dom@^18.2.0: version "18.2.0" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.2.0.tgz#22aaf38708db2674ed9ada224ca4aa708d821e3d" integrity sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g== @@ -8816,14 +8816,6 @@ react-docgen@^7.0.0: loose-envify "^1.1.0" scheduler "^0.23.0" -react-dom@^18.2.22: - version "18.3.0-next-fecc288b7-20221025" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.3.0-next-fecc288b7-20221025.tgz#f06afce21f68a6797eb4c740637aa844c7918bcd" - integrity sha512-EczZNIcOXzLFyPhSXpplVFekfUvbtHRC68TVAPfCopn8YxjMg2ROVgYs1VdSnEu2JlXKvpeIbjexAuhDprsp/A== - dependencies: - loose-envify "^1.1.0" - scheduler "0.24.0-next-fecc288b7-20221025" - react-element-to-jsx-string@^15.0.0: version "15.0.0" resolved "https://registry.yarnpkg.com/react-element-to-jsx-string/-/react-element-to-jsx-string-15.0.0.tgz#1cafd5b6ad41946ffc8755e254da3fc752a01ac6" @@ -8943,20 +8935,13 @@ react-transition-group@^4.3.0: loose-envify "^1.4.0" prop-types "^15.6.2" -"react@^16.8.0 || ^17.0.0 || ^18.0.0": +"react@^16.8.0 || ^17.0.0 || ^18.0.0", react@^18.2.0: version "18.2.0" resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5" integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ== dependencies: loose-envify "^1.1.0" -react@^18.2.69: - version "18.3.0-next-fecc288b7-20221025" - resolved "https://registry.yarnpkg.com/react/-/react-18.3.0-next-fecc288b7-20221025.tgz#8da77f8c8221bb2761ed817b7638feb108ba791c" - integrity sha512-lKvCNWRO9XPy8q7hLd0ODK/4Oqr54r3Vr49Y7EyNBz/kfsmNT6Vx0F69KRz/eGcbt1XDvtbA7KZd+mh8w3wONQ== - dependencies: - loose-envify "^1.1.0" - read-pkg-up@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507" @@ -9288,13 +9273,6 @@ safe-stable-stringify@^2.3.1: resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -scheduler@0.24.0-next-fecc288b7-20221025: - version "0.24.0-next-fecc288b7-20221025" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.24.0-next-fecc288b7-20221025.tgz#0f4b174cf0ee5866b78855f4bf41142cc3cecc0e" - integrity sha512-D2r7z/2EbRXXz4k8XRQab2l71zARIwmZzLLGPAM936/dW1iF835+FMwnOe4Iep96vNJAdQavqJBP4Fm+/MadsQ== - dependencies: - loose-envify "^1.1.0" - scheduler@^0.23.0: version "0.23.0" resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.23.0.tgz#ba8041afc3d30eb206a487b6b384002e4e61fdfe"