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