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:
Lukas Halbritter
2018-09-28 22:42:51 +02:00
parent 2ecf78c53d
commit 4566441d8c
+6 -6
View File
@@ -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());
} }
} }