fix(ledger): 修复历史净值双重汇率折算 bug 与汇率时间查询边界
This commit is contained in:
@@ -48,10 +48,10 @@ async function buildDailyRatesMap(targetDateStr: string): Promise<Record<string,
|
||||
function getClosestRateForDate(currencyPair: string): string | null {
|
||||
const records = ratesCache.get(currencyPair);
|
||||
if (!records || records.length === 0) return null;
|
||||
const targetDt = new Date(targetDateStr + 'T00:00:00Z');
|
||||
const endOfDay = new Date(targetDateStr + 'T23:59:59.999');
|
||||
let closest: RateRecord | null = null;
|
||||
for (const rec of records) {
|
||||
if (rec.fetchTime <= targetDt) {
|
||||
if (rec.fetchTime <= endOfDay) {
|
||||
closest = rec;
|
||||
} else {
|
||||
break;
|
||||
@@ -222,7 +222,7 @@ export async function GET(req: Request) {
|
||||
const fxNum = snapshotFxRate;
|
||||
|
||||
const calcMarketValueCny = holding.quantity.times(priceNum).times(fxNum);
|
||||
const calcCostCny = holding.totalCost.times(fxNum);
|
||||
const calcCostCny = holding.totalCost;
|
||||
|
||||
totalMarketValue = totalMarketValue.plus(calcMarketValueCny);
|
||||
totalCost = totalCost.plus(calcCostCny);
|
||||
|
||||
Reference in New Issue
Block a user