MT#17309 show interval values in customerbalances api

Change-Id: I39c6e79fc83da6bdffc3cf52156031ea56d5c55a
changes/84/5184/2
Gerhard Jungwirth 10 years ago
parent d1e0197045
commit f269c155be

@ -0,0 +1,58 @@
package NGCP::Panel::Form::CustomerBalanceAPI;
use HTML::FormHandler::Moose;
extends 'NGCP::Panel::Form::CustomerBalance';
use Moose::Util::TypeConstraints;
has_field 'cash_balance_interval' => (
type => 'Money',
label => 'Cash Balance (Interval)',
required => 1,
inflate_method => sub { return $_[1] * 100 },
deflate_method => sub { return $_[1] / 100 },
element_attr => {
rel => ['tooltip'],
title => ['The current cash balance of the customer in EUR/USD/etc for the current interval.'],
},
);
has_field 'free_time_balance_interval' => (
type => 'Integer',
label => 'Free-Time Balance',
required => 1,
element_attr => {
rel => ['tooltip'],
title => ['The current free-time balance of the customer for the current interval in seconds.'],
},
);
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/cash_balance cash_balance_interval free_time_balance free_time_balance_interval/],
);
1;
=head1 NAME
NGCP::Panel::Form::CustomerBalanceAPI
=head1 DESCRIPTION
=head1 METHODS
=head1 AUTHOR
Gerhard Jungwirth
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
# vim: set tabstop=4 expandtab:

@ -11,7 +11,7 @@ use TryCatch;
use Data::HAL qw();
use Data::HAL::Link qw();
use HTTP::Status qw(:constants);
use NGCP::Panel::Form::CustomerBalance;
use NGCP::Panel::Form::CustomerBalanceAPI;
use NGCP::Panel::Utils::Contract;
use NGCP::Panel::Utils::DateTime;
@ -32,7 +32,7 @@ sub item_rs {
sub get_form {
my ($self, $c) = @_;
return NGCP::Panel::Form::CustomerBalance->new;
return NGCP::Panel::Form::CustomerBalanceAPI->new;
}
sub hal_from_item {
@ -112,7 +112,11 @@ sub update_item {
);
$resource->{cash_balance} *= 100;
$item->update($resource);
# silently forbid to update cash_balance_interval and free_time_balance_interval
$item->update({
cash_balance => $resource->{cash_balance},
free_time_balance => $resource->{free_time_balance},
});
return $item;
}

Loading…
Cancel
Save