<commit_before>'use strict';

angular.module('ddsApp').factory('RessourceService', function() {
    return {
        spreadIndividuRessources: function(individu, months, ressource, dateDeValeur) {
            // injection des valeurs des 3 derniers mois
            var somme3DerniersMois = 0;
            [2, 1, 0].forEach(function(i) {
                var montant = ressource.montantsMensuels[i];
                somme3DerniersMois += montant;
                individu.ressources.push({
                    type: ressource.type.id,
                    periode: months[i].id,
                    montant: montant
                });

            });

            // injection du montant annuel étalé sur les 9 mois restants
            var montantMensuelEtale = (ressource.montantAnnuel - somme3DerniersMois) / 9;
            for (var j = 0; j < 9; j++) {
                var periode = moment(dateDeValeur).subtract(4 + j, 'months').format('YYYY-MM');
                individu.ressources.push({
                    type: ressource.type.id,
                    periode: periode,
                    montant: montantMensuelEtale
                });
                individu.ressourcesYearlyApproximation = individu.ressourcesYearlyApproximation || {};
                individu.ressourcesYearlyApproximation[ressource.type.id] = ressource.montantAnnuel;
            }

            if (! ressource.onGoing) {
                individu.interruptedRessources.push(ressource.type.id);
            }
        }
    };
});
<commit_msg>Introduce applyYearlyRessource function in ressourceServiceT<commit_after>'use strict';

angular.module('ddsApp').factory('RessourceService', function() {
    return {
        spreadIndividuRessources: function(individu, months, ressource, dateDeValeur) {
            // injection des valeurs des 3 derniers mois
            var somme3DerniersMois = 0;
            [2, 1, 0].forEach(function(i) {
                var montant = ressource.montantsMensuels[i];
                somme3DerniersMois += montant;
                individu.ressources.push({
                    type: ressource.type.id,
                    periode: months[i].id,
                    montant: montant
                });

            });

            // injection du montant annuel étalé sur les 9 mois restants
            var montantMensuelEtale = (ressource.montantAnnuel - somme3DerniersMois) / 9;
            for (var j = 0; j < 9; j++) {
                var periode = moment(dateDeValeur).subtract(4 + j, 'months').format('YYYY-MM');
                individu.ressources.push({
                    type: ressource.type.id,
                    periode: periode,
                    montant: montantMensuelEtale
                });
                individu.ressourcesYearlyApproximation = individu.ressourcesYearlyApproximation || {};
                individu.ressourcesYearlyApproximation[ressource.type.id] = ressource.montantAnnuel;
            }

            if (! ressource.onGoing) {
                individu.interruptedRessources.push(ressource.type.id);
            }
        },
        applyYearlyRessource: function(individu, ressource, dateDeValeur) {
            var montant = ressource.montantAnnuel;
            var periode = moment(dateDeValeur).subtract(1, 'year').format('YYYY');
            individu.ressources.push({
                type: ressource.type.id,
                periode: periode,
                montant: montant
            });

            // For  'professions libérales et entrepreneurs', we capture the 'CA' as well as the 'benefice'
            if (ressource.type.id == 'autresRevenusTns') {
                individu.ressources.push({
                    type: 'caAutresRevenusTns',
                    periode: periode,
                    montant: ressource.caAnnuel
                });
            }
        }
    };
});

{'fraction_non_alphanumeric': 0.09844559585492228, 'fraction_numerical': 0.006994818652849741, 'mean_word_length': 1.6609235010337697, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1062190', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1097, 'n_words': 198}