Skip to content

Commit

Permalink
Price adjustments statements import supported
Browse files Browse the repository at this point in the history
  • Loading branch information
rylorin committed Nov 15, 2024
1 parent 41ed10e commit 8f1c7f6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/bots/importer.bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,9 @@ export class ImporterBot extends ITradingBot {
case "Commission Adjustments":
statementType = StatementTypes.FeeStatement;
break;
case "Price Adjustments":
statementType = StatementTypes.PriceAdjustments;
break;
default:
console.error("undefined cash trasaction type:", element);
throw Error("undefined cash trasaction type: " + element.type);
Expand Down Expand Up @@ -734,6 +737,9 @@ export class ImporterBot extends ITradingBot {
([_interestStatement, _created]) => statement,
);

case StatementTypes.PriceAdjustments:
return Promise.resolve(statement);

default:
console.error(element);
throw Error("invalid statement type");
Expand Down
3 changes: 3 additions & 0 deletions src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import { FutureContract } from "./future_contract.model";
import { Index } from "./index.model";
import { OptionContract } from "./option_contract.model";
import { StockContract } from "./stock_contract.model";

export * from "./bag_contract.model";
export * from "./balance.model";
export * from "./bond_contract.model";
export * from "./bond_statement.model";
export * from "./cash_contract.model";
export * from "./contract.model";
export * from "./contract.types";
export * from "./corpo_statement.model";
export * from "./currency.model";
export * from "./dividend_statement.model";
Expand All @@ -28,6 +30,7 @@ export * from "./position.model";
export * from "./sales_taxes.model";
export * from "./setting.model";
export * from "./statement.model";
export * from "./statement.types";
export * from "./stock_contract.model";
export * from "./tax_statement.model";
export * from "./trade.model";
Expand Down
1 change: 1 addition & 0 deletions src/models/statement.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export const StatementTypes = {
CashStatement: "Cash",
BondStatement: "Bond",
SalesTaxStatement: "SalesTax",
PriceAdjustments: "Price Adjustments",
} as const;
export type StatementTypes = (typeof StatementTypes)[keyof typeof StatementTypes];
7 changes: 7 additions & 0 deletions src/routers/statements.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
InterestStatement,
OptionStatement,
Portfolio,
SalesTaxes,
Statement,
TaxStatement,
Trade,
Expand Down Expand Up @@ -116,6 +117,12 @@ const makeSynthesys = async (statements: Statement[]): Promise<StatementsSynthes
// Not included in synthesys
return Promise.resolve(value);

case StatementTypes.SalesTaxStatement:
return SalesTaxes.findByPk(item.id).then((_statement) => {
// Ignored at the moment
return value;
});

default: // Fallback
logger.log(
LogLevel.Warning,
Expand Down
7 changes: 5 additions & 2 deletions src/routers/statements.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContractType, OptionType } from "../models/contract.types";
import { ContractType, OptionType } from "../models";

export type SynthesysEntry = { stocks: number; options: number; dividends: number; interests: number; total: number };
export type StatementsSynthesysEntries = Record<"string", SynthesysEntry>;
Expand Down Expand Up @@ -87,6 +87,8 @@ export type CashStatementEntry = BaseStatement & { statementType: "Cash" };

export type SalesTaxStatementEntry = BaseStatement & { statementType: "SalesTax" };

export type PriceAjustmentsStatementEntry = BaseStatement & { statementType: "Price Adjustments" };

export type StatementEntry =
| EquityStatementEntry
| OptionStatementEntry
Expand All @@ -98,4 +100,5 @@ export type StatementEntry =
| CorporateStatementEntry
| CashStatementEntry
| BondStatementEntry
| SalesTaxStatementEntry;
| SalesTaxStatementEntry
| PriceAjustmentsStatementEntry;
6 changes: 6 additions & 0 deletions src/routers/statements.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ export const statementModelToStatementEntry = async (item: Statement): Promise<S
...baseStatement,
};

case StatementTypes.PriceAdjustments:
return {
statementType: StatementTypes.PriceAdjustments,
...baseStatement,
};

default:
throw Error("Undefined statement type");
}
Expand Down

0 comments on commit 8f1c7f6

Please sign in to comment.