mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 12:24:09 +00:00
supplier do recalculate
This commit is contained in:
@@ -470,13 +470,30 @@ class InvoiceController extends Controller
|
||||
|
||||
$booking = Booking::where('id', $id)->first();
|
||||
$invoice = Invoice::where('booking_id', $booking['id'])->first();
|
||||
$lines = InvoiceDetails::where('invoice_id', $invoice->id)->get();
|
||||
$supplierbooking = SupplierBooking::where('booking_id', $id)->first();
|
||||
$lines = DB::table('invoices')
|
||||
->join('invoice_details', function ($join) use ($id) {
|
||||
$join->where('invoices.booking_id', '=', $id);
|
||||
$join->on('invoice_details.invoice_id', '=', 'invoices.id');
|
||||
})
|
||||
->join('supplier_bookings', 'invoices.booking_id', '=', 'supplier_bookings.booking_id')
|
||||
->select(
|
||||
'order',
|
||||
'stock_code',
|
||||
'description',
|
||||
'quantity',
|
||||
DB::raw('ROUND((invoice_details.unit_price_rmb / supplier_bookings.rate), 2) as unit_price_rm'),
|
||||
DB::raw('ROUND((invoice_details.quantity * ROUND((invoice_details.unit_price_rmb / supplier_bookings.rate), 2)), 2) as total'),
|
||||
// subtotal
|
||||
// adjustment
|
||||
// total
|
||||
)->get();
|
||||
$supplierbooking = SupplierBooking::where('booking_id', $id)->first();
|
||||
$supplier = SettingSupplier::where('id', $supplierbooking->supplier_id)->first();
|
||||
$subtotal = InvoiceDetails::where('invoice_id', $invoice->id)->sum('total');
|
||||
$adjustment = $invoice->adjustment;
|
||||
$billing_charges = $booking->billing_charge;
|
||||
$total = $subtotal + $adjustment + $billing_charges;
|
||||
$subtotal = $lines->sum('total');
|
||||
$billing_charges = null;
|
||||
$total = $supplierbooking->amount_after_tax;
|
||||
$adjustment = $total - $subtotal;
|
||||
|
||||
$data = [
|
||||
'title' => 'Delivery Order',
|
||||
|
||||
Reference in New Issue
Block a user