Added: Purchases Return Module
This commit is contained in:
parent
3f9ff85595
commit
f65d180d5e
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'PurchasesReturn'
|
||||
];
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreatePurchaseReturnsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('purchase_returns', 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('purchase_returns');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreatePurchaseReturnDetailsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('purchase_return_details', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('purchase_return_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_return_id')->references('id')
|
||||
->on('purchase_returns')->cascadeOnDelete();
|
||||
$table->foreign('product_id')->references('id')
|
||||
->on('products')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('purchase_return_details');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreatePurchaseReturnPaymentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('purchase_return_payments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('purchase_return_id');
|
||||
$table->integer('amount');
|
||||
$table->date('date');
|
||||
$table->string('reference');
|
||||
$table->string('payment_method');
|
||||
$table->text('note')->nullable();
|
||||
$table->foreign('purchase_return_id')->references('id')->on('purchase_returns')->cascadeOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('purchase_return_payments');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\PurchasesReturn\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PurchasesReturnDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
// $this->call("OthersTableSeeder");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\PurchasesReturn\Entities;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class PurchaseReturn extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function purchaseReturnDetails() {
|
||||
return $this->hasMany(PurchaseReturnDetail::class, 'purchase_return_id', 'id');
|
||||
}
|
||||
|
||||
public function purchaseReturnPayments() {
|
||||
return $this->hasMany(PurchaseReturnPayment::class, 'purchase_return_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\PurchasesReturn\Entities;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\Product\Entities\Product;
|
||||
|
||||
class PurchaseReturnDetail extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $with = ['product'];
|
||||
|
||||
public function product() {
|
||||
return $this->belongsTo(Product::class, 'product_id', 'id');
|
||||
}
|
||||
|
||||
public function purchaseReturn() {
|
||||
return $this->belongsTo(PurchaseReturn::class, 'purchase_return_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\PurchasesReturn\Entities;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class PurchaseReturnPayment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function purchaseReturn() {
|
||||
return $this->belongsTo(PurchaseReturn::class, 'purchase_return_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 scopeByPurchaseReturn($query) {
|
||||
return $query->where('purchase_return_id', request()->route('purchase_return_id'));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\PurchasesReturn\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class PurchaseReturnPaymentsController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('purchasesreturn::index');
|
||||
}
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('purchasesreturn::create');
|
||||
}
|
||||
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
return view('purchasesreturn::show');
|
||||
}
|
||||
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
return view('purchasesreturn::edit');
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,233 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\PurchasesReturn\Http\Controllers;
|
||||
|
||||
use App\DataTables\PurchaseReturnsDataTable;
|
||||
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\PurchasesReturn\Entities\PurchaseReturn;
|
||||
use Modules\PurchasesReturn\Entities\PurchaseReturnDetail;
|
||||
use Modules\PurchasesReturn\Entities\PurchaseReturnPayment;
|
||||
use Modules\PurchasesReturn\Http\Requests\StorePurchaseReturnRequest;
|
||||
use Modules\PurchasesReturn\Http\Requests\UpdatePurchaseReturnRequest;
|
||||
|
||||
class PurchasesReturnController extends Controller
|
||||
{
|
||||
|
||||
public function index(PurchaseReturnsDataTable $dataTable) {
|
||||
abort_if(Gate::denies('access_purchase_returns'), 403);
|
||||
|
||||
return $dataTable->render('purchasesreturn::index');
|
||||
}
|
||||
|
||||
|
||||
public function create() {
|
||||
abort_if(Gate::denies('create_purchase_returns'), 403);
|
||||
|
||||
Cart::instance('purchase_return')->destroy();
|
||||
|
||||
return view('purchasesreturn::create');
|
||||
}
|
||||
|
||||
|
||||
public function store(StorePurchaseReturnRequest $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_return = PurchaseReturn::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_return')->tax() * 100,
|
||||
'discount_amount' => Cart::instance('purchase_return')->discount() * 100,
|
||||
]);
|
||||
|
||||
foreach (Cart::instance('purchase_return')->content() as $cart_item) {
|
||||
PurchaseReturnDetail::create([
|
||||
'purchase_return_id' => $purchase_return->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 == 'Shipped' || $request->status == 'Completed') {
|
||||
$product = Product::findOrFail($cart_item->id);
|
||||
$product->update([
|
||||
'product_quantity' => $product->product_quantity - $cart_item->qty
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Cart::instance('purchase_return')->destroy();
|
||||
|
||||
PurchaseReturnPayment::create([
|
||||
'date' => $request->date,
|
||||
'reference' => 'INV/'.$purchase_return->reference,
|
||||
'amount' => $purchase_return->paid_amount,
|
||||
'purchase_return_id' => $purchase_return->id,
|
||||
'payment_method' => $request->payment_method
|
||||
]);
|
||||
});
|
||||
|
||||
toast('Purchase Return Created!', 'success');
|
||||
|
||||
return redirect()->route('purchase-returns.index');
|
||||
}
|
||||
|
||||
|
||||
public function show(PurchaseReturn $purchase_return) {
|
||||
abort_if(Gate::denies('show_purchase_returns'), 403);
|
||||
|
||||
$supplier = Supplier::findOrFail($purchase_return->supplier_id);
|
||||
|
||||
return view('purchasesreturn::show', compact('purchase_return', 'supplier'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(PurchaseReturn $purchase_return) {
|
||||
abort_if(Gate::denies('edit_purchase_returns'), 403);
|
||||
|
||||
$purchase_return_details = $purchase_return->purchaseReturnDetails;
|
||||
|
||||
Cart::instance('purchase_return')->destroy();
|
||||
|
||||
$cart = Cart::instance('purchase_return');
|
||||
|
||||
foreach ($purchase_return_details as $purchase_return_detail) {
|
||||
$cart->add([
|
||||
'id' => $purchase_return_detail->product_id,
|
||||
'name' => $purchase_return_detail->product_name,
|
||||
'qty' => $purchase_return_detail->quantity,
|
||||
'price' => $purchase_return_detail->price,
|
||||
'weight' => 1,
|
||||
'options' => [
|
||||
'product_discount' => $purchase_return_detail->product_discount_amount,
|
||||
'product_discount_type' => $purchase_return_detail->product_discount_type,
|
||||
'sub_total' => $purchase_return_detail->sub_total,
|
||||
'code' => $purchase_return_detail->product_code,
|
||||
'stock' => Product::findOrFail($purchase_return_detail->product_id)->product_quantity,
|
||||
'product_tax' => $purchase_return_detail->product_tax_amount,
|
||||
'unit_price' => $purchase_return_detail->unit_price
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
return view('purchasesreturn::edit', compact('purchase_return'));
|
||||
}
|
||||
|
||||
|
||||
public function update(UpdatePurchaseReturnRequest $request, PurchaseReturn $purchase_return) {
|
||||
DB::transaction(function () use ($request, $purchase_return) {
|
||||
$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_return->purchaseReturnDetails as $purchase_return_detail) {
|
||||
if ($purchase_return->status == 'Shipped' || $purchase_return->status == 'Completed') {
|
||||
$product = Product::findOrFail($purchase_return_detail->product_id);
|
||||
$product->update([
|
||||
'product_quantity' => $product->product_quantity + $purchase_return_detail->quantity
|
||||
]);
|
||||
}
|
||||
$purchase_return_detail->delete();
|
||||
}
|
||||
|
||||
$purchase_return->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_return')->tax() * 100,
|
||||
'discount_amount' => Cart::instance('purchase_return')->discount() * 100,
|
||||
]);
|
||||
|
||||
foreach (Cart::instance('purchase_return')->content() as $cart_item) {
|
||||
PurchaseReturnDetail::create([
|
||||
'purchase_return_id' => $purchase_return->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 == 'Shipped' || $request->status == 'Completed') {
|
||||
$product = Product::findOrFail($cart_item->id);
|
||||
$product->update([
|
||||
'product_quantity' => $product->product_quantity - $cart_item->qty
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Cart::instance('purchase_return')->destroy();
|
||||
});
|
||||
|
||||
toast('Purchase Return Updated!', 'info');
|
||||
|
||||
return redirect()->route('purchase-returns.index');
|
||||
}
|
||||
|
||||
|
||||
public function destroy(PurchaseReturn $purchase_return) {
|
||||
abort_if(Gate::denies('delete_purchase_returns'), 403);
|
||||
|
||||
$purchase_return->delete();
|
||||
|
||||
toast('Purchase Return Deleted!', 'warning');
|
||||
|
||||
return redirect()->route('purchase-returns.index');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\PurchasesReturn\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class StorePurchaseReturnRequest 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_purchase_returns');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\PurchasesReturn\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class UpdatePurchaseReturnRequest 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_return->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_purchase_returns');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\PurchasesReturn\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
|
||||
class PurchasesReturnServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* @var string $moduleName
|
||||
*/
|
||||
protected $moduleName = 'PurchasesReturn';
|
||||
|
||||
/**
|
||||
* @var string $moduleNameLower
|
||||
*/
|
||||
protected $moduleNameLower = 'purchasesreturn';
|
||||
|
||||
/**
|
||||
* 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\PurchasesReturn\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\PurchasesReturn\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('PurchasesReturn', '/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('PurchasesReturn', '/Routes/api.php'));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('title', 'Create Purchase Return')
|
||||
|
||||
@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('purchase-returns.index') }}">Purchase Returns</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-return-form" action="{{ route('purchase-returns.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="PRRN">
|
||||
</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_return'"/>
|
||||
|
||||
<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="Shipped">Shipped</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 Received <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 Return <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_return')->total() }});
|
||||
});
|
||||
|
||||
$('#purchase-return-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 Return')
|
||||
|
||||
@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('purchase-returns.index') }}">Purchase Returns</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-return-form" action="{{ route('purchase-returns.update', $purchase_return) }}" 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="PRRN" 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_return->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_return->date }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<livewire:product-cart :cartInstance="'purchase_return'" :data="$purchase_return"/>
|
||||
|
||||
<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_return->status == 'Pending' ? 'selected' : '' }} value="Pending">Pending</option>
|
||||
<option {{ $purchase_return->status == 'Shipped' ? 'selected' : '' }} value="Shipped">Shipped</option>
|
||||
<option {{ $purchase_return->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_return->payment_method }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="paid_amount">Amount Paid <span class="text-danger">*</span></label>
|
||||
<input id="paid_amount" type="text" class="form-control" name="paid_amount" required value="{{ $purchase_return->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_return->note }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Update Purchase Return <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-return-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', 'Purchase Returns')
|
||||
|
||||
@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">Purchase Returns</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('purchase-returns.create') }}" class="btn btn-primary">
|
||||
Add Purchase Return <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_return_payments')
|
||||
<a href="{{ route('purchase-return-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_return_payments')
|
||||
@if($data->due_amount > 0)
|
||||
<a href="{{ route('purchase-return-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_purchase_returns')
|
||||
<a href="{{ route('purchase-returns.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_purchase_returns')
|
||||
<a href="{{ route('purchase-returns.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_purchase_return')
|
||||
<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('purchase-returns.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 == 'Shipped')
|
||||
<span class="badge badge-primary">
|
||||
{{ $data->status }}
|
||||
</span>
|
||||
@else
|
||||
<span class="badge badge-success">
|
||||
{{ $data->status }}
|
||||
</span>
|
||||
@endif
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
@can('access_purchase_return_payments')
|
||||
<a href="{{ route('purchase-return-payments.edit', [$data->purchaseReturn->id, $data->id]) }}" class="btn btn-info btn-sm">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('access_purchase_return_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-return-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 Return 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_return->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_return->reference }}</strong></div>
|
||||
<div>Date: {{ \Carbon\Carbon::parse($purchase_return->date)->format('d M, Y') }}</div>
|
||||
<div>
|
||||
Status: <strong>{{ $purchase_return->status }}</strong>
|
||||
</div>
|
||||
<div>
|
||||
Payment Status: <strong>{{ $purchase_return->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_return->purchaseReturnDetails 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_return->discount_percentage }}%)</strong></td>
|
||||
<td class="right">{{ format_currency($purchase_return->discount_amount) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left"><strong>Tax ({{ $purchase_return->tax_percentage }}%)</strong></td>
|
||||
<td class="right">{{ format_currency($purchase_return->tax_amount) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left"><strong>Shipping)</strong></td>
|
||||
<td class="right">{{ format_currency($purchase_return->shipping_amount) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left"><strong>Grand Total</strong></td>
|
||||
<td class="right"><strong>{{ format_currency($purchase_return->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', 'Purchase 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('purchase-returns.index') }}">Purchase Returns</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_return->reference }}</strong>
|
||||
</div>
|
||||
<a target="_blank" class="btn btn-sm btn-secondary mfs-auto mfe-1 d-print-none" href="{{ route('purchase-returns.pdf', $purchase_return->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('purchase-returns.pdf', $purchase_return->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_return->reference }}</strong></div>
|
||||
<div>Date: {{ \Carbon\Carbon::parse($purchase_return->date)->format('d M, Y') }}</div>
|
||||
<div>
|
||||
Status: <strong>{{ $purchase_return->status }}</strong>
|
||||
</div>
|
||||
<div>
|
||||
Payment Status: <strong>{{ $purchase_return->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_return->purchaseReturnDetails 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_return->discount_percentage }}%)</strong></td>
|
||||
<td class="right">{{ format_currency($purchase_return->discount_amount) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left"><strong>Tax ({{ $purchase_return->tax_percentage }}%)</strong></td>
|
||||
<td class="right">{{ format_currency($purchase_return->tax_amount) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left"><strong>Shipping)</strong></td>
|
||||
<td class="right">{{ format_currency($purchase_return->shipping_amount) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left"><strong>Grand Total</strong></td>
|
||||
<td class="right"><strong>{{ format_currency($purchase_return->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('/purchasesreturn', function (Request $request) {
|
||||
return $request->user();
|
||||
});
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?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('/purchase-returns/pdf/{id}', function ($id) {
|
||||
$purchaseReturn = \Modules\PurchasesReturn\Entities\PurchaseReturn::findOrFail($id);
|
||||
$supplier = \Modules\People\Entities\Supplier::findOrFail($purchaseReturn->supplier_id);
|
||||
|
||||
$pdf = \PDF::loadView('purchasesreturn::print', [
|
||||
'purchase_return' => $purchaseReturn,
|
||||
'supplier' => $supplier,
|
||||
])->setPaper('a4');
|
||||
|
||||
return $pdf->stream('purchase-return-'. $purchaseReturn->reference .'.pdf');
|
||||
})->name('purchase-returns.pdf');
|
||||
|
||||
//Purchase Returns
|
||||
Route::resource('purchase-returns', 'PurchasesReturnController');
|
||||
|
||||
//Payments
|
||||
Route::get('/purchase-return-payments/{purchase_return_id}', 'PurchaseReturnPaymentsController@index')
|
||||
->name('purchase-return-payments.index');
|
||||
Route::get('/purchase-return-payments/{purchase_return_id}/create', 'PurchaseReturnPaymentsController@create')
|
||||
->name('purchase-return-payments.create');
|
||||
Route::post('/purchase-return-payments/store', 'PurchaseReturnPaymentsController@store')
|
||||
->name('purchase-return-payments.store');
|
||||
Route::get('/purchase-return-payments/{purchase_return_id}/edit/{purchaseReturnPayment}', 'PurchaseReturnPaymentsController@edit')
|
||||
->name('purchase-return-payments.edit');
|
||||
Route::patch('/purchase-return-payments/update/{purchaseReturnPayment}', 'PurchaseReturnPaymentsController@update')
|
||||
->name('purchase-return-payments.update');
|
||||
Route::delete('/purchase-return-payments/destroy/{purchaseReturnPayment}', 'PurchaseReturnPaymentsController@destroy')
|
||||
->name('purchase-return-payments.destroy');
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "nwidart/purchasesreturn",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\PurchasesReturn\\": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "PurchasesReturn",
|
||||
"alias": "purchasesreturn",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\PurchasesReturn\\Providers\\PurchasesReturnServiceProvider"
|
||||
],
|
||||
"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/purchasesreturn.js')
|
||||
.sass( __dirname + '/Resources/assets/sass/app.scss', 'css/purchasesreturn.css');
|
||||
|
||||
if (mix.inProduction()) {
|
||||
mix.version();
|
||||
}
|
||||
|
|
@ -152,6 +152,7 @@ class SaleController extends Controller
|
|||
DB::transaction(function () use ($request, $sale) {
|
||||
|
||||
$due_amount = $request->total_amount - $request->paid_amount;
|
||||
|
||||
if ($due_amount == $request->total_amount) {
|
||||
$payment_status = 'Unpaid';
|
||||
} elseif ($due_amount > 0) {
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class SalesReturnController extends Controller
|
|||
|
||||
|
||||
public function edit(SaleReturn $sale_return) {
|
||||
abort_if(Gate::denies('edit_sales'), 403);
|
||||
abort_if(Gate::denies('edit_sale_returns'), 403);
|
||||
|
||||
$sale_return_details = $sale_return->saleReturnDetails;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,6 @@ class StoreSaleReturnRequest extends FormRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return Gate::allows('create_sales');
|
||||
return Gate::allows('create_sale_returns');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,14 @@ class PermissionsTableSeeder extends Seeder
|
|||
'delete_sales',
|
||||
//Sale Payments
|
||||
'access_sale_payments',
|
||||
//Sale Returns
|
||||
'access_sale_returns',
|
||||
'create_sale_returns',
|
||||
'show_sale_returns',
|
||||
'edit_sale_returns',
|
||||
'delete_sale_returns',
|
||||
//Sale Return Payments
|
||||
'access_sale_return_payments',
|
||||
//Purchases
|
||||
'access_purchases',
|
||||
'create_purchases',
|
||||
|
|
@ -68,6 +76,14 @@ class PermissionsTableSeeder extends Seeder
|
|||
'delete_purchases',
|
||||
//Purchase Payments
|
||||
'access_purchase_payments',
|
||||
//Sale Returns
|
||||
'access_purchase_returns',
|
||||
'create_purchase_returns',
|
||||
'show_purchase_returns',
|
||||
'edit_purchase_returns',
|
||||
'delete_purchase_returns',
|
||||
//Sale Return Payments
|
||||
'access_purchase_return_payments',
|
||||
//Currencies
|
||||
'access_currencies',
|
||||
'create_currencies',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
|
||||
use Modules\PurchasesReturn\Entities\PurchaseReturnPayment;
|
||||
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 PurchaseReturnPaymentsDataTable 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('purchasesreturn::payments.partials.actions', compact('data'));
|
||||
});
|
||||
}
|
||||
|
||||
public function query(PurchaseReturnPayment $model) {
|
||||
return $model->newQuery()->byPurchaseReturn()->with('purchaseReturn');
|
||||
}
|
||||
|
||||
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 'PurchaseReturnPayments_' . date('YmdHis');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
|
||||
use Modules\PurchasesReturn\Entities\PurchaseReturn;
|
||||
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 PurchaseReturnsDataTable 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('purchasesreturn::partials.status', compact('data'));
|
||||
})
|
||||
->addColumn('payment_status', function ($data) {
|
||||
return view('purchasesreturn::partials.payment-status', compact('data'));
|
||||
})
|
||||
->addColumn('action', function ($data) {
|
||||
return view('purchasesreturn::partials.actions', compact('data'));
|
||||
});
|
||||
}
|
||||
|
||||
public function query(PurchaseReturn $model) {
|
||||
return $model->newQuery();
|
||||
}
|
||||
|
||||
public function html() {
|
||||
return $this->builder()
|
||||
->setTableId('purchase-returns-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 'PurchaseReturns_' . date('YmdHis');
|
||||
}
|
||||
}
|
||||
|
|
@ -10,5 +10,6 @@
|
|||
"Sale": true,
|
||||
"Purchase": true,
|
||||
"SaleReturn": true,
|
||||
"SalesReturn": true
|
||||
"SalesReturn": true,
|
||||
"PurchasesReturn": true
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
@can('access_adjustments')
|
||||
<li class="c-sidebar-nav-item c-sidebar-nav-dropdown {{ request()->routeIs('adjustments.*') ? 'c-show' : '' }}">
|
||||
<a class="c-sidebar-nav-link c-sidebar-nav-dropdown-toggle" href="#">
|
||||
<i class="c-sidebar-nav-icon bi bi-pencil-square" style="line-height: 1;"></i> Adjustments
|
||||
<i class="c-sidebar-nav-icon bi bi-clipboard-check" style="line-height: 1;"></i> Adjustments
|
||||
</a>
|
||||
<ul class="c-sidebar-nav-dropdown-items">
|
||||
@can('create_adjustments')
|
||||
|
|
@ -86,6 +86,30 @@
|
|||
</li>
|
||||
@endcan
|
||||
|
||||
@can('access_purchase_returns')
|
||||
<li class="c-sidebar-nav-item c-sidebar-nav-dropdown {{ request()->routeIs('purchase-returns*') || request()->routeIs('purchase-return-payments*') ? 'c-show' : '' }}">
|
||||
<a class="c-sidebar-nav-link c-sidebar-nav-dropdown-toggle" href="#">
|
||||
<i class="c-sidebar-nav-icon bi bi-arrow-return-right" style="line-height: 1;"></i> Purchase Returns
|
||||
</a>
|
||||
@can('create_purchase_returns')
|
||||
<ul class="c-sidebar-nav-dropdown-items">
|
||||
<li class="c-sidebar-nav-item">
|
||||
<a class="c-sidebar-nav-link {{ request()->routeIs('purchase-returns.create') ? 'c-active' : '' }}" href="{{ route('purchase-returns.create') }}">
|
||||
<i class="c-sidebar-nav-icon bi bi-journal-plus" style="line-height: 1;"></i> Create Purchase Return
|
||||
</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('purchase-returns.index') ? 'c-active' : '' }}" href="{{ route('purchase-returns.index') }}">
|
||||
<i class="c-sidebar-nav-icon bi bi-journals" style="line-height: 1;"></i> All Purchase Returns
|
||||
</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="#">
|
||||
|
|
|
|||
Loading…
Reference in New Issue