update 20.10.2025

This commit is contained in:
Kevin Adametz 2025-10-20 17:42:08 +02:00
parent 8c11130b5d
commit a939cd51ef
616 changed files with 84821 additions and 4121 deletions

View file

@ -12,7 +12,8 @@ use App\Models\PaymentMethod;
use Illuminate\Support\Facades\Hash;
use App\Http\Controllers\Api\KasController;
class UserRepository extends BaseRepository {
class UserRepository extends BaseRepository
{
public function __construct(User $model)
@ -23,28 +24,27 @@ class UserRepository extends BaseRepository {
public function update($data)
{
if($data['user_id'] === "new" || $data['user_id'] == 0){
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
$this->model = User::create([
'email' => $data['email'],
'password' => env('APP_KEY'),
]);
$this->model->payment_methods = PaymentMethod::getDefaultAsArray();
$this->model->save();
}
else{
} else {
$this->model = $this->getById($data['user_id']);
}
if(!$this->model->account_id){
if (!$this->model->account_id) {
$account = new UserAccount();
}else{
} else {
$account = $this->model->account;
}
$data['same_as_billing'] = !isset($data['same_as_billing']) ? 0 : 1;
$account->fill($data)->save();
if(!$this->model->account_id){
if (!$this->model->account_id) {
$this->model->account_id = $account->id;
$this->model->save();
}
@ -52,7 +52,8 @@ class UserRepository extends BaseRepository {
return true;
}
public function create($data){
public function create($data)
{
$this->model = User::create([
'email' => $data['email'],
@ -75,20 +76,21 @@ class UserRepository extends BaseRepository {
return $this->model;
}
public function deleteUser(User $user, $complete = false)
{
$active_sponsor = UserUtil::findNextActiveSponsor($user->id);
if($active_sponsor){
if ($active_sponsor) {
UserUtil::setNewSponsorToChilds($user->id, $active_sponsor->id);
UserUtil::setShoppingUserToNewMember($user->id, $active_sponsor->id);
}
UserUtil::deleteUser($user, $complete);
}
public function reverse_charge_validate($data, $user, $route){
public function reverse_charge_validate($data, $user, $route)
{
if(isset($data['action']) && $data['action'] == 'reverse_charge_validate'){
if (isset($data['action']) && $data['action'] == 'reverse_charge_validate') {
$rules = array(
'tax_identification_number' => 'required',
);
@ -97,29 +99,30 @@ class UserRepository extends BaseRepository {
$data = [
'user' => $user,
];
return redirect($route.'#user-vat-validation')->withErrors($validator)->withInput($data);
}
return redirect($route . '#user-vat-validation')->withErrors($validator)->withInput($data);
}
$ret = $this->reverse_charge_activate($data, $user);
if($ret === 'error'){
if ($ret === 'error') {
$validator = Validator::make($data, []);
$validator->errors()->add('tax_identification_number_validated', __('msg.VATID_could_not_be_validated'));
$data['reverse_charge'] = 0;
$data = [
'user' => $user,
];
return redirect($route.'#user-vat-validation')->withErrors($validator)->withInput($data);
return redirect($route . '#user-vat-validation')->withErrors($validator)->withInput($data);
}
if($ret === 'valid'){
if ($ret === 'valid') {
\Session()->flash('alert-success', __('msg.VATID_successfully_entered'));
return redirect($route.'#user-vat-validation')->withInput($data);
return redirect($route . '#user-vat-validation')->withInput($data);
return redirect($route.'#user-vat-validation')->withInput($data);
return redirect($route . '#user-vat-validation')->withInput($data);
}
}
}
public function reverse_charge_delete($data, $user, $route){
if(isset($data['action']) && $data['action'] == 'reverse_charge_delete'){
public function reverse_charge_delete($data, $user, $route)
{
if (isset($data['action']) && $data['action'] == 'reverse_charge_delete') {
$user->account->tax_identification_number = '';
$user->account->reverse_charge = 0;
$user->account->reverse_charge_code = null;
@ -127,11 +130,12 @@ class UserRepository extends BaseRepository {
$user->account->save();
$data['tax_identification_number'] = '';
\Session()->flash('alert-success', __('msg.reverse_charge_procedure_and_VATID_deleted'));
return redirect($route.'#user-vat-validation')->withInput($data);
return redirect($route . '#user-vat-validation')->withInput($data);
}
}
public function reverse_charge_activate($data, $user){
public function reverse_charge_activate($data, $user)
{
/* 'AT' => 'AT-Oesterreich',
'BE' => 'BE-Belgien',
@ -161,42 +165,42 @@ class UserRepository extends BaseRepository {
'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';
}
}
}
$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';
}
}
}