mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
fixes for payments
This commit is contained in:
parent
87fb632b3f
commit
5fbdde6d61
@ -435,11 +435,40 @@ class CheckData extends Command
|
|||||||
|
|
||||||
private function checkEntityInvitations()
|
private function checkEntityInvitations()
|
||||||
{
|
{
|
||||||
|
|
||||||
RecurringInvoiceInvitation::where('deleted_at', "0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
|
RecurringInvoiceInvitation::where('deleted_at', "0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
|
||||||
InvoiceInvitation::where('deleted_at', "0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
|
InvoiceInvitation::where('deleted_at', "0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
|
||||||
QuoteInvitation::where('deleted_at', "0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
|
QuoteInvitation::where('deleted_at', "0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
|
||||||
CreditInvitation::where('deleted_at', "0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
|
CreditInvitation::where('deleted_at', "0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
|
||||||
|
|
||||||
|
InvoiceInvitation::where('sent_date', '0000-00-00 00:00:00')->cursor()->each(function ($ii) {
|
||||||
|
$ii->sent_date = null;
|
||||||
|
$ii->saveQuietly();
|
||||||
|
});
|
||||||
|
InvoiceInvitation::where('viewed_date', '0000-00-00 00:00:00')->cursor()->each(function ($ii) {
|
||||||
|
$ii->viewed_date = null;
|
||||||
|
$ii->saveQuietly();
|
||||||
|
});
|
||||||
|
|
||||||
|
QuoteInvitation::where('sent_date', '0000-00-00 00:00:00')->cursor()->each(function ($ii) {
|
||||||
|
$ii->sent_date = null;
|
||||||
|
$ii->saveQuietly();
|
||||||
|
});
|
||||||
|
QuoteInvitation::where('viewed_date', '0000-00-00 00:00:00')->cursor()->each(function ($ii) {
|
||||||
|
$ii->viewed_date = null;
|
||||||
|
$ii->saveQuietly();
|
||||||
|
});
|
||||||
|
|
||||||
|
CreditInvitation::where('sent_date', '0000-00-00 00:00:00')->cursor()->each(function ($ii) {
|
||||||
|
$ii->sent_date = null;
|
||||||
|
$ii->saveQuietly();
|
||||||
|
});
|
||||||
|
CreditInvitation::where('viewed_date', '0000-00-00 00:00:00')->cursor()->each(function ($ii) {
|
||||||
|
$ii->viewed_date = null;
|
||||||
|
$ii->saveQuietly();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
collect([Invoice::class, Quote::class, Credit::class, PurchaseOrder::class])->each(function ($entity) {
|
collect([Invoice::class, Quote::class, Credit::class, PurchaseOrder::class])->each(function ($entity) {
|
||||||
if ($entity::doesntHave('invitations')->count() > 0) {
|
if ($entity::doesntHave('invitations')->count() > 0) {
|
||||||
|
@ -102,8 +102,13 @@ class PaymentFilters extends QueryFilters
|
|||||||
if (count($payment_filters) >0) {
|
if (count($payment_filters) >0) {
|
||||||
$query->whereIn('status_id', $payment_filters);
|
$query->whereIn('status_id', $payment_filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(in_array('partially_unapplied', $status_parameters)) {
|
||||||
|
$query->where('amount', '>', 'applied')->where('refunded', 0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return $this->builder;
|
return $this->builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Jobs\Cron;
|
namespace App\Jobs\Cron;
|
||||||
|
|
||||||
|
use App\Models\Payment;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
@ -65,7 +66,6 @@ class UpdateCalculatedFields
|
|||||||
$project->save();
|
$project->save();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ use Illuminate\Support\Str;
|
|||||||
* @property \App\Models\Company $company
|
* @property \App\Models\Company $company
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\BelongsTo|\Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo|\App\Models\Company company()
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\BelongsTo|\Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo|\App\Models\Company company()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel with()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel newQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel query()
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel query()
|
||||||
|
@ -80,7 +80,7 @@ class ClientService
|
|||||||
$amount = Payment::where('client_id', $this->client->id)
|
$amount = Payment::where('client_id', $this->client->id)
|
||||||
->where('is_deleted', 0)
|
->where('is_deleted', 0)
|
||||||
->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment::STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED, Payment::STATUS_REFUNDED])
|
->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment::STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED, Payment::STATUS_REFUNDED])
|
||||||
->sum(DB::Raw('amount - refunded - applied'));
|
->sum(DB::Raw('amount - applied'));
|
||||||
|
|
||||||
DB::connection(config('database.default'))->transaction(function () use ($amount) {
|
DB::connection(config('database.default'))->transaction(function () use ($amount) {
|
||||||
$this->client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first();
|
$this->client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first();
|
||||||
|
@ -130,13 +130,6 @@ class CreditService
|
|||||||
->credits()
|
->credits()
|
||||||
->attach($this->credit->id, ['amount' => $adjustment]);
|
->attach($this->credit->id, ['amount' => $adjustment]);
|
||||||
|
|
||||||
//reduce client paid_to_date by $this->credit->balance amount
|
|
||||||
// $this->credit
|
|
||||||
// ->client
|
|
||||||
// ->service()
|
|
||||||
// ->updatePaidToDate($adjustment)
|
|
||||||
// ->save();
|
|
||||||
|
|
||||||
$client = $this->credit->client->fresh();
|
$client = $this->credit->client->fresh();
|
||||||
$client->service()
|
$client->service()
|
||||||
->updatePaidToDate($adjustment)
|
->updatePaidToDate($adjustment)
|
||||||
|
@ -123,7 +123,7 @@ class ARSummaryReport extends BaseExport
|
|||||||
->where('balance', '>', 0)
|
->where('balance', '>', 0)
|
||||||
->where('is_deleted', 0)
|
->where('is_deleted', 0)
|
||||||
->where(function ($query){
|
->where(function ($query){
|
||||||
$query->where('due_date', '<', now()->startOfDay())
|
$query->where('due_date', '>', now()->startOfDay())
|
||||||
->orWhereNull('due_date');
|
->orWhereNull('due_date');
|
||||||
})
|
})
|
||||||
->sum('balance');
|
->sum('balance');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user