style: align multiline ternary operators

This commit is contained in:
2026-09-28 16:37:01 +03:00
committed by ksv741
parent b78c215ff1
commit 183b7f1efd
54 changed files with 986 additions and 982 deletions
@@ -37,18 +37,18 @@ export class BondCatalogService {
data:
result.data?.map((item) => {
const short = toBond(item);
const detail = item.detail ?
toBond({ ...item.detail, uid: item.uid }) :
short;
const detail = item.detail
? toBond({ ...item.detail, uid: item.uid })
: short;
const last = item.price;
return {
...detail,
classCode: detail.classCode ?? short.classCode,
isin: detail.isin ?? short.isin,
apiTradeAvailable: short.apiTradeAvailable,
pricePercent: last?.price ?
formatDecimal(decimal(last.price)) :
null,
pricePercent: last?.price
? formatDecimal(decimal(last.price))
: null,
priceAt: timestamp(last?.time),
};
}) ?? null,
@@ -63,9 +63,9 @@ export class BondCatalogService {
const result = await this.discovery.detail(userId, 'bond', uid, observe);
return {
...result,
data: result.data ?
{ ...toBond(result.data), slug: result.data.slug } :
null,
data: result.data
? { ...toBond(result.data), slug: result.data.slug }
: null,
};
}
@@ -82,9 +82,9 @@ export class BondCatalogService {
);
return {
...result,
data: result.data ?
{ ...toBond(result.data), slug: result.data.slug } :
null,
data: result.data
? { ...toBond(result.data), slug: result.data.slug }
: null,
};
}
}
@@ -62,9 +62,9 @@ export class BondIncomeService {
observe,
);
return {
data: result.values.instrument ?
bondMetrics(result.values, result.unavailable, result.observedAt) :
null,
data: result.values.instrument
? bondMetrics(result.values, result.unavailable, result.observedAt)
: null,
meta: result.meta,
};
}
@@ -99,18 +99,18 @@ export class BondIncomeService {
throw new NotFoundException();
}
const events = sources[1].payload?.coupons;
const position = portfolio.data ?
instrumentPosition(portfolio.data, uid, 'BOND') :
null;
const projected = events ?
bondCoupons(
const position = portfolio.data
? instrumentPosition(portfolio.data, uid, 'BOND')
: null;
const projected = events
? bondCoupons(
events,
position,
{ from, to, today },
sources[1].meta.lastSuccessfulAt ?? new Date().toISOString(),
!portfolio.data,
) :
undefined;
)
: undefined;
const result = await this.forecasts.result({
userId,
revision: connection.revision,
@@ -121,9 +121,9 @@ export class BondIncomeService {
candidate:
portfolio.data && sources[0].instrument ? projected : undefined,
});
return result.data || !projected ?
result :
{
return result.data || !projected
? result
: {
data: bondCoupons(
events ?? [],
null,
@@ -146,19 +146,19 @@ export function bondCoupons(
const { from, to, today } = window;
const quantity =
position?.accounts.length &&
position.accounts.every((p) => decimalFromString(p.quantity).value > ZERO_QUANTITY) ?
decimalFromString(position.quantity) :
null;
position.accounts.every((p) => decimalFromString(p.quantity).value > ZERO_QUANTITY)
? decimalFromString(position.quantity)
: null;
const coupons = events
.map((event) => {
const paymentDate = timestamp(event.couponDate)?.slice(ISO_DATE_START, ISO_DATE_LENGTH) ?? null;
const recordDate = timestamp(event.fixDate)?.slice(ISO_DATE_START, ISO_DATE_LENGTH) ?? null;
const perBond = money(event.payOneBond);
const timing = !paymentDate ?
('undated' as const) :
paymentDate >= today ?
('upcoming' as const) :
('past' as const);
const timing = !paymentDate
? ('undated' as const)
: paymentDate >= today
? ('upcoming' as const)
: ('past' as const);
return {
number: event.couponNumber ?? null,
paymentDate,
@@ -172,14 +172,14 @@ export function bondCoupons(
perBond &&
timing === 'upcoming' &&
recordDate &&
recordDate >= today ?
{
recordDate >= today
? {
currency: perBond.currency,
value: formatDecimal(
multiply(quantity, decimalFromString(perBond.value)),
),
} :
null,
}
: null,
};
})
.sort((a, b) => (a.paymentDate ?? '').localeCompare(b.paymentDate ?? ''));
@@ -225,8 +225,8 @@ export function bondMetrics(
clean &&
coupon.currency === clean.currency &&
decimalFromString(coupon.value).value >= ZERO_AMOUNT &&
decimalFromString(clean.value).value > ZERO_AMOUNT ?
formatDecimal(
decimalFromString(clean.value).value > ZERO_AMOUNT
? formatDecimal(
divide(
multiply(
decimalFromString(coupon.value),
@@ -238,14 +238,14 @@ export function bondMetrics(
),
COUPON_YIELD_DECIMAL_PLACES,
),
) :
null;
)
: null;
const couponType =
next?.couponType && next.couponType !== 'COUPON_TYPE_UNSPECIFIED' ?
next.couponType :
instrument.floatingCouponFlag === true ?
'COUPON_TYPE_FLOATING' :
null;
next?.couponType && next.couponType !== 'COUPON_TYPE_UNSPECIFIED'
? next.couponType
: instrument.floatingCouponFlag === true
? 'COUPON_TYPE_FLOATING'
: null;
return {
creditRating,
coupon,
@@ -48,9 +48,9 @@ export class BondMarketService {
observe,
);
return {
data: result.values.instrument ?
bondQuote(result.values, result.unavailable, result.observedAt) :
null,
data: result.values.instrument
? bondQuote(result.values, result.unavailable, result.observedAt)
: null,
meta: result.meta,
};
}
@@ -83,8 +83,8 @@ export function bondQuote(
const cleanPrice =
pricePercent !== null &&
nominal &&
decimalFromString(nominal.value).value > ZERO_AMOUNT ?
{
decimalFromString(nominal.value).value > ZERO_AMOUNT
? {
currency: nominal.currency,
value: formatDecimal(
divide(
@@ -96,11 +96,11 @@ export function bondQuote(
PRICE_DECIMAL_PLACES,
),
),
} :
null;
}
: null;
const dirtyPrice =
cleanPrice && aci && aci.currency === cleanPrice.currency ?
{
cleanPrice && aci && aci.currency === cleanPrice.currency
? {
currency: cleanPrice.currency,
value: formatDecimal(
add(
@@ -108,8 +108,8 @@ export function bondQuote(
decimalFromString(aci.value),
),
),
} :
null;
}
: null;
return {
pricePercent,
cleanPrice,
@@ -118,9 +118,9 @@ export function bondQuote(
priceAt,
tradingStatus,
changePercentagePoints:
last?.price && previous?.close ?
formatDecimal(subtract(decimal(last.price), decimal(previous.close))) :
null,
last?.price && previous?.close
? formatDecimal(subtract(decimal(last.price), decimal(previous.close)))
: null,
previousCloseDate: timestamp(previous?.time)?.slice(ISO_DATE_START, ISO_DATE_LENGTH) ?? null,
unavailable,
observedAt,
@@ -123,9 +123,9 @@ describe('bond financial projections', () => {
{
couponDate: time('2026-10-10'),
payOneBond:
scenario === 'unknown' ?
undefined :
money('30', scenario === 'currency' ? 'usd' : 'rub'),
scenario === 'unknown'
? undefined
: money('30', scenario === 'currency' ? 'usd' : 'rub'),
couponPeriod: scenario === 'period' ? 0 : 90,
},
],