task #4898, Import CSV opération banquaire -> ING est correcte
This commit is contained in:
parent
3ff2af31cc
commit
a6b6559788
6 changed files with 47 additions and 22 deletions
|
|
@ -47,6 +47,21 @@ INSERT INTO format_csv_banque VALUES ('EUB', 'eub_be.inc.php');
|
|||
INSERT INTO format_csv_banque VALUES ('ING', 'ing_be.inc.php');
|
||||
INSERT INTO format_csv_banque VALUES ('CBC', 'cbc_be.inc.php');
|
||||
|
||||
CREATE TABLE import_tmp (
|
||||
code text,
|
||||
date_exec date,
|
||||
date_valeur date,
|
||||
montant text,
|
||||
devise text,
|
||||
compte_ordre text,
|
||||
detail text,
|
||||
num_compte text,
|
||||
poste_comptable text,
|
||||
ok boolean DEFAULT false,
|
||||
bq_account integer,
|
||||
jrn integer
|
||||
);
|
||||
|
||||
|
||||
|
||||
update version set val=9;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ if ( isset ($_GET["action"]) ) {
|
|||
if(isset($_FILES['fupload'])) {
|
||||
// load the table with the cvs' content
|
||||
echo '<DIV class="ccontent">';
|
||||
ImportCSV($cn,$_FILES['fupload']['tmp_name'],$_POST['import_bq'],$_POST['format_csv']);
|
||||
ImportCSV($cn,$_FILES['fupload']['tmp_name'],$_POST['import_bq'],$_POST['format_csv'],$_POST['import_jrn']);
|
||||
echo "</DIV>";
|
||||
} else {
|
||||
echo '<DIV class="ccontent">';
|
||||
|
|
|
|||
|
|
@ -23,14 +23,15 @@ if($code >= 100) $code = "0".$code;
|
|||
$code = $annee."-".$code;
|
||||
|
||||
|
||||
$Sql="insert into import_tmp (code
|
||||
$Sql="insert into import_tmp (code,
|
||||
date_exec ,
|
||||
date_valeur,
|
||||
montant,
|
||||
devise,
|
||||
detail,
|
||||
num_compte,
|
||||
poste_comptable,
|
||||
bq_account ,
|
||||
jrn,
|
||||
ok)
|
||||
values ('$code',
|
||||
'$date_exec',
|
||||
|
|
@ -39,6 +40,7 @@ values ('$code',
|
|||
'EUR',
|
||||
'".addslashes($detail)."',
|
||||
'$p_bq_account',
|
||||
$p_jrn,
|
||||
false)";
|
||||
$Res=ExecSql($p_cn,$Sql);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ if ( $row>1) {
|
|||
echo "Opération FORTIS ".$code." déj&eagrave; importée.<br/>";
|
||||
} else {
|
||||
// $Sql="insert into import_tmp values ('$code','$date_exec','$date_valeur','$montant','$devise','".addslashes($compte_ordre)."','".addslashes($detail)."','$num_compte','$poste_comptable')";
|
||||
$Sql="insert into import_tmp (code
|
||||
$Sql="insert into import_tmp (code ,
|
||||
date_exec ,
|
||||
date_valeur,
|
||||
montant,
|
||||
|
|
@ -54,7 +54,8 @@ if ( $row>1) {
|
|||
compte_ordre,
|
||||
detail,
|
||||
num_compte,
|
||||
poste_comptable,
|
||||
bq_account ,
|
||||
jrn
|
||||
ok)
|
||||
values ('$code',
|
||||
'$date_exec',
|
||||
|
|
@ -64,6 +65,7 @@ if ( $row>1) {
|
|||
'".addslashes($compte_ordre)."',
|
||||
'".addslashes($detail)."',
|
||||
'$p_bq_account',
|
||||
$p_jrn,
|
||||
false)";
|
||||
|
||||
$Res=ExecSql($p_cn,$Sql);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ include_once("user_common.php");
|
|||
* -
|
||||
* return:
|
||||
*/
|
||||
function ImportCSV($p_cn,$file,$p_bq_account,$p_format_csv)
|
||||
function ImportCSV($p_cn,$file,$p_bq_account,$p_format_csv,$p_jrn)
|
||||
{
|
||||
if(!$handle = fopen($file, "r")) {
|
||||
print 'could not open file. quitting';
|
||||
|
|
@ -48,7 +48,7 @@ function ImportCSV($p_cn,$file,$p_bq_account,$p_format_csv)
|
|||
while (($data = fgetcsv($handle, 2000, '#@!')) !== FALSE) {
|
||||
$num = count($data);
|
||||
for ($c=0; $c < $num; $c++) {
|
||||
// if $p_format_csv == fortis
|
||||
// include the right format for CSV --> given by the <form>
|
||||
include($p_format_csv);
|
||||
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ function UpdateCSV($p_cn, $code, $poste){
|
|||
}
|
||||
|
||||
function VerifImport($p_cn){
|
||||
$sql = "select * from import_tmp where poste_comptable=''";
|
||||
$sql = "select * from import_tmp where poste_comptable='' or poste_comptable is null";
|
||||
$Res=ExecSql($p_cn,$sql);
|
||||
$Num=pg_NumRows($Res);
|
||||
echo $Num." opérations à complèter.<br/><br/>";
|
||||
|
|
@ -95,7 +95,8 @@ function TransferCSV($p_cn, $periode){
|
|||
$val = pg_fetch_array($Res);
|
||||
$start = $val['p_start']; $end = $val['p_end'];
|
||||
|
||||
$sql = "select * from import_tmp where poste_comptable <> '' AND ok <> TRUE AND date_exec BETWEEN '".$start."' and '".$end."'";
|
||||
$sql = "select * from import_tmp where poste_comptable is not null and poste_comptable <> ''
|
||||
AND ok <> TRUE AND date_exec BETWEEN '".$start."' and '".$end."'";
|
||||
$Res=ExecSql($p_cn,$sql);
|
||||
//echo "boucle: ".sizeof($Res)."<br/>";
|
||||
//while($val = pg_fetch_array($Res)){
|
||||
|
|
@ -104,7 +105,9 @@ function TransferCSV($p_cn, $periode){
|
|||
for ($i = 0;$i < $Max;$i++) {
|
||||
$val=pg_fetch_array($Res,$i);
|
||||
|
||||
$code=$val['code']; $date_exec=$val['date_exec']; $montant=$val['montant']; $num_compte=$val['num_compte']; $poste_comptable=$val['poste_comptable'];
|
||||
$code=$val['code']; $date_exec=$val['date_exec']; $montant=$val['montant']; $num_compte=$val['num_compte'];
|
||||
$poste_comptable=$val['poste_comptable'];$bq_account=$val['bq_account'];
|
||||
$jrn=$val['jrn'];
|
||||
|
||||
list($annee, $mois, $jour) = explode("-", $date_exec);
|
||||
$date_exec = $jour.".".$mois.".".$annee;
|
||||
|
|
@ -120,7 +123,6 @@ function TransferCSV($p_cn, $periode){
|
|||
} else {
|
||||
|
||||
// Finances
|
||||
$p_jrn = 1;
|
||||
|
||||
//$seq = GetNextId($p_cn,'j_grpt')+1;
|
||||
$seq=NextSequence($p_cn,'s_grpt');
|
||||
|
|
@ -132,17 +134,17 @@ function TransferCSV($p_cn, $periode){
|
|||
// if($num_compte == '001-3983978-70') $r=InsertJrnx($p_cn,"d",$p_user,$p_jrn,'55000001',$date_exec,$montant,$seq,$periode);
|
||||
// elseif ($num_compte == '360-1062770-44' ) $r=InsertJrnx($p_cn,"d",$p_user,$p_jrn,'55000002',$date_exec,$montant,$seq,$periode);
|
||||
// elseif ($num_compte == '671-9032279-01' ) $r=InsertJrnx($p_cn,"d",$p_user,$p_jrn,'55000003',$date_exec,$montant,$seq,$periode);
|
||||
$r=InsertJrnx($p_cn,"d",$p_user,$p_jrn,$poste_comptable,$date_exec,$montant,$seq,$periode);
|
||||
$r=InsertJrnx($p_cn,"d",$p_user,$jrn,$bq_account,$date_exec,$montant,$seq,$periode);
|
||||
if ( $r == false) { $Rollback($p_cn);exit("error __FILE__ __LINE__");}
|
||||
|
||||
$r=InsertJrnx($p_cn,"c",$p_user,$p_jrn,$poste_comptable,$date_exec,$montant,$seq,$periode);
|
||||
$r=InsertJrnx($p_cn,"c",$p_user,$jrn,$poste_comptable,$date_exec,$montant,$seq,$periode);
|
||||
if ( $r == false) { $Rollback($p_cn);exit("error __FILE__ __LINE__");}
|
||||
|
||||
$r=InsertJrn($p_cn,$date_exec,NULL,$p_jrn,$num_compte." ".$code,$montant,$seq,$periode);
|
||||
$r=InsertJrn($p_cn,$date_exec,NULL,$jrn,$num_compte." ".$code,$montant,$seq,$periode);
|
||||
if ( $r == false ) { Rollback($p_cn); exit(" Error __FILE__ __LINE__");}
|
||||
|
||||
//$sql = "insert into jrn (jr_def_id,jr_montant,jr_comment,jr_date,jr_grpt_id,jr_tech_per) values ( ".$p_jrn.", abs(".round($montant,2)."), '".$num_compte." ".$code."','".$date_valeur."','".$seq."','".$periode."')";
|
||||
SetInternalCode($p_cn,$seq,$p_jrn);
|
||||
SetInternalCode($p_cn,$seq,$jrn);
|
||||
|
||||
Commit($p_cn);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ if ( $row > 1 ) {
|
|||
# Bug CSV ING : espace après la date
|
||||
$date_exec = str_replace(" ", "", $date_exec);
|
||||
$date_valeur = str_replace(" ", "", $date_valeur);
|
||||
|
||||
$date_exec = str_replace("\"", "", $date_exec);
|
||||
$date_valeur = str_replace("\"", "", $date_valeur);
|
||||
$montant = str_replace("\"", "", $montant);
|
||||
if ((ereg ("([0-9]{3})-([0-9]{7})-([0-9]{2})", $num_compte, $regs))){
|
||||
$num_compte = $regs[0];
|
||||
}
|
||||
|
|
@ -56,27 +58,29 @@ if ( $row > 1 ) {
|
|||
if($Num > 0) {
|
||||
echo "Opération FORTIS ".$code." déj&eagrave; importée.<br/>";
|
||||
} else {
|
||||
//echo $code." ".$date_exec." ".$date_valeur." ".$montant." ".$devise." ".$compte_ordre." detail ".$num_compte." <b>".$poste_comptable."</b><br/>";
|
||||
echo $code." ".$date_exec." ".$date_valeur." ".$montant." ".$devise." ".$compte_ordre." detail ".$num_compte." <b>".$poste_comptable."</b><br/>";
|
||||
//$Sql="insert into import_tmp values ('$code','$date_exec','$date_valeur','$montant','$devise','".addslashes($compte_ordre)."','".addslashes($detail)."','$num_compte','$poste_comptable')";
|
||||
$Sql="insert into import_tmp (code
|
||||
$Sql="insert into import_tmp (code,
|
||||
date_exec ,
|
||||
date_valeur,
|
||||
montant,
|
||||
devise,
|
||||
compte_ordre,
|
||||
detail,
|
||||
num_compte,
|
||||
poste_comptable,
|
||||
bq_account ,
|
||||
jrn,
|
||||
ok)
|
||||
values ('$code',
|
||||
'$date_exec',
|
||||
'$date_exec',
|
||||
'$montant',
|
||||
$montant,
|
||||
'$devise',
|
||||
'".addslashes($compte_ordre)."',
|
||||
'".addslashes($detail)."',
|
||||
'".addslashes($detail).$num_compte." ',
|
||||
'$p_bq_account',
|
||||
$p_jrn,
|
||||
false)";
|
||||
echo $sql;
|
||||
$Res=ExecSql($p_cn,$Sql);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue