mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 12:11:08 -04:00
fix item reports issue
This commit is contained in:
@ -83,8 +83,7 @@ class ReportController extends Controller
|
|||||||
{
|
{
|
||||||
$company = Company::where('unique_hash', $hash)->first();
|
$company = Company::where('unique_hash', $hash)->first();
|
||||||
|
|
||||||
$items = InvoiceItem::with('item')
|
$items = InvoiceItem::whereCompany($company->id)
|
||||||
->whereCompany($company->id)
|
|
||||||
->applyInvoiceFilters($request->only(['from_date', 'to_date']))
|
->applyInvoiceFilters($request->only(['from_date', 'to_date']))
|
||||||
->itemAttributes()
|
->itemAttributes()
|
||||||
->get();
|
->get();
|
||||||
|
|||||||
@ -78,7 +78,8 @@ class InvoiceItem extends Model
|
|||||||
public function scopeItemAttributes($query)
|
public function scopeItemAttributes($query)
|
||||||
{
|
{
|
||||||
$query->select(
|
$query->select(
|
||||||
DB::raw('sum(quantity) as total_quantity, sum(total) as total_amount, item_id')
|
DB::raw('sum(quantity) as total_quantity, sum(total) as total_amount, invoice_items.name')
|
||||||
)->groupBy('item_id');
|
)->groupBy('invoice_items.name');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user