1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Validations for recurring invoice start dates

This commit is contained in:
David Bomba 2024-01-26 08:09:06 +11:00
parent f25f905108
commit 0a8cf53be0
5 changed files with 26 additions and 8 deletions

View File

@ -75,6 +75,7 @@ class StoreRecurringInvoiceRequest extends Request
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
$rules['due_date_days'] = 'bail|sometimes|string';
$rules['exchange_rate'] = 'bail|sometimes|numeric';
$rules['next_send_date'] = 'bail|required|date|after:yesterday';
return $rules;
}

View File

@ -69,6 +69,7 @@ class UpdateRecurringInvoiceRequest extends Request
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
$rules['exchange_rate'] = 'bail|sometimes|numeric';
$rules['next_send_date'] = 'bail|required|date|after:yesterday';
return $rules;
}

View File

@ -28,14 +28,17 @@ return new class extends Migration
$line_items = $invoice->line_items;
foreach ($line_items as $key => $item) {
if(is_array($line_items))
{
foreach ($line_items as $key => $item) {
if(property_exists($item, 'product_cost')) {
$line_items[$key]->product_cost = (float) $line_items[$key]->product_cost;
}
if(property_exists($item, 'product_cost')) {
$line_items[$key]->product_cost = (float) $line_items[$key]->product_cost;
}
}
$invoice->line_items = $line_items;
$invoice->saveQuietly();

View File

@ -21,7 +21,6 @@ return new class extends Migration
Language::create(['id' => 41, 'name' => 'Lao', 'locale' => 'lo_LA']);
}
$cur = \App\Models\Currency::find(121);
if(!$cur) {
@ -36,8 +35,6 @@ return new class extends Migration
$cur->save();
}
}
/**

View File

@ -61,6 +61,22 @@ class RecurringInvoiceTest extends TestCase
$this->makeTestData();
}
public function testDateValidations()
{
$data = [
'client_id' => $this->client->hashed_id,
'frequency_id' => 5,
'next_send_date' => '0001-01-01',
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/recurring_invoices', $data)
->assertStatus(422);
}
public function testLinkingSubscription()
{
$s = Subscription::factory()