mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-30 23:44:33 -04:00
Merge pull request #4309 from turbo124/v5-develop
Ninja namespace in resources
This commit is contained in:
commit
49e4e77290
@ -321,9 +321,9 @@ class CheckData extends Command
|
|||||||
Client::withTrashed()->cursor()->each(function ($client) use ($wrong_paid_to_dates, $credit_total_applied) {
|
Client::withTrashed()->cursor()->each(function ($client) use ($wrong_paid_to_dates, $credit_total_applied) {
|
||||||
$total_invoice_payments = 0;
|
$total_invoice_payments = 0;
|
||||||
|
|
||||||
foreach ($client->invoices as $invoice) {
|
foreach ($client->invoices->where('is_deleted', false) as $invoice) {
|
||||||
$total_amount = $invoice->payments->sum('pivot.amount');
|
$total_amount = $invoice->payments->whereNull('deleted_at')->sum('pivot.amount');
|
||||||
$total_refund = $invoice->payments->sum('pivot.refunded');
|
$total_refund = $invoice->payments->whereNull('deleted_at')->sum('pivot.refunded');
|
||||||
|
|
||||||
$total_invoice_payments += ($total_amount - $total_refund);
|
$total_invoice_payments += ($total_amount - $total_refund);
|
||||||
}
|
}
|
||||||
@ -356,7 +356,7 @@ class CheckData extends Command
|
|||||||
$wrong_paid_to_dates = 0;
|
$wrong_paid_to_dates = 0;
|
||||||
|
|
||||||
Client::cursor()->each(function ($client) use ($wrong_balances) {
|
Client::cursor()->each(function ($client) use ($wrong_balances) {
|
||||||
$client->invoices->where('is_deleted', false)->each(function ($invoice) use ($wrong_balances, $client) {
|
$client->invoices->where('is_deleted', false)->whereIn('status_id', '!=', Invoice::STATUS_DRAFT)->each(function ($invoice) use ($wrong_balances, $client) {
|
||||||
$total_amount = $invoice->payments->sum('pivot.amount');
|
$total_amount = $invoice->payments->sum('pivot.amount');
|
||||||
$total_refund = $invoice->payments->sum('pivot.refunded');
|
$total_refund = $invoice->payments->sum('pivot.refunded');
|
||||||
$total_credit = $invoice->credits->sum('amount');
|
$total_credit = $invoice->credits->sum('amount');
|
||||||
|
@ -207,14 +207,17 @@ class InvoiceSum
|
|||||||
private function setCalculatedAttributes()
|
private function setCalculatedAttributes()
|
||||||
{
|
{
|
||||||
/* If amount != balance then some money has been paid on the invoice, need to subtract this difference from the total to set the new balance */
|
/* If amount != balance then some money has been paid on the invoice, need to subtract this difference from the total to set the new balance */
|
||||||
if ($this->invoice->amount != $this->invoice->balance) {
|
|
||||||
$paid_to_date = $this->invoice->amount - $this->invoice->balance;
|
|
||||||
|
|
||||||
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision) - $paid_to_date;
|
if($this->invoice->status_id != Invoice::STATUS_DRAFT)
|
||||||
} else {
|
{
|
||||||
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
|
if ($this->invoice->amount != $this->invoice->balance) {
|
||||||
|
$paid_to_date = $this->invoice->amount - $this->invoice->balance;
|
||||||
|
|
||||||
|
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision) - $paid_to_date;
|
||||||
|
} else {
|
||||||
|
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set new calculated total */
|
/* Set new calculated total */
|
||||||
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
|
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->invoice->client->currency()->precision);
|
||||||
|
|
||||||
|
@ -438,11 +438,13 @@ class PaymentController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function destroy(DestroyPaymentRequest $request, Payment $payment)
|
public function destroy(DestroyPaymentRequest $request, Payment $payment)
|
||||||
{
|
{
|
||||||
$payment->service()->reversePayment();
|
// $payment->service()->deletePayment();
|
||||||
|
|
||||||
$payment->is_deleted = true;
|
// $payment->is_deleted = true;
|
||||||
$payment->save();
|
// $payment->save();
|
||||||
$payment->delete();
|
// $payment->delete();
|
||||||
|
|
||||||
|
$this->payment_repo->delete($payment);
|
||||||
|
|
||||||
return $this->itemResponse($payment);
|
return $this->itemResponse($payment);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,9 @@ class StoreInvoiceRequest extends Request
|
|||||||
$input = $this->decodePrimaryKeys($input);
|
$input = $this->decodePrimaryKeys($input);
|
||||||
|
|
||||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||||
|
$input['amount'] = 0;
|
||||||
|
$input['balance'] = 0;
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,12 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
class Paymentable extends Pivot
|
class Paymentable extends Pivot
|
||||||
{
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
protected $table = 'paymentables';
|
protected $table = 'paymentables';
|
||||||
|
|
||||||
//protected $dateFormat = 'Y-m-d H:i:s.u';
|
//protected $dateFormat = 'Y-m-d H:i:s.u';
|
||||||
|
@ -158,6 +158,7 @@ class BaseRepository
|
|||||||
*/
|
*/
|
||||||
protected function alternativeSave($data, $model)
|
protected function alternativeSave($data, $model)
|
||||||
{
|
{
|
||||||
|
|
||||||
$class = new ReflectionClass($model);
|
$class = new ReflectionClass($model);
|
||||||
|
|
||||||
if (array_key_exists('client_id', $data)) {
|
if (array_key_exists('client_id', $data)) {
|
||||||
|
@ -46,6 +46,7 @@ class MarkSent extends AbstractService
|
|||||||
->setStatus(Invoice::STATUS_SENT)
|
->setStatus(Invoice::STATUS_SENT)
|
||||||
->applyNumber()
|
->applyNumber()
|
||||||
->setDueDate()
|
->setDueDate()
|
||||||
|
->updateBalance($this->invoice->amount)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
$this->client->service()->updateBalance($this->invoice->balance)->save();
|
$this->client->service()->updateBalance($this->invoice->balance)->save();
|
||||||
|
@ -40,6 +40,7 @@ class DeletePayment
|
|||||||
->updateCreditables() //return the credits first
|
->updateCreditables() //return the credits first
|
||||||
->adjustInvoices()
|
->adjustInvoices()
|
||||||
->updateClient()
|
->updateClient()
|
||||||
|
->deletePaymentables()
|
||||||
->save();
|
->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +52,13 @@ class DeletePayment
|
|||||||
|
|
||||||
//set applied amount to 0
|
//set applied amount to 0
|
||||||
|
|
||||||
|
private function deletePaymentables()
|
||||||
|
{
|
||||||
|
$this->payment->paymentables()->update(['deleted_at' => now()]);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
private function updateClient()
|
private function updateClient()
|
||||||
{
|
{
|
||||||
$this->payment->client->service()->updatePaidToDate(-1 * $this->payment->amount)->save();
|
$this->payment->client->service()->updatePaidToDate(-1 * $this->payment->amount)->save();
|
||||||
@ -66,7 +74,7 @@ class DeletePayment
|
|||||||
$paymentable_invoice->ledger()->updateInvoiceBalance($paymentable_invoice->pivot->amount)->save();
|
$paymentable_invoice->ledger()->updateInvoiceBalance($paymentable_invoice->pivot->amount)->save();
|
||||||
$paymentable_invoice->client->service()->updateBalance($paymentable_invoice->pivot->amount)->save();
|
$paymentable_invoice->client->service()->updateBalance($paymentable_invoice->pivot->amount)->save();
|
||||||
|
|
||||||
if (floatval($paymentable_invoice->balance) == 0) {
|
if ($paymentable_invoice->balance == $paymentable_invoice->amount) {
|
||||||
$paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save();
|
$paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save();
|
||||||
} else {
|
} else {
|
||||||
$paymentable_invoice->service()->setStatus(Invoice::STATUS_PARTIAL)->save();
|
$paymentable_invoice->service()->setStatus(Invoice::STATUS_PARTIAL)->save();
|
||||||
|
@ -46,6 +46,7 @@ class PaymentableTransformer extends EntityTransformer
|
|||||||
'refunded' => (float) $paymentable->refunded,
|
'refunded' => (float) $paymentable->refunded,
|
||||||
'created_at' => (int) $paymentable->created_at,
|
'created_at' => (int) $paymentable->created_at,
|
||||||
'updated_at' => (int) $paymentable->updated_at,
|
'updated_at' => (int) $paymentable->updated_at,
|
||||||
|
'archived_at' => (int) $paymentable->deleted_at,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -304,6 +304,8 @@ class HtmlEngine
|
|||||||
$data['$product.tax_name2'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
$data['$product.tax_name2'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
||||||
$data['$product.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
$data['$product.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
||||||
$data['$product.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')];
|
$data['$product.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')];
|
||||||
|
$data['$product.description'] = ['value' => '', 'label' => ctrans('texts.description')];
|
||||||
|
$data['$product.unit_cost'] = ['value' => '', 'label' => ctrans('texts.unit_cost')];
|
||||||
|
|
||||||
$data['$task.date'] = ['value' => '', 'label' => ctrans('texts.date')];
|
$data['$task.date'] = ['value' => '', 'label' => ctrans('texts.date')];
|
||||||
$data['$task.discount'] = ['value' => '', 'label' => ctrans('texts.discount')];
|
$data['$task.discount'] = ['value' => '', 'label' => ctrans('texts.discount')];
|
||||||
|
@ -617,6 +617,7 @@ trait MakesInvoiceValues
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data[$key][$table_type.'.product_key'] = $item->product_key;
|
$data[$key][$table_type.'.product_key'] = $item->product_key;
|
||||||
|
$data[$key][$table_type.'.notes'] = $item->notes;
|
||||||
$data[$key][$table_type.'.description'] = $item->notes;
|
$data[$key][$table_type.'.description'] = $item->notes;
|
||||||
$data[$key][$table_type.'.custom_value1'] = $item->custom_value1;
|
$data[$key][$table_type.'.custom_value1'] = $item->custom_value1;
|
||||||
$data[$key][$table_type.'.custom_value2'] = $item->custom_value2;
|
$data[$key][$table_type.'.custom_value2'] = $item->custom_value2;
|
||||||
@ -625,6 +626,8 @@ trait MakesInvoiceValues
|
|||||||
$data[$key][$table_type.'.quantity'] = $item->quantity;
|
$data[$key][$table_type.'.quantity'] = $item->quantity;
|
||||||
|
|
||||||
$data[$key][$table_type.'.unit_cost'] = Number::formatMoney($item->cost, $this->client);
|
$data[$key][$table_type.'.unit_cost'] = Number::formatMoney($item->cost, $this->client);
|
||||||
|
$data[$key][$table_type.'.cost'] = Number::formatMoney($item->cost, $this->client);
|
||||||
|
|
||||||
$data[$key][$table_type.'.line_total'] = Number::formatMoney($item->line_total, $this->client);
|
$data[$key][$table_type.'.line_total'] = Number::formatMoney($item->line_total, $this->client);
|
||||||
|
|
||||||
if (isset($item->discount) && $item->discount > 0) {
|
if (isset($item->discount) && $item->discount > 0) {
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class SoftDeletePaymentables extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('paymentables', function(Blueprint $table){
|
||||||
|
$table->softDeletes('deleted_at', 6);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
@component('email.template.master', ['design' => 'dark', 'settings' => $settings, 'whitelabel' => $whitelabel])
|
@component('email.template.master', ['design' => 'dark', 'settings' => $settings, 'whitelabel' => $whitelabel])
|
||||||
|
|
||||||
@slot('header')
|
@slot('header')
|
||||||
@component('email.components.header', ['p' => $body, 'logo' => 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png'])
|
@component('email.components.header', ['p' => $body, 'logo' => $settings->company_logo ?: 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png'])
|
||||||
|
|
||||||
@if(isset($title))
|
@if(isset($title))
|
||||||
{{$title}}
|
{{$title}}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@component('email.template.master', ['design' => 'light', 'settings' => $settings, 'whitelabel' => $whitelabel])
|
@component('email.template.master', ['design' => 'light', 'settings' => $settings, 'whitelabel' => $whitelabel])
|
||||||
|
|
||||||
@slot('header')
|
@slot('header')
|
||||||
@component('email.components.header', ['p' => $body, 'logo' => 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png'])
|
@component('email.components.header', ['p' => $body, 'logo' => $settings->company_logo ?: 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png'])
|
||||||
|
|
||||||
@if(isset($title))
|
@if(isset($title))
|
||||||
{{$title}}
|
{{$title}}
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
<link rel="canonical" href="{{ config('ninja.site_url') }}/{{ request()->path() }}"/>
|
<link rel="canonical" href="{{ config('ninja.site_url') }}/{{ request()->path() }}"/>
|
||||||
|
|
||||||
@if((bool) Ninja::isSelfHost())
|
@if((bool) \App\Utils\Ninja::isSelfHost())
|
||||||
<style>
|
<style>
|
||||||
{!! $client->getSetting('portal_custom_css') !!}
|
{!! $client->getSetting('portal_custom_css') !!}
|
||||||
</style>
|
</style>
|
||||||
@ -67,7 +67,7 @@
|
|||||||
{{-- Feel free to push anything to header using @push('header') --}}
|
{{-- Feel free to push anything to header using @push('header') --}}
|
||||||
@stack('head')
|
@stack('head')
|
||||||
|
|
||||||
@if((bool) Ninja::isSelfHost())
|
@if((bool) \App\Utils\Ninja::isSelfHost())
|
||||||
{!! $client->getSetting('portal_custom_head') !!}
|
{!! $client->getSetting('portal_custom_head') !!}
|
||||||
@endif
|
@endif
|
||||||
</head>
|
</head>
|
||||||
@ -92,12 +92,12 @@
|
|||||||
@yield('footer')
|
@yield('footer')
|
||||||
@stack('footer')
|
@stack('footer')
|
||||||
|
|
||||||
@if((bool) Ninja::isSelfHost())
|
@if((bool) \App\Utils\Ninja::isSelfHost())
|
||||||
{!! $client->getSetting('portal_custom_footer') !!}
|
{!! $client->getSetting('portal_custom_footer') !!}
|
||||||
@endif
|
@endif
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
@if((bool) Ninja::isSelfHost())
|
@if((bool) \App\Utils\Ninja::isSelfHost())
|
||||||
<script>
|
<script>
|
||||||
{!! $client->getSetting('portal_custom_js') !!}
|
{!! $client->getSetting('portal_custom_js') !!}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user