style updates
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Commerce\Services;
|
||||
|
||||
use Modules\Commerce\Contracts\TaxProvider;
|
||||
final class ConfiguredTaxProvider implements TaxProvider { public function calculate(float $subtotal,array $address=[]): float { return config('commerce.prices_include_tax') ? 0.0 : round($subtotal * 0.2,2); } }
|
||||
|
||||
final class ConfiguredTaxProvider implements TaxProvider
|
||||
{
|
||||
public function calculate(float $subtotal, array $address = []): float
|
||||
{
|
||||
return config('commerce.prices_include_tax') ? 0.0 : round($subtotal * 0.2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Commerce\Services;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Commerce\Contracts\InventoryProvider;
|
||||
use Modules\Commerce\Models\InventoryMovement;
|
||||
use Modules\Commerce\Models\Product;
|
||||
|
||||
final class DatabaseInventoryProvider implements InventoryProvider
|
||||
{
|
||||
public function adjust(Product $product, int $quantity, string $reason, ?int $userId = null): void
|
||||
{
|
||||
DB::transaction(function () use ($product,$quantity,$reason,$userId) { $product->increment('stock_quantity',$quantity); InventoryMovement::create(['product_id'=>$product->id,'quantity'=>$quantity,'reason'=>$reason,'created_by'=>$userId]); });
|
||||
DB::transaction(function () use ($product, $quantity, $reason, $userId) {
|
||||
$product->increment('stock_quantity', $quantity);
|
||||
InventoryMovement::create(['product_id' => $product->id, 'quantity' => $quantity, 'reason' => $reason, 'created_by' => $userId]);
|
||||
});
|
||||
}
|
||||
|
||||
public function available(Product $product): int
|
||||
{
|
||||
return max(0, (int) $product->stock_quantity);
|
||||
}
|
||||
public function available(Product $product): int { return max(0,(int)$product->stock_quantity); }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Commerce\Services;
|
||||
|
||||
use Modules\Commerce\Contracts\ShippingProvider;
|
||||
final class FlatRateShippingProvider implements ShippingProvider { public function quote(array $address,float $subtotal): float { return $subtotal >= 50 ? 0.0 : 4.95; } }
|
||||
|
||||
final class FlatRateShippingProvider implements ShippingProvider
|
||||
{
|
||||
public function quote(array $address, float $subtotal): float
|
||||
{
|
||||
return $subtotal >= 50 ? 0.0 : 4.95;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Commerce\Services;
|
||||
|
||||
use Modules\Commerce\Contracts\PaymentProvider;
|
||||
use Modules\Commerce\Models\Order;
|
||||
|
||||
final class ManualPaymentProvider implements PaymentProvider
|
||||
{ public function charge(Order $order,array $data=[]): array { return ['status'=>'pending','provider'=>'manual','reference'=>null]; } public function refund(Order $order,float $amount): array { return ['status'=>'pending','provider'=>'manual','amount'=>$amount]; } }
|
||||
{
|
||||
public function charge(Order $order, array $data = []): array
|
||||
{
|
||||
return ['status' => 'pending', 'provider' => 'manual', 'reference' => null];
|
||||
}
|
||||
|
||||
public function refund(Order $order, float $amount): array
|
||||
{
|
||||
return ['status' => 'pending', 'provider' => 'manual', 'amount' => $amount];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user