export module Faisan {

    export type SimulationCommunaute = {
        puissance: number,
        autoconso: number,
        autoprod: number,
        fraisDivers: number,
        tarif: number,
        apport: number,
        interet: number,
        echeances: number,
        consoMoyenneFoyer: number,
        productible: number,
        degradation: number,
        inflation: number,
        ratio: number,
        enedis: number,
        tarifCRE: {
            limites: number[],
            prix: number[],
            inflation: number,
        },
        coutElec: number,
        inflationElec: number,
        maintenance: number,
        turpe: number,
        turpeInjection: number,
        provisionOnduleurs: number,
        assurance: number,
        divers: number,
        ratioDcAc: number,
        dureeAmortissement: number,
        tauxIS: number,
        tauxDSRA: number,
    }


    export function newSimulationCommunaute(): SimulationCommunaute {
        return {
            puissance: 0,
            autoconso: 90,
            autoprod: 10,
            fraisDivers: 1000,
            tarif: 0.19,
            apport: 15000,
            interet: 4.5,
            echeances: 114,
            consoMoyenneFoyer: 2500,
            productible: 1100,
            degradation: 0.6,
            inflation: 1,
            ratio: 1.1, // €/Wc
            enedis: 1500,
            tarifCRE: {
                limites: [0, 9, 100],
                prix: [0.1339, 0.0803, 0.1312],
                inflation: 1,
            },
            coutElec: 0.1887, // €
            inflationElec: 12, // %
            maintenance: 7, // €/kWc
            turpe: 16, // €/kWc
            turpeInjection: 0.0278,
            provisionOnduleurs: 0.10, // €/Wc
            assurance: 1, // % des travaux estimé entre 0.5% et 0.8%
            divers: 12,
            ratioDcAc: 0.8,
            dureeAmortissement: 10, // durée fiscale en années
            tauxIS: 25,
            tauxDSRA: 1.7, // %
        }
    }

    export type ListProjets = { ListProjets: null }
    export type ListProjetsResp = ({ id: string, name: string }[])

    export type CreateProjet = { CreateProjet: {
        name?: string,
        porteur?: string,
        tel?: string,
        adresse?: string,
        simulation?: SimulationCommunaute,
    }}
    export type CreateProjetResp = null | string

    export type SaveProjet = { SaveProjet: {
        id: string,
        name?: string,
        porteur?: string,
        tel?: string,
        adresse?: string,
        simulation?: SimulationCommunaute,
    }}

    export type GetProjet = { GetProjet: string }
    export type GetProjetResp = null | {
        id: string,
        name?: string,
        porteur?: string,
        tel?: string,
        adresse?: string,
        simulation?: SimulationCommunaute,
        img?: string,
    }

    export type DelProjet = { DelProjet: {
        id: string,
    }}

    export type Cmd =
        ListProjets
        | CreateProjet
        | SaveProjet
        | DelProjet
        | GetProjet
}