export const helperMonths: {
	month: string;
	index: number;
}[] = [
	{
		month: 'January',
		index: 0
	},
	{
		month: 'February',
		index: 1
	},
	{
		month: 'March',
		index: 2
	},
	{
		month: 'April',
		index: 3
	},
	{
		month: 'May',
		index: 4
	},
	{
		month: 'June',
		index: 5
	},
	{
		month: 'July',
		index: 6
	},
	{
		month: 'August',
		index: 7
	},
	{
		month: 'September',
		index: 8
	},
	{
		month: 'October',
		index: 9
	},
	{
		month: 'November',
		index: 10
	},
	{
		month: 'December',
		index: 11
	}
];

export interface IndustryModel {
	name: string;
	zeroToOne: number;
	twoToFive: number;
	sixToTen: number;
	id: number;
}

// TODO THis is the small table with values for EBITDA for individual industry
export const ebitdaMapValues: IndustryModel[] = [
	{
		name: 'Manufacturing',
		zeroToOne: 4,
		twoToFive: 5,
		sixToTen: 6,
		id: 0
	},
	{
		name: 'Construction & Engineering',
		zeroToOne: 3.5,
		twoToFive: 4.5,
		sixToTen: 5.5,
		id: 1
	},
	{
		name: 'Construction Goods & Services',
		zeroToOne: 4,
		twoToFive: 5.5,
		sixToTen: 5.8,
		id: 2
	},
	{
		name: 'Wholesale & Distribution',
		zeroToOne: 4.5,
		twoToFive: 6,
		sixToTen: 6,
		id: 3
	},
	{
		name: 'Business Services',
		zeroToOne: 4,
		twoToFive: 5.3,
		sixToTen: 7,
		id: 4
	},
	{
		name: 'Basic Materials & Energy',
		zeroToOne: 3.3,
		twoToFive: 4,
		sixToTen: 5,
		id: 5
	},
	{
		name: 'Healthcare & Biotech',
		zeroToOne: 5.5,
		twoToFive: 6,
		sixToTen: 7,
		id: 6
	},
	{
		name: 'IT',
		zeroToOne: 6.5,
		twoToFive: 8,
		sixToTen: 8,
		id: 7
	},
	{
		name: 'Financial Services',
		zeroToOne: 5.5,
		twoToFive: 6.5,
		sixToTen: 7,
		id: 8
	},
	{
		name: 'Media & Entertainment',
		zeroToOne: 1,
		twoToFive: 5,
		sixToTen: 7.5,
		id: 9
	},
	{
		name: 'Average',
		zeroToOne: 4.5,
		twoToFive: 5.6,
		sixToTen: 6.5,
		id: 10
	}
];

export interface NetFlowHandlerInterface {
	cashAtBank: number;
	bankLoanCurrent: number;
	bankLoanNonCurrent: number;
	cashAtBank2: number;
	bankLoanCurrent2: number;
	bankLoanNonCurrent2: number;
}

function netCashFlowHandler(props: NetFlowHandlerInterface): number {
	const firstSum: number = -(props.cashAtBank - (props.bankLoanCurrent + props.bankLoanNonCurrent));
	const secondSum: number = -(
		props.cashAtBank2 -
		(props.bankLoanCurrent2 + props.bankLoanNonCurrent2)
	);
	// Excel approach:
	return firstSum - secondSum;
	// Alex approach:
	// const largerNumber: number = Math.max(firstSum, secondSum);
	// const smallerNumber: number = Math.min(firstSum, secondSum);
	// return largerNumber - smallerNumber;
}

interface PriceIncreaseCashFlowInterface {
	priceIncreaseEbit: number;
	lastFinancialTradeDebtors: number;
	lastFinancialRevenue: number;
}

export function priceIncreaseCashFlowHandler(props: PriceIncreaseCashFlowInterface): number {
	const result: number =
		props.priceIncreaseEbit -
		(((props.lastFinancialTradeDebtors / props.lastFinancialRevenue) * 365) / 365) *
			props.priceIncreaseEbit;
	localStorage.setItem('priceIncreaseCashFlow', JSON.stringify(result));
	return result;
}

export default netCashFlowHandler;
