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