BUB-21 Creato importazione Estratti conto Excel di INGDirect
This commit is contained in:
parent
7ba29c486d
commit
702b37d9d3
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,9 @@
|
||||
/node_modules
|
||||
/public/hot
|
||||
/public/storage
|
||||
/public/EC
|
||||
/public/*.xlsx
|
||||
/public/*.xls
|
||||
/storage/*.key
|
||||
/vendor
|
||||
.env
|
||||
|
@ -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'])
|
||||
if ($request->hasFile('filename'))
|
||||
{
|
||||
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,
|
||||
]
|
||||
);
|
||||
$filename=$request->file('filename')->store('EC');
|
||||
// dd($filename); Documenti/xyz.xls
|
||||
Movimenti::importEstrattoIng($filename);
|
||||
|
||||
return redirect(Route('movimenti'));
|
||||
}
|
||||
/*
|
||||
* "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);
|
||||
});
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
,flavio,fblaptop,03.04.2023 16:36,file:///home/flavio/.config/libreoffice/4;
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -31,7 +31,10 @@
|
||||
<a href="{{ route('budget'); }}">Report Annuale Movimenti</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ route('export'); }}"><i class="fa fa-file-o fa-fw"></i>Esporta tutti i movimenti</a>
|
||||
<a href="{{ route('export'); }}"><i class="fa fa-download fa-fw"></i>Esporta tutti i movimenti</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ route('importING'); }}"><i class="fa fa-upload fa-fw"></i>Importa Estratto ING</a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- /.nav-second-level -->
|
||||
|
26
resources/views/conti/import.blade.php
Normal file
26
resources/views/conti/import.blade.php
Normal file
@ -0,0 +1,26 @@
|
||||
@extends('admin')
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header">Importazione Estratto conto ING</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<!-- Content here -->
|
||||
<div class="row">
|
||||
<div class="col-lg-10">
|
||||
<form action="" method="POST" enctype='multipart/form-data'>
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
<label for="file" class="form-label">File</label>
|
||||
<input type="file" class="form-control" id="file" name="filename">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
@ -66,8 +66,8 @@ Route::get('/', [MovimentiController::class,'dashboard']);
|
||||
Route::get('movimenti/report/movimentibycat', [MovimentiController::class,'listMovbyCat']);
|
||||
Route::get('movdocs', [DocumentiController::class,'fileForm'])->name('documenti');
|
||||
Route::post('movdocs', [DocumentiController::class,'storeFile']);
|
||||
Route::get('movimenti/import', [MovimentiController::class,'importEC_ING']);
|
||||
|
||||
Route::get('movimenti/import', [MovimentiController::class,'importFile'])->name('importING');
|
||||
Route::post('movimenti/import', [MovimentiController::class,'importEC_ING']);
|
||||
# Automobili
|
||||
Route::get('auto', [AutoController::class, 'index'])->name('auto_list');
|
||||
Route::get('auto/new', [AutoController::class, 'newAuto'])->name('auto_new');
|
||||
|
Loading…
Reference in New Issue
Block a user