update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
246
dev/app-bak/Http/Controllers/PaymentTaxAdvisorController.php
Normal file
246
dev/app-bak/Http/Controllers/PaymentTaxAdvisorController.php
Normal file
|
|
@ -0,0 +1,246 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use Auth;
|
||||
use Request;
|
||||
use ZipArchive;
|
||||
use App\Models\UserInvoice;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Exports\UserTeamExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PaymentTaxAdvisorController extends Controller
|
||||
{
|
||||
|
||||
private $BUKey = [
|
||||
1 => 8120, //für Kunden aus der Schweiz
|
||||
11 => 8125, //Steuerfreie EU-Lieferungen
|
||||
2 => 8300, //Erlöse mit 7 % meistens für Käufe mit Aloe Vera
|
||||
3 => 8400, //Regulär mit 19 %
|
||||
];
|
||||
|
||||
|
||||
private $accountKey = [
|
||||
'A'=>'10000',
|
||||
'B'=>'10100',
|
||||
'C'=>'10200',
|
||||
'D'=>'10300',
|
||||
'E'=>'10400',
|
||||
'F'=>'10500',
|
||||
'G'=>'10600',
|
||||
'H'=>'10700',
|
||||
'I'=>'10800',
|
||||
'J'=>'10900',
|
||||
'K'=>'11000',
|
||||
'L'=>'11100',
|
||||
'M'=>'11200',
|
||||
'N'=>'11300',
|
||||
'O'=>'11400',
|
||||
'P'=>'11500',
|
||||
'Q'=>'11600',
|
||||
'R'=>'11700',
|
||||
'S'=>'11800',
|
||||
'SCH'=>'11900',
|
||||
'T'=>'12000',
|
||||
'U'=>'12100',
|
||||
'V'=>'12200',
|
||||
'W'=>'12300',
|
||||
'X'=>'12400',
|
||||
'Y'=>'12500',
|
||||
'Z'=>'12600'
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->setFilterVars();
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
'filter_years' => HTMLHelper::getYearRange(2023),
|
||||
];
|
||||
return view('admin.payment.taxadvisor', $data);
|
||||
}
|
||||
|
||||
|
||||
public function createZip($filesToZip)
|
||||
{
|
||||
$zip = new ZipArchive;
|
||||
$zipFileName = 'mysample.zip';
|
||||
$path = storage_path().'/app/public/zip/';
|
||||
if ($zip->open($path.$zipFileName, ZipArchive::CREATE) === TRUE) {
|
||||
foreach ($filesToZip as $file) {
|
||||
$zip->addFile($file, basename($file));
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
return response()->download($path.$zipFileName)->deleteFileAfterSend(true);
|
||||
} else {
|
||||
return "Failed to create the zip file.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function download(){
|
||||
|
||||
|
||||
$query = $this->initSearch();
|
||||
|
||||
$files = [];
|
||||
|
||||
$user_invoices = $query->get();
|
||||
foreach ($user_invoices as $user_invoice) {
|
||||
$filename = $user_invoice->filename;
|
||||
$disk = $user_invoice->disk;
|
||||
$path = $user_invoice->getDownloadPath();
|
||||
if (Storage::disk($disk)->exists($path)) {
|
||||
$file = Storage::disk($disk)->get($path);
|
||||
$pdf_path = storage_path().'/app/public/'.$path;
|
||||
$files[] = $pdf_path;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->createZip($files);
|
||||
|
||||
dd("asd");
|
||||
|
||||
|
||||
|
||||
if(Request::get('action') === "export"){
|
||||
$objects = $this->initSearch(false);
|
||||
$columns = [];
|
||||
$filename = "mivita-absatzmengen-".session('payment_taxadvisor_filter_month').'_'.session('payment_taxadvisor_filter_year')."-export";
|
||||
$headers = array(
|
||||
'#',
|
||||
'Produkt',
|
||||
'Artikelnummer',
|
||||
'Menge',
|
||||
|
||||
);
|
||||
if($objects){
|
||||
foreach ($objects as $key => $obj){
|
||||
$columns[] = array(
|
||||
'id' => $key,
|
||||
'name' => $obj['name'],
|
||||
'number' => $obj['number'],
|
||||
'value' => $obj['value'],
|
||||
);
|
||||
}
|
||||
}
|
||||
return Excel::download(new UserTeamExport($columns, $headers), $filename.'.xls');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function setFilterVars(){
|
||||
|
||||
if(!session('payment_taxadvisor_filter_month')){
|
||||
session(['payment_taxadvisor_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('payment_taxadvisor_filter_year')){
|
||||
session(['payment_taxadvisor_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
|
||||
if(Request::get('payment_taxadvisor_filter_month')){
|
||||
session(['payment_taxadvisor_filter_month' => Request::get('payment_taxadvisor_filter_month')]);
|
||||
}
|
||||
if(Request::get('payment_taxadvisor_filter_year')){
|
||||
session(['payment_taxadvisor_filter_year' => Request::get('payment_taxadvisor_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function initSearch()
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$query = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*')
|
||||
->where('user_invoices.month', '=', Request::get('payment_taxadvisor_filter_month'))
|
||||
->where('user_invoices.year', '=', Request::get('payment_taxadvisor_filter_year'));
|
||||
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$query = $this->initSearch();
|
||||
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserInvoice $UserInvoice) {
|
||||
return $UserInvoice->id;
|
||||
|
||||
})
|
||||
|
||||
->addColumn('turnover', function (UserInvoice $UserInvoice) {
|
||||
return '<span class="no-line-break">'.$UserInvoice->shopping_order->getFormattedTotalShipping()." €</span>";
|
||||
})
|
||||
->addColumn('debit_credit_indicator', function (UserInvoice $UserInvoice) {
|
||||
return "H";
|
||||
})
|
||||
->addColumn('account', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order && $UserInvoice->shopping_order->shopping_user){
|
||||
$key = strtoupper(substr($UserInvoice->shopping_order->shopping_user->billing_lastname, 0, 1));
|
||||
if($key === "S"){
|
||||
if(strtoupper(substr($UserInvoice->shopping_order->shopping_user->billing_lastname, 0, 3)) === "SCH"){
|
||||
return $this->accountKey['SCH'];
|
||||
}
|
||||
}
|
||||
return isset($this->accountKey[$key]) ? $this->accountKey[$key] : $key;
|
||||
}
|
||||
return "-";
|
||||
})
|
||||
->addColumn('contra_account', function (UserInvoice $UserInvoice) {
|
||||
return "-";
|
||||
})
|
||||
->addColumn('bu_key', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order){
|
||||
return $UserInvoice->shopping_order->country_id;
|
||||
}
|
||||
})
|
||||
->addColumn('voucher_date', function (UserInvoice $UserInvoice) {
|
||||
// 101 -> für 01 Januar
|
||||
return $UserInvoice->month."01";
|
||||
})
|
||||
->addColumn('document_field_1', function (UserInvoice $UserInvoice) {
|
||||
//Rechnungsnummer
|
||||
return $UserInvoice->full_number;
|
||||
})
|
||||
->addColumn('posting_text', function (UserInvoice $UserInvoice) {
|
||||
//Buchungstext – hier wäre es toll wenn der Name des Kunden steht.
|
||||
if($UserInvoice->shopping_order && $UserInvoice->shopping_order->shopping_user){
|
||||
return $UserInvoice->shopping_order->shopping_user->billing_firstname." ".$UserInvoice->shopping_order->shopping_user->billing_lastname;
|
||||
}
|
||||
return "-";
|
||||
})
|
||||
->addColumn('invoice', function (UserInvoice $UserInvoice) {
|
||||
$ret = "";
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
return $ret;
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('invoice_number', 'invoice_number $1')
|
||||
->orderColumn('turnover', 'turnover $1')
|
||||
->orderColumn('shipped', 'shipped $1')
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
->rawColumns(['id', 'shipping_order', 'turnover', 'total_shipping', 'status', 'txaction', 'invoice'])
|
||||
->make(true);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue