Merge Invoice and Bill into Document
This commit is contained in:
@@ -4,7 +4,7 @@ namespace App\Reports;
|
||||
|
||||
use App\Abstracts\Report;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Purchase\Bill;
|
||||
use App\Models\Document\Document;
|
||||
use App\Utilities\Recurring;
|
||||
|
||||
class ExpenseSummary extends Report
|
||||
@@ -41,9 +41,9 @@ class ExpenseSummary extends Report
|
||||
break;
|
||||
default:
|
||||
// Bills
|
||||
$bills = $this->applyFilters(Bill::with('recurring', 'transactions')->accrued(), ['date_field' => 'billed_at'])->get();
|
||||
Recurring::reflect($bills, 'billed_at');
|
||||
$this->setTotals($bills, 'billed_at');
|
||||
$bills = $this->applyFilters(Document::bill()->with('recurring', 'transactions')->accrued(), ['date_field' => 'issued_at'])->get();
|
||||
Recurring::reflect($bills, 'issued_at');
|
||||
$this->setTotals($bills, 'issued_at');
|
||||
|
||||
// Payments
|
||||
$payments = $transactions->isNotDocument()->get();
|
||||
|
||||
@@ -4,8 +4,7 @@ namespace App\Reports;
|
||||
|
||||
use App\Abstracts\Report;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Purchase\Bill;
|
||||
use App\Models\Sale\Invoice;
|
||||
use App\Models\Document\Document;
|
||||
use App\Utilities\Recurring;
|
||||
|
||||
class IncomeExpenseSummary extends Report
|
||||
@@ -32,9 +31,9 @@ class IncomeExpenseSummary extends Report
|
||||
break;
|
||||
default:
|
||||
// Invoices
|
||||
$invoices = $this->applyFilters(Invoice::with('recurring', 'transactions')->accrued(), ['date_field' => 'invoiced_at'])->get();
|
||||
Recurring::reflect($invoices, 'invoiced_at');
|
||||
$this->setTotals($invoices, 'invoiced_at', true);
|
||||
$invoices = $this->applyFilters(Document::invoice()->with('recurring', 'transactions')->accrued(), ['date_field' => 'issued_at'])->get();
|
||||
Recurring::reflect($invoices, 'issued_at');
|
||||
$this->setTotals($invoices, 'issued_at', true);
|
||||
|
||||
// Revenues
|
||||
$revenues = $income_transactions->isNotDocument()->get();
|
||||
@@ -42,9 +41,9 @@ class IncomeExpenseSummary extends Report
|
||||
$this->setTotals($revenues, 'paid_at', true);
|
||||
|
||||
// Bills
|
||||
$bills = $this->applyFilters(Bill::with('recurring', 'transactions')->accrued(), ['date_field' => 'billed_at'])->get();
|
||||
Recurring::reflect($bills, 'bill', 'billed_at');
|
||||
$this->setTotals($bills, 'billed_at', true);
|
||||
$bills = $this->applyFilters(Document::bill()->with('recurring', 'transactions')->accrued(), ['date_field' => 'issued_at'])->get();
|
||||
Recurring::reflect($bills, 'issued_at');
|
||||
$this->setTotals($bills, 'issued_at', true);
|
||||
|
||||
// Payments
|
||||
$payments = $expense_transactions->isNotDocument()->get();
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Reports;
|
||||
|
||||
use App\Abstracts\Report;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Sale\Invoice;
|
||||
use App\Models\Document\Document;
|
||||
use App\Utilities\Recurring;
|
||||
|
||||
class IncomeSummary extends Report
|
||||
@@ -41,9 +41,9 @@ class IncomeSummary extends Report
|
||||
break;
|
||||
default:
|
||||
// Invoices
|
||||
$invoices = $this->applyFilters(Invoice::with('recurring', 'transactions')->accrued(), ['date_field' => 'invoiced_at'])->get();
|
||||
Recurring::reflect($invoices, 'invoiced_at');
|
||||
$this->setTotals($invoices, 'invoiced_at');
|
||||
$invoices = $this->applyFilters(Document::invoice()->with('recurring', 'transactions')->accrued(), ['date_field' => 'issued_at'])->get();
|
||||
Recurring::reflect($invoices, 'issued_at');
|
||||
$this->setTotals($invoices, 'issued_at');
|
||||
|
||||
// Revenues
|
||||
$revenues = $transactions->isNotDocument()->get();
|
||||
|
||||
@@ -4,8 +4,7 @@ namespace App\Reports;
|
||||
|
||||
use App\Abstracts\Report;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Purchase\Bill;
|
||||
use App\Models\Sale\Invoice;
|
||||
use App\Models\Document\Document;
|
||||
use App\Utilities\Recurring;
|
||||
|
||||
class ProfitLoss extends Report
|
||||
@@ -51,9 +50,9 @@ class ProfitLoss extends Report
|
||||
break;
|
||||
default:
|
||||
// Invoices
|
||||
$invoices = $this->applyFilters(Invoice::with('recurring', 'totals', 'transactions')->accrued(), ['date_field' => 'invoiced_at'])->get();
|
||||
Recurring::reflect($invoices, 'invoiced_at');
|
||||
$this->setTotals($invoices, 'invoiced_at', true, $this->tables['income'], false);
|
||||
$invoices = $this->applyFilters(Document::invoice()->with('recurring', 'totals', 'transactions')->accrued(), ['date_field' => 'issued_at'])->get();
|
||||
Recurring::reflect($invoices, 'issued_at');
|
||||
$this->setTotals($invoices, 'issued_at', true, $this->tables['income'], false);
|
||||
|
||||
// Revenues
|
||||
$revenues = $income_transactions->isNotDocument()->get();
|
||||
@@ -61,9 +60,9 @@ class ProfitLoss extends Report
|
||||
$this->setTotals($revenues, 'paid_at', true, $this->tables['income'], false);
|
||||
|
||||
// Bills
|
||||
$bills = $this->applyFilters(Bill::with('recurring', 'totals', 'transactions')->accrued(), ['date_field' => 'billed_at'])->get();
|
||||
Recurring::reflect($bills, 'bill', 'billed_at');
|
||||
$this->setTotals($bills, 'billed_at', true, $this->tables['expense'], false);
|
||||
$bills = $this->applyFilters(Document::bill()->with('recurring', 'totals', 'transactions')->accrued(), ['date_field' => 'issued_at'])->get();
|
||||
Recurring::reflect($bills, 'issued_at');
|
||||
$this->setTotals($bills, 'issued_at', true, $this->tables['expense'], false);
|
||||
|
||||
// Payments
|
||||
$payments = $expense_transactions->isNotDocument()->get();
|
||||
|
||||
@@ -4,8 +4,7 @@ namespace App\Reports;
|
||||
|
||||
use App\Abstracts\Report;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Purchase\Bill;
|
||||
use App\Models\Sale\Invoice;
|
||||
use App\Models\Document\Document;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Traits\Currencies;
|
||||
use App\Utilities\Recurring;
|
||||
@@ -54,14 +53,14 @@ class TaxSummary extends Report
|
||||
break;
|
||||
default:
|
||||
// Invoices
|
||||
$invoices = $this->applyFilters(Invoice::with('recurring', 'totals', 'transactions')->accrued(), ['date_field' => 'invoiced_at'])->get();
|
||||
Recurring::reflect($invoices, 'invoiced_at');
|
||||
$this->setTotals($invoices, 'invoiced_at');
|
||||
$invoices = $this->applyFilters(Document::invoice()->with('recurring', 'totals', 'transactions')->accrued(), ['date_field' => 'issued_at'])->get();
|
||||
Recurring::reflect($invoices, 'issued_at');
|
||||
$this->setTotals($invoices, 'issued_at');
|
||||
|
||||
// Bills
|
||||
$bills = $this->applyFilters(Bill::with('recurring', 'totals', 'transactions')->accrued(), ['date_field' => 'billed_at'])->get();
|
||||
Recurring::reflect($bills, 'billed_at');
|
||||
$this->setTotals($bills, 'billed_at');
|
||||
$bills = $this->applyFilters(Document::bill()->with('recurring', 'totals', 'transactions')->accrued(), ['date_field' => 'issued_at'])->get();
|
||||
Recurring::reflect($bills, 'issued_at');
|
||||
$this->setTotals($bills, 'issued_at');
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -73,7 +72,7 @@ class TaxSummary extends Report
|
||||
// Make groups extensible
|
||||
$item = $this->applyGroups($item);
|
||||
|
||||
$type = (($item instanceof Invoice) || (($item instanceof Transaction) && ($item->type == 'income'))) ? 'income' : 'expense';
|
||||
$type = ($item->type === Document::INVOICE_TYPE || $item->type === 'income') ? 'income' : 'expense';
|
||||
|
||||
$date = $this->getFormattedDate(Date::parse($item->$date_field));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user