mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improvements for payment idempotency
This commit is contained in:
parent
5e1d45436e
commit
1ba1b1b1a3
@ -96,6 +96,10 @@ class StorePaymentRequest extends Request
|
|||||||
$input['date'] = now()->addSeconds($user->company()->timezone()->utc_offset)->format('Y-m-d');
|
$input['date'] = now()->addSeconds($user->company()->timezone()->utc_offset)->format('Y-m-d');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! isset($input['idempotency_key'])) {
|
||||||
|
$input['idempotency_key'] = substr(sha1(json_encode($input)).time()."{$input['date']}{$input['amount']}{$input['client_id']}{$user->id}",0,64);
|
||||||
|
}
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +110,6 @@ class StorePaymentRequest extends Request
|
|||||||
|
|
||||||
$rules = [
|
$rules = [
|
||||||
'amount' => ['numeric', 'bail', new PaymentAmountsBalanceRule(), new ValidCreditsPresentRule($this->all())],
|
'amount' => ['numeric', 'bail', new PaymentAmountsBalanceRule(), new ValidCreditsPresentRule($this->all())],
|
||||||
// 'client_id' => 'bail|required|exists:clients,id',
|
|
||||||
'client_id' => 'bail|required|exists:clients,id,company_id,'.$user->company()->id.',is_deleted,0',
|
'client_id' => 'bail|required|exists:clients,id,company_id,'.$user->company()->id.',is_deleted,0',
|
||||||
'invoices.*.invoice_id' => 'bail|required|distinct|exists:invoices,id',
|
'invoices.*.invoice_id' => 'bail|required|distinct|exists:invoices,id',
|
||||||
'invoices.*.amount' => 'bail|required',
|
'invoices.*.amount' => 'bail|required',
|
||||||
@ -117,7 +120,6 @@ class StorePaymentRequest extends Request
|
|||||||
'invoices' => new ValidPayableInvoicesRule(),
|
'invoices' => new ValidPayableInvoicesRule(),
|
||||||
'number' => ['nullable', 'bail', Rule::unique('payments')->where('company_id', $user->company()->id)],
|
'number' => ['nullable', 'bail', Rule::unique('payments')->where('company_id', $user->company()->id)],
|
||||||
'idempotency_key' => ['nullable', 'bail', 'string','max:64', Rule::unique('payments')->where('company_id', $user->company()->id)],
|
'idempotency_key' => ['nullable', 'bail', 'string','max:64', Rule::unique('payments')->where('company_id', $user->company()->id)],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
|
@ -40,7 +40,7 @@ class UpdateLedger implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle() :void
|
public function handle() :void
|
||||||
{
|
{
|
||||||
nlog("Updating company ledger for client ". $this->company_ledger_id);
|
// nlog("Updating company ledger for client ". $this->company_ledger_id);
|
||||||
|
|
||||||
MultiDB::setDb($this->db);
|
MultiDB::setDb($this->db);
|
||||||
|
|
||||||
|
@ -158,6 +158,7 @@ class Payment extends BaseModel
|
|||||||
'custom_value3',
|
'custom_value3',
|
||||||
'custom_value4',
|
'custom_value4',
|
||||||
'category_id',
|
'category_id',
|
||||||
|
'idempotency_key',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user