06 2022
This commit is contained in:
parent
9b0b5feb7e
commit
7a040c3e19
106 changed files with 4074 additions and 1349 deletions
|
|
@ -2,13 +2,14 @@
|
|||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Libraries\InvoicePDF;
|
||||
use PDF;
|
||||
use Storage;
|
||||
use App\Services\Invoice;
|
||||
use App\Models\UserInvoice;
|
||||
use App\Libraries\InvoicePDF;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Services\MyPDFMerger;
|
||||
use App\Services\UserService;
|
||||
use App\Models\UserSalesVolume;
|
||||
|
||||
class InvoiceRepository extends BaseRepository {
|
||||
|
|
@ -32,7 +33,10 @@ class InvoiceRepository extends BaseRepository {
|
|||
{
|
||||
//need invoice $data
|
||||
$number = Invoice::getInvoiceNumber();
|
||||
$this->invoice_date = isset($request['invoice_date']) ? $request['invoice_date'] : $this->model->created_at->format("d.m.Y");
|
||||
if($payt = $this->model->getLastShoppingPaymentTransaction()){
|
||||
$invoice_date = $payt->created_at->format("d.m.Y");
|
||||
}
|
||||
$this->invoice_date = isset($request['invoice_date']) ? $request['invoice_date'] : $invoice_date;
|
||||
$invoice_send_mail = isset($request['invoice_send_mail']) ? false : true;
|
||||
$this->invoice_number = Invoice::createInvoiceNumber($number, $this->invoice_date);
|
||||
$this->dir = Invoice::getInvoiceStorageDir($this->invoice_date);
|
||||
|
|
@ -100,6 +104,7 @@ class InvoiceRepository extends BaseRepository {
|
|||
}
|
||||
|
||||
private function makePDF(){
|
||||
|
||||
$data = [
|
||||
'shopping_order' => $this->model,
|
||||
'invoice_date' => $this->invoice_date,
|
||||
|
|
@ -107,6 +112,11 @@ class InvoiceRepository extends BaseRepository {
|
|||
'user_sales_volume' => $this->user_sales_volume,
|
||||
];
|
||||
|
||||
if($this->model->auth_user_id){
|
||||
UserService::checkUserTaxShippingCountry($this->model->auth_user, $this->model->country_id);
|
||||
$data = array_merge($data, UserService::getYardInfo());
|
||||
}
|
||||
|
||||
if(!Storage::disk('public')->exists( $this->dir )){
|
||||
Storage::disk('public')->makeDirectory($this->dir); //creates directory
|
||||
}
|
||||
|
|
@ -144,8 +154,10 @@ class InvoiceRepository extends BaseRepository {
|
|||
*/
|
||||
$status = UserSalesVolume::getStatusByOrder($this->model);
|
||||
$user_id = $this->model->auth_user_id ? $this->model->auth_user_id : $this->model->member_id;
|
||||
//akuteller tag / Monat.
|
||||
$month = date('m');
|
||||
$year = date('Y');
|
||||
$date = date('d.m.Y');
|
||||
|
||||
if($status === 3){ //shop bestellung User pending
|
||||
$user_id = $this->model->auth_user_id ? $this->model->auth_user_id : $this->model->member_id;
|
||||
|
|
@ -175,7 +187,7 @@ class InvoiceRepository extends BaseRepository {
|
|||
'shopping_order_id' => $this->model->id,
|
||||
'month' => $month,
|
||||
'year' => $year,
|
||||
'date' => date('d.m.Y'),
|
||||
'date' => $date,
|
||||
'points' => $this->model->points,
|
||||
'month_points' => $month_points,
|
||||
'month_shop_points' => $month_shop_points,
|
||||
|
|
|
|||
|
|
@ -2,12 +2,14 @@
|
|||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\UserAccount;
|
||||
use App\User;
|
||||
use App\Models\UserAccount;
|
||||
use App\Models\PaymentMethod;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
|
||||
use App\Http\Controllers\Api\KasController;
|
||||
use Util;
|
||||
use Validator;
|
||||
use Request;
|
||||
|
||||
class UserRepository extends BaseRepository {
|
||||
|
||||
|
|
@ -17,8 +19,6 @@ class UserRepository extends BaseRepository {
|
|||
$this->model = $model;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function update($data)
|
||||
{
|
||||
|
||||
|
|
@ -74,81 +74,28 @@ class UserRepository extends BaseRepository {
|
|||
|
||||
return $this->model;
|
||||
}
|
||||
public function reverse_charge_activate($data, $user){
|
||||
|
||||
/* 'AT' => 'AT-Oesterreich',
|
||||
'BE' => 'BE-Belgien',
|
||||
'BG' => 'BG-Bulgarien',
|
||||
'CY' => 'CY-Zypern',
|
||||
'CZ' => 'CZ-Tschechische Republik',
|
||||
'DE' => 'DE-Deutschland',
|
||||
'DK' => 'DK-Dänemark',
|
||||
'EE' => 'EE-Estland',
|
||||
'EL' => 'EL-Griechenland',
|
||||
'ES' => 'ES-Spanien',
|
||||
'FI' => 'FI-Finnland',
|
||||
'FR' => 'FR-Frankreich ',
|
||||
'HR' => 'HR-Kroatien ',
|
||||
'HU' => 'HU-Ungarn',
|
||||
'IE' => 'IE-Irland',
|
||||
'IT' => 'IT-Italien',
|
||||
'LT' => 'LT-Litauen',
|
||||
'LU' => 'LU-Luxemburg',
|
||||
'LV' => 'LV-Lettland',
|
||||
'MT' => 'MT-Malta',
|
||||
'NL' => 'NL-Niederlande',
|
||||
'PL' => 'PL-Polen',
|
||||
'PT' => 'PT-Portugal',
|
||||
'RO' => 'RO-Rumänien',
|
||||
'SE' => 'SE-Schweden',
|
||||
'SI' => 'SI-Slowenien',
|
||||
'SK' => 'SK-Slowakei',
|
||||
'XI' => 'XI-Nordirland', */
|
||||
$countryCode = 'DE';
|
||||
|
||||
if($user->account->country_id){
|
||||
$countryCode = $user->account->country->code;
|
||||
}
|
||||
|
||||
$vatid = str_replace(array(' ', '.', '-', ',', ', '), '', trim($data['tax_identification_number']));
|
||||
$cc = substr($vatid, 0, 2);
|
||||
$vatNo = substr($vatid, 2);
|
||||
|
||||
$options = [
|
||||
'cache_wsdl' => WSDL_CACHE_NONE,
|
||||
'trace' => 1,
|
||||
'stream_context' => stream_context_create(
|
||||
[
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'allow_self_signed' => true
|
||||
]
|
||||
]
|
||||
)
|
||||
];
|
||||
|
||||
$client = new \SoapClient("https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl", $options);
|
||||
$result = $client->checkVat(['countryCode' => $countryCode, 'vatNumber' => $vatNo]);
|
||||
|
||||
if($result->valid == true) {
|
||||
$user->account->tax_identification_number = $data['tax_identification_number'];
|
||||
$user->account->reverse_charge = 1;
|
||||
$user->account->reverse_charge_code = $countryCode;
|
||||
$user->account->reverse_charge_valid = now();
|
||||
$user->account->save();
|
||||
return 'valid';
|
||||
} else {
|
||||
return 'error';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function deleteUser(User $user)
|
||||
{
|
||||
if($user->account){
|
||||
$user->account->delete();
|
||||
}
|
||||
if($user->shop){
|
||||
$subdomain_name = $user->shop->slug.'.mivita.care';
|
||||
$user->shop->name = "delete".$user->shop->id;
|
||||
$user->shop->slug = "delete".$user->shop->id;
|
||||
$user->shop->save();
|
||||
$user->shop->delete();
|
||||
//isset KAS - delete Subdomain
|
||||
if(!Util::isTestSystem()){
|
||||
$kas = new KasController();
|
||||
$pra = array(
|
||||
'subdomain_name' => $subdomain_name,
|
||||
);
|
||||
$kas->action('delete_subdomain', $pra);
|
||||
}
|
||||
|
||||
}
|
||||
$user->email = "delete".time();
|
||||
$user->password = "delete".time();
|
||||
$user->confirmed = 0;
|
||||
|
|
@ -167,5 +114,114 @@ class UserRepository extends BaseRepository {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function reverse_charge_validate($data, $user){
|
||||
if(isset($data['reverse_charge_validate'])){
|
||||
|
||||
$rules = array(
|
||||
'tax_identification_number' => 'required',
|
||||
'reverse_charge' => 'required',
|
||||
);
|
||||
$validator = Validator::make($data, $rules);
|
||||
if ($validator->fails()) {
|
||||
$data = [
|
||||
'user' => $user,
|
||||
];
|
||||
return view('user.edit', $data)->withErrors($validator);
|
||||
}
|
||||
$ret = $this->reverse_charge_activate($data, $user);
|
||||
if($ret === 'error'){
|
||||
$validator = Validator::make($data, []);
|
||||
$validator->errors()->add('tax_identification_number', __('Die UST-ID konnte nicht validiert werden, Eingabe bitte prüfen.'));
|
||||
$data['reverse_charge'] = 0;
|
||||
return redirect(route('user_edit'))->withErrors($validator)->withInput($data);
|
||||
}
|
||||
if($ret === 'valid'){
|
||||
\Session()->flash('alert-success', 'UST-ID erfolgreich eingetragen.');
|
||||
return redirect('/user/edit');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function reverse_charge_delete($data, $user){
|
||||
if(isset($data['reverse_charge_delete'])){
|
||||
$user->account->tax_identification_number = '';
|
||||
$user->account->reverse_charge = 0;
|
||||
$user->account->reverse_charge_code = null;
|
||||
$user->account->reverse_charge_valid = null;
|
||||
$user->account->save();
|
||||
\Session()->flash('alert-success', 'Reverse Charge Verfahren und UST-ID gelöscht.');
|
||||
return redirect('/user/edit');
|
||||
}
|
||||
}
|
||||
|
||||
public function reverse_charge_activate($data, $user){
|
||||
|
||||
/* 'AT' => 'AT-Oesterreich',
|
||||
'BE' => 'BE-Belgien',
|
||||
'BG' => 'BG-Bulgarien',
|
||||
'CY' => 'CY-Zypern',
|
||||
'CZ' => 'CZ-Tschechische Republik',
|
||||
'DE' => 'DE-Deutschland',
|
||||
'DK' => 'DK-Dänemark',
|
||||
'EE' => 'EE-Estland',
|
||||
'EL' => 'EL-Griechenland',
|
||||
'ES' => 'ES-Spanien',
|
||||
'FI' => 'FI-Finnland',
|
||||
'FR' => 'FR-Frankreich ',
|
||||
'HR' => 'HR-Kroatien ',
|
||||
'HU' => 'HU-Ungarn',
|
||||
'IE' => 'IE-Irland',
|
||||
'IT' => 'IT-Italien',
|
||||
'LT' => 'LT-Litauen',
|
||||
'LU' => 'LU-Luxemburg',
|
||||
'LV' => 'LV-Lettland',
|
||||
'MT' => 'MT-Malta',
|
||||
'NL' => 'NL-Niederlande',
|
||||
'PL' => 'PL-Polen',
|
||||
'PT' => 'PT-Portugal',
|
||||
'RO' => 'RO-Rumänien',
|
||||
'SE' => 'SE-Schweden',
|
||||
'SI' => 'SI-Slowenien',
|
||||
'SK' => 'SK-Slowakei',
|
||||
'XI' => 'XI-Nordirland', */
|
||||
$countryCode = 'DE';
|
||||
|
||||
if($user->account->country_id){
|
||||
$countryCode = $user->account->country->code;
|
||||
}
|
||||
|
||||
$vatid = str_replace(array(' ', '.', '-', ',', ', '), '', trim($data['tax_identification_number']));
|
||||
$cc = substr($vatid, 0, 2);
|
||||
$vatNo = substr($vatid, 2);
|
||||
|
||||
$options = [
|
||||
'cache_wsdl' => WSDL_CACHE_NONE,
|
||||
'trace' => 1,
|
||||
'stream_context' => stream_context_create(
|
||||
[
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'allow_self_signed' => true
|
||||
]
|
||||
]
|
||||
)
|
||||
];
|
||||
|
||||
$client = new \SoapClient("https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl", $options);
|
||||
$result = $client->checkVat(['countryCode' => $countryCode, 'vatNumber' => $vatNo]);
|
||||
|
||||
if($result->valid == true) {
|
||||
$user->account->tax_identification_number = $data['tax_identification_number'];
|
||||
$user->account->reverse_charge = 1;
|
||||
$user->account->reverse_charge_code = $countryCode;
|
||||
$user->account->reverse_charge_valid = now();
|
||||
$user->account->save();
|
||||
return 'valid';
|
||||
} else {
|
||||
return 'error';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue