fixed - No query results for model [Crater\Models\Currency] (#1070)

* fixed report pdf issue

* Removed telescope service provider file
This commit is contained in:
Dhruv Bhatt
2022-10-26 19:33:25 +05:30
committed by GitHub
parent d8c429912e
commit 4e47f58bad
10 changed files with 169 additions and 157 deletions

View File

@ -2,24 +2,25 @@
namespace Crater\Http\Controllers\V1\Admin\Report;
use PDF;
use Carbon\Carbon;
use Crater\Http\Controllers\Controller;
use Crater\Models\Company;
use Crater\Models\CompanySetting;
use Crater\Models\Currency;
use Crater\Models\Customer;
use Illuminate\Http\Request;
use Crater\Models\CompanySetting;
use Illuminate\Support\Facades\App;
use PDF;
use Crater\Http\Controllers\Controller;
class CustomerSalesReportController extends Controller
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param string $hash
* @return \Illuminate\Http\JsonResponse
*/
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param string $hash
* @return \Illuminate\Http\JsonResponse
*/
public function __invoke(Request $request, $hash)
{
$company = Company::where('unique_hash', $hash)->first();
@ -56,6 +57,7 @@ class CustomerSalesReportController extends Controller
$dateFormat = CompanySetting::getSetting('carbon_date_format', $company->id);
$from_date = Carbon::createFromFormat('Y-m-d', $request->from_date)->format($dateFormat);
$to_date = Carbon::createFromFormat('Y-m-d', $request->to_date)->format($dateFormat);
$currency = Currency::findOrFail(CompanySetting::getSetting('currency', $company->id));
$colors = [
'primary_text_color',
@ -80,6 +82,7 @@ class CustomerSalesReportController extends Controller
'company' => $company,
'from_date' => $from_date,
'to_date' => $to_date,
'currency' => $currency,
]);
$pdf = PDF::loadView('app.pdf.reports.sales-customers');

View File

@ -2,24 +2,25 @@
namespace Crater\Http\Controllers\V1\Admin\Report;
use Carbon\Carbon;
use Crater\Http\Controllers\Controller;
use Crater\Models\Company;
use Crater\Models\CompanySetting;
use Crater\Models\Expense;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use PDF;
use Carbon\Carbon;
use Crater\Models\Company;
use Crater\Models\Expense;
use Crater\Models\Currency;
use Illuminate\Http\Request;
use Crater\Models\CompanySetting;
use Illuminate\Support\Facades\App;
use Crater\Http\Controllers\Controller;
class ExpensesReportController extends Controller
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param string $hash
* @return \Illuminate\Http\JsonResponse
*/
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param string $hash
* @return \Illuminate\Http\JsonResponse
*/
public function __invoke(Request $request, $hash)
{
$company = Company::where('unique_hash', $hash)->first();
@ -43,6 +44,7 @@ class ExpensesReportController extends Controller
$dateFormat = CompanySetting::getSetting('carbon_date_format', $company->id);
$from_date = Carbon::createFromFormat('Y-m-d', $request->from_date)->format($dateFormat);
$to_date = Carbon::createFromFormat('Y-m-d', $request->to_date)->format($dateFormat);
$currency = Currency::findOrFail(CompanySetting::getSetting('currency', $company->id));
$colors = [
'primary_text_color',
@ -66,6 +68,7 @@ class ExpensesReportController extends Controller
'company' => $company,
'from_date' => $from_date,
'to_date' => $to_date,
'currency' => $currency,
]);
$pdf = PDF::loadView('app.pdf.reports.expenses');

View File

@ -2,24 +2,25 @@
namespace Crater\Http\Controllers\V1\Admin\Report;
use Carbon\Carbon;
use Crater\Http\Controllers\Controller;
use Crater\Models\Company;
use Crater\Models\CompanySetting;
use Crater\Models\InvoiceItem;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use PDF;
use Carbon\Carbon;
use Crater\Models\Company;
use Crater\Models\Currency;
use Illuminate\Http\Request;
use Crater\Models\InvoiceItem;
use Crater\Models\CompanySetting;
use Illuminate\Support\Facades\App;
use Crater\Http\Controllers\Controller;
class ItemSalesReportController extends Controller
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param string $hash
* @return \Illuminate\Http\JsonResponse
*/
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param string $hash
* @return \Illuminate\Http\JsonResponse
*/
public function __invoke(Request $request, $hash)
{
$company = Company::where('unique_hash', $hash)->first();
@ -43,6 +44,7 @@ class ItemSalesReportController extends Controller
$dateFormat = CompanySetting::getSetting('carbon_date_format', $company->id);
$from_date = Carbon::createFromFormat('Y-m-d', $request->from_date)->format($dateFormat);
$to_date = Carbon::createFromFormat('Y-m-d', $request->to_date)->format($dateFormat);
$currency = Currency::findOrFail(CompanySetting::getSetting('currency', $company->id));
$colors = [
'primary_text_color',
@ -66,6 +68,7 @@ class ItemSalesReportController extends Controller
'company' => $company,
'from_date' => $from_date,
'to_date' => $to_date,
'currency' => $currency,
]);
$pdf = PDF::loadView('app.pdf.reports.sales-items');

View File

@ -2,25 +2,26 @@
namespace Crater\Http\Controllers\V1\Admin\Report;
use PDF;
use Carbon\Carbon;
use Crater\Http\Controllers\Controller;
use Crater\Models\Company;
use Crater\Models\CompanySetting;
use Crater\Models\Expense;
use Crater\Models\Payment;
use Crater\Models\Currency;
use Illuminate\Http\Request;
use Crater\Models\CompanySetting;
use Illuminate\Support\Facades\App;
use PDF;
use Crater\Http\Controllers\Controller;
class ProfitLossReportController extends Controller
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param string $hash
* @return \Illuminate\Http\JsonResponse
*/
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param string $hash
* @return \Illuminate\Http\JsonResponse
*/
public function __invoke(Request $request, $hash)
{
$company = Company::where('unique_hash', $hash)->first();
@ -49,6 +50,8 @@ class ProfitLossReportController extends Controller
$dateFormat = CompanySetting::getSetting('carbon_date_format', $company->id);
$from_date = Carbon::createFromFormat('Y-m-d', $request->from_date)->format($dateFormat);
$to_date = Carbon::createFromFormat('Y-m-d', $request->to_date)->format($dateFormat);
$currency = Currency::findOrFail(CompanySetting::getSetting('currency', $company->id));
$colors = [
'primary_text_color',
@ -74,6 +77,7 @@ class ProfitLossReportController extends Controller
'company' => $company,
'from_date' => $from_date,
'to_date' => $to_date,
'currency' => $currency,
]);
$pdf = PDF::loadView('app.pdf.reports.profit-loss');

View File

@ -2,24 +2,25 @@
namespace Crater\Http\Controllers\V1\Admin\Report;
use Carbon\Carbon;
use Crater\Http\Controllers\Controller;
use Crater\Models\Company;
use Crater\Models\CompanySetting;
use Crater\Models\Tax;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use PDF;
use Carbon\Carbon;
use Crater\Models\Tax;
use Crater\Models\Company;
use Crater\Models\Currency;
use Illuminate\Http\Request;
use Crater\Models\CompanySetting;
use Illuminate\Support\Facades\App;
use Crater\Http\Controllers\Controller;
class TaxSummaryReportController extends Controller
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param string $hash
* @return \Illuminate\Http\JsonResponse
*/
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param string $hash
* @return \Illuminate\Http\JsonResponse
*/
public function __invoke(Request $request, $hash)
{
$company = Company::where('unique_hash', $hash)->first();
@ -44,6 +45,8 @@ class TaxSummaryReportController extends Controller
$dateFormat = CompanySetting::getSetting('carbon_date_format', $company->id);
$from_date = Carbon::createFromFormat('Y-m-d', $request->from_date)->format($dateFormat);
$to_date = Carbon::createFromFormat('Y-m-d', $request->to_date)->format($dateFormat);
$currency = Currency::findOrFail(CompanySetting::getSetting('currency', $company->id));
$colors = [
'primary_text_color',
@ -68,6 +71,7 @@ class TaxSummaryReportController extends Controller
'company' => $company,
'from_date' => $from_date,
'to_date' => $to_date,
'currency' => $currency,
]);
$pdf = PDF::loadView('app.pdf.reports.tax-summary');

View File

@ -133,11 +133,10 @@
line-height: 21px;
color: #5851D8;
}
</style>
@if (App::isLocale('th'))
@include('app.pdf.locale.th')
@include('app.pdf.locale.th')
@endif
</head>
@ -162,18 +161,18 @@
<div class="expenses-table-container">
<table class="expenses-table">
@foreach ($expenseCategories as $expenseCategory)
<tr>
<td>
<p class="expense-title">
{{ $expenseCategory->category->name }}
</p>
</td>
<td>
<p class="expense-amount">
{!! format_money_pdf($expenseCategory->total_amount) !!}
</p>
</td>
</tr>
<tr>
<td>
<p class="expense-title">
{{ $expenseCategory->category->name }}
</p>
</td>
<td>
<p class="expense-amount">
{!! format_money_pdf($expenseCategory->total_amount, $currency) !!}
</p>
</td>
</tr>
@endforeach
</table>
</div>
@ -182,7 +181,7 @@
<table class="expense-total-table">
<tr>
<td class="expense-total-cell">
<p class="expense-total">{!! format_money_pdf($totalExpense) !!}</p>
<p class="expense-total">{!! format_money_pdf($totalExpense, $currency) !!}</p>
</td>
</tr>
</table>
@ -192,10 +191,10 @@
<p class="report-footer-label">@lang('pdf_total_expenses_label')</p>
</td>
<td>
<p class="report-footer-value">{!! format_money_pdf($totalExpense) !!}</p>
<p class="report-footer-value">{!! format_money_pdf($totalExpense, $currency) !!}</p>
</td>
</tr>
</table>
</body>
</html>
</html>

