Invoice testing and line item catchup
This commit is contained in:
@@ -13,65 +13,84 @@ $factory->define(App\Models\InvoiceItem::class, function (Faker $faker) {
|
||||
$factory->state(App\Models\InvoiceItem::class,'week',[
|
||||
'date_start'=>Carbon::now()->startOfWeek(),
|
||||
'date_stop'=>Carbon::now()->endOfWeek(),
|
||||
'item_type'=>0,
|
||||
]);
|
||||
|
||||
$factory->state(App\Models\InvoiceItem::class,'week-mid',[
|
||||
'date_start'=>Carbon::now()->startOfWeek(),
|
||||
'date_stop'=>Carbon::now()->endOfWeek()->addDays(3),
|
||||
'item_type'=>0,
|
||||
]);
|
||||
|
||||
// Monthly
|
||||
$factory->state(App\Models\InvoiceItem::class,'month',[
|
||||
'date_start'=>Carbon::now()->startOfMonth(),
|
||||
'date_stop'=>Carbon::now()->endOfMonth(),
|
||||
'item_type'=>0,
|
||||
]);
|
||||
|
||||
$factory->state(App\Models\InvoiceItem::class,'month-mid',[
|
||||
'date_start'=>Carbon::now()->startOfMonth(),
|
||||
'date_stop'=>Carbon::now()->endOfMonth()->addDays(Carbon::now()->daysInMonth/2+1),
|
||||
'item_type'=>0,
|
||||
]);
|
||||
|
||||
// Quarterly
|
||||
$factory->state(App\Models\InvoiceItem::class,'quarter',[
|
||||
'date_start'=>Carbon::now()->startOfQuarter(),
|
||||
'date_stop'=>Carbon::now()->endOfQuarter(),
|
||||
'item_type'=>0,
|
||||
]);
|
||||
|
||||
$factory->state(App\Models\InvoiceItem::class,'quarter-mid',[
|
||||
'date_start'=>Carbon::now()->startOfQuarter(),
|
||||
'date_stop'=>Carbon::now()->startOfQuarter()->addDays(45),
|
||||
'item_type'=>0,
|
||||
]);
|
||||
|
||||
// Half Yearly
|
||||
$factory->state(App\Models\InvoiceItem::class,'half',[
|
||||
'date_start'=>Carbon::now()->startOfHalf(),
|
||||
'date_stop'=>Carbon::now()->endOfHalf(),
|
||||
'item_type'=>0,
|
||||
]);
|
||||
|
||||
$factory->state(App\Models\InvoiceItem::class,'half-mid',[
|
||||
'date_start'=>Carbon::now()->startOfHalf(),
|
||||
'date_stop'=>Carbon::now()->startOfHalf()->addDays(90),
|
||||
'item_type'=>0,
|
||||
]);
|
||||
|
||||
// Yearly
|
||||
$factory->state(App\Models\InvoiceItem::class,'year',[
|
||||
'date_start'=>Carbon::now()->startOfYear(),
|
||||
'date_stop'=>Carbon::now()->endOfYear(),
|
||||
'item_type'=>0,
|
||||
]);
|
||||
|
||||
$factory->state(App\Models\InvoiceItem::class,'year-mid',[
|
||||
'date_start'=>Carbon::now()->startOfYear(),
|
||||
'date_stop'=>Carbon::now()->startOfYear()->addDays(181),
|
||||
'item_type'=>0,
|
||||
]);
|
||||
|
||||
// Two Yearly (price_recurr_strict ignored)
|
||||
$factory->state(App\Models\InvoiceItem::class,'2year',[
|
||||
'date_start'=>Carbon::now()->subyear(),
|
||||
'date_stop'=>Carbon::now()->subday(),
|
||||
'item_type'=>0,
|
||||
]);
|
||||
|
||||
// Three Yearly (price_recurr_strict ignored)
|
||||
$factory->state(App\Models\InvoiceItem::class,'3year',[
|
||||
'date_start'=>Carbon::now()->subyear(2),
|
||||
'date_stop'=>Carbon::now()->subday(),
|
||||
'item_type'=>0,
|
||||
]);
|
||||
|
||||
// Last Month
|
||||
$factory->state(App\Models\InvoiceItem::class,'next-invoice',[
|
||||
'date_start'=>Carbon::now()->startOfMonth(),
|
||||
'date_stop'=>Carbon::now()->endOfMonth(),
|
||||
'item_type'=>0,
|
||||
]);
|
@@ -5,15 +5,25 @@ use Faker\Generator as Faker;
|
||||
$factory->define(App\Models\Product::class, function (Faker $faker) {
|
||||
return [
|
||||
'id'=>1,
|
||||
'site_id'=>1,
|
||||
'taxable'=>1,
|
||||
'price_group'=>serialize([
|
||||
1=>[
|
||||
0=>[
|
||||
'price_setup'=>50,
|
||||
'price_base'=>100,
|
||||
]
|
||||
]
|
||||
]),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Product::class,'active',[
|
||||
'active' => '1',
|
||||
'active' => 1,
|
||||
]);
|
||||
$factory->state(App\Models\Product::class,'strict',[
|
||||
'price_recurr_strict' => '1',
|
||||
'price_recurr_strict' => 1,
|
||||
]);
|
||||
$factory->state(App\Models\Product::class,'notstrict',[
|
||||
'price_recurr_strict' => '0',
|
||||
'price_recurr_strict' => 0,
|
||||
]);
|
@@ -5,6 +5,7 @@ use Faker\Generator as Faker;
|
||||
$factory->define(App\Models\Service::class, function (Faker $faker) {
|
||||
return [
|
||||
'account_id'=>1,
|
||||
'active'=>1,
|
||||
];
|
||||
});
|
||||
|
||||
@@ -92,4 +93,17 @@ $factory->afterMakingState(App\Models\Service::class,'3year',function ($service,
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('3year')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 6;
|
||||
});
|
||||
|
||||
// Last Month
|
||||
$factory->afterMakingState(App\Models\Service::class,'next-invoice',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('next-invoice')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 1;
|
||||
});
|
||||
|
||||
// New Connect
|
||||
$factory->afterMakingState(App\Models\Service::class,'new-connect',function ($service,$faker) {
|
||||
$service->recur_schedule = 1;
|
||||
$service->date_next_invoice = \Carbon\Carbon::now()->subMonth()->startOfMonth()->addDays(\Carbon\Carbon::now()->subMonth()->daysInMonth/2);
|
||||
});
|
Reference in New Issue
Block a user