refactor: enforce frontend view model boundaries
Frontend verify / commits (pull_request) Successful in 28s
Frontend verify / security (pull_request) Successful in 10s
Frontend verify / verify (pull_request) Successful in 8m19s

This commit is contained in:
2026-09-28 18:48:23 +03:00
parent 5b69003516
commit ca0ad4f824
287 changed files with 8558 additions and 4538 deletions
+15 -12
View File
@@ -22,7 +22,9 @@ const operationTransferPrefix = "OPERATION_TYPE_TRANS_";
type PaymentPresentation = {
amount: string;
label: string;
tone: "negative" | "neutral" | "positive";
tone: "negative"
| "neutral"
| "positive";
};
function entryLabelKey(operation: BrokerageOperation): string {
@@ -30,6 +32,7 @@ function entryLabelKey(operation: BrokerageOperation): string {
return isOperationType(operation.type, OperationType.Coupon)
? "ledger.entryLabel.income.coupon"
: "ledger.entryLabel.income.dividend";
return `ledger.category.${operation.category}`;
}
@@ -43,19 +46,15 @@ function isZeroDecimal(value: string): boolean {
function operationLabelKey(type: string): string {
if (
[
OperationType.Buy,
OperationType.BuyCard,
OperationType.BuyMargin,
].some(candidate => isOperationType(type, candidate))
[OperationType.Buy, OperationType.BuyCard, OperationType.BuyMargin].some(
candidate => isOperationType(type, candidate),
)
)
return "ledger.operationType.buy";
if (
[
OperationType.Sell,
OperationType.SellCard,
OperationType.SellMargin,
].some(candidate => isOperationType(type, candidate))
[OperationType.Sell, OperationType.SellCard, OperationType.SellMargin].some(
candidate => isOperationType(type, candidate),
)
)
return "ledger.operationType.sell";
if (
@@ -72,7 +71,10 @@ function operationLabelKey(type: string): string {
return "ledger.operationType.input";
if (isOperationType(type, OperationType.OutputSecurities))
return "ledger.operationType.output";
return type.startsWith(operationTransferPrefix) ? "ledger.operationType.transfer" : "ledger.operationType.other";
return type.startsWith(operationTransferPrefix)
? "ledger.operationType.transfer"
: "ledger.operationType.other";
}
function paymentPresentation(
@@ -99,6 +101,7 @@ function paymentPresentation(
label: entryLabelKey(operation),
tone: "negative",
};
return {
amount: `+${formatMoney(operation.payment)}`,
label: entryLabelKey(operation),