mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Validations for recurring invoice start dates
This commit is contained in:
parent
f25f905108
commit
0a8cf53be0
@ -75,6 +75,7 @@ class StoreRecurringInvoiceRequest extends Request
|
|||||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['due_date_days'] = 'bail|sometimes|string';
|
$rules['due_date_days'] = 'bail|sometimes|string';
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
|
$rules['next_send_date'] = 'bail|required|date|after:yesterday';
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ class UpdateRecurringInvoiceRequest extends Request
|
|||||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
|
$rules['next_send_date'] = 'bail|required|date|after:yesterday';
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,15 @@ return new class extends Migration
|
|||||||
|
|
||||||
$line_items = $invoice->line_items;
|
$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->line_items = $line_items;
|
||||||
|
@ -21,7 +21,6 @@ return new class extends Migration
|
|||||||
Language::create(['id' => 41, 'name' => 'Lao', 'locale' => 'lo_LA']);
|
Language::create(['id' => 41, 'name' => 'Lao', 'locale' => 'lo_LA']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$cur = \App\Models\Currency::find(121);
|
$cur = \App\Models\Currency::find(121);
|
||||||
|
|
||||||
if(!$cur) {
|
if(!$cur) {
|
||||||
@ -36,8 +35,6 @@ return new class extends Migration
|
|||||||
$cur->save();
|
$cur->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,6 +61,22 @@ class RecurringInvoiceTest extends TestCase
|
|||||||
$this->makeTestData();
|
$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()
|
public function testLinkingSubscription()
|
||||||
{
|
{
|
||||||
$s = Subscription::factory()
|
$s = Subscription::factory()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user