MT#6443 Calculate dashboard costs correctly

agranig/selfsignup
Gerhard Jungwirth 11 years ago
parent 32f704451a
commit 51b508fd60

@ -30,29 +30,35 @@ around handle => sub {
peering_sum => $c->model('DB')->resultset('contract_balances')->search_rs({ peering_sum => $c->model('DB')->resultset('contract_balances')->search_rs({
'start' => { '>=' => $stime }, 'start' => { '>=' => $stime },
'end' => { '<' => $etime}, 'end' => { '<' => $etime},
'product.class' => 'sippeering', -exists => $c->model('DB')->resultset('billing_mappings')->search({
}, { contract_id => \'= me.contract_id',
join => { 'product.class' => 'sippeering',
'contract' => { 'billing_mappings' => 'product' }, },{
}, alias => 'myinner',
join => 'product',
})->as_query,
})->get_column('cash_balance_interval')->sum, })->get_column('cash_balance_interval')->sum,
reseller_sum => $c->model('DB')->resultset('contract_balances')->search_rs({ reseller_sum => $c->model('DB')->resultset('contract_balances')->search_rs({
'start' => { '>=' => $stime }, 'start' => { '>=' => $stime },
'end' => { '<' => $etime}, 'end' => { '<' => $etime},
'product.class' => 'reseller', -exists => $c->model('DB')->resultset('billing_mappings')->search({
}, { contract_id => \'= me.contract_id',
join => { 'product.class' => 'reseller',
'contract' => { 'billing_mappings' => 'product' }, },{
}, alias => 'myinner',
join => 'product',
})->as_query,
})->get_column('cash_balance_interval')->sum, })->get_column('cash_balance_interval')->sum,
customer_sum => $c->model('DB')->resultset('contract_balances')->search_rs({ customer_sum => $c->model('DB')->resultset('contract_balances')->search_rs({
'start' => { '>=' => $stime }, 'start' => { '>=' => $stime },
'end' => { '<' => $etime}, 'end' => { '<' => $etime},
'billing_mappings.product_id' => undef, -exists => $c->model('DB')->resultset('billing_mappings')->search({
}, { contract_id => \'= me.contract_id',
join => { 'product.class' => 'sipaccount',
'contract' => 'billing_mappings', },{
}, alias => 'myinner',
join => 'product',
})->as_query,
})->get_column('cash_balance_interval')->sum, })->get_column('cash_balance_interval')->sum,
); );
return; return;

Loading…
Cancel
Save