TT#78467 OWNER_VAT_SETTINGS option for calllist/conversations

OWNER_VAT_SETTINGS = 1: apply the callist "owner's" VAT settings
(VAT rate and Add VAT Y/N) for each CDR displayed.

OWNER_VAT_SETTINGS = 0: apply the CDR's source/destination
account's VAT settings for each CDR individually.

Change-Id: I08cc88afeb0a0c7cc5592b9542dc9da25bb86286
changes/41/38941/7
Rene Krenn 6 years ago
parent 00e94251ac
commit f5459af67e

@ -151,6 +151,14 @@ my $cdr_proto = NGCP::Panel::Utils::Generic::hash2obj(
my $self = shift;
return $self->{c}->model('DB')->resultset('voip_subscribers')->find({ uuid => $self->destination_user_id() });
},
source_account => sub {
my $self = shift;
return $self->{c}->model('DB')->resultset('contracts')->find($self->source_account_id());
},
destination_account => sub {
my $self = shift;
return $self->{c}->model('DB')->resultset('contracts')->find($self->destination_account_id());
},
},
);
my $fax_proto = NGCP::Panel::Utils::Generic::hash2obj(
@ -926,4 +934,3 @@ sub hal_links {
1;

@ -10,6 +10,8 @@ use NGCP::Panel::Utils::MySQL;
use NGCP::Panel::Utils::DateTime;
use NGCP::Panel::Utils::Subscriber;
use constant OWNER_VAT_SETTINGS => 1;
use constant SUPPRESS_OUT => 1;
use constant SUPPRESS_IN => 2;
use constant SUPPRESS_INOUT => 3;
@ -329,15 +331,21 @@ sub process_cdr_item {
$resource->{init_time} = $item->init_time;
$resource->{start_time} = $item->start_time;
$resource->{duration} = NGCP::Panel::Utils::DateTime::sec_to_hms($c,$item->duration,3);
$resource->{customer_cost} = $resource->{direction} eq "out" ?
$item->source_customer_cost : $item->destination_customer_cost;
if (defined $cust && $cust->add_vat) {
$resource->{total_customer_cost} = $resource->{customer_cost} * (1 + $cust->vat_rate / 100);
my $customer = $cust;
if ($resource->{direction} eq "out") {
$resource->{customer_cost} = $item->source_customer_cost;
$resource->{customer_free_time} = $item->source_customer_free_time;
$customer = $item->source_account unless OWNER_VAT_SETTINGS;
} else {
$resource->{customer_cost} = $item->destination_customer_cost;
$resource->{customer_free_time} = 0;
$customer = $item->destination_account unless OWNER_VAT_SETTINGS;
}
if (defined $customer && $customer->add_vat) {
$resource->{total_customer_cost} = $resource->{customer_cost} * (1.0 + $customer->vat_rate / 100.0);
} else {
$resource->{total_customer_cost} = $resource->{customer_cost};
}
$resource->{customer_free_time} = $resource->{direction} eq "out" ?
$item->source_customer_free_time : 0;
return $resource;

Loading…
Cancel
Save