fix item reports issue

This commit is contained in:
Mohit Panjwani
2019-11-23 11:54:35 +05:30
parent 2ad39bfbd6
commit 06807275b9
2 changed files with 4 additions and 4 deletions

View File

@ -83,8 +83,7 @@ class ReportController extends Controller
{
$company = Company::where('unique_hash', $hash)->first();
$items = InvoiceItem::with('item')
->whereCompany($company->id)
$items = InvoiceItem::whereCompany($company->id)
->applyInvoiceFilters($request->only(['from_date', 'to_date']))
->itemAttributes()
->get();

View File

@ -78,7 +78,8 @@ class InvoiceItem extends Model
public function scopeItemAttributes($query)
{
$query->select(
DB::raw('sum(quantity) as total_quantity, sum(total) as total_amount, item_id')
)->groupBy('item_id');
DB::raw('sum(quantity) as total_quantity, sum(total) as total_amount, invoice_items.name')
)->groupBy('invoice_items.name');
}
}