View File

@ -158,11 +158,10 @@
line-height: 21px;
color: #5851D8;
}
</style>
@if (App::isLocale('th'))
@include('app.pdf.locale.th')
@include('app.pdf.locale.th')
@endif
</head>
@ -190,7 +189,7 @@
<p class="income-title">@lang("pdf_income_label")</p>
</td>
<td>
<p class="income-amount">{!! format_money_pdf($income) !!}</p>
<p class="income-amount">{!! format_money_pdf($income, $currency) !!}</p>
</td>
</tr>
</table>
@ -198,18 +197,18 @@
<div class="expenses-table-container">
<table class="expenses-table">
@foreach ($expenseCategories as $expenseCategory)
<tr>
<td>
<p class="expense-title">
{{ $expenseCategory->category->name }}
</p>
</td>
<td>
<p class="expense-amount">
{!! format_money_pdf($expenseCategory->total_amount) !!}
</p>
</td>
</tr>
<tr>
<td>
<p class="expense-title">
{{ $expenseCategory->category->name }}
</p>
</td>
<td>
<p class="expense-amount">
{!! format_money_pdf($expenseCategory->total_amount, $currency) !!}
</p>
</td>
</tr>
@endforeach
</table>
@ -219,7 +218,7 @@
<table class="expense-total-indicator-table">
<tr>
<td class="expense-total-cell">
<p class="expense-total">{!! format_money_pdf($totalExpense) !!}</p>
<p class="expense-total">{!! format_money_pdf($totalExpense, $currency) !!}</p>
</td>
</tr>
</table>
@ -229,10 +228,10 @@
<p class="report-footer-label">@lang("pdf_net_profit_label")</p>
</td>
<td>
<p class="report-footer-value">{!! format_money_pdf($income - $totalExpense) !!}</p>
<p class="report-footer-value">{!! format_money_pdf($income - $totalExpense, $currency) !!}</p>
</td>
</tr>
</table>
</body>
</html>
</html>

