From 248a3c39d4792f7b45a3362ec51a3e2f3a4feb5a Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 23 Apr 2015 15:36:12 +0000 Subject: [PATCH] =?UTF-8?q?RRG=20:=20Nouvelles=20r=C3=A8gles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1.2/scripts/clients/RrgSurv.php | 45 +++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/1.2/scripts/clients/RrgSurv.php b/1.2/scripts/clients/RrgSurv.php index 24dfad32..bd92c546 100644 --- a/1.2/scripts/clients/RrgSurv.php +++ b/1.2/scripts/clients/RrgSurv.php @@ -245,30 +245,47 @@ if ( count($resultItem) == 0 ) { $DateCreaEn = $tabIdentite['DateCreaEn']; } + // --- Correction pour l'envoi des dates + if ( !empty($DateCreaEn) ) { + if (substr($DateCreaEn, -2) * 1 == 0) { + $DateCreaEn = substr($DateCreaEn,0,6).'01'; + } + } + // --- Gestion des bilans $today = new Zend_Date(); if ( !empty($tabIdentite['bilanDate']) ) { $compare = $today->sub($tabIdentite['bilanDate'], 'yyMMdd'); - if ( $compare->toValue(Zend_Date::DAY) < 800 ) { + if ( $compare->toValue(Zend_Date::MONTH) < 37 ) { $BilanDateCloture = substr($tabIdentite['bilanDate'],6,2).substr($tabIdentite['bilanDate'],4,2).substr($tabIdentite['bilanDate'],0,4); $BilanCA = $tabIdentite['bilanFL']; } } // --- Estimation du CA bilan - if (empty($BilanCA)) { - //@todo : vérifier pour l'estimé - if ( !empty($tabIdentite['bilanAnnee']) ) { - $BilanDateCloture = '3112'.$tabIdentite['bilanAnnee']; - $BilanCA = $tabIdentite['bilanFLestime']; - } - } - - // --- Correction pour l'envoi des dates - if ( !empty($DateCreaEn) ) { - if (substr($DateCreaEn, -2) * 1 == 0) { - $DateCreaEn = substr($DateCreaEn,0,6).'01'; - } + if (empty($BilanCA) && !empty($tabIdentite['bilanAnnee'])) { + + $dateCreaRecente = new Zend_Date(); + $dateCreaRecente->subYear(2)->setMonth(1)->setDay(1); + $dateClotureEstime = new Zend_Date(); + $dateClotureEstime->setMonth(12)->setDay(31); + + // --- Condition RRG + if ( $tabIdentite['Eff'] > 0 + || substr($tabIdentite['FJ'],0,1) == 1 && $tabIdentite['Eff'] < 1 + || !empty($tabIdentite['NafEnt']) && strlen($tabIdentite['NafEnt']) == 5 && $tabIdentite['NafEnt'] != '0000Z' ) { + + // --- Création récente + if ( $dateCreaRecente->compareDate($DateCreaEn, 'yyMMdd') == 1 ) { + $BilanDateCloture = '3112'.date('Y'); + $BilanCA = $tabIdentite['bilanFLestime']; + } + // --- Date cloture estimée < Date de création + elseif ( $dateClotureEstime->compare($DateCreaEn, 'yyMMdd') == -1) { + $BilanDateCloture = '3112'.$tabIdentite['bilanAnnee']; + $BilanCA = $tabIdentite['bilanFLestime']; + } + } } // Récupération du libellé d'information de paiement