BUB-21 Creato importazione Estratti conto Excel di INGDirect
This commit is contained in:
@@ -266,30 +266,25 @@ class MovimentiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function importEC_ING()
|
||||
public function importEC_ING(Request $request)
|
||||
{
|
||||
$collection = (new FastExcel)->import('file1.xlsx', function ($line){
|
||||
if($line['Data valuta'])
|
||||
{
|
||||
return Movimenti::insEntrata([
|
||||
'mov_data'=>$this->dateFormat(0,$line['Data valuta']),
|
||||
'mov_fk_categoria'=>1,
|
||||
'mov_descrizione'=>$line['Descrizione operazione'],
|
||||
'mov_importo'=>trim(str_replace(',','.',(str_replace('.','',str_replace('€', '', $line['Importo']))))),
|
||||
'mov_fk_tags'=>1,
|
||||
'userid'=>1,
|
||||
]
|
||||
);
|
||||
}
|
||||
/*
|
||||
* "Data contabile" => "29/03/2023"
|
||||
"Data valuta" => "29/03/2023"
|
||||
"Causale" => "PAGAMENTI DIVERSI"
|
||||
"Descrizione operazione" => "Addebito SDD CORE Scad. 29/03/2023 Imp. 5.99 Creditor id. IT46ZZZ0000013970161009 ILIAD Id Mandato ILIAD-FR9HXO-1 Debitore FLAVIO BARACHINO E PAOLA BRENTARI Rif ▶"
|
||||
"Importo" => "€ -5,99"
|
||||
*/
|
||||
//dd($line);
|
||||
});
|
||||
if ($request->hasFile('filename'))
|
||||
{
|
||||
$filename=$request->file('filename')->store('EC');
|
||||
// dd($filename); Documenti/xyz.xls
|
||||
Movimenti::importEstrattoIng($filename);
|
||||
|
||||
return redirect(Route('movimenti'));
|
||||
}
|
||||
else {
|
||||
return 'Nessun File trovato';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function importFile()
|
||||
{
|
||||
return view('conti.import');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Rap2hpoutre\FastExcel\FastExcel;
|
||||
|
||||
class Movimenti extends Model
|
||||
{
|
||||
@@ -143,8 +144,37 @@ class Movimenti extends Model
|
||||
|
||||
public static function importEstrattoIng($filename)
|
||||
{
|
||||
|
||||
//$file = str_replace('/EC/','',$filename);
|
||||
$inputPath='/var/www/html/bubofamily/public/storage/'.$filename;
|
||||
$outputPath='/var/www/html/bubofamily/public/'.$filename;
|
||||
rename($inputPath,$outputPath);
|
||||
|
||||
$collection = (new FastExcel)->import($filename, function ($line){
|
||||
if($line['Data valuta'])
|
||||
{
|
||||
Movimenti::insEntrata([
|
||||
'mov_data'=>Movimenti::dateFormat(0,$line['Data valuta']),
|
||||
'mov_fk_categoria'=>1,
|
||||
'mov_descrizione'=>$line['Descrizione operazione'],
|
||||
'mov_importo'=>trim(str_replace(',','.',(str_replace('.','',str_replace('€', '', $line['Importo']))))),
|
||||
'mov_fk_tags'=>1,
|
||||
'userid'=>1,
|
||||
]);
|
||||
}
|
||||
|
||||
});
|
||||
//dd($outputPath);
|
||||
}
|
||||
|
||||
private static function dateFormat($type,$string)
|
||||
{
|
||||
if($type)
|
||||
{
|
||||
list($year,$month,$day) = explode('-',$string);
|
||||
return $day.'/'.$month.'/'.$year;
|
||||
} else {
|
||||
list($day,$month,$year) =explode('/',$string);
|
||||
return $year.'-'.$month.'-'.$day;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user