The SubBooking factory now uses the abs() function to generate values, since
amount is an absolute value and the sign is stored as property of the i_o_type.
This commit is contained in:
@@ -19,27 +19,27 @@ $factory->define(App\SubBooking::class, function (Faker $faker) {
|
||||
// Overpaid
|
||||
if ($randomPersonTarget->ioType->name === 'Einnahme') {
|
||||
$randomAccountType = AccountType::incomes()->random();
|
||||
$amount = $randomPersonTarget->difference() + rand(1, 100);
|
||||
$amount = abs($randomPersonTarget->difference() + rand(1, 100));
|
||||
} else {
|
||||
$randomAccountType = AccountType::expeditures()->random();
|
||||
$amount = $randomPersonTarget->difference() + rand(1, 100);
|
||||
$amount = abs($randomPersonTarget->difference() + rand(1, 100));
|
||||
}
|
||||
} else if (rand_bool(20)) {
|
||||
// Underpaid
|
||||
if ($randomPersonTarget->ioType->name === 'Einnahme') {
|
||||
$randomAccountType = AccountType::incomes()->random();
|
||||
$amount = $randomPersonTarget->difference() - rand(1, $randomPersonTarget->difference());
|
||||
$amount = abs($randomPersonTarget->difference() - rand(1, $randomPersonTarget->difference()));
|
||||
} else {
|
||||
$randomAccountType = AccountType::expeditures()->random();
|
||||
$amount = $randomPersonTarget->difference() - rand(1, $randomPersonTarget->difference());
|
||||
$amount = abs($randomPersonTarget->difference() - rand(1, $randomPersonTarget->difference()));
|
||||
}
|
||||
} else {
|
||||
if ($randomPersonTarget->ioType->name === 'Einnahme') {
|
||||
$randomAccountType = AccountType::incomes()->random();
|
||||
$amount = $randomPersonTarget->difference();
|
||||
$amount = abs($randomPersonTarget->difference());
|
||||
} else {
|
||||
$randomAccountType = AccountType::expeditures()->random();
|
||||
$amount = $randomPersonTarget->difference();
|
||||
$amount = abs($randomPersonTarget->difference());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user