View File

@ -137,11 +137,10 @@
.text-center {
text-align: center;
}
</style>
@if (App::isLocale('th'))
@include('app.pdf.locale.th')
@include('app.pdf.locale.th')
@endif
</head>
@ -164,34 +163,34 @@
</table>
@foreach ($customers as $customer)
<p class="sales-customer-name">{{ $customer->name }}</p>
<div class="sales-table-container">
<table class="sales-table">
@foreach ($customer->invoices as $invoice)
<tr>
<td>
<p class="sales-information-text">
{{ $invoice->formattedInvoiceDate }} ({{ $invoice->invoice_number }})
</p>
</td>
<td>
<p class="sales-amount">
{!! format_money_pdf($invoice->base_total) !!}
</p>
</td>
</tr>
@endforeach
</table>
</div>
<table class="sales-total-indicator-table">
<p class="sales-customer-name">{{ $customer->name }}</p>
<div class="sales-table-container">
<table class="sales-table">
@foreach ($customer->invoices as $invoice)
<tr>
<td class="sales-total-cell">
<p class="sales-total-amount">
{!! format_money_pdf($customer->totalAmount) !!}
<td>
<p class="sales-information-text">
{{ $invoice->formattedInvoiceDate }} ({{ $invoice->invoice_number }})
</p>
</td>
<td>
<p class="sales-amount">
{!! format_money_pdf($invoice->base_total, $currency) !!}
</p>
</td>
</tr>
@endforeach
</table>
</div>
<table class="sales-total-indicator-table">
<tr>
<td class="sales-total-cell">
<p class="sales-total-amount">
{!! format_money_pdf($customer->totalAmount, $currency) !!}
</p>
</td>
</tr>
</table>
@endforeach
</div>
@ -203,11 +202,11 @@
</td>
<td>
<p class="report-footer-value">
{!! format_money_pdf($totalAmount) !!}
{!! format_money_pdf($totalAmount, $currency) !!}
</p>
</td>
</tr>
</table>
</body>
</html>
</html>

