Fixes identified by CI testing

This commit is contained in:
Deon George 2022-04-20 17:05:49 +10:00
parent 16b7e0b493
commit 3fb6c0a052
4 changed files with 26 additions and 23 deletions

View File

@ -27,14 +27,12 @@ class ProductFactory extends Factory
{ {
return [ return [
'id' => $this->faker->numberBetween(1,65535), 'id' => $this->faker->numberBetween(1,65535),
// 'created_at',
// 'updated_at',
//* 'site_id', // Needs to be passed in //* 'site_id', // Needs to be passed in
// 'date_orig',
// 'date_last',
'taxable' => TRUE, 'taxable' => TRUE,
'active' => TRUE, 'active' => TRUE,
// 'position' // 'position'
// 'group_avail'
// 'avail_category'
// 'price_type' // 'price_type'
'pricing'=>json_encode([ 'pricing'=>json_encode([
[ [
@ -45,12 +43,9 @@ class ProductFactory extends Factory
] ]
] ]
]), ]),
// 'price_recurr_default' // 'price_recur_default'
// 'price_recurr_day' // 'price_recur_strict'
// 'price_recurr_weekday' // 'model_id' => 1,
// 'price_recurr_strict'
// 'prod_plugin_file'
// 'prod_plugin_data' => 1,
// 'accounting' // 'accounting'
// 'model' => 'App\Models\Product\Adsl', // 'model' => 'App\Models\Product\Adsl',
]; ];
@ -62,7 +57,7 @@ class ProductFactory extends Factory
{ {
return $this->state(function () { return $this->state(function () {
return [ return [
'price_recurr_strict' => FALSE, 'price_recur_strict' => FALSE,
]; ];
}); });
} }
@ -71,7 +66,7 @@ class ProductFactory extends Factory
{ {
return $this->state(function () { return $this->state(function () {
return [ return [
'price_recurr_strict' => TRUE, 'price_recur_strict' => TRUE,
]; ];
}); });
} }

View File

@ -42,8 +42,8 @@ class ServiceFactory extends Factory
{ {
return [ return [
'id' => $this->faker->numberBetween(1,65535), 'id' => $this->faker->numberBetween(1,65535),
// 'date_orig', // 'created_at',
// 'date_last', // 'updated_at',
//* 'site_id', // Needs to be passed in //* 'site_id', // Needs to be passed in
//* 'account_id' //* 'account_id'
// 'account_billing_id' // 'account_billing_id'
@ -52,17 +52,16 @@ class ServiceFactory extends Factory
'suspend_billing' => FALSE, 'suspend_billing' => FALSE,
'external_billing' => FALSE, 'external_billing' => FALSE,
'price' => 100, 'price' => 100,
'price_group' => 1,
// 'price_override', // 'price_override',
// 'taxable', // 'taxable',
// 'queue', // 'queue',
'date_last_invoice' => Carbon::createFromFormat('Y-m-d','2021-01-01'), 'invoice_last_at' => Carbon::createFromFormat('Y-m-d','2021-01-01'),
// 'date_next_invoice', // 'invoice_next_at',
// 'recur_schedule', // 'recur_schedule',
// 'prod_attr', // 'prod_attr',
// 'date_start', // 'start_at',
// 'date_end', // 'stop_at',
// 'orderedby_id', // 'ordered_by',
// 'order_status', // 'order_status',
// 'order_info', // 'order_info',
'model' => 'App\Models\Service\Broadband', 'model' => 'App\Models\Service\Broadband',

View File

@ -59,7 +59,7 @@ class RenameServiceTables extends Migration
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts'); $table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products'); $table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
$table->foreign(['ordered_by','site_id'])->references(['id','site_id'])->on('users'); $table->foreign(['ordered_by','site_id'])->references(['id','site_id'])->on('users');
$table->foreign(['site_id'])->references(['id'])->on('sites'); $table->foreign(['site_id'])->references(['site_id'])->on('sites');
}); });
DB::statement('ALTER TABLE service_domains RENAME TO service_domain'); DB::statement('ALTER TABLE service_domains RENAME TO service_domain');
@ -326,6 +326,11 @@ class RenameServiceTables extends Migration
foreach (DB::select('SELECT * FROM products where model="App\\\\Models\\\\Product\\\\SSL"') as $o) { foreach (DB::select('SELECT * FROM products where model="App\\\\Models\\\\Product\\\\SSL"') as $o) {
DB::select('UPDATE services set model="App\\\\Models\\\\Service\\\\SSL" WHERE product_id='.$o->id); DB::select('UPDATE services set model="App\\\\Models\\\\Service\\\\SSL" WHERE product_id='.$o->id);
}; };
Schema::table('products', function (Blueprint $table) {
$table->dropForeign(['site_id']);
$table->foreign(['site_id'])->references(['site_id'])->on('sites');
});
} }
/** /**

View File

@ -42,15 +42,19 @@ class InvoiceTest extends TestCase
$this->site_setup(); $this->site_setup();
$this->account_setup(); $this->account_setup();
dump($this->setup['site']);
// Create two services for the same account // Create two services for the same account
// First service was billed a month ago, so this invoice will have 1 service charge // First service was billed a month ago, so this invoice will have 1 service charge
$po = Product::factory()->notStrict()->create([
'site_id'=>Arr::get($this->setup,'site.a')->site_id,
]);
dump($po);
$o = Service::factory()->create([ $o = Service::factory()->create([
'site_id'=>Arr::get($this->setup,'site.a')->site_id, 'site_id'=>Arr::get($this->setup,'site.a')->site_id,
'account_id'=>Arr::get($this->setup,'account.a')->id, 'account_id'=>Arr::get($this->setup,'account.a')->id,
'product_id'=>$po->id,
]); ]);
$po = Product::factory()->notStrict()->make();
$o->product_id = $po->id;
$o->setRelation('product',$po); $o->setRelation('product',$po);
$this->assertEquals(110,$o->next_invoice_items(FALSE)->sum('total'),'Invoice Equals 110'); $this->assertEquals(110,$o->next_invoice_items(FALSE)->sum('total'),'Invoice Equals 110');