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
|
// Overpaid
|
||||||
if ($randomPersonTarget->ioType->name === 'Einnahme') {
|
if ($randomPersonTarget->ioType->name === 'Einnahme') {
|
||||||
$randomAccountType = AccountType::incomes()->random();
|
$randomAccountType = AccountType::incomes()->random();
|
||||||
$amount = $randomPersonTarget->difference() + rand(1, 100);
|
$amount = abs($randomPersonTarget->difference() + rand(1, 100));
|
||||||
} else {
|
} else {
|
||||||
$randomAccountType = AccountType::expeditures()->random();
|
$randomAccountType = AccountType::expeditures()->random();
|
||||||
$amount = $randomPersonTarget->difference() + rand(1, 100);
|
$amount = abs($randomPersonTarget->difference() + rand(1, 100));
|
||||||
}
|
}
|
||||||
} else if (rand_bool(20)) {
|
} else if (rand_bool(20)) {
|
||||||
// Underpaid
|
// Underpaid
|
||||||
if ($randomPersonTarget->ioType->name === 'Einnahme') {
|
if ($randomPersonTarget->ioType->name === 'Einnahme') {
|
||||||
$randomAccountType = AccountType::incomes()->random();
|
$randomAccountType = AccountType::incomes()->random();
|
||||||
$amount = $randomPersonTarget->difference() - rand(1, $randomPersonTarget->difference());
|
$amount = abs($randomPersonTarget->difference() - rand(1, $randomPersonTarget->difference()));
|
||||||
} else {
|
} else {
|
||||||
$randomAccountType = AccountType::expeditures()->random();
|
$randomAccountType = AccountType::expeditures()->random();
|
||||||
$amount = $randomPersonTarget->difference() - rand(1, $randomPersonTarget->difference());
|
$amount = abs($randomPersonTarget->difference() - rand(1, $randomPersonTarget->difference()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($randomPersonTarget->ioType->name === 'Einnahme') {
|
if ($randomPersonTarget->ioType->name === 'Einnahme') {
|
||||||
$randomAccountType = AccountType::incomes()->random();
|
$randomAccountType = AccountType::incomes()->random();
|
||||||
$amount = $randomPersonTarget->difference();
|
$amount = abs($randomPersonTarget->difference());
|
||||||
} else {
|
} else {
|
||||||
$randomAccountType = AccountType::expeditures()->random();
|
$randomAccountType = AccountType::expeditures()->random();
|
||||||
$amount = $randomPersonTarget->difference();
|
$amount = abs($randomPersonTarget->difference());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user