View File

@ -137,11 +137,10 @@
.text-center {
text-align: center;
}
</style>
@if (App::isLocale('th'))
@include('app.pdf.locale.th')
@include('app.pdf.locale.th')
@endif
</head>
@ -165,29 +164,29 @@
<p class="sales-items-title">@lang('pdf_items_label')</p>
@foreach ($items as $item)
<div class="items-table-container">
<table class="items-table">
<tr>
<td>
<p class="item-title">
{{ $item->name }}
</p>
</td>
<td>
<p class="item-sales-amount">
{!! format_money_pdf($item->total_amount) !!}
</p>
</td>
</tr>
</table>
</div>
<div class="items-table-container">
<table class="items-table">
<tr>
<td>
<p class="item-title">
{{ $item->name }}
</p>
</td>
<td>
<p class="item-sales-amount">
{!! format_money_pdf($item->total_amount, $currency) !!}
</p>
</td>
</tr>
</table>
</div>
@endforeach
<table class="sales-total-indicator-table">
<tr>
<td class="sales-total-cell">
<p class="sales-total-amount">
{!! format_money_pdf($totalAmount) !!}
{!! format_money_pdf($totalAmount, $currency) !!}
</p>
</td>
</tr>
@ -202,11 +201,11 @@
</td>
<td>
<p class="report-footer-value">
{!! format_money_pdf($totalAmount) !!}
{!! format_money_pdf($totalAmount, $currency) !!}
</p>
</td>
</tr>
</table>
</body>
</html>
</html>

View File

@ -134,11 +134,10 @@
line-height: 21px;
color: #5851D8;
}
</style>
@if (App::isLocale('th'))
@include('app.pdf.locale.th')
@include('app.pdf.locale.th')
@endif
</head>
@ -167,18 +166,18 @@
<div class="tax-table-container">
<table class="tax-table">
@foreach ($taxTypes as $tax)
<tr>
<td>
<p class="tax-title">
{{ $tax->taxType->name }}
</p>
</td>
<td>
<p class="tax-amount">
{!! format_money_pdf($tax->total_tax_amount) !!}
</p>
</td>
</tr>
<tr>
<td>
<p class="tax-title">
{{ $tax->taxType->name }}
</p>
</td>
<td>
<p class="tax-amount">
{!! format_money_pdf($tax->total_tax_amount, $currency) !!}
</p>
</td>
</tr>
@endforeach
</table>
@ -189,7 +188,7 @@
<tr>
<td class="tax-total-cell">
<p class="tax-total">
{!! format_money_pdf($totalTaxAmount) !!}
{!! format_money_pdf($totalTaxAmount, $currency) !!}
</p>
</td>
</tr>
@ -201,11 +200,11 @@
</td>
<td>
<p class="report-footer-value">
{!! format_money_pdf($totalTaxAmount) !!}
{!! format_money_pdf($totalTaxAmount, $currency) !!}
</p>
</td>
</tr>
</table>
</body>
</html>
</html>