replaced revenues/payments with transactions
This commit is contained in:
parent
e4d0de0677
commit
3a15c1d615
@ -89,8 +89,8 @@ class Accounts extends BulkAction
|
||||
protected function getRelationships($account)
|
||||
{
|
||||
$relationships = $this->countRelationships($account, [
|
||||
'payments' => 'payments',
|
||||
'revenues' => 'revenues',
|
||||
'expense_transactions' => 'transactions',
|
||||
'income_transacions' => 'transactions',
|
||||
]);
|
||||
|
||||
return $relationships;
|
||||
|
@ -87,7 +87,7 @@ class Customers extends BulkAction
|
||||
{
|
||||
$rels = [
|
||||
'invoices' => 'invoices',
|
||||
'revenues' => 'revenues',
|
||||
'income_transactions' => 'transactions',
|
||||
];
|
||||
|
||||
$relationships = $this->countRelationships($contact, $rels);
|
||||
|
@ -88,9 +88,9 @@ class Categories extends BulkAction
|
||||
$relationships = $this->countRelationships($category, [
|
||||
'items' => 'items',
|
||||
'invoices' => 'invoices',
|
||||
'revenues' => 'revenues',
|
||||
'income_transacions' => 'transactions',
|
||||
'bills' => 'bills',
|
||||
'payments' => 'payments',
|
||||
'expense_transactions' => 'transactions',
|
||||
]);
|
||||
|
||||
return $relationships;
|
||||
|
@ -82,9 +82,9 @@ class Currencies extends BulkAction
|
||||
'accounts' => 'accounts',
|
||||
'customers' => 'customers',
|
||||
'invoices' => 'invoices',
|
||||
'revenues' => 'revenues',
|
||||
'income_transactions' => 'transactions',
|
||||
'bills' => 'bills',
|
||||
'payments' => 'payments',
|
||||
'expense_transactions' => 'transactions',
|
||||
]);
|
||||
|
||||
if ($currency->code == setting('default.currency')) {
|
||||
|
@ -197,15 +197,15 @@ class Reconciliations extends Controller
|
||||
// Opening Balance
|
||||
$total = $account->opening_balance;
|
||||
|
||||
// Sum revenues
|
||||
$revenues = $account->revenues()->whereDate('paid_at', '<', $started_at)->get();
|
||||
foreach ($revenues as $item) {
|
||||
// Sum income transactions
|
||||
$transactions = $account->income_transacions()->whereDate('paid_at', '<', $started_at)->get();
|
||||
foreach ($transactions as $item) {
|
||||
$total += $item->amount;
|
||||
}
|
||||
|
||||
// Subtract payments
|
||||
$payments = $account->payments()->whereDate('paid_at', '<', $started_at)->get();
|
||||
foreach ($payments as $item) {
|
||||
// Subtract expense transactions
|
||||
$transactions = $account->expense_transactions()->whereDate('paid_at', '<', $started_at)->get();
|
||||
foreach ($transactions as $item) {
|
||||
$total -= $item->amount;
|
||||
}
|
||||
|
||||
|
@ -68,16 +68,16 @@ class Search extends Controller
|
||||
}
|
||||
}/*
|
||||
|
||||
$revenues = Transaction::type('income')->usingSearchString($keyword)->get();
|
||||
$income_transactions = Transaction::type('income')->usingSearchString($keyword)->get();
|
||||
|
||||
if ($revenues->count()) {
|
||||
foreach ($revenues as $revenue) {
|
||||
if ($income_transactions->count()) {
|
||||
foreach ($income_transactions as $transaction) {
|
||||
$results[] = (object)[
|
||||
'id' => $revenue->id,
|
||||
'name' => $revenue->contact_name,
|
||||
'id' => $transaction->id,
|
||||
'name' => $transaction->contact_name,
|
||||
'type' => trans_choice('general.revenues', 1),
|
||||
'color' => '#00c0ef',
|
||||
'href' => url('incomes/revenues/' . $revenue->id),
|
||||
'href' => url('incomes/revenues/' . $transaction->id),
|
||||
];
|
||||
}
|
||||
}*/
|
||||
|
@ -362,7 +362,7 @@ class Bills extends Controller
|
||||
{
|
||||
$paid = 0;
|
||||
|
||||
foreach ($bill->payments as $item) {
|
||||
foreach ($bill->transactions as $item) {
|
||||
$amount = $item->amount;
|
||||
|
||||
if ($bill->currency_code != $item->currency_code) {
|
||||
@ -378,8 +378,6 @@ class Bills extends Controller
|
||||
|
||||
$bill->template_path = 'expenses.bills.bill';
|
||||
|
||||
//event(new BillPrinting($bill));
|
||||
|
||||
return $bill;
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class Customers extends Controller
|
||||
|
||||
$counts = [
|
||||
'invoices' => 0,
|
||||
'revenues' => 0,
|
||||
'transactions' => 0,
|
||||
];
|
||||
|
||||
// Handle invoices
|
||||
@ -62,7 +62,7 @@ class Customers extends Controller
|
||||
$today = Date::today()->toDateString();
|
||||
|
||||
foreach ($invoices as $item) {
|
||||
// Already in revenues
|
||||
// Already in transactions
|
||||
if ($item->invoice_status_code == 'paid') {
|
||||
continue;
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ class Invoices extends Controller
|
||||
{
|
||||
$paid = 0;
|
||||
|
||||
foreach ($invoice->payments as $item) {
|
||||
foreach ($invoice->transactions as $item) {
|
||||
$amount = $item->amount;
|
||||
|
||||
if ($invoice->currency_code != $item->currency_code) {
|
||||
|
@ -109,14 +109,14 @@ class BillTransactions extends Controller
|
||||
{
|
||||
$paid = 0;
|
||||
|
||||
// Get Bill Payments
|
||||
if (!$bill->payments->count()) {
|
||||
// Get Bill Transactions
|
||||
if (!$bill->transactions->count()) {
|
||||
return $paid;
|
||||
}
|
||||
|
||||
$currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
|
||||
|
||||
foreach ($bill->payments as $item) {
|
||||
foreach ($bill->transactions as $item) {
|
||||
$default_amount = (double) $item->amount;
|
||||
|
||||
if ($bill->currency_code == $item->currency_code) {
|
||||
|
@ -116,14 +116,14 @@ class InvoiceTransactions extends Controller
|
||||
{
|
||||
$paid = 0;
|
||||
|
||||
// Get Invoice Payments
|
||||
if (!$invoice->payments->count()) {
|
||||
// Get invoice transactions
|
||||
if (!$invoice->transactions->count()) {
|
||||
return $paid;
|
||||
}
|
||||
|
||||
$_currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
|
||||
|
||||
foreach ($invoice->payments as $item) {
|
||||
foreach ($invoice->transactions as $item) {
|
||||
$default_amount = $item->amount;
|
||||
|
||||
if ($invoice->currency_code == $item->currency_code) {
|
||||
|
@ -198,7 +198,7 @@ class Dashboard extends Controller
|
||||
{
|
||||
foreach ($items as $item) {
|
||||
if ($type == 'partial') {
|
||||
$item->amount = $item->payments()->paid();
|
||||
$item->amount = $item->transactions()->paid();
|
||||
}
|
||||
|
||||
$i = Date::parse($item->paid_at)->format($date_format);
|
||||
|
@ -110,7 +110,7 @@ class Invoices extends Controller
|
||||
{
|
||||
$paid = 0;
|
||||
|
||||
foreach ($invoice->payments as $item) {
|
||||
foreach ($invoice->transactions as $item) {
|
||||
$amount = $item->amount;
|
||||
|
||||
if ($invoice->currency_code != $item->currency_code) {
|
||||
@ -139,7 +139,7 @@ class Invoices extends Controller
|
||||
|
||||
$paid = 0;
|
||||
|
||||
foreach ($invoice->payments as $item) {
|
||||
foreach ($invoice->transactions as $item) {
|
||||
$amount = $item->amount;
|
||||
|
||||
if ($invoice->currency_code != $item->currency_code) {
|
||||
|
@ -34,16 +34,16 @@ class Account extends Model
|
||||
return $this->belongsTo('App\Models\Setting\Currency', 'currency_code', 'code');
|
||||
}
|
||||
|
||||
public function revenues()
|
||||
{
|
||||
return $this->transactions()->where('type', 'income');
|
||||
}
|
||||
|
||||
public function payments()
|
||||
public function expense_transactions()
|
||||
{
|
||||
return $this->transactions()->where('type', 'expense');
|
||||
}
|
||||
|
||||
public function income_transacions()
|
||||
{
|
||||
return $this->transactions()->where('type', 'income');
|
||||
}
|
||||
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasMany('App\Models\Banking\Transaction');
|
||||
@ -71,10 +71,10 @@ class Account extends Model
|
||||
$total = $this->opening_balance;
|
||||
|
||||
// Sum Incomes
|
||||
$total += $this->revenues->sum('amount');
|
||||
$total += $this->income_transacions->sum('amount');
|
||||
|
||||
// Subtract Expenses
|
||||
$total -= $this->payments->sum('amount');
|
||||
$total -= $this->expense_transactions->sum('amount');
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
@ -88,6 +88,16 @@ class Company extends Eloquent
|
||||
return $this->hasMany('App\Models\Common\Dashboard');
|
||||
}
|
||||
|
||||
public function expense_transactions()
|
||||
{
|
||||
return $this->transactions()->where('type', 'expense');
|
||||
}
|
||||
|
||||
public function income_transactions()
|
||||
{
|
||||
return $this->transactions()->where('type', 'income');
|
||||
}
|
||||
|
||||
public function invoice_histories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\InvoiceHistory');
|
||||
@ -113,21 +123,11 @@ class Company extends Eloquent
|
||||
return $this->hasMany('App\Models\Common\Item');
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->transactions()->where('type', 'expense');
|
||||
}
|
||||
|
||||
public function recurring()
|
||||
{
|
||||
return $this->hasMany('App\Models\Common\Recurring');
|
||||
}
|
||||
|
||||
public function revenues()
|
||||
{
|
||||
return $this->transactions()->where('type', 'income');
|
||||
}
|
||||
|
||||
public function settings()
|
||||
{
|
||||
return $this->hasMany('App\Models\Setting\Setting');
|
||||
|
@ -38,21 +38,21 @@ class Contact extends Model
|
||||
return $this->belongsTo('App\Models\Setting\Currency', 'currency_code', 'code');
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\Invoice');
|
||||
}
|
||||
|
||||
public function payments()
|
||||
public function expense_transactions()
|
||||
{
|
||||
return $this->transactions()->where('type', 'expense');
|
||||
}
|
||||
|
||||
public function revenues()
|
||||
public function income_transactions()
|
||||
{
|
||||
return $this->transactions()->where('type', 'income');
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\Invoice');
|
||||
}
|
||||
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasMany('App\Models\Banking\Transaction');
|
||||
|
@ -225,10 +225,10 @@ class Invoice extends Model
|
||||
$paid = 0;
|
||||
$reconciled = $reconciled_amount = 0;
|
||||
|
||||
if ($this->payments->count()) {
|
||||
if ($this->transactions->count()) {
|
||||
$currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
|
||||
|
||||
foreach ($this->payments as $item) {
|
||||
foreach ($this->transactions as $item) {
|
||||
if ($this->currency_code == $item->currency_code) {
|
||||
$amount = (double) $item->amount;
|
||||
} else {
|
||||
|
@ -27,6 +27,16 @@ class Category extends Model
|
||||
return $this->hasMany('App\Models\Expense\Bill');
|
||||
}
|
||||
|
||||
public function expense_transactions()
|
||||
{
|
||||
return $this->transactions()->where('type', 'expense');
|
||||
}
|
||||
|
||||
public function income_transacions()
|
||||
{
|
||||
return $this->transactions()->where('type', 'income');
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\Invoice');
|
||||
@ -37,16 +47,6 @@ class Category extends Model
|
||||
return $this->hasMany('App\Models\Common\Item');
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->transactions()->where('type', 'expense');
|
||||
}
|
||||
|
||||
public function revenues()
|
||||
{
|
||||
return $this->transactions()->where('type', 'income');
|
||||
}
|
||||
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasMany('App\Models\Banking\Transaction');
|
||||
|
@ -43,21 +43,21 @@ class Currency extends Model
|
||||
return $this->contacts()->where('type', 'customer');
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\Invoice', 'currency_code', 'code');
|
||||
}
|
||||
|
||||
public function payments()
|
||||
public function expense_transactions()
|
||||
{
|
||||
return $this->transactions()->where('type', 'expense');
|
||||
}
|
||||
|
||||
public function revenues()
|
||||
public function income_transactions()
|
||||
{
|
||||
return $this->transactions()->where('type', 'income');
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Income\Invoice', 'currency_code', 'code');
|
||||
}
|
||||
|
||||
public function transactions()
|
||||
{
|
||||
return $this->hasMany('App\Models\Banking\Transaction', 'currency_code', 'code');
|
||||
|
@ -29,7 +29,7 @@ class Transaction
|
||||
{
|
||||
$invoice = $transaction->invoice;
|
||||
|
||||
if ($invoice->payments->count() > 1) {
|
||||
if ($invoice->transactions->count() > 1) {
|
||||
$invoice->invoice_status_code = 'partial';
|
||||
} else {
|
||||
$invoice->invoice_status_code = 'sent';
|
||||
@ -55,7 +55,7 @@ class Transaction
|
||||
{
|
||||
$bill = $transaction->bill;
|
||||
|
||||
if ($bill->payments->count() > 1) {
|
||||
if ($bill->transactions->count() > 1) {
|
||||
$bill->bill_status_code = 'partial';
|
||||
} else {
|
||||
$bill->bill_status_code = 'received';
|
||||
|
@ -21,16 +21,16 @@ class IncomeExpenseSummary extends Report
|
||||
|
||||
public function getTotals()
|
||||
{
|
||||
$revenues = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
||||
$payments = $this->applyFilters(Transaction::type('expense')->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
||||
$income_transactions = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
||||
$expense_transactions = $this->applyFilters(Transaction::type('expense')->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
||||
|
||||
switch ($this->report->basis) {
|
||||
case 'cash':
|
||||
// Revenues
|
||||
$this->setTotals($revenues, 'paid_at', true);
|
||||
// Income Transactions
|
||||
$this->setTotals($income_transactions, 'paid_at', true);
|
||||
|
||||
// Payments
|
||||
$this->setTotals($payments, 'paid_at', true);
|
||||
// Expense Transactions
|
||||
$this->setTotals($expense_transactions, 'paid_at', true);
|
||||
|
||||
break;
|
||||
default:
|
||||
@ -39,18 +39,18 @@ class IncomeExpenseSummary extends Report
|
||||
Recurring::reflect($invoices, 'invoice', 'invoiced_at');
|
||||
$this->setTotals($invoices, 'invoiced_at', true);
|
||||
|
||||
// Revenues
|
||||
Recurring::reflect($revenues, 'revenue', 'paid_at');
|
||||
$this->setTotals($revenues, 'paid_at', true);
|
||||
// Income Transactions
|
||||
Recurring::reflect($income_transactions, 'transaction', 'paid_at');
|
||||
$this->setTotals($income_transactions, 'paid_at', true);
|
||||
|
||||
// Bills
|
||||
$bills = $this->applyFilters(Bill::accrued(), ['date_field' => 'billed_at'])->get();
|
||||
Recurring::reflect($bills, 'bill', 'billed_at');
|
||||
$this->setTotals($bills, 'billed_at', true);
|
||||
|
||||
// Payments
|
||||
Recurring::reflect($payments, 'payment', 'paid_at');
|
||||
$this->setTotals($payments, 'paid_at', true);
|
||||
// Expense Transactions
|
||||
Recurring::reflect($expense_transactions, 'transaction', 'paid_at');
|
||||
$this->setTotals($expense_transactions, 'paid_at', true);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -36,12 +36,12 @@ class IncomeSummary extends Report
|
||||
|
||||
public function getTotals()
|
||||
{
|
||||
$revenues = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
||||
$transactions = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
||||
|
||||
switch ($this->report->basis) {
|
||||
case 'cash':
|
||||
// Revenues
|
||||
$this->setTotals($revenues, 'paid_at');
|
||||
// Transactions
|
||||
$this->setTotals($transactions, 'paid_at');
|
||||
|
||||
break;
|
||||
default:
|
||||
@ -50,9 +50,9 @@ class IncomeSummary extends Report
|
||||
Recurring::reflect($invoices, 'invoice', 'invoiced_at');
|
||||
$this->setTotals($invoices, 'invoiced_at');
|
||||
|
||||
// Revenues
|
||||
Recurring::reflect($revenues, 'revenue', 'paid_at');
|
||||
$this->setTotals($revenues, 'paid_at');
|
||||
// Transactions
|
||||
Recurring::reflect($transactions, 'transaction', 'paid_at');
|
||||
$this->setTotals($transactions, 'paid_at');
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -67,16 +67,16 @@ class ProfitLoss extends Report
|
||||
|
||||
public function getTotals()
|
||||
{
|
||||
$revenues = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
||||
$payments = $this->applyFilters(Transaction::type('expense')->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
||||
$income_transactions = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
||||
$expense_transactions = $this->applyFilters(Transaction::type('expense')->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
||||
|
||||
switch ($this->report->basis) {
|
||||
case 'cash':
|
||||
// Revenues
|
||||
$this->setTotals($revenues, 'paid_at', true, $this->tables['income']);
|
||||
// Income Transactions
|
||||
$this->setTotals($income_transactions, 'paid_at', true, $this->tables['income']);
|
||||
|
||||
// Payments
|
||||
$this->setTotals($payments, 'paid_at', true, $this->tables['expense']);
|
||||
// Expense Transactions
|
||||
$this->setTotals($expense_transactions, 'paid_at', true, $this->tables['expense']);
|
||||
|
||||
break;
|
||||
default:
|
||||
@ -85,18 +85,18 @@ class ProfitLoss extends Report
|
||||
Recurring::reflect($invoices, 'invoice', 'invoiced_at');
|
||||
$this->setTotals($invoices, 'invoiced_at', true, $this->tables['income']);
|
||||
|
||||
// Revenues
|
||||
Recurring::reflect($revenues, 'revenue', 'paid_at');
|
||||
$this->setTotals($revenues, 'paid_at', true, $this->tables['income']);
|
||||
// Income Transactions
|
||||
Recurring::reflect($income_transactions, 'transaction', 'paid_at');
|
||||
$this->setTotals($income_transactions, 'paid_at', true, $this->tables['income']);
|
||||
|
||||
// Bills
|
||||
$bills = $this->applyFilters(Bill::accrued(), ['date_field' => 'billed_at'])->get();
|
||||
Recurring::reflect($bills, 'bill', 'billed_at');
|
||||
$this->setTotals($bills, 'billed_at', true, $this->tables['expense']);
|
||||
|
||||
// Payments
|
||||
Recurring::reflect($payments, 'payment', 'paid_at');
|
||||
$this->setTotals($payments, 'paid_at', true, $this->tables['expense']);
|
||||
// Expense Transactions
|
||||
Recurring::reflect($expense_transactions, 'transaction', 'paid_at');
|
||||
$this->setTotals($expense_transactions, 'paid_at', true, $this->tables['expense']);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -29,14 +29,14 @@ class ExpensesByCategory extends AbstractWidget
|
||||
$expenses_amount = $open_bill = $overdue_bill = 0;
|
||||
|
||||
// Get categories
|
||||
$categories = Category::with(['bills', 'payments'])->type(['expense'])->enabled()->get();
|
||||
$categories = Category::with(['bills', 'expense_transactions'])->type(['expense'])->enabled()->get();
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$amount = 0;
|
||||
|
||||
// Payments
|
||||
foreach ($category->payments as $payment) {
|
||||
$amount += $payment->getAmountConvertedToDefault();
|
||||
// Transactions
|
||||
foreach ($category->expense_transactions as $transaction) {
|
||||
$amount += $transaction->getAmountConvertedToDefault();
|
||||
}
|
||||
|
||||
$expenses_amount += $amount;
|
||||
@ -149,14 +149,14 @@ class ExpensesByCategory extends AbstractWidget
|
||||
$expenses_amount = $open_bill = $overdue_bill = 0;
|
||||
|
||||
// Get categories
|
||||
$categories = Category::with(['bills', 'payments'])->type(['expense'])->enabled()->get();
|
||||
$categories = Category::with(['bills', 'expense_transactions'])->type(['expense'])->enabled()->get();
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$amount = 0;
|
||||
|
||||
// Payments
|
||||
foreach ($category->payments as $payment) {
|
||||
$amount += $payment->getAmountConvertedToDefault();
|
||||
// Transactions
|
||||
foreach ($category->expense_transactions as $transaction) {
|
||||
$amount += $transaction->getAmountConvertedToDefault();
|
||||
}
|
||||
|
||||
$expenses_amount += $amount;
|
||||
|
@ -30,14 +30,14 @@ class IncomesByCategory extends AbstractWidget
|
||||
$incomes_amount = $open_invoice = $overdue_invoice = 0;
|
||||
|
||||
// Get categories
|
||||
$categories = Category::with(['invoices', 'revenues'])->type(['income'])->enabled()->get();
|
||||
$categories = Category::with(['invoices', 'income_transacions'])->type(['income'])->enabled()->get();
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$amount = 0;
|
||||
|
||||
// Revenues
|
||||
foreach ($category->revenues as $revenue) {
|
||||
$amount += $revenue->getAmountConvertedToDefault();
|
||||
// Transactions
|
||||
foreach ($category->income_transacions as $transacion) {
|
||||
$amount += $transacion->getAmountConvertedToDefault();
|
||||
}
|
||||
|
||||
$incomes_amount += $amount;
|
||||
@ -151,14 +151,14 @@ class IncomesByCategory extends AbstractWidget
|
||||
$incomes_amount = $open_invoice = $overdue_invoice = 0;
|
||||
|
||||
// Get categories
|
||||
$categories = Category::with(['invoices', 'revenues'])->type(['income'])->enabled()->get();
|
||||
$categories = Category::with(['invoices', 'income_transacions'])->type(['income'])->enabled()->get();
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$amount = 0;
|
||||
|
||||
// Revenues
|
||||
foreach ($category->revenues as $revenue) {
|
||||
$amount += $revenue->getAmountConvertedToDefault();
|
||||
// Transactions
|
||||
foreach ($category->income_transacions as $transacion) {
|
||||
$amount += $transacion->getAmountConvertedToDefault();
|
||||
}
|
||||
|
||||
$incomes_amount += $amount;
|
||||
|
@ -27,14 +27,14 @@ class TotalExpenses extends AbstractWidget
|
||||
$expenses_amount = $open_bill = $overdue_bill = 0;
|
||||
|
||||
// Get categories
|
||||
$categories = Category::with(['bills', 'payments'])->type(['expense'])->enabled()->get();
|
||||
$categories = Category::with(['bills', 'expense_transactions'])->type(['expense'])->enabled()->get();
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$amount = 0;
|
||||
|
||||
// Payments
|
||||
foreach ($category->payments as $payment) {
|
||||
$amount += $payment->getAmountConvertedToDefault();
|
||||
// Transactions
|
||||
foreach ($category->expense_transactions as $transaction) {
|
||||
$amount += $transaction->getAmountConvertedToDefault();
|
||||
}
|
||||
|
||||
$expenses_amount += $amount;
|
||||
|
@ -27,14 +27,14 @@ class TotalIncomes extends AbstractWidget
|
||||
$incomes_amount = $open_invoice = $overdue_invoice = 0;
|
||||
|
||||
// Get categories
|
||||
$categories = Category::with(['invoices', 'revenues'])->type(['income'])->enabled()->get();
|
||||
$categories = Category::with(['invoices', 'income_transacions'])->type(['income'])->enabled()->get();
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$amount = 0;
|
||||
|
||||
// Revenues
|
||||
foreach ($category->revenues as $revenue) {
|
||||
$amount += $revenue->getAmountConvertedToDefault();
|
||||
// Transactions
|
||||
foreach ($category->income_transacions as $transacion) {
|
||||
$amount += $transacion->getAmountConvertedToDefault();
|
||||
}
|
||||
|
||||
$incomes_amount += $amount;
|
||||
|
@ -82,16 +82,16 @@ class TotalProfit extends AbstractWidget
|
||||
$expenses_amount = $open_bill = $overdue_bill = 0;
|
||||
|
||||
// Get categories
|
||||
$categories = Category::with(['bills', 'invoices', 'payments', 'revenues'])->type(['income', 'expense'])->enabled()->get();
|
||||
$categories = Category::with(['bills', 'expense_transactions', 'invoices', 'income_transacions'])->type(['income', 'expense'])->enabled()->get();
|
||||
|
||||
foreach ($categories as $category) {
|
||||
switch ($category->type) {
|
||||
case 'income':
|
||||
$amount = 0;
|
||||
|
||||
// Revenues
|
||||
foreach ($category->revenues as $revenue) {
|
||||
$amount += $revenue->getAmountConvertedToDefault();
|
||||
// Transactions
|
||||
foreach ($category->income_transacions as $transacion) {
|
||||
$amount += $transacion->getAmountConvertedToDefault();
|
||||
}
|
||||
|
||||
$incomes_amount += $amount;
|
||||
@ -109,9 +109,9 @@ class TotalProfit extends AbstractWidget
|
||||
case 'expense':
|
||||
$amount = 0;
|
||||
|
||||
// Payments
|
||||
foreach ($category->payments as $payment) {
|
||||
$amount += $payment->getAmountConvertedToDefault();
|
||||
// Transactions
|
||||
foreach ($category->expense_transactions as $transaction) {
|
||||
$amount += $transaction->getAmountConvertedToDefault();
|
||||
}
|
||||
|
||||
$expenses_amount += $amount;
|
||||
|
Loading…
x
Reference in New Issue
Block a user