diff --git a/lib/NGCP/Panel/Widget/Dashboard/AdminBillingOverview.pm b/lib/NGCP/Panel/Widget/Dashboard/AdminBillingOverview.pm index 6f08b05cd8..19ea2673c7 100644 --- a/lib/NGCP/Panel/Widget/Dashboard/AdminBillingOverview.pm +++ b/lib/NGCP/Panel/Widget/Dashboard/AdminBillingOverview.pm @@ -79,13 +79,18 @@ sub _prepare_customer_sum { my ($stime,$etime) = $self->_get_interval(); $c->stash( - customer_sum => $c->model('DB')->resultset('contract_balances')->search_rs({ - 'start' => { '>=' => $stime }, - 'end' => { '<' => $etime}, + customer_sum => $c->model('DB')->resultset('cdr_period_costs')->search_rs({ + 'period_date' => { + '>=' => $stime, + '<' => $etime, + }, + 'period' => 'month', 'product.class' => { -in => [ 'sipaccount', 'pbxaccount' ] }, - },{ - join => { contract => 'product', }, - })->get_column('cash_balance_interval'), + }, { + join => { + contract => 'product', + }, + })->get_column('customer_cost'), ); } diff --git a/lib/NGCP/Panel/Widget/Dashboard/ResellerBillingOverview.pm b/lib/NGCP/Panel/Widget/Dashboard/ResellerBillingOverview.pm index a7b26c6adf..2667743be2 100644 --- a/lib/NGCP/Panel/Widget/Dashboard/ResellerBillingOverview.pm +++ b/lib/NGCP/Panel/Widget/Dashboard/ResellerBillingOverview.pm @@ -71,20 +71,20 @@ sub reseller_sum { sub _prepare_customer_sum { my ($self, $c) = @_; my ($stime,$etime) = $self->_get_interval(); - - # how to catchup contract balances of all contracts here? - # well, we don't care for a stats view ... $c->stash( - customer_sum => $c->model('DB')->resultset('contract_balances')->search_rs({ - 'start' => { '>=' => $stime }, - 'end' => { '<' => $etime}, + customer_sum => $c->model('DB')->resultset('cdr_period_costs')->search_rs({ + 'period_date' => { + '>=' => $stime, + '<' => $etime, + }, + 'period' => 'month', 'contact.reseller_id' => $c->user->reseller_id, }, { join => { 'contract' => 'contact', }, - })->get_column('cash_balance_interval'), + })->get_column('customer_cost'), ); }