1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Merge pull request #7532 from turbo124/v5-develop

v5.3.98
This commit is contained in:
David Bomba 2022-06-10 10:13:01 +10:00 committed by GitHub
commit 93cc575148
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 5 deletions

View File

@ -74,6 +74,9 @@ class StorePaymentRequest extends Request
}
}
// if (array_key_exists('amount', $input))
// $input['amount'] = 0;
if (isset($input['credits']) && is_array($input['credits']) === false) {
$input['credits'] = null;
}
@ -94,8 +97,7 @@ class StorePaymentRequest extends Request
public function rules()
{
$rules = [
'amount' => 'sometimes|numeric',
'amount' => [new PaymentAmountsBalanceRule(), new ValidCreditsPresentRule()],
'amount' => ['numeric', 'bail', new PaymentAmountsBalanceRule(), new ValidCreditsPresentRule()],
'client_id' => 'bail|required|exists:clients,id',
'invoices.*.invoice_id' => 'bail|required|distinct|exists:invoices,id',
'invoices.*.amount' => 'bail|required',

View File

@ -71,14 +71,14 @@ class ClientLedgerBalanceUpdate implements ShouldQueue
}
nlog("Updating Balance NOW");
// nlog("Updating Balance NOW");
$company_ledger->balance = $last_record->balance + $company_ledger->adjustment;
$company_ledger->save();
});
nlog("Updating company ledger for client ". $this->client->id);
// nlog("Updating company ledger for client ". $this->client->id);
}

View File

@ -153,7 +153,7 @@ Route::group(['middleware' => ['throttle:100,1', 'api_db', 'token_auth', 'locale
Route::post('recurring_quotes/bulk', 'RecurringQuoteController@bulk')->name('recurring_quotes.bulk');
Route::put('recurring_quotes/{recurring_quote}/upload', 'RecurringQuoteController@upload');
Route::post('refresh', 'Auth\LoginController@refresh')->middleware('throttle:50,1');
Route::post('refresh', 'Auth\LoginController@refresh')->middleware('throttle:150,3');
Route::post('reports/clients', 'Reports\ClientReportController');
Route::post('reports/contacts', 'Reports\ClientContactReportController');

View File

@ -61,6 +61,77 @@ class StorePaymentValidationTest extends TestCase
);
}
public function testNumericParse()
{
$this->assertFalse(is_numeric("2760.0,139.14"));
}
public function testNoAmountGiven()
{
$data = [
// 'amount' => 0,
'client_id' => $this->client->hashed_id,
'invoices' => [
[
'invoice_id' => $this->invoice->hashed_id,
'amount' => 10,
],
],
'credits' => [
[
'credit_id' => $this->credit->hashed_id,
'amount' => 5
]
],
'date' => '2019/12/12',
];
$response = false;
try {
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/payments/', $data);
} catch (ValidationException $e) {
$message = json_decode($e->validator->getMessageBag(), 1);
nlog($e->validator->getMessageBag());
}
$response->assertStatus(200);
}
public function testInValidPaymentAmount()
{
$data = [
'amount' => "10,33",
'client_id' => $this->client->hashed_id,
'invoices' => [
],
'date' => '2019/12/12',
];
$response = false;
try {
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/payments/', $data);
} catch (ValidationException $e) {
$message = json_decode($e->validator->getMessageBag(), 1);
nlog($e->validator->getMessageBag());
}
$response->assertStatus(302);
}
public function testValidPayment()
{