feat: group all-account rows by instrument and day (WealthLedger/main#47) (#126)
This commit was merged in pull request #126.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { formatMoney } from "@/shared/lib";
|
||||
import { formatMoney, formatSnapshotDay } from "@/shared/lib";
|
||||
|
||||
import type { BrokerageOperation } from "../api/useBrokerageOperations";
|
||||
|
||||
@@ -27,6 +27,19 @@ type PaymentPresentation = {
|
||||
| "positive";
|
||||
};
|
||||
|
||||
function brokerageOperationGroupKey(
|
||||
operation: BrokerageOperation,
|
||||
): null | string {
|
||||
const identity = operation.instrumentUid || operation.figi;
|
||||
if (!identity) return null;
|
||||
|
||||
return JSON.stringify([
|
||||
formatSnapshotDay(operation.occurredAt),
|
||||
identity,
|
||||
operation.type,
|
||||
]);
|
||||
}
|
||||
|
||||
function entryLabelKey(operation: BrokerageOperation): string {
|
||||
if (operation.category === "income")
|
||||
return isOperationType(operation.type, OperationType.Coupon)
|
||||
@@ -115,4 +128,11 @@ function paymentPresentation(
|
||||
};
|
||||
}
|
||||
|
||||
export { isIncomePayment, operationLabelKey, paymentPresentation };
|
||||
export {
|
||||
brokerageOperationGroupKey,
|
||||
entryLabelKey,
|
||||
isIncomePayment,
|
||||
isZeroDecimal,
|
||||
operationLabelKey,
|
||||
paymentPresentation,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user