From 4c4d64f30fa6da0dba41c9e7a72967dfbf7a9f16 Mon Sep 17 00:00:00 2001 From: 1day2die Date: Thu, 4 Nov 2021 21:02:40 +0100 Subject: [PATCH 01/19] Migration --- .../2021_11_04_195244_tax_in_config.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 database/migrations/2021_11_04_195244_tax_in_config.php diff --git a/database/migrations/2021_11_04_195244_tax_in_config.php b/database/migrations/2021_11_04_195244_tax_in_config.php new file mode 100644 index 00000000..1412ca59 --- /dev/null +++ b/database/migrations/2021_11_04_195244_tax_in_config.php @@ -0,0 +1,35 @@ +insert( + array( + 'key' => 'TAX_IN_PERCENT', + 'value' => '0', + 'type' => 'integer', + 'description' => 'This will be added to the Product Price on Checkout', + ) + ); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + + } +} From bff97e836d04a0246508d16fc2a80f9b22f2325d Mon Sep 17 00:00:00 2001 From: 1day2die Date: Thu, 4 Nov 2021 21:42:17 +0100 Subject: [PATCH 02/19] basically added tax --- .../Controllers/Admin/PaymentController.php | 23 +++++++++++++++++-- .../2021_11_04_195244_tax_in_config.php | 2 +- resources/views/store/checkout.blade.php | 6 ++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index a7001427..9538e668 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -27,6 +27,21 @@ use PayPalHttp\HttpException; class PaymentController extends Controller { + + + public function getTaxPercent(){ + return Configuration::getValueByKey("TAX_IN_PERCENT"); + } + + public function getTaxValue(PaypalProduct $paypalProduct){ + return $paypalProduct->price*Configuration::getValueByKey("TAX_IN_PERCENT")/100; + } + + public function getTotalPrice(PaypalProduct $paypalProduct){ + return $paypalProduct->price+($this->getTaxValue($paypalProduct)); + } + + /** * @return Application|Factory|View */ @@ -45,7 +60,10 @@ class PaymentController extends Controller public function checkOut(Request $request, PaypalProduct $paypalProduct) { return view('store.checkout')->with([ - 'product' => $paypalProduct + 'product' => $paypalProduct, + 'taxvalue' => $this->getTaxValue($paypalProduct), + 'taxpercent' => $this->getTaxPercent(), + 'total' => $this->getTotalPrice($paypalProduct) ]); } @@ -56,6 +74,7 @@ class PaymentController extends Controller */ public function pay(Request $request, PaypalProduct $paypalProduct) { + $tax = $paypalProduct->price*Configuration::getValueByKey("TAX_IN_PERCENT")/100; $request = new OrdersCreateRequest(); $request->prefer('return=representation'); $request->body = [ @@ -65,7 +84,7 @@ class PaymentController extends Controller "reference_id" => uniqid(), "description" => $paypalProduct->description, "amount" => [ - "value" => $paypalProduct->price, + "value" => $this->getTotalPrice($paypalProduct), "currency_code" => strtoupper($paypalProduct->currency_code) ] ] diff --git a/database/migrations/2021_11_04_195244_tax_in_config.php b/database/migrations/2021_11_04_195244_tax_in_config.php index 1412ca59..c5aa7a8a 100644 --- a/database/migrations/2021_11_04_195244_tax_in_config.php +++ b/database/migrations/2021_11_04_195244_tax_in_config.php @@ -18,7 +18,7 @@ class TaxInConfig extends Migration 'key' => 'TAX_IN_PERCENT', 'value' => '0', 'type' => 'integer', - 'description' => 'This will be added to the Product Price on Checkout', + 'description' => 'The %-value of tax that will be added to the product price on checkout', ) ); } diff --git a/resources/views/store/checkout.blade.php b/resources/views/store/checkout.blade.php index d6401374..1f817071 100644 --- a/resources/views/store/checkout.blade.php +++ b/resources/views/store/checkout.blade.php @@ -114,8 +114,8 @@ {{$product->formatCurrency()}} - Tax (0%) - 0.00 + Tax ({{$taxpercent}}%) + €{{number_format($taxvalue, 2, '.', '')}} Quantity: @@ -123,7 +123,7 @@ Total: - {{$product->formatCurrency()}} + €{{number_format($total, 2, '.', '')}} From 6797410cb42927dfa6935c55dc335055316f2c0f Mon Sep 17 00:00:00 2001 From: WBLKLeipe Date: Fri, 5 Nov 2021 07:43:57 +0100 Subject: [PATCH 03/19] Adding Tax, beautify --- .../Controllers/Admin/PaymentController.php | 26 ++++++++++---- .../2021_11_04_195244_tax_in_config.php | 35 ------------------- .../seeders/Seeds/ConfigurationSeeder.php | 8 +++++ 3 files changed, 28 insertions(+), 41 deletions(-) delete mode 100644 database/migrations/2021_11_04_195244_tax_in_config.php diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index 9538e668..dfe7108e 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -30,11 +30,15 @@ class PaymentController extends Controller public function getTaxPercent(){ - return Configuration::getValueByKey("TAX_IN_PERCENT"); + $tax = Configuration::getValueByKey("SALES_TAX"); + if ( $tax < 0 ) { + return 0; + } + return $tax; } public function getTaxValue(PaypalProduct $paypalProduct){ - return $paypalProduct->price*Configuration::getValueByKey("TAX_IN_PERCENT")/100; + return $paypalProduct->price*$this->getTaxPercent()/100; } public function getTotalPrice(PaypalProduct $paypalProduct){ @@ -74,7 +78,6 @@ class PaymentController extends Controller */ public function pay(Request $request, PaypalProduct $paypalProduct) { - $tax = $paypalProduct->price*Configuration::getValueByKey("TAX_IN_PERCENT")/100; $request = new OrdersCreateRequest(); $request->prefer('return=representation'); $request->body = [ @@ -85,10 +88,21 @@ class PaymentController extends Controller "description" => $paypalProduct->description, "amount" => [ "value" => $this->getTotalPrice($paypalProduct), - "currency_code" => strtoupper($paypalProduct->currency_code) + 'currency_code' => strtoupper($paypalProduct->currency_code), + 'breakdown' =>[ + 'item_total' => + [ + 'currency_code' => strtoupper($paypalProduct->currency_code), + 'value' => $paypalProduct->price, + ], + 'tax_total' => + [ + 'currency_code' => strtoupper($paypalProduct->currency_code), + 'value' => $this->getTaxValue($paypalProduct), + ] + ] ] - ] - ], + ], "application_context" => [ "cancel_url" => route('payment.cancel'), "return_url" => route('payment.success', ['product' => $paypalProduct->id]), diff --git a/database/migrations/2021_11_04_195244_tax_in_config.php b/database/migrations/2021_11_04_195244_tax_in_config.php deleted file mode 100644 index c5aa7a8a..00000000 --- a/database/migrations/2021_11_04_195244_tax_in_config.php +++ /dev/null @@ -1,35 +0,0 @@ -insert( - array( - 'key' => 'TAX_IN_PERCENT', - 'value' => '0', - 'type' => 'integer', - 'description' => 'The %-value of tax that will be added to the product price on checkout', - ) - ); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - - } -} diff --git a/database/seeders/Seeds/ConfigurationSeeder.php b/database/seeders/Seeds/ConfigurationSeeder.php index cce8c991..98d3a57a 100644 --- a/database/seeders/Seeds/ConfigurationSeeder.php +++ b/database/seeders/Seeds/ConfigurationSeeder.php @@ -136,6 +136,14 @@ class ConfigurationSeeder extends Seeder 'type' => 'boolean', 'description' => 'Charges the first hour worth of credits upon creating a server.' ]); + //sales tax + Configuration::firstOrCreate([ + 'key' => 'SALES_TAX', + ], [ + 'value' => '0', + 'type' => 'integer', + 'description' => 'The %-value of tax that will be added to the product price on checkout' + ]); } } From c69c28bd8948751a03dedcb69defb2304d4c25a4 Mon Sep 17 00:00:00 2001 From: WBLKLeipe Date: Fri, 5 Nov 2021 07:59:25 +0100 Subject: [PATCH 04/19] Brackets! --- app/Http/Controllers/Admin/PaymentController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index dfe7108e..fea2e07e 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -102,13 +102,16 @@ class PaymentController extends Controller ] ] ] - ], + ] + ], "application_context" => [ "cancel_url" => route('payment.cancel'), "return_url" => route('payment.success', ['product' => $paypalProduct->id]), 'brand_name' => config('app.name', 'Laravel'), 'shipping_preference' => 'NO_SHIPPING' ] + + ]; From 93d8dfcf0be8b815b86b85208c1f5b5256d8ee10 Mon Sep 17 00:00:00 2001 From: WBLKLeipe Date: Fri, 5 Nov 2021 08:45:29 +0100 Subject: [PATCH 05/19] EVERYTHING WORKING - Safing --- .../Controllers/Admin/PaymentController.php | 6 +++- app/Models/Payment.php | 3 ++ ...21_11_05_071456_add_tax_to_paymentlogs.php | 36 +++++++++++++++++++ .../views/admin/payments/index.blade.php | 8 ++++- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2021_11_05_071456_add_tax_to_paymentlogs.php diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index fea2e07e..a6aedf09 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -197,6 +197,9 @@ class PaymentController extends Controller 'status' => $response->result->status, 'amount' => $paypalProduct->quantity, 'price' => $paypalProduct->price, + 'tax_value' => $this->getTaxValue($paypalProduct), + 'tax_percent' => $this->getTaxPercent(), + 'total_price' => $this->getTotalPrice($paypalProduct), 'currency_code' => $paypalProduct->currency_code, 'payer' => json_encode($response->result->payer), ]); @@ -235,7 +238,7 @@ class PaymentController extends Controller */ public function cancel(Request $request) { - return redirect()->route('store.index')->with('success', 'Payment was Cannceled'); + return redirect()->route('store.index')->with('success', 'Payment was Canceled'); } @@ -254,6 +257,7 @@ class PaymentController extends Controller ->editColumn('price', function (Payment $payment) { return $payment->formatCurrency(); }) + ->editColumn('created_at', function (Payment $payment) { return $payment->created_at ? $payment->created_at->diffForHumans() : ''; }) diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 85bb4b0d..6646327e 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -29,6 +29,9 @@ class Payment extends Model 'type', 'amount', 'price', + 'tax_value', + 'total_price', + 'tax_percent', 'currency_code', ]; diff --git a/database/migrations/2021_11_05_071456_add_tax_to_paymentlogs.php b/database/migrations/2021_11_05_071456_add_tax_to_paymentlogs.php new file mode 100644 index 00000000..3796ee9e --- /dev/null +++ b/database/migrations/2021_11_05_071456_add_tax_to_paymentlogs.php @@ -0,0 +1,36 @@ +decimal('tax_value',8,2)->after('price')->nullable(); + $table->integer('tax_percent')->after('tax_value')->nullable(); + $table->decimal('total_price',8,2)->after('tax_percent')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('payments', function (Blueprint $table) { + $table->dropColumn('tax_value'); + $table->dropColumn('tax_percent'); + $table->dropColumn('total_price'); + }); + } +} diff --git a/resources/views/admin/payments/index.blade.php b/resources/views/admin/payments/index.blade.php index d22b2788..b6765901 100644 --- a/resources/views/admin/payments/index.blade.php +++ b/resources/views/admin/payments/index.blade.php @@ -37,7 +37,10 @@ User Type Amount - Price + Product Price + Tax + Tax(%) + Total Price Payment_ID Payer_ID Created at @@ -68,6 +71,9 @@ {data: 'type'}, {data: 'amount'}, {data: 'price'}, + {data: 'tax_value'}, + {data: 'tax_percent'}, + {data: 'total_price'}, {data: 'payment_id'}, {data: 'payer_id'}, {data: 'created_at'}, From 3f67ac5f2138019f19c88945fef25b3d6a849537 Mon Sep 17 00:00:00 2001 From: WBLKLeipe Date: Fri, 5 Nov 2021 09:00:18 +0100 Subject: [PATCH 06/19] Fixing FormatCurrency --- app/Http/Controllers/Admin/PaymentController.php | 9 +++++++-- app/Models/Payment.php | 5 ++--- app/Models/PaypalProduct.php | 4 ++-- resources/views/store/checkout.blade.php | 8 ++++---- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index a6aedf09..ef1cf7b2 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -255,9 +255,14 @@ class PaymentController extends Controller return $payment->user->name; }) ->editColumn('price', function (Payment $payment) { - return $payment->formatCurrency(); + return $payment->formatToCurrency($payment->price); + }) + ->editColumn('tax_value', function (Payment $payment) { + return $payment->formatToCurrency($payment->tax_value); + }) + ->editColumn('total_price', function (Payment $payment) { + return $payment->formatToCurrency($payment->total_price); }) - ->editColumn('created_at', function (Payment $payment) { return $payment->created_at ? $payment->created_at->diffForHumans() : ''; }) diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 6646327e..d43c291d 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -53,10 +53,9 @@ class Payment extends Model { return $this->belongsTo(User::class); } - - public function formatCurrency($locale = 'en_US') + public function formatToCurrency($value,$locale = 'de_DE') { $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); - return $formatter->formatCurrency($this->price, $this->currency_code); + return $formatter->formatCurrency($value, $this->currency_code); } } diff --git a/app/Models/PaypalProduct.php b/app/Models/PaypalProduct.php index c39c0f8e..f0aef5d9 100644 --- a/app/Models/PaypalProduct.php +++ b/app/Models/PaypalProduct.php @@ -43,9 +43,9 @@ class PaypalProduct extends Model * @param string $locale * @return string */ - public function formatCurrency($locale = 'en_US') + public function formatToCurrency($value,$locale = 'de_DE') { $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); - return $formatter->formatCurrency($this->price, $this->currency_code); + return $formatter->formatCurrency($value, $this->currency_code); } } diff --git a/resources/views/store/checkout.blade.php b/resources/views/store/checkout.blade.php index 1f817071..f2bce40a 100644 --- a/resources/views/store/checkout.blade.php +++ b/resources/views/store/checkout.blade.php @@ -83,7 +83,7 @@ 1 {{$product->quantity}} {{strtolower($product->type) == 'credits' ? CREDITS_DISPLAY_NAME : $product->type}} {{$product->description}} - {{$product->formatCurrency()}} + {{$product->formatToCurrency($product->price)}} @@ -111,11 +111,11 @@ - + - + @@ -123,7 +123,7 @@ - +
Subtotal:{{$product->formatCurrency()}}{{$product->formatToCurrency($product->price)}}
Tax ({{$taxpercent}}%)€{{number_format($taxvalue, 2, '.', '')}}{{$product->formatToCurrency($taxvalue)}}
Quantity:
Total:€{{number_format($total, 2, '.', '')}}{{$product->formatToCurrency($total)}}
From fd32a4aa97eafbc6c1081f4bff5d27b5df089f46 Mon Sep 17 00:00:00 2001 From: WBLKLeipe Date: Fri, 5 Nov 2021 09:04:22 +0100 Subject: [PATCH 07/19] Update index.blade.php --- resources/views/store/index.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/store/index.blade.php b/resources/views/store/index.blade.php index 8bc3f077..880d83a4 100644 --- a/resources/views/store/index.blade.php +++ b/resources/views/store/index.blade.php @@ -50,7 +50,7 @@ @foreach($products as $product) - {{$product->formatCurrency()}} + {{$product->formatToCurrency($product->price)}} {{strtolower($product->type) == 'credits' ? CREDITS_DISPLAY_NAME : $product->type}} {{$product->display}} Purchase From 9e8abe314b6237894e2125ba1da4c99722dbe00e Mon Sep 17 00:00:00 2001 From: 1day2die Date: Fri, 5 Nov 2021 17:38:05 +0100 Subject: [PATCH 08/19] Refactor as J22j suggested --- .../Controllers/Admin/PaymentController.php | 34 +++++-------------- app/Models/PaypalProduct.php | 17 ++++++++++ 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index ef1cf7b2..4c52a310 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -28,24 +28,6 @@ use PayPalHttp\HttpException; class PaymentController extends Controller { - - public function getTaxPercent(){ - $tax = Configuration::getValueByKey("SALES_TAX"); - if ( $tax < 0 ) { - return 0; - } - return $tax; - } - - public function getTaxValue(PaypalProduct $paypalProduct){ - return $paypalProduct->price*$this->getTaxPercent()/100; - } - - public function getTotalPrice(PaypalProduct $paypalProduct){ - return $paypalProduct->price+($this->getTaxValue($paypalProduct)); - } - - /** * @return Application|Factory|View */ @@ -65,9 +47,9 @@ class PaymentController extends Controller { return view('store.checkout')->with([ 'product' => $paypalProduct, - 'taxvalue' => $this->getTaxValue($paypalProduct), - 'taxpercent' => $this->getTaxPercent(), - 'total' => $this->getTotalPrice($paypalProduct) + 'taxvalue' => $paypalProduct->getTaxValue(), + 'taxpercent' => $paypalProduct->getTaxPercent(), + 'total' => $paypalProduct->getTotalPrice() ]); } @@ -87,7 +69,7 @@ class PaymentController extends Controller "reference_id" => uniqid(), "description" => $paypalProduct->description, "amount" => [ - "value" => $this->getTotalPrice($paypalProduct), + "value" => $paypalProduct->getTotalPrice(), 'currency_code' => strtoupper($paypalProduct->currency_code), 'breakdown' =>[ 'item_total' => @@ -98,7 +80,7 @@ class PaymentController extends Controller 'tax_total' => [ 'currency_code' => strtoupper($paypalProduct->currency_code), - 'value' => $this->getTaxValue($paypalProduct), + 'value' => $paypalProduct->getTaxValue(), ] ] ] @@ -197,9 +179,9 @@ class PaymentController extends Controller 'status' => $response->result->status, 'amount' => $paypalProduct->quantity, 'price' => $paypalProduct->price, - 'tax_value' => $this->getTaxValue($paypalProduct), - 'tax_percent' => $this->getTaxPercent(), - 'total_price' => $this->getTotalPrice($paypalProduct), + 'tax_value' => $paypalProduct->getTaxValue(), + 'tax_percent' => $paypalProduct->getTaxPercent(), + 'total_price' => $paypalProduct->getTotalPrice(), 'currency_code' => $paypalProduct->currency_code, 'payer' => json_encode($response->result->payer), ]); diff --git a/app/Models/PaypalProduct.php b/app/Models/PaypalProduct.php index f0aef5d9..82177a4a 100644 --- a/app/Models/PaypalProduct.php +++ b/app/Models/PaypalProduct.php @@ -6,6 +6,7 @@ use Hidehalo\Nanoid\Client; use Illuminate\Database\Eloquent\Model; use NumberFormatter; use Spatie\Activitylog\Traits\LogsActivity; +use App\Models\Configuration; class PaypalProduct extends Model { @@ -48,4 +49,20 @@ class PaypalProduct extends Model $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); return $formatter->formatCurrency($value, $this->currency_code); } + + public function getTaxPercent(){ + $tax = Configuration::getValueByKey("SALES_TAX"); + if ( $tax < 0 ) { + return 0; + } + return $tax; + } + + public function getTaxValue(){ + return $this->price*$this->getTaxPercent()/100; + } + + public function getTotalPrice(){ + return $this->price+($this->getTaxValue()); + } } From 9ac391d75b8e0de4dc86078629e892ebd1d2e18a Mon Sep 17 00:00:00 2001 From: Jovan Jovanovic Date: Sat, 6 Nov 2021 01:32:51 +0100 Subject: [PATCH 09/19] fix(tax): formatCurrency -> formatToCurrency --- app/Http/Controllers/Admin/PaypalProductController.php | 2 +- resources/views/mail/payment/confirmed.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Admin/PaypalProductController.php b/app/Http/Controllers/Admin/PaypalProductController.php index 2fe1998e..00f9a382 100644 --- a/app/Http/Controllers/Admin/PaypalProductController.php +++ b/app/Http/Controllers/Admin/PaypalProductController.php @@ -173,7 +173,7 @@ class PaypalProductController extends Controller return $paypalProduct->created_at ? $paypalProduct->created_at->diffForHumans() : ''; }) ->editColumn('price', function (PaypalProduct $paypalProduct) { - return $paypalProduct->formatCurrency(); + return $paypalProduct->formatToCurrency($paypalProduct->price); }) ->rawColumns(['actions', 'disabled']) ->make(); diff --git a/resources/views/mail/payment/confirmed.blade.php b/resources/views/mail/payment/confirmed.blade.php index e8a30931..2ba7c487 100644 --- a/resources/views/mail/payment/confirmed.blade.php +++ b/resources/views/mail/payment/confirmed.blade.php @@ -6,7 +6,7 @@ Your payment has been confirmed; Your credit balance has been updated.
___ ### Payment ID: **{{$payment->id}}**
### Status: **{{$payment->status}}**
-### Price: **{{$payment->formatCurrency()}}**
+### Price: **{{$payment->formatToCurrency($payment->total_price)}}**
### Type: **{{$payment->type}}**
### Amount: **{{$payment->amount}}**
### Balance: **{{$payment->user->credits}}**
From 23424d4ed49b5c3dc55eaf49c60d753453f45270 Mon Sep 17 00:00:00 2001 From: AnonDev <85408287+anondev-sudo@users.noreply.github.com> Date: Sun, 7 Nov 2021 17:58:01 +0100 Subject: [PATCH 10/19] Update ServerController.php --- app/Http/Controllers/ServerController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php index 313634fb..3ec0e29f 100644 --- a/app/Http/Controllers/ServerController.php +++ b/app/Http/Controllers/ServerController.php @@ -138,7 +138,7 @@ class ServerController extends Controller } } - return redirect()->route('servers.index')->with('success', 'server created'); + return redirect()->route('servers.index')->with('success', 'Server created'); } /** @@ -151,7 +151,7 @@ class ServerController extends Controller $server->delete(); Auth::user()->notify(new ServerCreationError($server)); - return redirect()->route('servers.index')->with('error', 'No allocations satisfying the requirements for automatic deployment were found.'); + return redirect()->route('servers.index')->with('error', 'No allocations satisfying the requirements for automatic deployment on this node were found.'); } /** @@ -172,7 +172,7 @@ class ServerController extends Controller { try { $server->delete(); - return redirect()->route('servers.index')->with('success', 'server removed'); + return redirect()->route('servers.index')->with('success', 'Server removed'); } catch (Exception $e) { return redirect()->route('servers.index')->with('error', 'An exception has occurred while trying to remove a resource "' . $e->getMessage() . '"'); } From 5b8ca6e9c5a38947861626e21b5ce5d57ca07d62 Mon Sep 17 00:00:00 2001 From: AnonDev <85408287+anondev-sudo@users.noreply.github.com> Date: Sun, 7 Nov 2021 18:00:29 +0100 Subject: [PATCH 11/19] Update ProfileController.php --- app/Http/Controllers/ProfileController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index bdeb024c..00ec4b1c 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -86,6 +86,6 @@ class ProfileController extends Controller 'email' => $request->input('email'), ]); - return redirect()->route('profile.index')->with('success' , 'profile updated'); + return redirect()->route('profile.index')->with('success' , 'Profile updated'); } } From 84a214aeddb698e0a345090105e8fed6d3d169e9 Mon Sep 17 00:00:00 2001 From: AnonDev <85408287+anondev-sudo@users.noreply.github.com> Date: Sun, 7 Nov 2021 18:01:23 +0100 Subject: [PATCH 12/19] Update ProductController.php --- app/Http/Controllers/ProductController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index b2ac0c2e..c88f8334 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -21,7 +21,7 @@ class ProductController extends Controller */ public function getNodesBasedOnEgg(Request $request, Egg $egg) { - if (is_null($egg->id)) return response()->json('egg id is required', '400'); + if (is_null($egg->id)) return response()->json('Egg ID is required', '400'); #get products that include this egg $products = Product::query()->with('nodes')->whereHas('eggs', function (Builder $builder) use ($egg) { @@ -80,7 +80,7 @@ class ProductController extends Controller */ public function getProductsBasedOnNode(Node $node) { - if (is_null($node->id)) return response()->json('node id is required', '400'); + if (is_null($node->id)) return response()->json('Node ID is required', '400'); return Product::query()->whereHas('nodes', function (Builder $builder) use ($node) { $builder->where('id', '=', $node->id); From 487040f06a242a340f432ee9fe4252aa38269e62 Mon Sep 17 00:00:00 2001 From: 1day2die Date: Sun, 7 Nov 2021 18:02:53 +0100 Subject: [PATCH 13/19] DocBlocks --- app/Models/Payment.php | 8 +++++++- app/Models/PaypalProduct.php | 29 +++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/app/Models/Payment.php b/app/Models/Payment.php index d43c291d..4303cd55 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -53,7 +53,13 @@ class Payment extends Model { return $this->belongsTo(User::class); } - public function formatToCurrency($value,$locale = 'de_DE') + + /** + * @param float/int + * @param string + * @return string + */ + public function formatToCurrency($value,$locale = 'en_US') { $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); return $formatter->formatCurrency($value, $this->currency_code); diff --git a/app/Models/PaypalProduct.php b/app/Models/PaypalProduct.php index 82177a4a..0fc5ecb8 100644 --- a/app/Models/PaypalProduct.php +++ b/app/Models/PaypalProduct.php @@ -41,28 +41,41 @@ class PaypalProduct extends Model } /** + * @param float/int * @param string $locale * @return string */ - public function formatToCurrency($value,$locale = 'de_DE') + public function formatToCurrency($value,$locale = 'en_US') { $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); return $formatter->formatCurrency($value, $this->currency_code); } - public function getTaxPercent(){ + /** + * @desc Returns the tax in % or 0 if less than 0 + * @return int + */ + public function getTaxPercent() + { $tax = Configuration::getValueByKey("SALES_TAX"); - if ( $tax < 0 ) { - return 0; - } - return $tax; + return $tax < 0 ? 0 : $tax; } - public function getTaxValue(){ + /** + * @desc Returns the total tax value. + * @return float + */ + public function getTaxValue() + { return $this->price*$this->getTaxPercent()/100; } - public function getTotalPrice(){ + /** + * @desc Returns the total price incl. tax + * @return float + */ + public function getTotalPrice() + { return $this->price+($this->getTaxValue()); } } From 574dd24871775ddb050542ff7ced41d718cd9a70 Mon Sep 17 00:00:00 2001 From: AnonDev <85408287+anondev-sudo@users.noreply.github.com> Date: Sun, 7 Nov 2021 18:04:56 +0100 Subject: [PATCH 14/19] Update ServerController.php --- app/Http/Controllers/Admin/ServerController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Admin/ServerController.php b/app/Http/Controllers/Admin/ServerController.php index 6d333feb..493993d8 100644 --- a/app/Http/Controllers/Admin/ServerController.php +++ b/app/Http/Controllers/Admin/ServerController.php @@ -92,7 +92,7 @@ class ServerController extends Controller { try { $server->delete(); - return redirect()->route('admin.servers.index')->with('success', 'server removed'); + return redirect()->route('admin.servers.index')->with('success', 'Server removed'); } catch (Exception $e) { return redirect()->route('admin.servers.index')->with('error', 'An exception has occurred while trying to remove a resource "' . $e->getMessage() . '"'); } @@ -109,7 +109,7 @@ class ServerController extends Controller return redirect()->back()->with('error', $exception->getMessage()); } - return redirect()->back()->with('success', 'server has been updated!'); + return redirect()->back()->with('success', 'Server has been updated!'); } /** From c66f820462829bbb6051f59395dd9b5e2b8cb22d Mon Sep 17 00:00:00 2001 From: AnonDev <85408287+anondev-sudo@users.noreply.github.com> Date: Sun, 7 Nov 2021 18:05:47 +0100 Subject: [PATCH 15/19] Update ProductController.php --- app/Http/Controllers/Admin/ProductController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index f394058b..a71f81da 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/app/Http/Controllers/Admin/ProductController.php @@ -84,7 +84,7 @@ class ProductController extends Controller $product->eggs()->attach($request->input('eggs')); $product->nodes()->attach($request->input('nodes')); - return redirect()->route('admin.products.index')->with('success', 'product has been created!'); + return redirect()->route('admin.products.index')->with('success', 'Product has been created!'); } /** @@ -152,7 +152,7 @@ class ProductController extends Controller $product->eggs()->attach($request->input('eggs')); $product->nodes()->attach($request->input('nodes')); - return redirect()->route('admin.products.index')->with('success', 'product has been updated!'); + return redirect()->route('admin.products.index')->with('success', 'Product has been updated!'); } /** @@ -164,7 +164,7 @@ class ProductController extends Controller { $product->update(['disabled' => !$product->disabled]); - return redirect()->route('admin.products.index')->with('success', 'product has been updated!'); + return redirect()->route('admin.products.index')->with('success', 'Product has been updated!'); } /** @@ -181,7 +181,7 @@ class ProductController extends Controller } $product->delete(); - return redirect()->back()->with('success', 'product has been removed!'); + return redirect()->back()->with('success', 'Product has been removed!'); } From 18e2a88e06fdf9e9ba1cc24bd20d5f4c8ad80efd Mon Sep 17 00:00:00 2001 From: AnonDev <85408287+anondev-sudo@users.noreply.github.com> Date: Sun, 7 Nov 2021 18:06:32 +0100 Subject: [PATCH 16/19] Update PaypalProductController.php --- app/Http/Controllers/Admin/PaypalProductController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Admin/PaypalProductController.php b/app/Http/Controllers/Admin/PaypalProductController.php index 2fe1998e..f7b7f36f 100644 --- a/app/Http/Controllers/Admin/PaypalProductController.php +++ b/app/Http/Controllers/Admin/PaypalProductController.php @@ -62,7 +62,7 @@ class PaypalProductController extends Controller $disabled = !is_null($request->input('disabled')); PaypalProduct::create(array_merge($request->all(), ['disabled' => $disabled])); - return redirect()->route('admin.store.index')->with('success', 'store item has been created!'); + return redirect()->route('admin.store.index')->with('success', 'Store item has been created!'); } /** @@ -112,7 +112,7 @@ class PaypalProductController extends Controller $disabled = !is_null($request->input('disabled')); $paypalProduct->update(array_merge($request->all(), ['disabled' => $disabled])); - return redirect()->route('admin.store.index')->with('success', 'store item has been updated!'); + return redirect()->route('admin.store.index')->with('success', 'Store item has been updated!'); } /** @@ -124,7 +124,7 @@ class PaypalProductController extends Controller { $paypalProduct->update(['disabled' => !$paypalProduct->disabled]); - return redirect()->route('admin.store.index')->with('success', 'product has been updated!'); + return redirect()->route('admin.store.index')->with('success', 'Product has been updated!'); } /** @@ -136,7 +136,7 @@ class PaypalProductController extends Controller public function destroy(PaypalProduct $paypalProduct) { $paypalProduct->delete(); - return redirect()->back()->with('success', 'store item has been removed!'); + return redirect()->back()->with('success', 'Store item has been removed!'); } From 8593bb8517e9d4d9720409cd44b742d1ba0fa3bb Mon Sep 17 00:00:00 2001 From: 1day2die Date: Sun, 7 Nov 2021 18:39:20 +0100 Subject: [PATCH 17/19] fix docblocks? --- app/Models/Payment.php | 6 +++--- app/Models/PaypalProduct.php | 25 ++++++++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 4303cd55..f6ac1c55 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -55,9 +55,9 @@ class Payment extends Model } /** - * @param float/int - * @param string - * @return string + * @param mixed $value + * @param string $locale + * @return NumberFormatter */ public function formatToCurrency($value,$locale = 'en_US') { diff --git a/app/Models/PaypalProduct.php b/app/Models/PaypalProduct.php index 0fc5ecb8..90767ade 100644 --- a/app/Models/PaypalProduct.php +++ b/app/Models/PaypalProduct.php @@ -41,9 +41,9 @@ class PaypalProduct extends Model } /** - * @param float/int + * @param mixed $value * @param string $locale - * @return string + * @return NumberFormatter */ public function formatToCurrency($value,$locale = 'en_US') { @@ -52,9 +52,10 @@ class PaypalProduct extends Model } /** - * @desc Returns the tax in % or 0 if less than 0 - * @return int - */ + * @description Returns the tax in % taken from the Configuration + * + * @return int + */ public function getTaxPercent() { $tax = Configuration::getValueByKey("SALES_TAX"); @@ -62,18 +63,20 @@ class PaypalProduct extends Model } /** - * @desc Returns the total tax value. - * @return float - */ + * @description Returns the tax as Number + * + * @return float + */ public function getTaxValue() { return $this->price*$this->getTaxPercent()/100; } /** - * @desc Returns the total price incl. tax - * @return float - */ + * @description Returns the full price of a Product including tax + * + * @return int + */ public function getTotalPrice() { return $this->price+($this->getTaxValue()); From e3829af1163d20926ff4b28223fe696165343162 Mon Sep 17 00:00:00 2001 From: 1day2die Date: Sun, 7 Nov 2021 18:43:38 +0100 Subject: [PATCH 18/19] fix docblocks? at this point im really nervous whats right and whats wrong --- app/Models/Payment.php | 2 +- app/Models/PaypalProduct.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Models/Payment.php b/app/Models/Payment.php index f6ac1c55..04e871ea 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -57,7 +57,7 @@ class Payment extends Model /** * @param mixed $value * @param string $locale - * @return NumberFormatter + * @return float */ public function formatToCurrency($value,$locale = 'en_US') { diff --git a/app/Models/PaypalProduct.php b/app/Models/PaypalProduct.php index 90767ade..2463bf00 100644 --- a/app/Models/PaypalProduct.php +++ b/app/Models/PaypalProduct.php @@ -43,7 +43,8 @@ class PaypalProduct extends Model /** * @param mixed $value * @param string $locale - * @return NumberFormatter + * + * @return float */ public function formatToCurrency($value,$locale = 'en_US') { @@ -75,7 +76,7 @@ class PaypalProduct extends Model /** * @description Returns the full price of a Product including tax * - * @return int + * @return float */ public function getTotalPrice() { From c664e60af7127187f5d37b8276a5e406a9ae3392 Mon Sep 17 00:00:00 2001 From: 1day2die Date: Sun, 7 Nov 2021 19:18:06 +0100 Subject: [PATCH 19/19] Update Payment.php --- app/Models/Payment.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 04e871ea..2fb1db0e 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -57,6 +57,7 @@ class Payment extends Model /** * @param mixed $value * @param string $locale + * * @return float */ public function formatToCurrency($value,$locale = 'en_US')