Payout bugfix
This commit is contained in:
parent
922db48c36
commit
622ecaf97c
8 changed files with 73 additions and 54 deletions
|
|
@ -8,21 +8,25 @@ use DB;
|
|||
|
||||
class Quota extends Model
|
||||
{
|
||||
public static function getPayouts($season_id) {
|
||||
$quotas = Quota::getQuotas($season_id);
|
||||
public static function getPayouts() {
|
||||
$season_id = Season::getCurrent()->id;
|
||||
|
||||
$quotas = Quota::getQuotas();
|
||||
|
||||
$roundCount=Round::getCount();
|
||||
|
||||
//Quotas fuer Season wegwerfen falls vorhanden und default Wert reinschreiben
|
||||
if (sizeof($quotas)==0) {
|
||||
Quota::createDefaultQuota($season_id->id);
|
||||
$quotas = Quota::getQuotas($season_id);
|
||||
Quota::createDefaultQuota();
|
||||
$quotas = Quota::getQuotas();
|
||||
}
|
||||
|
||||
$active_user_count = sizeof(User::getActives());
|
||||
|
||||
$euro_pott = $active_user_count * $quotas["Einsatz"];
|
||||
|
||||
$euro_tagessieg_sum = intval ($euro_pott * ( $quotas["Tagessieg"] / 100 ) );
|
||||
$euro_tagessieg = Quota::get6Divisor( intval($euro_tagessieg_sum / $quotas['Runden']));
|
||||
|
||||
$euro_tagessieg = Quota::get6Divisor( intval($euro_tagessieg_sum / $roundCount));
|
||||
|
||||
$euro_gruenes_trikot = intval($euro_pott * (($quotas["Gruenes Trikot"] / 100)));
|
||||
$euro_gruenes_trikot = Quota::get6Divisor($euro_gruenes_trikot);
|
||||
|
|
@ -30,7 +34,7 @@ class Quota extends Model
|
|||
$euro_pokal= Quota::get6Divisor($euro_pokal);
|
||||
|
||||
$euro_platzierung = intval ( $euro_pott * (($quotas["Platzierung"] / 100)));
|
||||
$tagessieg_rest = $euro_tagessieg_sum - ($euro_tagessieg * $quotas['Runden']);
|
||||
$tagessieg_rest = $euro_tagessieg_sum - ($euro_tagessieg * $roundCount);
|
||||
|
||||
//Log::info("Tagessieg Rest=".$tagessieg_rest." €");
|
||||
$euro_platzierung += $tagessieg_rest;
|
||||
|
|
@ -52,7 +56,7 @@ class Quota extends Model
|
|||
$euro_liga_platz2 = Quota::get6Divisor(intval($euro_liga*(($quotas["Liga Platz 2"] / 100))));
|
||||
$euro_liga_platz3 = Quota::get6Divisor(intval($euro_liga*(($quotas["Liga Platz 3"] / 100))));
|
||||
|
||||
$finaler_rest = $euro_pott - ( $quotas['Runden']*$euro_tagessieg + $euro_gruenes_trikot + $euro_pokal + $euro_platz1
|
||||
$finaler_rest = $euro_pott - ( $roundCount*$euro_tagessieg + $euro_gruenes_trikot + $euro_pokal + $euro_platz1
|
||||
+ $euro_platz2 + $euro_platz3+ $euro_platz4 + $euro_platz5
|
||||
+ $euro_platz6 + $euro_platz7 + $euro_platz8 + $euro_platz9 + $euro_platz10
|
||||
+ $euro_liga_platz1 + $euro_liga_platz2 + $euro_liga_platz3);
|
||||
|
|
@ -83,7 +87,8 @@ class Quota extends Model
|
|||
}
|
||||
|
||||
// Subfunction of setQuotas
|
||||
public static function setQuota($name, $value, $season_id) {
|
||||
public static function setQuota($name, $value) {
|
||||
$season_id = Season::getCurrent()->id;
|
||||
$quota = Quota::all()->where('season_id','=',$season_id)->where('name','=',$name)->first();
|
||||
if (!$quota) {
|
||||
$quota = new Quota();
|
||||
|
|
@ -94,13 +99,14 @@ class Quota extends Model
|
|||
|
||||
$quota->save();
|
||||
}
|
||||
|
||||
public static function getQuota($season_id,$quota_name) {
|
||||
/*
|
||||
public static function getQuota($quota_name) {
|
||||
$quota=Quota::all()->where('season_id','=', $season_id)->where('name','=', $quota_name)->first();
|
||||
return $quota['prc'];
|
||||
}
|
||||
|
||||
public static function getQuotas($season_id) {
|
||||
*/
|
||||
public static function getQuotas() {
|
||||
$season_id = Season::getCurrent()->id;
|
||||
$quotas=Quota::all()->where('season_id','=', $season_id);
|
||||
$arr=array();
|
||||
foreach($quotas as $quota) {
|
||||
|
|
@ -110,15 +116,17 @@ class Quota extends Model
|
|||
}
|
||||
|
||||
|
||||
public static function setQuotas($quotas,$season_id) {
|
||||
public static function setQuotas($quotas) {
|
||||
$season_id = Season::getCurrent()->id;
|
||||
foreach ($quotas as $key => $quota) {
|
||||
setQuota($key, $quota, $season_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function createDefaultQuota($season_id)
|
||||
public static function createDefaultQuota()
|
||||
{
|
||||
$season_id = Season::getCurrent()->id;
|
||||
Log::info('Creating default quotas');
|
||||
DB::table('quotas')->where('season_id', '=', $season_id)->delete();
|
||||
|
||||
|
|
@ -126,13 +134,6 @@ class Quota extends Model
|
|||
$roundCount=Season::getCurrent()->rounds;
|
||||
Log::info("Creating new Quota");
|
||||
|
||||
$quota = new Quota;
|
||||
$quota->season_id = $season_id;
|
||||
$quota->name = "Runden";
|
||||
$quota->prc = $roundCount;
|
||||
$quota->save();
|
||||
|
||||
|
||||
$quota = new Quota;
|
||||
$quota->season_id = $season_id;
|
||||
$quota->name = "Einsatz";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue