import React from "react"; import Head from "next/head"; import Image from "next/image"; import moment from "moment"; import 'moment/locale/ru'; import numeral from "numeral"; import { SpinnerCircular } from "spinners-react"; import Link from "next/link"; export default class Comparison extends React.Component { constructor(props) { super(props); this.state = { date: null, loading: false, calculation: null, today: moment(), show_previous: false, mixed_index: 0, signatories_show_all: false, }; } componentDidMount() { if(this.props.signer === undefined) { if(this.props.signatories !== undefined && this.props.signatories !== null) { this._handle_onSigner(this.props.signatories[0].signatoryid); } } const { calculations, calculation_id, } = this.props; let calculation = null; for(let i in calculations) { if(calculations[i].addcontract_number === calculation_id) { calculation = calculations[i]; break; } } this.setState({ calculation : calculation }); } componentDidUpdate(prevProps, prevState) { if(prevProps.signatories === undefined || prevProps.signatories === null) { if(this.props.signer === undefined && this.props.signatories !== undefined && this.props.signatories !== null) { this._handle_onSigner(this.props.signatories[0].signatoryid); } } } _handle_onSigner = (signer_id) => { this.props.onSigner(signer_id); } _handle_onOptions = () => { if(this.props.editable) { this.props.onOptions(); } else { this.props.onBack(); } } _handle_onSignPaper = () => { this.props.onSign(0); } _handle_onSignEDO = () => { this.props.onSign(1); } _handle_onMixedPayment = (index) => { this.setState({ mixed_index: index }); } _handle_onShowPrevious = () => { this.setState({ show_previous: true }); } render() { const { calculation, mixed_index, today, show_previous, signatories_show_all } = this.state; const { number, signer, signatories, current, calculated } = this.props; return (

Выбранный(ые) варианты изменения графика Вернуться к параметрам изменения графика

{ calculation !== undefined && calculation !== null && calculation.fix_last_payment_available_comment !== null && (
) } { calculation !== undefined && calculation !== null && calculation.date_offset_type_comment !== null && (
) } { calculation !== undefined && calculation !== null && calculation.insurance_price_result_comment !== null && (

{ calculation.insurance_price_result_comment.label }: { numeral(calculation.insurance_price_result_comment.value).format(' ., ') } ₽

) } { calculation !== undefined && calculation !== null && calculation.number_paydate_comment !== null && (

{ calculation.number_paydate_comment.label }: { calculation.number_paydate_comment.value }

) } { calculation !== undefined && calculation !== null && calculation.period_new_comment !== null && (

{ calculation.period_new_comment.label }: { calculation.period_new_comment.value }

) } { calculation !== undefined && calculation !== null && calculation.sum_comment !== null && (

{ calculation.sum_comment.label } { numeral(calculation.sum_comment.value).format(' ., ') } ₽

) } {/*}

Дата платежа: 1 месяц (37 платежей)

Тип каникул: С увеличением срока

{*/}

Текущий график

Дата лизингового платежа
{/* className="sortable" */}
Лизинговый платеж с НДС ₽
{/* className="sortable" */}
Сумма досрочного выкупа
{/* className="sortable" */}
{ !show_previous && (
) } { current !== undefined && current !== null && current.map((payment, index) => { if(!show_previous && moment(payment.plandate) < today) { return null; } return (
{ payment.name }
{ moment(payment.plandate, "YYYY.MM.DD").format("DD.MM.YYYY") }
{ numeral(payment.sum).format(' ., ') } ₽
{ numeral(payment.early_repayment_sum).format(' ., ') } ₽
) }) }
{ calculation !== undefined && calculation !== null && (

Изменения с платежа №{ calculation.label }

) }
Дата лизингового платежа
{/* className="sortable" */}
Лизинговый платеж с НДС ₽
{/* className="sortable" */}
Сумма досрочного выкупа
{/* className="sortable" */}
{ !show_previous && (
) } { calculated !== undefined && calculated !== null && calculated.map((payment, index) => { if(!show_previous && moment(payment.plandate) < today) { return null; } return (
{ payment.name }
{ moment(payment.plandate, "YYYY.MM.DD").format("DD.MM.YYYY") }
{ numeral(payment.sum).format(' ., ') } ₽
{ numeral(payment.early_repayment_sum).format(' ., ') }  ₽
) }) }
{ !show_previous && ( ) } { current !== undefined && current !== null && calculated !== undefined && calculated !== null && current.map((payment, index) => { if(!show_previous && moment(payment.plandate) < today) { return null; } return (
this._handle_onMixedPayment(index) }>

Платеж №{ payment.name }

Текущий график { moment(payment.plandate, "YYYY.MM.DD").format("DD.MM.YYYY") }
На сумму { numeral(payment.sum).format(' ., ') } ₽
Сумма досрочного выкупа { numeral(payment.early_repayment_sum).format(' ., ') } ₽
Новый график { calculated[index] !== undefined ? moment(calculated[index].plandate, "YYYY.MM.DD").format("DD.MM.YYYY") : (`-`) }
На сумму { calculated[index] !== undefined ? (<>{ numeral(calculated[index].sum).format(' ., ') } ₽) : (`-`) }
Сумма досрочного выкупа { calculated[index] !== undefined ? (<>{ numeral(calculated[index].early_repayment_sum).format(' ., ') } ₽) : (`-`) }
) }) }

Подписанты { signatories.length > 3 && ( { this.setState({ signatories_show_all: true })}}>Все )}

{ signatories.slice(0, signatories_show_all ? signatories.length : 3).map((person, index) => (
this._handle_onSigner(person.signatoryid) }/>

{ `${ person.lastname } ${ person.firstname } ${ person.middlename }` }

{ person.jobtitle }

)) }
{/*} {*/}
); } }