MT#17309 show interval values in customerbalances api

Change-Id: I39c6e79fc83da6bdffc3cf52156031ea56d5c55a
(cherry picked from commit f269c155be)
(cherry picked from commit 77bf89004d)
changes/00/5300/2
Gerhard Jungwirth 10 years ago
parent 3b044379b0
commit a90e97da0c

@ -0,0 +1,58 @@
package NGCP::Panel::Form::Balance::CustomerBalanceAPI;
use HTML::FormHandler::Moose;
extends 'NGCP::Panel::Form::Balance::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 (Read-only).'],
},
);
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 (Read-only).'],
},
);
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::Balance::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:

@ -9,7 +9,7 @@ use TryCatch;
use Data::HAL qw();
use Data::HAL::Link qw();
use HTTP::Status qw(:constants);
use NGCP::Panel::Form::Balance::CustomerBalance;
use NGCP::Panel::Form::Balance::CustomerBalanceAPI;
use NGCP::Panel::Utils::Contract;
use NGCP::Panel::Utils::ProfilePackages qw();
use NGCP::Panel::Utils::DateTime;
@ -38,7 +38,7 @@ sub _item_rs {
sub get_form {
my ($self, $c) = @_;
return NGCP::Panel::Form::Balance::CustomerBalance->new;
return NGCP::Panel::Form::Balance::CustomerBalanceAPI->new;
}
sub hal_from_item {
@ -104,7 +104,12 @@ sub update_item {
new_cash_balance => $resource->{cash_balance} * 100.0);
$resource->{cash_balance} *= 100.0;
$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},
});
$item->discard_changes;
return $item;
}

Loading…
Cancel
Save