Updated credit max module

This commit is contained in:
Prashant Singh 2019-06-28 17:22:17 +05:30
parent b00374fa81
commit f6f06d7a40
1 changed files with 7 additions and 3 deletions

View File

@ -55,14 +55,18 @@ class Cart
return;
$baseGrandTotal = $this->orderRepository->scopeQuery(function ($query) {
return $query->where('orders.customer_id', $this->getCurrentCustomerGuard()->user()->id);
return $query
->where('orders.customer_id', '=', $this->getCurrentCustomerGuard()->user()->id)
->where('orders.status', '<>', 'canceled');
})->sum('base_grand_total');
$baseGrandTotalInvoiced = $this->orderRepository->scopeQuery(function ($query) {
return $query->where('orders.customer_id', $this->getCurrentCustomerGuard()->user()->id);
return $query
->where('orders.customer_id', $this->getCurrentCustomerGuard()->user()->id)
->where('orders.status', '<>', 'canceled');
})->sum('base_grand_total_invoiced');
if ( ($baseGrandTotal - $baseGrandTotalInvoiced) >= core()->getConfigData('customer.settings.credit_max.amount'))
if ( ($baseGrandTotal - $baseGrandTotalInvoiced) >= (core()->getConfigData('customer.settings.credit_max.amount') - ($baseGrandTotal - $baseGrandTotalInvoiced)))
throw new \Exception('You available credit limit has been exceeded. Please you pay your pending invoice.');
}
}