process/payments: extract function generateSeasonPaymentsRows
This commit is contained in:
parent
600bb1a730
commit
de26e39eff
@ -403,6 +403,20 @@ export default function paymentsReactions(
|
||||
}
|
||||
);
|
||||
|
||||
function generateSeasonPaymentsRows(seasonType: number, shiftNumber: number, payments: number[]) {
|
||||
const shiftedPeriods = new Set(
|
||||
seasonsConstants.SEASONS_PERIODS[seasonType].map(
|
||||
(position) => (position + shiftNumber) % seasonsConstants.SEASONS_PERIOD_NUMBER
|
||||
)
|
||||
);
|
||||
const rows: Row[] = payments.map((value, i) => ({
|
||||
value,
|
||||
status: shiftedPeriods.has(i) ? 'Default' : 'Disabled',
|
||||
}));
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
reaction(
|
||||
() => {
|
||||
const seasonType = $calculation.getElementValue('selectSeasonType');
|
||||
@ -434,15 +448,7 @@ export default function paymentsReactions(
|
||||
leasingPeriod,
|
||||
shift(seasons, shiftNumber)
|
||||
);
|
||||
const shiftedPeriods = new Set(
|
||||
seasonsConstants.SEASONS_PERIODS[seasonType].map(
|
||||
(position) => (position + shiftNumber) % seasonsConstants.SEASONS_PERIOD_NUMBER
|
||||
)
|
||||
);
|
||||
const rows: Row[] = payments.map((value, i) => ({
|
||||
value,
|
||||
status: shiftedPeriods.has(i) ? 'Default' : 'Disabled',
|
||||
}));
|
||||
const rows: Row[] = generateSeasonPaymentsRows(seasonType, shiftNumber, payments);
|
||||
const firstPaymentPerc = $calculation.getElementValue('tbxFirstPaymentPerc');
|
||||
const lastPaymentPerc = $calculation.getElementValue('tbxLastPaymentPerc');
|
||||
|
||||
@ -494,15 +500,7 @@ export default function paymentsReactions(
|
||||
leasingPeriod,
|
||||
shift(seasons, shiftNumber)
|
||||
);
|
||||
const shiftedPeriods = new Set(
|
||||
seasonsConstants.SEASONS_PERIODS[seasonType].map(
|
||||
(position) => (position + shiftNumber) % seasonsConstants.SEASONS_PERIOD_NUMBER
|
||||
)
|
||||
);
|
||||
const rows: Row[] = payments.map((value, i) => ({
|
||||
value,
|
||||
status: shiftedPeriods.has(i) ? 'Default' : 'Disabled',
|
||||
}));
|
||||
const rows: Row[] = generateSeasonPaymentsRows(seasonType, shiftNumber, payments);
|
||||
const firstPaymentPerc = $calculation.getElementValue('tbxFirstPaymentPerc');
|
||||
const lastPaymentPerc = $calculation.getElementValue('tbxLastPaymentPerc');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user