fix editing of billing_fees

- the foreign key billing_zone_id was not treated correctly
- also added a link to billing in the dashboard widget
- update some documentation
agranig/1_0_subfix
Gerhard Jungwirth 12 years ago
parent d1d4ec754b
commit 0af4c6293f

@ -139,7 +139,8 @@ sub fees_base :Chained('fees_list') :PathPart('') :CaptureArgs(1) {
return;
}
$c->stash(fee => {$res->get_columns}); #get_columns should not be used
$c->stash->{fee}->{'billing_zone.id'} = $res->billing_zone->id;
$c->stash->{fee}->{'billing_zone.id'} = $res->billing_zone->id
if (defined $res->billing_zone);
$c->stash(fee_result => $res);
}
@ -199,7 +200,7 @@ sub fees_edit :Chained('fees_base') :PathPart('edit') :Args(0) {
);
if($posted && $form->validated) {
$c->stash->{'fee_result'}
->update($form->fif() );
->update($form->custom_get_values_to_update() );
$c->flash(messages => [{type => 'success', text => 'Billing Profile successfully changed!'}]);
$c->response->redirect($c->uri_for($c->stash->{profile}->{id}, 'fees'));
return;
@ -307,8 +308,20 @@ Show a modal to add a new billing_fee.
=head2 fees_edit
Show a modal to edit a billing_fee.
=head2 fees_delete
Delete a billing_fee.
=head2 zones_list
basis for billing zones. part of a certain billing profile.
=head2 zones_ajax
sends a JSON representation of billing_zones und the current billing profile.
=head1 AUTHOR
Gerhard Jungwirth C<< <gjungwirth@sipwise.com> >>

@ -100,13 +100,25 @@ has_block 'actions' => (
sub custom_get_values {
my ($self) = @_;
#TODO: this has sideeffects: the value remains changed, is this bad?
my $hashvalues = $self->value;
my $hashvalues = {%{$self->value}}; #prevents sideeffects
foreach my $val(values %$hashvalues) {
$val = '' unless defined($val);
}
return $hashvalues;
}
sub custom_get_values_to_update {
my ($self) = @_;
my $hashvalues = { %{$self->value} }; #prevents sideeffects
foreach my $val(values %$hashvalues) {
$val = '' unless defined($val);
}
$hashvalues->{billing_zone_id} = defined $hashvalues->{billing_zone}->{id} ?
$hashvalues->{billing_zone}->{id}+0 :
'';
delete $hashvalues->{billing_zone};
return $hashvalues;
}
1;
# vim: set tabstop=4 expandtab:

@ -14,7 +14,7 @@
</ul>
</div>
<div class="plan-actions">
<a href="javascript:;" class="btn">Configure</a>
<a href="/billing" class="btn">Configure</a>
</div>
</div>
</div>

Loading…
Cancel
Save