diff --git a/app/BulkActions/Banking/Accounts.php b/app/BulkActions/Banking/Accounts.php index dfd45380e..a6f2441fa 100644 --- a/app/BulkActions/Banking/Accounts.php +++ b/app/BulkActions/Banking/Accounts.php @@ -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; diff --git a/app/BulkActions/Incomes/Customers.php b/app/BulkActions/Incomes/Customers.php index e0594e625..d155cb353 100644 --- a/app/BulkActions/Incomes/Customers.php +++ b/app/BulkActions/Incomes/Customers.php @@ -87,7 +87,7 @@ class Customers extends BulkAction { $rels = [ 'invoices' => 'invoices', - 'revenues' => 'revenues', + 'income_transactions' => 'transactions', ]; $relationships = $this->countRelationships($contact, $rels); diff --git a/app/BulkActions/Settings/Categories.php b/app/BulkActions/Settings/Categories.php index 0d27f0c18..fd9288485 100644 --- a/app/BulkActions/Settings/Categories.php +++ b/app/BulkActions/Settings/Categories.php @@ -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; diff --git a/app/BulkActions/Settings/Currencies.php b/app/BulkActions/Settings/Currencies.php index 19984c40c..49c98bf0f 100644 --- a/app/BulkActions/Settings/Currencies.php +++ b/app/BulkActions/Settings/Currencies.php @@ -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')) { diff --git a/app/Http/Controllers/Banking/Reconciliations.php b/app/Http/Controllers/Banking/Reconciliations.php index e245e730d..96e0b9b29 100644 --- a/app/Http/Controllers/Banking/Reconciliations.php +++ b/app/Http/Controllers/Banking/Reconciliations.php @@ -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; } diff --git a/app/Http/Controllers/Common/Search.php b/app/Http/Controllers/Common/Search.php index bdf2cb400..30ac8e40f 100644 --- a/app/Http/Controllers/Common/Search.php +++ b/app/Http/Controllers/Common/Search.php @@ -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), ]; } }*/ diff --git a/app/Http/Controllers/Expenses/Bills.php b/app/Http/Controllers/Expenses/Bills.php index 2755ea0cd..db56aaba3 100644 --- a/app/Http/Controllers/Expenses/Bills.php +++ b/app/Http/Controllers/Expenses/Bills.php @@ -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; } } diff --git a/app/Http/Controllers/Incomes/Customers.php b/app/Http/Controllers/Incomes/Customers.php index 3eed50281..c7973722d 100644 --- a/app/Http/Controllers/Incomes/Customers.php +++ b/app/Http/Controllers/Incomes/Customers.php @@ -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; } diff --git a/app/Http/Controllers/Incomes/Invoices.php b/app/Http/Controllers/Incomes/Invoices.php index 0c32e4990..f801dda2b 100644 --- a/app/Http/Controllers/Incomes/Invoices.php +++ b/app/Http/Controllers/Incomes/Invoices.php @@ -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) { diff --git a/app/Http/Controllers/Modals/BillTransactions.php b/app/Http/Controllers/Modals/BillTransactions.php index 8bb756b59..dd5cc4e60 100644 --- a/app/Http/Controllers/Modals/BillTransactions.php +++ b/app/Http/Controllers/Modals/BillTransactions.php @@ -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) { diff --git a/app/Http/Controllers/Modals/InvoiceTransactions.php b/app/Http/Controllers/Modals/InvoiceTransactions.php index 7ab1aebf9..38d8407fe 100644 --- a/app/Http/Controllers/Modals/InvoiceTransactions.php +++ b/app/Http/Controllers/Modals/InvoiceTransactions.php @@ -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) { diff --git a/app/Http/Controllers/Portal/Dashboard.php b/app/Http/Controllers/Portal/Dashboard.php index 1ffb4ec18..29dfdb1ab 100644 --- a/app/Http/Controllers/Portal/Dashboard.php +++ b/app/Http/Controllers/Portal/Dashboard.php @@ -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); diff --git a/app/Http/Controllers/Portal/Invoices.php b/app/Http/Controllers/Portal/Invoices.php index f7b42d55c..18a2a56c8 100644 --- a/app/Http/Controllers/Portal/Invoices.php +++ b/app/Http/Controllers/Portal/Invoices.php @@ -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) { diff --git a/app/Models/Banking/Account.php b/app/Models/Banking/Account.php index 0e748db09..094b073b1 100644 --- a/app/Models/Banking/Account.php +++ b/app/Models/Banking/Account.php @@ -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; } diff --git a/app/Models/Common/Company.php b/app/Models/Common/Company.php index b3885ab40..1bf7ae25c 100644 --- a/app/Models/Common/Company.php +++ b/app/Models/Common/Company.php @@ -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'); diff --git a/app/Models/Common/Contact.php b/app/Models/Common/Contact.php index c73fd09ca..15f8025a4 100644 --- a/app/Models/Common/Contact.php +++ b/app/Models/Common/Contact.php @@ -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'); diff --git a/app/Models/Income/Invoice.php b/app/Models/Income/Invoice.php index a614da012..99a2dbf63 100644 --- a/app/Models/Income/Invoice.php +++ b/app/Models/Income/Invoice.php @@ -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 { diff --git a/app/Models/Setting/Category.php b/app/Models/Setting/Category.php index 5300dd03e..dc13d7e03 100644 --- a/app/Models/Setting/Category.php +++ b/app/Models/Setting/Category.php @@ -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'); diff --git a/app/Models/Setting/Currency.php b/app/Models/Setting/Currency.php index 028168050..f449d57fa 100644 --- a/app/Models/Setting/Currency.php +++ b/app/Models/Setting/Currency.php @@ -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'); diff --git a/app/Observers/Transaction.php b/app/Observers/Transaction.php index d3f4c77ab..3c413a449 100644 --- a/app/Observers/Transaction.php +++ b/app/Observers/Transaction.php @@ -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'; diff --git a/app/Reports/IncomeExpenseSummary.php b/app/Reports/IncomeExpenseSummary.php index b581a72eb..34dda1230 100644 --- a/app/Reports/IncomeExpenseSummary.php +++ b/app/Reports/IncomeExpenseSummary.php @@ -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; } diff --git a/app/Reports/IncomeSummary.php b/app/Reports/IncomeSummary.php index fd0c5cc00..eb3cfc322 100644 --- a/app/Reports/IncomeSummary.php +++ b/app/Reports/IncomeSummary.php @@ -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; } diff --git a/app/Reports/ProfitLoss.php b/app/Reports/ProfitLoss.php index 9640ce8f0..8d03cbe64 100644 --- a/app/Reports/ProfitLoss.php +++ b/app/Reports/ProfitLoss.php @@ -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; } diff --git a/app/Widgets/ExpensesByCategory.php b/app/Widgets/ExpensesByCategory.php index 890df9a96..53272119e 100644 --- a/app/Widgets/ExpensesByCategory.php +++ b/app/Widgets/ExpensesByCategory.php @@ -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; diff --git a/app/Widgets/IncomesByCategory.php b/app/Widgets/IncomesByCategory.php index 91508176b..299ea0a8c 100644 --- a/app/Widgets/IncomesByCategory.php +++ b/app/Widgets/IncomesByCategory.php @@ -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; diff --git a/app/Widgets/TotalExpenses.php b/app/Widgets/TotalExpenses.php index e43e6dd04..7326a7c3d 100644 --- a/app/Widgets/TotalExpenses.php +++ b/app/Widgets/TotalExpenses.php @@ -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; diff --git a/app/Widgets/TotalIncomes.php b/app/Widgets/TotalIncomes.php index c30316af6..488969df0 100644 --- a/app/Widgets/TotalIncomes.php +++ b/app/Widgets/TotalIncomes.php @@ -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; diff --git a/app/Widgets/TotalProfit.php b/app/Widgets/TotalProfit.php index 5f4bc2cfa..c21b2b857 100644 --- a/app/Widgets/TotalProfit.php +++ b/app/Widgets/TotalProfit.php @@ -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;