mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Working on reports
This commit is contained in:
parent
94eee37124
commit
c8a51a6265
@ -1279,7 +1279,7 @@ class Utils
|
||||
$tax1 = round($amount * $taxRate1 / 100, 2);
|
||||
$tax2 = round($amount * $taxRate2 / 100, 2);
|
||||
|
||||
return round($amount + $tax1 + $tax2, 2);
|
||||
return round($tax1 + $tax2, 2);
|
||||
}
|
||||
|
||||
public static function roundSignificant($value, $precision = 2) {
|
||||
|
@ -253,6 +253,11 @@ class Expense extends EntityModel
|
||||
}
|
||||
|
||||
public function amountWithTax()
|
||||
{
|
||||
return $this->amount + $this->taxAmount();
|
||||
}
|
||||
|
||||
public function taxAmount()
|
||||
{
|
||||
return Utils::calculateTaxes($this->amount, $this->tax_rate1, $this->tax_rate2);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class RecurringExpense extends EntityModel
|
||||
|
||||
public function amountWithTax()
|
||||
{
|
||||
return Utils::calculateTaxes($this->amount, $this->tax_rate1, $this->tax_rate2);
|
||||
return $this->amount + Utils::calculateTaxes($this->amount, $this->tax_rate1, $this->tax_rate2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ class ExpenseDatatable extends EntityDatatable
|
||||
[
|
||||
'amount',
|
||||
function ($model) {
|
||||
$amount = Utils::calculateTaxes($model->amount, $model->tax_rate1, $model->tax_rate2);
|
||||
$amount = $model->amount + Utils::calculateTaxes($model->amount, $model->tax_rate1, $model->tax_rate2);
|
||||
$str = Utils::formatMoney($amount, $model->expense_currency_id);
|
||||
|
||||
// show both the amount and the converted amount
|
||||
|
@ -70,7 +70,7 @@ class RecurringExpenseDatatable extends EntityDatatable
|
||||
[
|
||||
'amount',
|
||||
function ($model) {
|
||||
$amount = Utils::calculateTaxes($model->amount, $model->tax_rate1, $model->tax_rate2);
|
||||
$amount = $model->amount + Utils::calculateTaxes($model->amount, $model->tax_rate1, $model->tax_rate2);
|
||||
$str = Utils::formatMoney($amount, $model->expense_currency_id);
|
||||
|
||||
/*
|
||||
|
@ -41,7 +41,12 @@ class ExpensePresenter extends EntityPresenter
|
||||
|
||||
public function amount()
|
||||
{
|
||||
return Utils::formatMoney($this->entity->amount, $this->entity->expense_currency_id);
|
||||
return Utils::formatMoney($this->entity->amountWithTax(), $this->entity->expense_currency_id);
|
||||
}
|
||||
|
||||
public function taxAmount()
|
||||
{
|
||||
return Utils::formatMoney($this->entity->taxAmount(), $this->entity->expense_currency_id);
|
||||
}
|
||||
|
||||
public function category()
|
||||
|
@ -10,10 +10,10 @@ class ActivityReport extends AbstractReport
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'date',
|
||||
'client',
|
||||
'user',
|
||||
'activity',
|
||||
'date' => [],
|
||||
'client' => [],
|
||||
'user' => [],
|
||||
'activity' => [],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -10,13 +10,13 @@ class AgingReport extends AbstractReport
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'client',
|
||||
'invoice_number',
|
||||
'invoice_date',
|
||||
'due_date',
|
||||
'age',
|
||||
'amount',
|
||||
'balance',
|
||||
'client' => [],
|
||||
'invoice_number' => [],
|
||||
'invoice_date' => [],
|
||||
'due_date' => [],
|
||||
'age' => [],
|
||||
'amount' => [],
|
||||
'balance' => [],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -10,10 +10,10 @@ class ClientReport extends AbstractReport
|
||||
public function getColumns()
|
||||
{
|
||||
$columns = [
|
||||
'client',
|
||||
'amount',
|
||||
'paid',
|
||||
'balance',
|
||||
'client' => [],
|
||||
'amount' => [],
|
||||
'paid' => [],
|
||||
'balance' => [],
|
||||
'public_notes' => ['columnSelector-false'],
|
||||
'private_notes' => ['columnSelector-false'],
|
||||
];
|
||||
|
@ -11,10 +11,10 @@ class DocumentReport extends AbstractReport
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'document',
|
||||
'client',
|
||||
'invoice_or_expense',
|
||||
'date',
|
||||
'document' => [],
|
||||
'client' => [],
|
||||
'invoice_or_expense' => [],
|
||||
'date' => [],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -12,11 +12,12 @@ class ExpenseReport extends AbstractReport
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'vendor',
|
||||
'client',
|
||||
'date',
|
||||
'category',
|
||||
'amount',
|
||||
'vendor' => [],
|
||||
'client' => [],
|
||||
'date' => [],
|
||||
'category' => [],
|
||||
'amount' => [],
|
||||
'tax' => ['columnSelector-false'],
|
||||
'public_notes' => ['columnSelector-false'],
|
||||
'private_notes' => ['columnSelector-false'],
|
||||
];
|
||||
@ -35,7 +36,7 @@ class ExpenseReport extends AbstractReport
|
||||
$expenses = Expense::scope()
|
||||
->orderBy('expense_date', 'desc')
|
||||
->withArchived()
|
||||
->with('client.contacts', 'vendor')
|
||||
->with('client.contacts', 'vendor', 'expense_category')
|
||||
->where('expense_date', '>=', $this->startDate)
|
||||
->where('expense_date', '<=', $this->endDate);
|
||||
|
||||
@ -62,6 +63,7 @@ class ExpenseReport extends AbstractReport
|
||||
$this->isExport ? $expense->present()->expense_date : link_to($expense->present()->url, $expense->present()->expense_date),
|
||||
$expense->present()->category,
|
||||
Utils::formatMoney($amount, $expense->currency_id),
|
||||
$expense->present()->taxAmount,
|
||||
$expense->public_notes,
|
||||
$expense->private_notes,
|
||||
];
|
||||
|
@ -11,14 +11,14 @@ class InvoiceReport extends AbstractReport
|
||||
public function getColumns()
|
||||
{
|
||||
$columns = [
|
||||
'client',
|
||||
'invoice_number',
|
||||
'invoice_date',
|
||||
'amount',
|
||||
'status',
|
||||
'payment_date',
|
||||
'paid',
|
||||
'method',
|
||||
'client' => [],
|
||||
'invoice_number' => [],
|
||||
'invoice_date' => [],
|
||||
'amount' => [],
|
||||
'status' => [],
|
||||
'payment_date' => [],
|
||||
'paid' => [],
|
||||
'method' => [],
|
||||
'private_notes' => ['columnSelector-false'],
|
||||
];
|
||||
|
||||
|
@ -11,13 +11,13 @@ class PaymentReport extends AbstractReport
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'client',
|
||||
'invoice_number',
|
||||
'invoice_date',
|
||||
'amount',
|
||||
'payment_date',
|
||||
'paid',
|
||||
'method',
|
||||
'client' => [],
|
||||
'invoice_number' => [],
|
||||
'invoice_date' => [],
|
||||
'amount' => [],
|
||||
'payment_date' => [],
|
||||
'paid' => [],
|
||||
'method' => [],
|
||||
'private_notes' => ['columnSelector-false'],
|
||||
];
|
||||
}
|
||||
|
@ -11,13 +11,13 @@ class ProductReport extends AbstractReport
|
||||
public function getColumns()
|
||||
{
|
||||
$columns = [
|
||||
'client',
|
||||
'invoice_number',
|
||||
'invoice_date',
|
||||
'product',
|
||||
'description',
|
||||
'qty',
|
||||
'cost',
|
||||
'client' => [],
|
||||
'invoice_number' => [],
|
||||
'invoice_date' => [],
|
||||
'product' => [],
|
||||
'description' => [],
|
||||
'qty' => [],
|
||||
'cost' => [],
|
||||
//'tax_rate1',
|
||||
//'tax_rate2',
|
||||
];
|
||||
|
@ -11,11 +11,11 @@ class ProfitAndLossReport extends AbstractReport
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'type',
|
||||
'client',
|
||||
'amount',
|
||||
'date',
|
||||
'notes',
|
||||
'type' => [],
|
||||
'client' => [],
|
||||
'amount' => [],
|
||||
'date' => [],
|
||||
'notes' => [],
|
||||
];
|
||||
}
|
||||
|
||||
@ -68,8 +68,8 @@ class ProfitAndLossReport extends AbstractReport
|
||||
];
|
||||
|
||||
$this->addToTotals($expense->expense_currency_id, 'revenue', 0, $expense->present()->month);
|
||||
$this->addToTotals($expense->expense_currency_id, 'expenses', $expense->amount, $expense->present()->month);
|
||||
$this->addToTotals($expense->expense_currency_id, 'profit', $expense->amount * -1, $expense->present()->month);
|
||||
$this->addToTotals($expense->expense_currency_id, 'expenses', $expense->amountWithTax(), $expense->present()->month);
|
||||
$this->addToTotals($expense->expense_currency_id, 'profit', $expense->amountWithTax() * -1, $expense->present()->month);
|
||||
}
|
||||
|
||||
//$this->addToTotals($client->currency_id, 'paid', $payment ? $payment->getCompletedAmount() : 0);
|
||||
|
@ -11,11 +11,11 @@ class QuoteReport extends AbstractReport
|
||||
public function getColumns()
|
||||
{
|
||||
$columns = [
|
||||
'client',
|
||||
'quote_number',
|
||||
'quote_date',
|
||||
'amount',
|
||||
'status',
|
||||
'client' => [],
|
||||
'quote_number' => [],
|
||||
'quote_date' => [],
|
||||
'amount' => [],
|
||||
'status' => [],
|
||||
'private_notes' => ['columnSelector-false'],
|
||||
];
|
||||
|
||||
|
@ -10,12 +10,12 @@ class TaskReport extends AbstractReport
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'client',
|
||||
'date',
|
||||
'project',
|
||||
'description',
|
||||
'duration',
|
||||
'amount',
|
||||
'client' => [],
|
||||
'date' => [],
|
||||
'project' => [],
|
||||
'description' => [],
|
||||
'duration' => [],
|
||||
'amount' => [],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -10,12 +10,12 @@ class TaxRateReport extends AbstractReport
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'client',
|
||||
'invoice',
|
||||
'tax_name',
|
||||
'tax_rate',
|
||||
'tax_amount',
|
||||
'tax_paid',
|
||||
'client' => [],
|
||||
'invoice' => [],
|
||||
'tax_name' => [],
|
||||
'tax_rate' => [],
|
||||
'tax_amount' => [],
|
||||
'tax_paid' => [],
|
||||
'invoice_amount' => ['columnSelector-false'],
|
||||
'payment_amount' => ['columnSelector-false'],
|
||||
];
|
||||
|
@ -445,10 +445,10 @@
|
||||
}
|
||||
|
||||
var sumColumns = [];
|
||||
@foreach ($columns as $column)
|
||||
sumColumns.push("{{ in_array($column, ['amount', 'paid', 'balance', 'cost', 'duration']) ? trans("texts.{$column}") : false }}");
|
||||
@foreach ($columns as $column => $class)
|
||||
sumColumns.push("{{ in_array($column, ['amount', 'paid', 'balance', 'cost', 'duration', 'tax']) ? trans("texts.{$column}") : false }}");
|
||||
@endforeach
|
||||
|
||||
console.log(sumColumns);
|
||||
$(function() {
|
||||
$('.start_date .input-group-addon').click(function() {
|
||||
toggleDatePicker('start_date');
|
||||
|
Loading…
x
Reference in New Issue
Block a user