mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-29 17:34:02 +00:00
Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into development
This commit is contained in:
@@ -64,7 +64,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$bookings = Booking::whereMonth('created_at', 9)
|
||||
$bookings = Booking::whereMonth('created_at', 10)
|
||||
->whereYear('created_at', 2021)
|
||||
->whereDoesntHave('transactions', function($q){
|
||||
$q->where('type', TransactionType::PURCHASE_ORDER);
|
||||
|
||||
@@ -30,14 +30,15 @@ class GeneratesPurchaseOrderProducts
|
||||
$amountDifference = $amount - $transaction->amount;
|
||||
$transactionDetails = $transaction->transactionDetails()->select('*', DB::raw('abs(price - '.abs($amountDifference).') as nearest_price'))->orderBy('nearest_price')->get();
|
||||
foreach ($transactionDetails as $product) {
|
||||
$units = floor(abs($amountDifference) / $product->price);
|
||||
$quantity = $product->quantity;
|
||||
|
||||
if($product->price <= 0){
|
||||
$amountDifference = $amountDifference + ($product->price * $product->quantity);
|
||||
continue;
|
||||
}
|
||||
|
||||
$units = floor(abs($amountDifference) / $product->price);
|
||||
$quantity = $product->quantity;
|
||||
|
||||
if($amountDifference > 0){
|
||||
$quantity = $product->quantity + $units;
|
||||
$amountDifference = $amountDifference - ($product->price * $units);
|
||||
|
||||
Reference in New Issue
Block a user