Added: Purchase Module & Purchase Payments
This commit is contained in:
parent
a3182ef5f9
commit
7719b464e9
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'Purchase'
|
||||
];
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreatePurchasesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('purchases', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->date('date');
|
||||
$table->string('reference');
|
||||
$table->unsignedBigInteger('supplier_id')->nullable();
|
||||
$table->string('supplier_name');
|
||||
$table->integer('tax_percentage')->default(0);
|
||||
$table->integer('tax_amount')->default(0);
|
||||
$table->integer('discount_percentage')->default(0);
|
||||
$table->integer('discount_amount')->default(0);
|
||||
$table->integer('shipping_amount')->default(0);
|
||||
$table->integer('total_amount');
|
||||
$table->integer('paid_amount');
|
||||
$table->integer('due_amount');
|
||||
$table->string('status');
|
||||
$table->string('payment_status');
|
||||
$table->string('payment_method');
|
||||
$table->text('note')->nullable();
|
||||
$table->foreign('supplier_id')->references('id')->on('suppliers')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('purchases');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreatePurchasePaymentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('purchase_payments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('purchase_id');
|
||||
$table->integer('amount');
|
||||
$table->date('date');
|
||||
$table->string('reference');
|
||||
$table->string('payment_method');
|
||||
$table->text('note')->nullable();
|
||||
$table->foreign('purchase_id')->references('id')->on('purchase_payments')->cascadeOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('purchase_payments');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreatePurchaseDetailsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('purchase_details', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('purchase_id');
|
||||
$table->unsignedBigInteger('product_id')->nullable();
|
||||
$table->string('product_name');
|
||||
$table->string('product_code');
|
||||
$table->integer('quantity');
|
||||
$table->integer('price');
|
||||
$table->integer('unit_price');
|
||||
$table->integer('sub_total');
|
||||
$table->integer('product_discount_amount');
|
||||
$table->string('product_discount_type')->default('fixed');
|
||||
$table->integer('product_tax_amount');
|
||||
$table->foreign('purchase_id')->references('id')
|
||||
->on('purchases')->cascadeOnDelete();
|
||||
$table->foreign('product_id')->references('id')
|
||||
->on('products')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('purchase_details');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Purchase\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PurchaseDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
// $this->call("OthersTableSeeder");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Purchase\Entities;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Purchase extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function purchaseDetails() {
|
||||
return $this->hasMany(PurchaseDetail::class, 'purchase_id', 'id');
|
||||
}
|
||||
|
||||
public function purchasePayments() {
|
||||
return $this->hasMany(PurchasePayment::class, 'purchase_id', 'id');
|
||||
}
|
||||
|
||||
public function getReferenceAttribute($value) {
|
||||
return strtoupper($value) . '_' . str_pad($this->attributes['id'], 6, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function getShippingAmountAttribute($value) {
|
||||
return $value / 100;
|
||||
}
|
||||
|
||||
public function getPaidAmountAttribute($value) {
|
||||
return $value / 100;
|
||||
}
|
||||
|
||||
public function getTotalAmountAttribute($value) {
|
||||
return $value / 100;
|
||||
}
|
||||
|
||||
public function getDueAmountAttribute($value) {
|
||||
return $value / 100;
|
||||
}
|
||||
|
||||
public function getTaxAmountAttribute($value) {
|
||||
return $value / 100;
|
||||
}
|
||||
|
||||
public function getDiscountAmountAttribute($value) {
|
||||
return $value / 100;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Purchase\Entities;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Product\Entities\Product;
|
||||
|
||||
class PurchaseDetail extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $with = ['product'];
|
||||
|
||||
public function product() {
|
||||
return $this->belongsTo(Product::class, 'product_id', 'id');
|
||||
}
|
||||
|
||||
public function purchase() {
|
||||
return $this->belongsTo(Purchase::class, 'purchase_id', 'id');
|
||||
}
|
||||
|
||||
public function getPriceAttribute($value) {
|
||||
return $value / 100;
|
||||
}
|
||||
|
||||
public function getUnitPriceAttribute($value) {
|
||||
return $value / 100;
|
||||
}
|
||||
|
||||
public function getSubTotalAttribute($value) {
|
||||
return $value / 100;
|
||||
}
|
||||
|
||||
public function getProductDiscountAmountAttribute($value) {
|
||||
return $value / 100;
|
||||
}
|
||||
|
||||
public function getProductTaxAmountAttribute($value) {
|
||||
return $value / 100;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Purchase\Entities;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class PurchasePayment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function purchase() {
|
||||
return $this->belongsTo(Purchase::class, 'purchase_id', 'id');
|
||||
}
|
||||
|
||||
public function setAmountAttribute($value) {
|
||||
$this->attributes['amount'] = $value * 100;
|
||||
}
|
||||
|
||||
public function getAmountAttribute($value) {
|
||||
return $value / 100;
|
||||
}
|
||||
|
||||
public function getDateAttribute($value) {
|
||||
return Carbon::parse($value)->format('d M, Y');
|
||||
}
|
||||
|
||||
public function scopeByPurchase($query) {
|
||||
return $query->where('purchase_id', request()->route('purchase_id'));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,231 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Purchase\Http\Controllers;
|
||||
|
||||
use App\DataTables\PurchaseDataTable;
|
||||
use Gloudemans\Shoppingcart\Facades\Cart;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Modules\People\Entities\Supplier;
|
||||
use Modules\Product\Entities\Product;
|
||||
use Modules\Purchase\Entities\Purchase;
|
||||
use Modules\Purchase\Entities\PurchaseDetail;
|
||||
use Modules\Purchase\Entities\PurchasePayment;
|
||||
use Modules\Purchase\Http\Requests\StorePurchaseRequest;
|
||||
use Modules\Purchase\Http\Requests\UpdatePurchaseRequest;
|
||||
|
||||
class PurchaseController extends Controller
|
||||
{
|
||||
|
||||
public function index(PurchaseDataTable $dataTable) {
|
||||
abort_if(Gate::denies('access_purchases'), 403);
|
||||
|
||||
return $dataTable->render('purchase::index');
|
||||
}
|
||||
|
||||
|
||||
public function create() {
|
||||
abort_if(Gate::denies('create_purchases'), 403);
|
||||
|
||||
Cart::instance('purchase')->destroy();
|
||||
|
||||
return view('purchase::create');
|
||||
}
|
||||
|
||||
|
||||
public function store(StorePurchaseRequest $request) {
|
||||
DB::transaction(function () use ($request) {
|
||||
$due_amount = $request->total_amount - $request->paid_amount;
|
||||
if ($due_amount == $request->total_amount) {
|
||||
$payment_status = 'Unpaid';
|
||||
} elseif ($due_amount > 0) {
|
||||
$payment_status = 'Partial';
|
||||
} else {
|
||||
$payment_status = 'Paid';
|
||||
}
|
||||
|
||||
$purchase = Purchase::create([
|
||||
'date' => $request->date,
|
||||
'reference' => $request->reference,
|
||||
'supplier_id' => $request->supplier_id,
|
||||
'supplier_name' => Supplier::findOrFail($request->supplier_id)->supplier_name,
|
||||
'tax_percentage' => $request->tax_percentage,
|
||||
'discount_percentage' => $request->discount_percentage,
|
||||
'shipping_amount' => $request->shipping_amount * 100,
|
||||
'paid_amount' => $request->paid_amount * 100,
|
||||
'total_amount' => $request->total_amount * 100,
|
||||
'due_amount' => $due_amount * 100,
|
||||
'status' => $request->status,
|
||||
'payment_status' => $payment_status,
|
||||
'payment_method' => $request->payment_method,
|
||||
'note' => $request->note,
|
||||
'tax_amount' => Cart::instance('purchase')->tax() * 100,
|
||||
'discount_amount' => Cart::instance('purchase')->discount() * 100,
|
||||
]);
|
||||
|
||||
foreach (Cart::instance('purchase')->content() as $cart_item) {
|
||||
PurchaseDetail::create([
|
||||
'purchase_id' => $purchase->id,
|
||||
'product_id' => $cart_item->id,
|
||||
'product_name' => $cart_item->name,
|
||||
'product_code' => $cart_item->options->code,
|
||||
'quantity' => $cart_item->qty,
|
||||
'price' => $cart_item->price * 100,
|
||||
'unit_price' => $cart_item->options->unit_price * 100,
|
||||
'sub_total' => $cart_item->options->sub_total * 100,
|
||||
'product_discount_amount' => $cart_item->options->product_discount * 100,
|
||||
'product_discount_type' => $cart_item->options->product_discount_type,
|
||||
'product_tax_amount' => $cart_item->options->product_tax * 100,
|
||||
]);
|
||||
|
||||
if ($request->status == 'Completed') {
|
||||
$product = Product::findOrFail($cart_item->id);
|
||||
$product->update([
|
||||
'product_quantity' => $product->product_quantity + $cart_item->qty
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Cart::instance('purchase')->destroy();
|
||||
|
||||
PurchasePayment::create([
|
||||
'date' => $request->date,
|
||||
'reference' => 'INV/'.$purchase->reference,
|
||||
'amount' => $purchase->paid_amount,
|
||||
'purchase_id' => $purchase->id,
|
||||
'payment_method' => $request->payment_method
|
||||
]);
|
||||
});
|
||||
|
||||
toast('Purchase Created!', 'success');
|
||||
|
||||
return redirect()->route('purchases.index');
|
||||
}
|
||||
|
||||
|
||||
public function show(Purchase $purchase) {
|
||||
abort_if(Gate::denies('show_purchases'), 403);
|
||||
|
||||
$supplier = Supplier::findOrFail($purchase->supplier_id);
|
||||
|
||||
return view('purchase::show', compact('purchase', 'supplier'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Purchase $purchase) {
|
||||
abort_if(Gate::denies('edit_purchases'), 403);
|
||||
|
||||
$purchase_details = $purchase->purchaseDetails;
|
||||
|
||||
Cart::instance('purchase')->destroy();
|
||||
|
||||
$cart = Cart::instance('purchase');
|
||||
|
||||
foreach ($purchase_details as $purchase_detail) {
|
||||
$cart->add([
|
||||
'id' => $purchase_detail->product_id,
|
||||
'name' => $purchase_detail->product_name,
|
||||
'qty' => $purchase_detail->quantity,
|
||||
'price' => $purchase_detail->price,
|
||||
'weight' => 1,
|
||||
'options' => [
|
||||
'product_discount' => $purchase_detail->product_discount_amount,
|
||||
'product_discount_type' => $purchase_detail->product_discount_type,
|
||||
'sub_total' => $purchase_detail->sub_total,
|
||||
'code' => $purchase_detail->product_code,
|
||||
'stock' => Product::findOrFail($purchase_detail->product_id)->product_quantity,
|
||||
'product_tax' => $purchase_detail->product_tax_amount,
|
||||
'unit_price' => $purchase_detail->unit_price
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
return view('purchase::edit', compact('purchase'));
|
||||
}
|
||||
|
||||
|
||||
public function update(UpdatePurchaseRequest $request, Purchase $purchase) {
|
||||
DB::transaction(function () use ($request, $purchase) {
|
||||
$due_amount = $request->total_amount - $request->paid_amount;
|
||||
if ($due_amount == $request->total_amount) {
|
||||
$payment_status = 'Unpaid';
|
||||
} elseif ($due_amount > 0) {
|
||||
$payment_status = 'Partial';
|
||||
} else {
|
||||
$payment_status = 'Paid';
|
||||
}
|
||||
|
||||
foreach ($purchase->purchaseDetails as $purchase_detail) {
|
||||
if ($purchase->status == 'Completed') {
|
||||
$product = Product::findOrFail($purchase_detail->product_id);
|
||||
$product->update([
|
||||
'product_quantity' => $product->product_quantity - $purchase_detail->quantity
|
||||
]);
|
||||
}
|
||||
$purchase_detail->delete();
|
||||
}
|
||||
|
||||
$purchase->update([
|
||||
'date' => $request->date,
|
||||
'reference' => $request->reference,
|
||||
'supplier_id' => $request->supplier_id,
|
||||
'supplier_name' => Supplier::findOrFail($request->supplier_id)->supplier_name,
|
||||
'tax_percentage' => $request->tax_percentage,
|
||||
'discount_percentage' => $request->discount_percentage,
|
||||
'shipping_amount' => $request->shipping_amount * 100,
|
||||
'paid_amount' => $request->paid_amount * 100,
|
||||
'total_amount' => $request->total_amount * 100,
|
||||
'due_amount' => $due_amount * 100,
|
||||
'status' => $request->status,
|
||||
'payment_status' => $payment_status,
|
||||
'payment_method' => $request->payment_method,
|
||||
'note' => $request->note,
|
||||
'tax_amount' => Cart::instance('purchase')->tax() * 100,
|
||||
'discount_amount' => Cart::instance('purchase')->discount() * 100,
|
||||
]);
|
||||
|
||||
foreach (Cart::instance('purchase')->content() as $cart_item) {
|
||||
PurchaseDetail::create([
|
||||
'purchase_id' => $purchase->id,
|
||||
'product_id' => $cart_item->id,
|
||||
'product_name' => $cart_item->name,
|
||||
'product_code' => $cart_item->options->code,
|
||||
'quantity' => $cart_item->qty,
|
||||
'price' => $cart_item->price * 100,
|
||||
'unit_price' => $cart_item->options->unit_price * 100,
|
||||
'sub_total' => $cart_item->options->sub_total * 100,
|
||||
'product_discount_amount' => $cart_item->options->product_discount * 100,
|
||||
'product_discount_type' => $cart_item->options->product_discount_type,
|
||||
'product_tax_amount' => $cart_item->options->product_tax * 100,
|
||||
]);
|
||||
|
||||
if ($request->status == 'Completed') {
|
||||
$product = Product::findOrFail($cart_item->id);
|
||||
$product->update([
|
||||
'product_quantity' => $product->product_quantity + $cart_item->qty
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Cart::instance('purchase')->destroy();
|
||||
});
|
||||
|
||||
toast('Purchase Updated!', 'info');
|
||||
|
||||
return redirect()->route('purchases.index');
|
||||
}
|
||||
|
||||
|
||||
public function destroy(Purchase $purchase) {
|
||||
abort_if(Gate::denies('delete_purchases'), 403);
|
||||
|
||||
$purchase->delete();
|
||||
|
||||
toast('Purchase Deleted!', 'warning');
|
||||
|
||||
return redirect()->route('purchases.index');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Purchase\Http\Controllers;
|
||||
|
||||
use App\DataTables\PurchasePaymentsDataTable;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Modules\Purchase\Entities\Purchase;
|
||||
use Modules\Purchase\Entities\PurchasePayment;
|
||||
|
||||
class PurchasePaymentsController extends Controller
|
||||
{
|
||||
|
||||
public function index($purchase_id, PurchasePaymentsDataTable $dataTable) {
|
||||
abort_if(Gate::denies('access_purchase_payments'), 403);
|
||||
|
||||
$purchase = Purchase::findOrFail($purchase_id);
|
||||
|
||||
return $dataTable->render('purchase::payments.index', compact('purchase'));
|
||||
}
|
||||
|
||||
|
||||
public function create($purchase_id) {
|
||||
abort_if(Gate::denies('access_purchase_payments'), 403);
|
||||
|
||||
$purchase = Purchase::findOrFail($purchase_id);
|
||||
|
||||
return view('purchase::payments.create', compact('purchase'));
|
||||
}
|
||||
|
||||
|
||||
public function store(Request $request) {
|
||||
abort_if(Gate::denies('access_purchase_payments'), 403);
|
||||
|
||||
$request->validate([
|
||||
'date' => 'required|date',
|
||||
'reference' => 'required|string|max:255',
|
||||
'amount' => 'required|numeric',
|
||||
'note' => 'nullable|string|max:1000',
|
||||
'purchase_id' => 'required',
|
||||
'payment_method' => 'required|string|max:255'
|
||||
]);
|
||||
|
||||
DB::transaction(function () use ($request) {
|
||||
PurchasePayment::create([
|
||||
'date' => $request->date,
|
||||
'reference' => $request->reference,
|
||||
'amount' => $request->amount,
|
||||
'note' => $request->note,
|
||||
'purchase_id' => $request->purchase_id,
|
||||
'payment_method' => $request->payment_method
|
||||
]);
|
||||
|
||||
$purchase = Purchase::findOrFail($request->purchase_id);
|
||||
|
||||
$due_amount = $purchase->due_amount - $request->amount;
|
||||
|
||||
if ($due_amount == $purchase->total_amount) {
|
||||
$payment_status = 'Unpaid';
|
||||
} elseif ($due_amount > 0) {
|
||||
$payment_status = 'Partial';
|
||||
} else {
|
||||
$payment_status = 'Paid';
|
||||
}
|
||||
|
||||
$purchase->update([
|
||||
'paid_amount' => ($purchase->paid_amount + $request->amount) * 100,
|
||||
'due_amount' => $due_amount * 100,
|
||||
'payment_status' => $payment_status
|
||||
]);
|
||||
});
|
||||
|
||||
toast('Purchase Payment Created!', 'success');
|
||||
|
||||
return redirect()->route('purchases.index');
|
||||
}
|
||||
|
||||
|
||||
public function edit($purchase_id, PurchasePayment $purchasePayment) {
|
||||
abort_if(Gate::denies('access_purchase_payments'), 403);
|
||||
|
||||
$purchase = Purchase::findOrFail($purchase_id);
|
||||
|
||||
return view('purchase::payments.edit', compact('purchasePayment', 'purchase'));
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, PurchasePayment $purchasePayment) {
|
||||
abort_if(Gate::denies('access_purchase_payments'), 403);
|
||||
|
||||
$request->validate([
|
||||
'date' => 'required|date',
|
||||
'reference' => 'required|string|max:255',
|
||||
'amount' => 'required|numeric',
|
||||
'note' => 'nullable|string|max:1000',
|
||||
'purchase_id' => 'required',
|
||||
'payment_method' => 'required|string|max:255'
|
||||
]);
|
||||
|
||||
DB::transaction(function () use ($request, $purchasePayment) {
|
||||
$purchase = $purchasePayment->purchase;
|
||||
|
||||
$due_amount = ($purchase->due_amount + $purchasePayment->amount) - $request->amount;
|
||||
|
||||
if ($due_amount == $purchase->total_amount) {
|
||||
$payment_status = 'Unpaid';
|
||||
} elseif ($due_amount > 0) {
|
||||
$payment_status = 'Partial';
|
||||
} else {
|
||||
$payment_status = 'Paid';
|
||||
}
|
||||
|
||||
$purchase->update([
|
||||
'paid_amount' => (($purchase->paid_amount - $purchasePayment->amount) + $request->amount) * 100,
|
||||
'due_amount' => $due_amount * 100,
|
||||
'payment_status' => $payment_status
|
||||
]);
|
||||
|
||||
$purchasePayment->update([
|
||||
'date' => $request->date,
|
||||
'reference' => $request->reference,
|
||||
'amount' => $request->amount,
|
||||
'note' => $request->note,
|
||||
'purchase_id' => $request->purchase_id,
|
||||
'payment_method' => $request->payment_method
|
||||
]);
|
||||
});
|
||||
|
||||
toast('Purchase Payment Updated!', 'info');
|
||||
|
||||
return redirect()->route('purchases.index');
|
||||
}
|
||||
|
||||
|
||||
public function destroy(PurchasePayment $purchasePayment) {
|
||||
abort_if(Gate::denies('access_purchase_payments'), 403);
|
||||
|
||||
$purchasePayment->delete();
|
||||
|
||||
toast('Purchase Payment Deleted!', 'warning');
|
||||
|
||||
return redirect()->route('purchases.index');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Purchase\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class StorePurchaseRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'supplier_id' => 'required|numeric',
|
||||
'reference' => 'required|string|max:255',
|
||||
'tax_percentage' => 'required|integer|min:0|max:100',
|
||||
'discount_percentage' => 'required|integer|min:0|max:100',
|
||||
'shipping_amount' => 'required|numeric',
|
||||
'total_amount' => 'required|numeric',
|
||||
'paid_amount' => 'required|numeric',
|
||||
'status' => 'required|string|max:255',
|
||||
'payment_method' => 'required|string|max:255',
|
||||
'note' => 'nullable|string|max:1000'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return Gate::allows('create_sales');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Purchase\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class UpdatePurchaseRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'supplier_id' => 'required|numeric',
|
||||
'reference' => 'required|string|max:255',
|
||||
'tax_percentage' => 'required|integer|min:0|max:100',
|
||||
'discount_percentage' => 'required|integer|min:0|max:100',
|
||||
'shipping_amount' => 'required|numeric',
|
||||
'total_amount' => 'required|numeric',
|
||||
'paid_amount' => 'required|numeric|max:' . $this->purchase->total_amount,
|
||||
'status' => 'required|string|max:255',
|
||||
'payment_method' => 'required|string|max:255',
|
||||
'note' => 'nullable|string|max:1000'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return Gate::allows('edit_purchases');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Purchase\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
|
||||
class PurchaseServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* @var string $moduleName
|
||||
*/
|
||||
protected $moduleName = 'Purchase';
|
||||
|
||||
/**
|
||||
* @var string $moduleNameLower
|
||||
*/
|
||||
protected $moduleNameLower = 'purchase';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerConfig()
|
||||
{
|
||||
$this->publishes([
|
||||
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
|
||||
], 'config');
|
||||
$this->mergeConfigFrom(
|
||||
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerViews()
|
||||
{
|
||||
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
|
||||
|
||||
$sourcePath = module_path($this->moduleName, 'Resources/views');
|
||||
|
||||
$this->publishes([
|
||||
$sourcePath => $viewPath
|
||||
], ['views', $this->moduleNameLower . '-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerTranslations()
|
||||
{
|
||||
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (\Config::get('view.paths') as $path) {
|
||||
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
|
||||
$paths[] = $path . '/modules/' . $this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
return $paths;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Purchase\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The module namespace to assume when generating URLs to actions.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $moduleNamespace = 'Modules\Purchase\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('Purchase', '/Routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('Purchase', '/Routes/api.php'));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('title', 'Create Purchase')
|
||||
|
||||
@section('breadcrumb')
|
||||
<ol class="breadcrumb border-0 m-0">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('purchases.index') }}">Purchases</a></li>
|
||||
<li class="breadcrumb-item active">Add</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid mb-4">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<livewire:search-product/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-4">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@include('utils.alerts')
|
||||
<form id="purchase-form" action="{{ route('purchases.store') }}" method="POST">
|
||||
@csrf
|
||||
|
||||
<div class="form-row">
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="reference">Reference <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="reference" required readonly value="PR">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="from-group">
|
||||
<div class="form-group">
|
||||
<label for="supplier_id">Supplier <span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="supplier_id" id="supplier_id" required>
|
||||
@foreach(\Modules\People\Entities\Supplier::all() as $supplier)
|
||||
<option value="{{ $supplier->id }}">{{ $supplier->supplier_name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="from-group">
|
||||
<div class="form-group">
|
||||
<label for="date">Date <span class="text-danger">*</span></label>
|
||||
<input type="date" class="form-control" name="date" required value="{{ now()->format('Y-m-d') }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<livewire:product-cart :cartInstance="'purchase'"/>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="status">Status <span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="status" id="status" required>
|
||||
<option value="Pending">Pending</option>
|
||||
<option value="Ordered">Ordered</option>
|
||||
<option value="Completed">Completed</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="from-group">
|
||||
<div class="form-group">
|
||||
<label for="payment_method">Payment Method <span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="payment_method" id="payment_method" required>
|
||||
<option value="Cash">Cash</option>
|
||||
<option value="Credit Card">Credit Card</option>
|
||||
<option value="Bank Transfer">Bank Transfer</option>
|
||||
<option value="Cheque">Cheque</option>
|
||||
<option value="Other">Other</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="paid_amount">Amount Paid <span class="text-danger">*</span></label>
|
||||
<div class="input-group">
|
||||
<input id="paid_amount" type="text" class="form-control" name="paid_amount" required>
|
||||
<div class="input-group-append">
|
||||
<button id="getTotalAmount" class="btn btn-primary" type="button">
|
||||
<i class="bi bi-check-square"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="note">Note (If Needed)</label>
|
||||
<textarea name="note" id="note" rows="5" class="form-control"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Create Purchase <i class="bi bi-check"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script src="{{ asset('js/jquery-mask-money.js') }}"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#paid_amount').maskMoney({
|
||||
prefix:'{{ settings()->currency->symbol }}',
|
||||
thousands:'{{ settings()->currency->thousand_separator }}',
|
||||
decimal:'{{ settings()->currency->decimal_separator }}',
|
||||
allowZero: true,
|
||||
});
|
||||
|
||||
$('#getTotalAmount').click(function () {
|
||||
$('#paid_amount').maskMoney('mask', {{ Cart::instance('purchase')->total() }});
|
||||
});
|
||||
|
||||
$('#purchase-form').submit(function () {
|
||||
var paid_amount = $('#paid_amount').maskMoney('unmasked')[0];
|
||||
$('#paid_amount').val(paid_amount);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('title', 'Edit Purchase')
|
||||
|
||||
@section('breadcrumb')
|
||||
<ol class="breadcrumb border-0 m-0">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('purchases.index') }}">Purchases</a></li>
|
||||
<li class="breadcrumb-item active">Edit</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid mb-4">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<livewire:search-product/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-4">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@include('utils.alerts')
|
||||
<form id="purchase-form" action="{{ route('purchases.update', $purchase) }}" method="POST">
|
||||
@csrf
|
||||
@method('patch')
|
||||
<div class="form-row">
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="reference">Reference <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="reference" required value="PR" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="from-group">
|
||||
<div class="form-group">
|
||||
<label for="supplier_id">Supplier <span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="supplier_id" id="supplier_id" required>
|
||||
@foreach(\Modules\People\Entities\Supplier::all() as $supplier)
|
||||
<option {{ $purchase->supplier_id == $supplier->id ? 'selected' : '' }} value="{{ $supplier->id }}">{{ $supplier->supplier_name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="from-group">
|
||||
<div class="form-group">
|
||||
<label for="date">Date <span class="text-danger">*</span></label>
|
||||
<input type="date" class="form-control" name="date" required value="{{ $purchase->date }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<livewire:product-cart :cartInstance="'purchase'" :data="$purchase"/>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="status">Status <span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="status" id="status" required>
|
||||
<option {{ $purchase->status == 'Pending' ? 'selected' : '' }} value="Pending">Pending</option>
|
||||
<option {{ $purchase->status == 'Ordered' ? 'selected' : '' }} value="Ordered">Ordered</option>
|
||||
<option {{ $purchase->status == 'Completed' ? 'selected' : '' }} value="Completed">Completed</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="from-group">
|
||||
<div class="form-group">
|
||||
<label for="payment_method">Payment Method <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="payment_method" required value="{{ $purchase->payment_method }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="paid_amount">Amount Received <span class="text-danger">*</span></label>
|
||||
<input id="paid_amount" type="text" class="form-control" name="paid_amount" required value="{{ $purchase->paid_amount }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="note">Note (If Needed)</label>
|
||||
<textarea name="note" id="note" rows="5" class="form-control">{{ $purchase->note }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Update Purchase <i class="bi bi-check"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script src="{{ asset('js/jquery-mask-money.js') }}"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#paid_amount').maskMoney({
|
||||
prefix:'{{ settings()->currency->symbol }}',
|
||||
thousands:'{{ settings()->currency->thousand_separator }}',
|
||||
decimal:'{{ settings()->currency->decimal_separator }}',
|
||||
allowZero: true,
|
||||
});
|
||||
|
||||
$('#paid_amount').maskMoney('mask');
|
||||
|
||||
$('#purchase-form').submit(function () {
|
||||
var paid_amount = $('#paid_amount').maskMoney('unmasked')[0];
|
||||
$('#paid_amount').val(paid_amount);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('title', 'Purchases')
|
||||
|
||||
@section('third_party_stylesheets')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/dataTables.bootstrap4.min.css">
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
<ol class="breadcrumb border-0 m-0">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||||
<li class="breadcrumb-item active">Purchases</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="{{ route('purchases.create') }}" class="btn btn-primary">
|
||||
Add Purchase <i class="bi bi-plus"></i>
|
||||
</a>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="table-responsive">
|
||||
{!! $dataTable->table() !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
{!! $dataTable->scripts() !!}
|
||||
@endpush
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<div class="btn-group dropleft">
|
||||
<button type="button" class="btn btn-ghost-primary dropdown rounded" data-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-three-dots-vertical"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
@can('access_purchase_payments')
|
||||
<a href="{{ route('purchase-payments.index', $data->id) }}" class="dropdown-item">
|
||||
<i class="bi bi-cash-coin mr-2 text-warning" style="line-height: 1;"></i> Show Payments
|
||||
</a>
|
||||
@endcan
|
||||
@can('access_purchase_payments')
|
||||
@if($data->due_amount > 0)
|
||||
<a href="{{ route('purchase-payments.create', $data->id) }}" class="dropdown-item">
|
||||
<i class="bi bi-plus-circle-dotted mr-2 text-success" style="line-height: 1;"></i> Add Payment
|
||||
</a>
|
||||
@endif
|
||||
@endcan
|
||||
@can('edit_purchases')
|
||||
<a href="{{ route('purchases.edit', $data->id) }}" class="dropdown-item">
|
||||
<i class="bi bi-pencil mr-2 text-primary" style="line-height: 1;"></i> Edit
|
||||
</a>
|
||||
@endcan
|
||||
@can('show_purchases')
|
||||
<a href="{{ route('purchases.show', $data->id) }}" class="dropdown-item">
|
||||
<i class="bi bi-eye mr-2 text-info" style="line-height: 1;"></i> Details
|
||||
</a>
|
||||
@endcan
|
||||
@can('delete_purchases')
|
||||
<button id="delete" class="dropdown-item" onclick="
|
||||
event.preventDefault();
|
||||
if (confirm('Are you sure? It will delete the data permanently!')) {
|
||||
document.getElementById('destroy{{ $data->id }}').submit()
|
||||
}">
|
||||
<i class="bi bi-trash mr-2 text-danger" style="line-height: 1;"></i> Delete
|
||||
<form id="destroy{{ $data->id }}" class="d-none" action="{{ route('purchases.destroy', $data->id) }}" method="POST">
|
||||
@csrf
|
||||
@method('delete')
|
||||
</form>
|
||||
</button>
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
@if ($data->payment_status == 'Partial')
|
||||
<span class="badge badge-warning">
|
||||
{{ $data->payment_status }}
|
||||
</span>
|
||||
@elseif ($data->payment_status == 'Paid')
|
||||
<span class="badge badge-success">
|
||||
{{ $data->payment_status }}
|
||||
</span>
|
||||
@else
|
||||
<span class="badge badge-danger">
|
||||
{{ $data->payment_status }}
|
||||
</span>
|
||||
@endif
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
@if ($data->status == 'Pending')
|
||||
<span class="badge badge-info">
|
||||
{{ $data->status }}
|
||||
</span>
|
||||
@elseif ($data->status == 'Ordered')
|
||||
<span class="badge badge-primary">
|
||||
{{ $data->status }}
|
||||
</span>
|
||||
@else
|
||||
<span class="badge badge-success">
|
||||
{{ $data->status }}
|
||||
</span>
|
||||
@endif
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('title', 'Create Payment')
|
||||
|
||||
@section('breadcrumb')
|
||||
<ol class="breadcrumb border-0 m-0">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('purchases.index') }}">Purchase</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('purchases.show', $purchase) }}">{{ $purchase->reference }}</a></li>
|
||||
<li class="breadcrumb-item active">Add Payment</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<form id="payment-form" action="{{ route('purchase-payments.store') }}" method="POST">
|
||||
@csrf
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
@include('utils.alerts')
|
||||
<div class="form-group">
|
||||
<button class="btn btn-primary">Create Payment <i class="bi bi-check"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-row">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label for="reference">Reference <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="reference" required readonly value="INV/{{ $purchase->reference }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label for="date">Date <span class="text-danger">*</span></label>
|
||||
<input type="date" class="form-control" name="date" required value="{{ now()->format('Y-m-d') }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="due_amount">Due Amount <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="due_amount" required value="{{ format_currency($purchase->due_amount) }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="amount">Amount <span class="text-danger">*</span></label>
|
||||
<div class="input-group">
|
||||
<input id="amount" type="text" class="form-control" name="amount" required value="{{ old('amount') }}">
|
||||
<div class="input-group-append">
|
||||
<button id="getTotalAmount" class="btn btn-primary" type="button">
|
||||
<i class="bi bi-check-square"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="from-group">
|
||||
<div class="form-group">
|
||||
<label for="payment_method">Payment Method <span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="payment_method" id="payment_method" required>
|
||||
<option value="Cash">Cash</option>
|
||||
<option value="Credit Card">Credit Card</option>
|
||||
<option value="Bank Transfer">Bank Transfer</option>
|
||||
<option value="Cheque">Cheque</option>
|
||||
<option value="Other">Other</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="note">Note</label>
|
||||
<textarea class="form-control" rows="4" name="note">{{ old('note') }}</textarea>
|
||||
</div>
|
||||
|
||||
<input type="hidden" value="{{ $purchase->id }}" name="purchase_id">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script src="{{ asset('js/jquery-mask-money.js') }}"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#amount').maskMoney({
|
||||
prefix:'{{ settings()->currency->symbol }}',
|
||||
thousands:'{{ settings()->currency->thousand_separator }}',
|
||||
decimal:'{{ settings()->currency->decimal_separator }}',
|
||||
});
|
||||
|
||||
$('#getTotalAmount').click(function () {
|
||||
$('#amount').maskMoney('mask', {{ $purchase->due_amount }});
|
||||
});
|
||||
|
||||
$('#payment-form').submit(function () {
|
||||
var amount = $('#amount').maskMoney('unmasked')[0];
|
||||
$('#amount').val(amount);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('title', 'Edit Payment')
|
||||
|
||||
@section('breadcrumb')
|
||||
<ol class="breadcrumb border-0 m-0">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('purchases.index') }}">Purchases</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('purchases.show', $purchase) }}">{{ $purchase->reference }}</a></li>
|
||||
<li class="breadcrumb-item active">Edit Payment</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<form id="payment-form" action="{{ route('purchase-payments.update', $purchasePayment) }}" method="POST">
|
||||
@csrf
|
||||
@method('patch')
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
@include('utils.alerts')
|
||||
<div class="form-group">
|
||||
<button class="btn btn-primary">Update Payment <i class="bi bi-check"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-row">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label for="reference">Reference <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="reference" required readonly value="{{ $purchasePayment->reference }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label for="date">Date <span class="text-danger">*</span></label>
|
||||
<input type="date" class="form-control" name="date" required value="{{ $purchasePayment->getAttributes()['date'] }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="due_amount">Due Amount <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="due_amount" required value="{{ format_currency($purchase->due_amount) }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="amount">Amount <span class="text-danger">*</span></label>
|
||||
<div class="input-group">
|
||||
<input id="amount" type="text" class="form-control" name="amount" required value="{{ old('amount') ?? $purchasePayment->amount }}">
|
||||
<div class="input-group-append">
|
||||
<button id="getTotalAmount" class="btn btn-primary" type="button">
|
||||
<i class="bi bi-check-square"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="from-group">
|
||||
<div class="form-group">
|
||||
<label for="payment_method">Payment Method <span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="payment_method" id="payment_method" required>
|
||||
<option {{ $purchasePayment->payment_method == 'Cash' ? 'selected' : '' }} value="Cash">Cash</option>
|
||||
<option {{ $purchasePayment->payment_method == 'Credit Card' ? 'selected' : '' }} value="Credit Card">Credit Card</option>
|
||||
<option {{ $purchasePayment->payment_method == 'Bank Transfer' ? 'selected' : '' }} value="Bank Transfer">Bank Transfer</option>
|
||||
<option {{ $purchasePayment->payment_method == 'Cheque' ? 'selected' : '' }} value="Cheque">Cheque</option>
|
||||
<option {{ $purchasePayment->payment_method == 'Other' ? 'selected' : '' }} value="Other">Other</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="note">Note</label>
|
||||
<textarea class="form-control" rows="4" name="note">{{ old('note') ?? $purchasePayment->note }}</textarea>
|
||||
</div>
|
||||
|
||||
<input type="hidden" value="{{ $purchase->id }}" name="purchase_id">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script src="{{ asset('js/jquery-mask-money.js') }}"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#amount').maskMoney({
|
||||
prefix:'{{ settings()->currency->symbol }}',
|
||||
thousands:'{{ settings()->currency->thousand_separator }}',
|
||||
decimal:'{{ settings()->currency->decimal_separator }}',
|
||||
});
|
||||
|
||||
$('#amount').maskMoney('mask');
|
||||
|
||||
$('#getTotalAmount').click(function () {
|
||||
$('#amount').maskMoney('mask', {{ $purchase->due_amount }});
|
||||
});
|
||||
|
||||
$('#payment-form').submit(function () {
|
||||
var amount = $('#amount').maskMoney('unmasked')[0];
|
||||
$('#amount').val(amount);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('title', 'Purchase Payments')
|
||||
|
||||
@section('third_party_stylesheets')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/dataTables.bootstrap4.min.css">
|
||||
@endsection
|
||||
|
||||
@section('breadcrumb')
|
||||
<ol class="breadcrumb border-0 m-0">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('purchases.index') }}">Purchases</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('purchases.show', $purchase) }}">{{ $purchase->reference }}</a></li>
|
||||
<li class="breadcrumb-item active">Payments</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@include('utils.alerts')
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
{!! $dataTable->table() !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
{!! $dataTable->scripts() !!}
|
||||
@endpush
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
@can('access_sale_payments')
|
||||
<a href="{{ route('purchase-payments.edit', [$data->purchase->id, $data->id]) }}" class="btn btn-info btn-sm">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('access_sale_payments')
|
||||
<button id="delete" class="btn btn-danger btn-sm" onclick="
|
||||
event.preventDefault();
|
||||
if (confirm('Are you sure? It will delete the data permanently!')) {
|
||||
document.getElementById('destroy{{ $data->id }}').submit()
|
||||
}
|
||||
">
|
||||
<i class="bi bi-trash"></i>
|
||||
<form id="destroy{{ $data->id }}" class="d-none" action="{{ route('purchase-payments.destroy', $data->id) }}" method="POST">
|
||||
@csrf
|
||||
@method('delete')
|
||||
</form>
|
||||
</button>
|
||||
@endcan
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Purchase Details</title>
|
||||
<link rel="stylesheet" href="{{ public_path('b3/bootstrap.min.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div style="text-align: center;margin-bottom: 25px;">
|
||||
<img width="180" src="{{ public_path('images/logo-dark.png') }}" alt="Logo">
|
||||
<h4 style="margin-bottom: 20px;">
|
||||
<span>Reference::</span> <strong>{{ $purchase->reference }}</strong>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row mb-4">
|
||||
<div class="col-xs-4 mb-3 mb-md-0">
|
||||
<h4 class="mb-2" style="border-bottom: 1px solid #dddddd;padding-bottom: 10px;">Company Info:</h4>
|
||||
<div><strong>{{ settings()->company_name }}</strong></div>
|
||||
<div>{{ settings()->company_address }}</div>
|
||||
<div>Email: {{ settings()->company_email }}</div>
|
||||
<div>Phone: {{ settings()->company_phone }}</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-4 mb-3 mb-md-0">
|
||||
<h4 class="mb-2" style="border-bottom: 1px solid #dddddd;padding-bottom: 10px;">Supplier Info:</h4>
|
||||
<div><strong>{{ $supplier->supplier_name }}</strong></div>
|
||||
<div>{{ $supplier->address }}</div>
|
||||
<div>Email: {{ $supplier->supplier_email }}</div>
|
||||
<div>Phone: {{ $supplier->supplier_phone }}</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-4 mb-3 mb-md-0">
|
||||
<h4 class="mb-2" style="border-bottom: 1px solid #dddddd;padding-bottom: 10px;">Invoice Info:</h4>
|
||||
<div>Invoice: <strong>INV/{{ $purchase->reference }}</strong></div>
|
||||
<div>Date: {{ \Carbon\Carbon::parse($purchase->date)->format('d M, Y') }}</div>
|
||||
<div>
|
||||
Status: <strong>{{ $purchase->status }}</strong>
|
||||
</div>
|
||||
<div>
|
||||
Payment Status: <strong>{{ $purchase->payment_status }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="table-responsive-sm" style="margin-top: 30px;">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="align-middle">Product</th>
|
||||
<th class="align-middle">Net Unit Price</th>
|
||||
<th class="align-middle">Stock</th>
|
||||
<th class="align-middle">Quantity</th>
|
||||
<th class="align-middle">Discount</th>
|
||||
<th class="align-middle">Tax</th>
|
||||
<th class="align-middle">Sub Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($purchase->purchaseDetails as $item)
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
{{ $item->product_name }} <br>
|
||||
<span class="badge badge-success">
|
||||
{{ $item->product_code }}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td class="align-middle">{{ format_currency($item->unit_price) }}</td>
|
||||
|
||||
<td class="align-middle">
|
||||
<span class="badge badge-info">{{ $item->product->product_quantity }}</span>
|
||||
</td>
|
||||
|
||||
<td class="align-middle">
|
||||
{{ $item->quantity }}
|
||||
</td>
|
||||
|
||||
<td class="align-middle">
|
||||
{{ format_currency($item->product_discount_amount) }}
|
||||
</td>
|
||||
|
||||
<td class="align-middle">
|
||||
{{ format_currency($item->product_tax_amount) }}
|
||||
</td>
|
||||
|
||||
<td class="align-middle">
|
||||
{{ format_currency($item->sub_total) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-4 col-xs-offset-8">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="left"><strong>Discount ({{ $purchase->discount_percentage }}%)</strong></td>
|
||||
<td class="right">{{ format_currency($purchase->discount_amount) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left"><strong>Tax ({{ $purchase->tax_percentage }}%)</strong></td>
|
||||
<td class="right">{{ format_currency($purchase->tax_amount) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left"><strong>Shipping)</strong></td>
|
||||
<td class="right">{{ format_currency($purchase->shipping_amount) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left"><strong>Grand Total</strong></td>
|
||||
<td class="right"><strong>{{ format_currency($purchase->total_amount) }}</strong></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="margin-top: 25px;">
|
||||
<div class="col-xs-12">
|
||||
<p style="font-style: italic;text-align: center">Computer generated invoice. {{ settings()->company_name }} © {{ date('Y') }}.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('title', 'Purchases Details')
|
||||
|
||||
@section('breadcrumb')
|
||||
<ol class="breadcrumb border-0 m-0">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('purchases.index') }}">Purchases</a></li>
|
||||
<li class="breadcrumb-item active">Details</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header d-flex flex-wrap align-items-center">
|
||||
<div>
|
||||
Reference: <strong>{{ $purchase->reference }}</strong>
|
||||
</div>
|
||||
<a target="_blank" class="btn btn-sm btn-secondary mfs-auto mfe-1 d-print-none" href="{{ route('purchases.pdf', $purchase->id) }}">
|
||||
<i class="bi bi-printer"></i> Print
|
||||
</a>
|
||||
<a target="_blank" class="btn btn-sm btn-info mfe-1 d-print-none" href="{{ route('purchases.pdf', $purchase->id) }}">
|
||||
<i class="bi bi-save"></i> Save
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row mb-4">
|
||||
<div class="col-sm-4 mb-3 mb-md-0">
|
||||
<h5 class="mb-2 border-bottom pb-2">Company Info:</h5>
|
||||
<div><strong>{{ settings()->company_name }}</strong></div>
|
||||
<div>{{ settings()->company_address }}</div>
|
||||
<div>Email: {{ settings()->company_email }}</div>
|
||||
<div>Phone: {{ settings()->company_phone }}</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4 mb-3 mb-md-0">
|
||||
<h5 class="mb-2 border-bottom pb-2">Supplier Info:</h5>
|
||||
<div><strong>{{ $supplier->supplier_name }}</strong></div>
|
||||
<div>{{ $supplier->address }}</div>
|
||||
<div>Email: {{ $supplier->supplier_email }}</div>
|
||||
<div>Phone: {{ $supplier->supplier_phone }}</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4 mb-3 mb-md-0">
|
||||
<h5 class="mb-2 border-bottom pb-2">Invoice Info:</h5>
|
||||
<div>Invoice: <strong>INV/{{ $purchase->reference }}</strong></div>
|
||||
<div>Date: {{ \Carbon\Carbon::parse($purchase->date)->format('d M, Y') }}</div>
|
||||
<div>
|
||||
Status: <strong>{{ $purchase->status }}</strong>
|
||||
</div>
|
||||
<div>
|
||||
Payment Status: <strong>{{ $purchase->payment_status }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="table-responsive-sm">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="align-middle">Product</th>
|
||||
<th class="align-middle">Net Unit Price</th>
|
||||
<th class="align-middle">Stock</th>
|
||||
<th class="align-middle">Quantity</th>
|
||||
<th class="align-middle">Discount</th>
|
||||
<th class="align-middle">Tax</th>
|
||||
<th class="align-middle">Sub Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($purchase->purchaseDetails as $item)
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
{{ $item->product_name }} <br>
|
||||
<span class="badge badge-success">
|
||||
{{ $item->product_code }}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td class="align-middle">{{ format_currency($item->unit_price) }}</td>
|
||||
|
||||
<td class="align-middle">
|
||||
<span class="badge badge-info">{{ $item->product->product_quantity }}</span>
|
||||
</td>
|
||||
|
||||
<td class="align-middle">
|
||||
{{ $item->quantity }}
|
||||
</td>
|
||||
|
||||
<td class="align-middle">
|
||||
{{ format_currency($item->product_discount_amount) }}
|
||||
</td>
|
||||
|
||||
<td class="align-middle">
|
||||
{{ format_currency($item->product_tax_amount) }}
|
||||
</td>
|
||||
|
||||
<td class="align-middle">
|
||||
{{ format_currency($item->sub_total) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-4 col-sm-5 ml-md-auto">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="left"><strong>Discount ({{ $purchase->discount_percentage }}%)</strong></td>
|
||||
<td class="right">{{ format_currency($purchase->discount_amount) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left"><strong>Tax ({{ $purchase->tax_percentage }}%)</strong></td>
|
||||
<td class="right">{{ format_currency($purchase->tax_amount) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left"><strong>Shipping)</strong></td>
|
||||
<td class="right">{{ format_currency($purchase->shipping_amount) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left"><strong>Grand Total</strong></td>
|
||||
<td class="right"><strong>{{ format_currency($purchase->total_amount) }}</strong></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register API routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| is assigned the "api" middleware group. Enjoy building your API!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::middleware('auth:api')->get('/purchase', function (Request $request) {
|
||||
return $request->user();
|
||||
});
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register web routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| contains the "web" middleware group. Now create something great!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::group(['middleware' => 'auth'], function () {
|
||||
|
||||
//Generate PDF
|
||||
Route::get('/purchases/pdf/{id}', function ($id) {
|
||||
$purchase = \Modules\Purchase\Entities\Purchase::findOrFail($id);
|
||||
$supplier = \Modules\People\Entities\Supplier::findOrFail($purchase->supplier_id);
|
||||
|
||||
$pdf = \PDF::loadView('purchase::print', [
|
||||
'purchase' => $purchase,
|
||||
'supplier' => $supplier,
|
||||
])->setPaper('a4');
|
||||
|
||||
return $pdf->stream('purchase-'. $purchase->reference .'.pdf');
|
||||
})->name('purchases.pdf');
|
||||
|
||||
//Sales
|
||||
Route::resource('purchases', 'PurchaseController');
|
||||
|
||||
//Payments
|
||||
Route::get('/purchase-payments/{purchase_id}', 'PurchasePaymentsController@index')->name('purchase-payments.index');
|
||||
Route::get('/purchase-payments/{purchase_id}/create', 'PurchasePaymentsController@create')->name('purchase-payments.create');
|
||||
Route::post('/purchase-payments/store', 'PurchasePaymentsController@store')->name('purchase-payments.store');
|
||||
Route::get('/purchase-payments/{purchase_id}/edit/{purchasePayment}', 'PurchasePaymentsController@edit')->name('purchase-payments.edit');
|
||||
Route::patch('/purchase-payments/update/{purchasePayment}', 'PurchasePaymentsController@update')->name('purchase-payments.update');
|
||||
Route::delete('/purchase-payments/destroy/{purchasePayment}', 'PurchasePaymentsController@destroy')->name('purchase-payments.destroy');
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "nwidart/purchase",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Purchase\\": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "Purchase",
|
||||
"alias": "purchase",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\Purchase\\Providers\\PurchaseServiceProvider"
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
"requires": []
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "npm run development",
|
||||
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"watch-poll": "npm run watch -- --watch-poll",
|
||||
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"prod": "npm run production",
|
||||
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "^7.0",
|
||||
"laravel-mix": "^5.0.1",
|
||||
"laravel-mix-merge-manifest": "^0.1.2"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
const dotenvExpand = require('dotenv-expand');
|
||||
dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/}));
|
||||
|
||||
const mix = require('laravel-mix');
|
||||
require('laravel-mix-merge-manifest');
|
||||
|
||||
mix.setPublicPath('../../public').mergeManifest();
|
||||
|
||||
mix.js(__dirname + '/Resources/assets/js/app.js', 'js/purchase.js')
|
||||
.sass( __dirname + '/Resources/assets/sass/app.scss', 'css/purchase.css');
|
||||
|
||||
if (mix.inProduction()) {
|
||||
mix.version();
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
@can('delete_sales')
|
||||
<button id="delete" class="dropdown-item" onclick="
|
||||
event.preventDefault();
|
||||
if (confirm('Are you sure? It will delete the dNPata permanently!')) {
|
||||
if (confirm('Are you sure? It will delete the data permanently!')) {
|
||||
document.getElementById('destroy{{ $data->id }}').submit()
|
||||
}">
|
||||
<i class="bi bi-trash mr-2 text-danger" style="line-height: 1;"></i> Delete
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
@if ($data->status == 'Pending')
|
||||
d@if ($data->status == 'Pending')
|
||||
<span class="badge badge-info">
|
||||
{{ $data->status }}
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('title', 'Payments')
|
||||
@section('title', 'Sale Payments')
|
||||
|
||||
@section('third_party_stylesheets')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/dataTables.bootstrap4.min.css">
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ class PermissionsTableSeeder extends Seeder
|
|||
'show_sales',
|
||||
'edit_sales',
|
||||
'delete_sales',
|
||||
//Sale Payments
|
||||
'access_sale_payments',
|
||||
//Currencies
|
||||
'access_currencies',
|
||||
'create_currencies',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
|
||||
use Modules\Purchase\Entities\Purchase;
|
||||
use Yajra\DataTables\Html\Button;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use Yajra\DataTables\Html\Editor\Editor;
|
||||
use Yajra\DataTables\Html\Editor\Fields;
|
||||
use Yajra\DataTables\Services\DataTable;
|
||||
|
||||
class PurchaseDataTable extends DataTable
|
||||
{
|
||||
|
||||
public function dataTable($query) {
|
||||
return datatables()
|
||||
->eloquent($query)
|
||||
->addColumn('total_amount', function ($data) {
|
||||
return format_currency($data->total_amount);
|
||||
})
|
||||
->addColumn('paid_amount', function ($data) {
|
||||
return format_currency($data->paid_amount);
|
||||
})
|
||||
->addColumn('due_amount', function ($data) {
|
||||
return format_currency($data->due_amount);
|
||||
})
|
||||
->addColumn('status', function ($data) {
|
||||
return view('purchase::partials.status', compact('data'));
|
||||
})
|
||||
->addColumn('payment_status', function ($data) {
|
||||
return view('purchase::partials.payment-status', compact('data'));
|
||||
})
|
||||
->addColumn('action', function ($data) {
|
||||
return view('purchase::partials.actions', compact('data'));
|
||||
});
|
||||
}
|
||||
|
||||
public function query(Purchase $model) {
|
||||
return $model->newQuery();
|
||||
}
|
||||
|
||||
public function html() {
|
||||
return $this->builder()
|
||||
->setTableId('purchases-table')
|
||||
->columns($this->getColumns())
|
||||
->minifiedAjax()
|
||||
->dom("<'row'<'col-md-3'l><'col-md-5 mb-2'B><'col-md-4'f>> .
|
||||
'tr' .
|
||||
<'row'<'col-md-5'i><'col-md-7 mt-2'p>>")
|
||||
->orderBy(8)
|
||||
->buttons(
|
||||
Button::make('excel')
|
||||
->text('<i class="bi bi-file-earmark-excel-fill"></i> Excel'),
|
||||
Button::make('print')
|
||||
->text('<i class="bi bi-printer-fill"></i> Print'),
|
||||
Button::make('reset')
|
||||
->text('<i class="bi bi-x-circle"></i> Reset'),
|
||||
Button::make('reload')
|
||||
->text('<i class="bi bi-arrow-repeat"></i> Reload')
|
||||
);
|
||||
}
|
||||
|
||||
protected function getColumns() {
|
||||
return [
|
||||
Column::make('reference')
|
||||
->className('text-center align-middle'),
|
||||
|
||||
Column::make('supplier_name')
|
||||
->title('Supplier')
|
||||
->className('text-center align-middle'),
|
||||
|
||||
Column::computed('status')
|
||||
->className('text-center align-middle'),
|
||||
|
||||
Column::computed('total_amount')
|
||||
->className('text-center align-middle'),
|
||||
|
||||
Column::computed('paid_amount')
|
||||
->className('text-center align-middle'),
|
||||
|
||||
Column::computed('due_amount')
|
||||
->className('text-center align-middle'),
|
||||
|
||||
Column::computed('payment_status')
|
||||
->className('text-center align-middle'),
|
||||
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->className('text-center align-middle'),
|
||||
|
||||
Column::make('created_at')
|
||||
->visible(false)
|
||||
];
|
||||
}
|
||||
|
||||
protected function filename() {
|
||||
return 'Purchase_' . date('YmdHis');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
|
||||
use Modules\Purchase\Entities\PurchasePayment;
|
||||
use Yajra\DataTables\Html\Button;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use Yajra\DataTables\Html\Editor\Editor;
|
||||
use Yajra\DataTables\Html\Editor\Fields;
|
||||
use Yajra\DataTables\Services\DataTable;
|
||||
|
||||
class PurchasePaymentsDataTable extends DataTable
|
||||
{
|
||||
public function dataTable($query) {
|
||||
return datatables()
|
||||
->eloquent($query)
|
||||
->addColumn('amount', function ($data) {
|
||||
return format_currency($data->amount);
|
||||
})
|
||||
->addColumn('action', function ($data) {
|
||||
return view('purchase::payments.partials.actions', compact('data'));
|
||||
});
|
||||
}
|
||||
|
||||
public function query(PurchasePayment $model) {
|
||||
return $model->newQuery()->byPurchase()->with('purchase');
|
||||
}
|
||||
|
||||
public function html() {
|
||||
return $this->builder()
|
||||
->setTableId('purchase-payments-table')
|
||||
->columns($this->getColumns())
|
||||
->minifiedAjax()
|
||||
->dom("<'row'<'col-md-3'l><'col-md-5 mb-2'B><'col-md-4'f>> .
|
||||
'tr' .
|
||||
<'row'<'col-md-5'i><'col-md-7 mt-2'p>>")
|
||||
->orderBy(5)
|
||||
->buttons(
|
||||
Button::make('excel')
|
||||
->text('<i class="bi bi-file-earmark-excel-fill"></i> Excel'),
|
||||
Button::make('print')
|
||||
->text('<i class="bi bi-printer-fill"></i> Print'),
|
||||
Button::make('reset')
|
||||
->text('<i class="bi bi-x-circle"></i> Reset'),
|
||||
Button::make('reload')
|
||||
->text('<i class="bi bi-arrow-repeat"></i> Reload')
|
||||
);
|
||||
}
|
||||
|
||||
protected function getColumns() {
|
||||
return [
|
||||
Column::make('date')
|
||||
->className('align-middle text-center'),
|
||||
|
||||
Column::make('reference')
|
||||
->className('align-middle text-center'),
|
||||
|
||||
Column::computed('amount')
|
||||
->className('align-middle text-center'),
|
||||
|
||||
Column::make('payment_method')
|
||||
->className('align-middle text-center'),
|
||||
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->className('align-middle text-center'),
|
||||
|
||||
Column::make('created_at')
|
||||
->visible(false),
|
||||
];
|
||||
}
|
||||
|
||||
protected function filename() {
|
||||
return 'PurchasePayments_' . date('YmdHis');
|
||||
}
|
||||
}
|
||||
|
|
@ -7,5 +7,6 @@
|
|||
"People": true,
|
||||
"Currency": true,
|
||||
"Setting": true,
|
||||
"Sale": true
|
||||
"Sale": true,
|
||||
"Purchase": true
|
||||
}
|
||||
|
|
@ -62,6 +62,30 @@
|
|||
</li>
|
||||
@endcan
|
||||
|
||||
@can('access_purchases')
|
||||
<li class="c-sidebar-nav-item c-sidebar-nav-dropdown {{ request()->routeIs('purchases*') || request()->routeIs('purchase-payments*') ? 'c-show' : '' }}">
|
||||
<a class="c-sidebar-nav-link c-sidebar-nav-dropdown-toggle" href="#">
|
||||
<i class="c-sidebar-nav-icon bi bi-bag" style="line-height: 1;"></i> Purchases
|
||||
</a>
|
||||
@can('create_purchase')
|
||||
<ul class="c-sidebar-nav-dropdown-items">
|
||||
<li class="c-sidebar-nav-item">
|
||||
<a class="c-sidebar-nav-link {{ request()->routeIs('purchases.create') ? 'c-active' : '' }}" href="{{ route('purchases.create') }}">
|
||||
<i class="c-sidebar-nav-icon bi bi-journal-plus" style="line-height: 1;"></i> Create Purchase
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@endcan
|
||||
<ul class="c-sidebar-nav-dropdown-items">
|
||||
<li class="c-sidebar-nav-item">
|
||||
<a class="c-sidebar-nav-link {{ request()->routeIs('purchases.index') ? 'c-active' : '' }}" href="{{ route('purchases.index') }}">
|
||||
<i class="c-sidebar-nav-icon bi bi-journals" style="line-height: 1;"></i> All Purchases
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
@endcan
|
||||
|
||||
@can('access_sales')
|
||||
<li class="c-sidebar-nav-item c-sidebar-nav-dropdown {{ request()->routeIs('sales*') || request()->routeIs('sale-payments*') ? 'c-show' : '' }}">
|
||||
<a class="c-sidebar-nav-link c-sidebar-nav-dropdown-toggle" href="#">
|
||||
|
|
|
|||
|
|
@ -85,11 +85,11 @@
|
|||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Order Tax ({{ $global_tax }}%)</th>
|
||||
<td>(+) {{ format_currency(Cart::instance('sale')->tax()) }}</td>
|
||||
<td>(+) {{ format_currency(Cart::instance($cart_instance)->tax()) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Discount ({{ $global_discount }}%)</th>
|
||||
<td>(-) {{ format_currency(Cart::instance('sale')->discount()) }}</td>
|
||||
<td>(-) {{ format_currency(Cart::instance($cart_instance)->discount()) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Shipping</th>
|
||||
|
|
@ -99,7 +99,7 @@
|
|||
<tr>
|
||||
<th>Grand Total</th>
|
||||
@php
|
||||
$total_with_shipping = Cart::instance('sale')->total() + (float) $shipping
|
||||
$total_with_shipping = Cart::instance($cart_instance)->total() + (float) $shipping
|
||||
@endphp
|
||||
<th>
|
||||
(=) {{ format_currency($total_with_shipping) }}
|
||||
|
|
|
|||
Loading…
Reference in New Issue