Merge branch 'v5-develop' of https://github.com/turbo124/invoiceninja into v5-develop

This commit is contained in:
David Bomba 2023-08-01 07:49:24 +10:00
commit 32d1114d26
5 changed files with 15 additions and 8 deletions

View File

@ -71,7 +71,7 @@ class UpdateInvoiceRequest extends Request
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
$rules['status_id'] = 'bail|sometimes|not_in:5'; //do not all cancelled invoices to be modfified.
$rules['status_id'] = 'bail|sometimes|not_in:5'; //do not allow cancelled invoices to be modfified.
$rules['exchange_rate'] = 'bail|sometimes|gt:0';
// not needed.

View File

@ -106,7 +106,7 @@ class ValidRefundableRequest implements Rule
if ($payment->credits()->exists()) {
$paymentable_credit = $payment->credits->where('id', $credit->id)->first();
if (! $paymentable_invoice) {
if (! $paymentable_credit) {
$this->error_msg = ctrans('texts.credit_not_related_to_payment', ['credit' => $credit->hashed_id]);
return false;

View File

@ -21,6 +21,7 @@ use App\Utils\Traits\Inviteable;
use App\Utils\Traits\MakesDates;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\Payment\Refundable;
use Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
@ -251,6 +252,11 @@ class Payment extends BaseModel
return $this->belongsTo(Currency::class);
}
public function transaction(): BelongsTo
{
return $this->belongsTo(BankTransaction::class);
}
public function exchange_currency()
{
return $this->belongsTo(Currency::class, 'exchange_currency_id', 'id');

View File

@ -198,7 +198,7 @@ class Product extends BaseModel
],
]);
return $converter->convert($this->notes);
return $converter->convert($this->notes ?? '');
}
public function portalUrl($use_react_url): string

View File

@ -54,13 +54,14 @@ class DeletePayment
/** @return $this */
private function cleanupPayment()
{
$this->payment->is_deleted = true;
$this->payment->delete();
// BankTransaction::where('payment_id', $this->payment->id)->cursor()->each(function ($bt){
// $bt->payment_id = null;
// $bt->save();
// });
BankTransaction::where('payment_id', $this->payment->id)->cursor()->each(function ($bt){
$bt->payment_id = null;
$bt->save();
});
return $this;
}