Unverified Commit 882d4b52 authored by Wijdan Arif's avatar Wijdan Arif Committed by GitHub
Browse files

Merge pull request #319 from arneyva/dev-eth

fixing transfer
No related merge requests found
Showing with 124 additions and 23 deletions
+124 -23
......@@ -380,7 +380,96 @@ public function Avilable_Products_by_Warehouse(request $request, $id)
return response()->json($data);
}
public function Sale_Avilable_Products_by_Warehouse(request $request, $id)
{
$data = []; //menyimpan data array
$product_warehouse_data = ProductWarehouse::with('warehouse', 'product', 'productVariant')
->where(function ($query) use ($request, $id) {
return $query->where('warehouse_id', $id)
->where('deleted_at', '=', null)
->where(function ($query) use ($request) {
return $query->whereHas('product', function ($q) use ($request) {
if ($request->is_sale == '1') {
$q->where('not_selling', '=', 0);
}
});
}) // mencari data product warehouse berdasarkan yang sudah dipilih di dropdown warehouse sebelumnya
->where('qty', '>=', 1);
})->get();
foreach ($product_warehouse_data as $product_warehouse) { //araay setelah dapat data product warehouse
if ($product_warehouse->product_variant_id) { //jika memiliki data product_variant_id
$item['product_variant_id'] = $product_warehouse->product_variant_id;
$item['code'] = $product_warehouse['productVariant']->code; //code ngambil dari relasi productVariant
$item['Variant'] = '[' . $product_warehouse['productVariant']->name . ']' . $product_warehouse['product']->name; //code ngambil dari relasi productVariant
$item['name'] = '[' . $product_warehouse['productVariant']->name . ']' . $product_warehouse['product']->name; //code ngambil dari relasi productVariant
$item['barcode'] = $product_warehouse['productVariant']->code; //code ngambil dari relasi productVariant
$product_price = $product_warehouse['productVariant']->price; //code ngambil dari relasi productVariant
} else { //jika tidak memiliki data product_variant_id
$item['product_variant_id'] = null;
$item['Variant'] = null;
$item['code'] = $product_warehouse['product']->code;
$item['name'] = $product_warehouse['product']->name;
$item['barcode'] = $product_warehouse['product']->code;
$product_price = $product_warehouse['product']->price;
}
$item['id'] = $product_warehouse->product_id;
$item['product_type'] = $product_warehouse['product']->type;
$item['Type_barcode'] = $product_warehouse['product']->Type_barcode;
$firstimage = explode(',', $product_warehouse['product']->image);
$item['image'] = $firstimage[0];
if ($product_warehouse['product']['unitSale']) {
if ($product_warehouse['product']['unitSale']->operator == '/') {
$item['qty_sale'] = $product_warehouse->qty * $product_warehouse['product']['unitSale']->operator_value;
$price = $product_price / $product_warehouse['product']['unitSale']->operator_value;
} else {
$item['qty_sale'] = $product_warehouse->qty / $product_warehouse['product']['unitSale']->operator_value;
$price = $product_price * $product_warehouse['product']['unitSale']->operator_value;
}
} else {
$item['qty_sale'] = $product_warehouse['product']->type != 'is_service' ? $product_warehouse->qty : '---';
$price = $product_price;
}
if ($product_warehouse['product']['unitPurchase']) { //memeriksa apakah ada informasi tentang penjualan unit untuk produk di gudang.
if ($product_warehouse['product']['unitPurchase']->operator == '/') {
$item['qty_purchase'] = round($product_warehouse->qty * $product_warehouse['product']['unitPurchase']->operator_value, 5);
} else {
$item['qty_purchase'] = round($product_warehouse->qty / $product_warehouse['product']['unitPurchase']->operator_value, 5);
}
} else {
$item['qty_purchase'] = $product_warehouse->qty;
}
$item['manage_stock'] = $product_warehouse->manage_stock;
$item['qty'] = $product_warehouse['product']->type != 'is_service' ? $product_warehouse->qty : '---';
$item['unitSale'] = $product_warehouse['product']['unitSale'] ? $product_warehouse['product']['unitSale']->ShortName : '';
$item['unitPurchase'] = $product_warehouse['product']['unitPurchase'] ? $product_warehouse['product']['unitPurchase']->ShortName : '';
if ($product_warehouse['product']->TaxNet !== 0.0) {
//Exclusive
if ($product_warehouse['product']->tax_method == '1') {
$tax_price = $price * $product_warehouse['product']->TaxNet / 100;
$item['Net_price'] = $price + $tax_price;
// Inxclusive
} else {
$item['Net_price'] = $price;
}
} else {
$item['Net_price'] = $price;
}
$data[] = $item;
}
return response()->json($data);
}
public function show_product_data($id, $variant_id, $warehouse_id)
{
......
......@@ -356,6 +356,12 @@ public function edit(Request $request, $id)
if ($detail->purchase_unit_id !== null) {
$unit = Unit::where('id', $detail->purchase_unit_id)->first();
$data['no_unit'] = 1;
if ($unit->operator == '/') {
// $item['qty_product_purchase'] = floor($stock->qty * $Product_data['unitPurchase']->operator_value);
} else {
// $item['qty_product_purchase'] = floor($stock->qty / $Product_data['unitPurchase']->operator_value);
$data['unitPurchaseOperatorValue'] = $unit['operator_value'];
}
} else {
$product_unit_purchase_id = Product::with('unitPurchase')
->where('id', $detail->product_id)
......@@ -436,7 +442,8 @@ public function edit(Request $request, $id)
$data['purchase_unit_id'] = $unit->id;
$data['total'] = $detail->total;
$data['quantity_discount'] = $quantity_discount;
$data['quantity_discount_init'] = $quantity_discount / $data['stock_sale'];
$data['quantity_discount_init'] = $quantity_discount / $data['unitPurchaseOperatorValue'];
// $data['quantity_discount_init'] = $detail->discount;
$data['discount_percentage'] = $discount_percentage;
// $data['total'] = $detail->total;
......@@ -730,6 +737,7 @@ public function update(Request $request, $id)
$TransDetail['product_variant_id'] = $product_detail['product_variant_id'];
$TransDetail['cost'] = $product_detail['Unit_cost'];
$TransDetail['TaxNet'] = $product_detail['tax_percent'];
$TransDetail['tax_method'] = 'Exclusive';
$TransDetail['total'] = $product_detail['subtotal'];
$TransDetail['discount'] = $product_detail['discount'] ? $product_detail['discount'] : 0;
$TransDetail['discount_method'] = $product_detail['discount_method'] ? $product_detail['discount_method'] : 0;
......
{
"Add Adjustment": "Tambahkan Penyesuaian",
"Adjustment": "Penyesuaian",
"Do Something with all your adjustment": "Lakukan Sesuatu dengan Semua Adjustment Anda",
"Do Something with all your adjustment": "Lakukan Sesuatu dengan Semua Penyesuaian Anda",
"Do Something with your Product": "Lakukan Sesuatu dengan Produk Anda",
"Create Adjustment": "Buat Penyesuaian",
"Warehouse/Outlet": "Gudang/Outlet",
......
......@@ -242,8 +242,9 @@
row += '<td>' + 'New Data' + '</td>';
row += '<td>' + data.qty + ' ' + data.unit + '</td>';
row +=
'<td><input type="number" class="form-control" name="details[new-' +
newIndex + '][quantity]" value="0" min="0"></td>';
'<td><input type="number" class="form-control item-quantity" name="details[new-' +
newIndex + '][quantity]" value="' + initialQuantity +
'" data-min-quantity="1"></td>';
row += '<td><select class="form-select" name="details[new-' +
newIndex +
'][type]"><option value="add">Add</option><option value="sub">Subtract</option></select></td>';
......
......@@ -24,13 +24,14 @@
<h4 class="card-title">{{ __('All Adjustment') }}</h4>
</div>
<div class="header-title">
<button type="button" class="btn btn-soft-primary" data-bs-toggle="modal"
<button type="button" class="btn btn-soft-warning" data-bs-toggle="modal"
data-bs-target="#createModal">{{ __('Filter') }}</button>
<a href="{{ route('adjustment.pdf', request()->query()) }}"
class="btn btn-soft-success">{{ __('PDF') }}</a>
<a href="{{ route('adjustment.export', request()->query()) }}"
class="btn btn-soft-danger">{{ __('Excel') }}</a>
<button type="button" class="btn btn-soft-gray">{{ __('Import Product') }}</button>
@role('superadmin|inventaris')
<a href="{{ route('adjustment.pdf', request()->query()) }}"
class="btn btn-soft-success">{{ __('PDF') }}</a>
<a href="{{ route('adjustment.export', request()->query()) }}"
class="btn btn-soft-danger">{{ __('Excel') }}</a>
@endrole
<a href="{{ route('adjustment.create') }}" class="btn btn-soft-primary">{{ __('+create') }}</a>
<div class="modal fade" id="createModal" tabindex="-1" aria-labelledby="createModalLabel"
aria-hidden="true">
......@@ -129,8 +130,7 @@ class="btn btn-soft-danger">{{ __('Excel') }}</a>
<circle cx="12" cy="12" r="3" fill="#130F26">
</circle>
</mask>
<circle opacity="0.89" cx="13.5" cy="10.5" r="1.5"
fill="white">
<circle opacity="0.89" cx="13.5" cy="10.5" r="1.5" fill="white">
</circle>
</svg>
<div class="modal fade" id="detailModal{{ $item['id'] }}" tabindex="-1"
......
......@@ -498,7 +498,7 @@ function formatRupiah(number) {
var warehouseId = $(this).val();
if (warehouseId) {
$.ajax({
url: '/adjustment/get_Available_Products_by_warehouse/' + warehouseId,
url: '/adjustment/Sale_get_Available_Products_by_warehouse/' + warehouseId,
type: "GET",
dataType: "json",
success: function(data) {
......
......@@ -81,7 +81,7 @@
<tr>
<th>#</th>
<th>{{ __('Product') }}</th>
<th>{{ __('Purchase') }} {{ __('Cost') }}</th>
<th>{{ __('Purchases') }} {{ __('Cost') }}</th>
<th>{{ __('Stock') }}</th>
<th>{{ __('Quantity') }}</th>
<th>{{ __('Discount') }}</th>
......
......@@ -487,14 +487,14 @@ function formatRupiah(number) {
'][tax_method]" value="' + data.tax_method + '">';
row +=
'<input type="hidden" class="item-subtotal" name="details[new-' +
newIndex + '][subtotal]" value="' + formattedInitialTotal +
newIndex + '][subtotal]" value="' + initialTotal +
'">';
row +=
'<input type="hidden" class="item-subdiscount" name="details[new-' +
newIndex + '][discount]" value="0">';
row +=
'<input type="hidden" class="item-subdiscountmethod" name="details[new-' +
newIndex + '][discount_method]" value="0">';
newIndex + '][discount_method]" value="nodiscount">';
row += '<input type="hidden" name="details[new-' + newIndex +
'][quantity_discount]" value="' + data.
quantity_discount_purchase +
......@@ -519,7 +519,7 @@ function formatRupiah(number) {
function loadProductsByWarehouse(warehouseId) {
if (warehouseId) {
$.ajax({
url: '/adjustment/get_Products_by_warehouse/' + warehouseId,
url: '/adjustment/get_Available_Products_by_warehouse/' + warehouseId,
type: "GET",
dataType: "json",
success: function(data) {
......
......@@ -25,12 +25,14 @@
</h4>
</div>
<div class="header-title">
<button type="button" class="btn btn-soft-primary" data-bs-toggle="modal"
<button type="button" class="btn btn-soft-warning" data-bs-toggle="modal"
data-bs-target="#createModal">{{ __('Filter') }}</button>
<a href="{{ route('transfer.pdf', request()->query()) }}" class="btn btn-soft-success">PDF</a>
<a href="{{ route('transfer.export', request()->query()) }}" class="btn btn-soft-danger">Excel</a>
<a href="{{ route('transfer.create') }}"><button type="button"
class="btn btn-soft-primary">{{ __('Create +') }}</button></a>
@role('superadmin|inventaris')
<a href="{{ route('transfer.pdf', request()->query()) }}" class="btn btn-soft-success">PDF</a>
<a href="{{ route('transfer.export', request()->query()) }}" class="btn btn-soft-danger">Excel</a>
<a href="{{ route('transfer.create') }}"><button type="button"
class="btn btn-soft-primary">{{ __('Create +') }}</button></a>
@endrole
<div class="modal fade" id="createModal" tabindex="-1" aria-labelledby="createModalLabel"
aria-hidden="true">
<div class="modal-dialog">
......
......@@ -118,6 +118,7 @@
//
Route::get('get_Products_by_warehouse/{id}', [AdjustmentController::class, 'Products_by_Warehouse'])->name('get_Warehouses');
Route::get('get_Available_Products_by_warehouse/{id}', [AdjustmentController::class, 'Avilable_Products_by_Warehouse'])->name('get_Available_Warehouses');
Route::get('Sale_get_Available_Products_by_warehouse/{id}', [AdjustmentController::class, 'Sale_Avilable_Products_by_Warehouse'])->name('Sale_get_Available_Warehouses');
Route::get('show_product_data/{id}/{variant_id}/{warehouse_id}', [AdjustmentController::class, 'show_product_data']);
//
Route::get('export', [AdjustmentController::class, 'export'])->name('export');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment