<?php

/** @var \Illuminate\Database\Eloquent\Factory $factory */

use App\Loop;
use App\LoopGroup;
use Faker\Generator as Faker;
/**
 * "max_budget" is the assumption budget for this group
 * so the outcome from this group every month must not exceed this value,
 *
 * "real_budget" the actual budget of the group after loop has been closed
 *
 * "paid" in each month object, is the money must be paid every month to users.
 *
 * "remain" in each month object, demonstrates remains amount of money in this month.
 * he intial value will be the release value
 * remain= max_budget - sum(loop_group_users.share of this month for this loop group)
 * so it demonstrates if there is another place
 *
 * "Score" the minmum score the user must have to can choose this month as a collection month
 *
 * "credit" may be plus or minus values,
 * positive values mean extra money in the group credit,
 * whereas negative values mean money taken from the system to cover the  paid amount
 */
$factory->define(LoopGroup::class, function (Faker $faker, $attributes) {
    // dd($attributes);
    return [
        'loop_id'=> factory(Loop::class)->create()->id,
        'setting' => [
            "period" => $attributes['period'] ?? $faker->numberBetween($min=3, $max= 12),
            "max_budget" => $faker->randomFloat(2),
            "real_budget" => $faker->randomFloat(2),
            "months" => [
                [
                    "hold" => $faker->randomFloat(2, 0, 100),
                    "release" => $faker->randomFloat(2, 0, 100),
                    "fees" => $faker->randomFloat(2),
                    "score" => $faker->randomFloat(2),
                    "remain" => 0,
                    "paid" => 0,
                    "credit" => 0
                ],
                [
                    "hold" => $faker->randomFloat(2, 0, 100),
                    "release" => $faker->randomFloat(2, 0, 100),
                    "fees" => $faker->randomFloat(2),
                    "score" => $faker->randomFloat(2),
                    "remain" => 0,
                    "paid" => 0,
                    "credit" => 0
                ],
                [
                    "hold" => $faker->randomFloat(2, 0, 100),
                    "release" => $faker->randomFloat(2, 0, 100),
                    "fees" => $faker->randomFloat(2),
                    "score" => $faker->randomFloat(2),
                    "remain" => 0,
                    "paid" => 0,
                    "credit" => 0
                ],
                [
                    "hold" => $faker->randomFloat(2, 0, 100),
                    "release" => $faker->randomFloat(2, 0, 100),
                    "fees" => $faker->randomFloat(2),
                    "score" => $faker->randomFloat(2),
                    "remain" => 0,
                    "paid" => 0,
                    "credit" => 0
                ]
            ],
        ],
    ];
});
