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(); $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();

View File

@ -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');
} }
} }