MT#5879 Rework VAT handling in invoices.

mr3.3.1
Andreas Granig 12 years ago
parent 8efa32a98a
commit 98364a891b

@ -190,20 +190,16 @@ sub create :Chained('inv_list') :PathPart('create') :Args() :Does(ACL) :ACLDetac
);
die;
}
use Data::Printer; say ">>>>>>>>>>>>>>>>>>> balance\n"; p $balance;
# TODO: generate pdf here, then insert as data
$form->params->{serial} = "test".time.int(rand(99999));
# TODO: vat should be moved to contracts
# TODO: the base fee needs to be added too!
$form->params->{amount_net} = $balance->cash_balance_interval;
$form->params->{amount_vat} =
$form->params->{amount_net} * ($billing_profile->vat_rate/100); # TODO: is it really in percent?
$form->params->{amount_net} = $balance->cash_balance_interval + $billing_profile->interval_charge; # TODO: if not a full month, calculate fraction?
$form->params->{amount_net} = $customer->add_vat ?
$form->params->{amount_net} * ($customer->vat_rate/100) : 0;
$form->params->{amount_total} = $form->params->{amount_net} + $form->params->{amount_vat};
my $svg = $tmpl->data;
my $t = NGCP::Panel::Utils::InvoiceTemplate::get_tt();
my $out = '';
@ -215,8 +211,8 @@ sub create :Chained('inv_list') :PathPart('create') :Args() :Does(ACL) :ACLDetac
$vars->{custcontact} = { $customer->contact->get_inflated_columns };
$vars->{billprof} = { $billing_profile->get_inflated_columns };
$vars->{invoice} = {
period_start => $stime->epoch, # TODO: really?
period_end => $etime->epoch,
period_start => $stime,
period_end => $etime,
serial => $form->params->{serial},
amount_net => $form->params->{amount_net},
amount_vat => $form->params->{amount_vat},
@ -224,7 +220,7 @@ sub create :Chained('inv_list') :PathPart('create') :Args() :Does(ACL) :ACLDetac
};
$vars->{calls} = []; # TODO: outbound cdrs call list
$vars->{zones} = {
totalcost => $form->params->{amount_net},
totalcost => $balance->cash_balance_interval,
data => [ values(%{ $zonecalls }) ],
};

@ -148,27 +148,6 @@ has_field 'currency' => (
},
);
has_field 'vat_rate' => (
type => 'Integer',
label => 'VAT Rate',
range_start => 0,
range_end => 100,
element_attr => {
rel => ['tooltip'],
title => ['The VAT rate in percentage (e.g. 20).']
},
);
has_field 'vat_included' => (
type => 'Boolean',
label => 'VAT Included',
element_attr => {
rel => ['tooltip'],
title => ['Whether the fees already incluside VAT.']
},
default => 0,
);
has_field 'save' => (
type => 'Submit',
value => 'Save',
@ -182,7 +161,7 @@ has_block 'fields' => (
render_list => [qw/handle name prepaid interval_charge interval_free_time interval_free_cash
fraud_interval_limit fraud_interval_lock fraud_interval_notify
fraud_daily_limit fraud_daily_lock fraud_daily_notify
currency vat_rate vat_included id/],
currency id/],
);
has_block 'actions' => (

@ -61,6 +61,10 @@ has_field 'subscriber_email_template' => (
label => 'Subscriber Creation Email Template',
do_label => 1,
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['The email template used to notify users about subscriber creation.']
},
);
has_field 'passreset_email_template' => (
@ -68,6 +72,32 @@ has_field 'passreset_email_template' => (
label => 'Password Reset Email Template',
do_label => 1,
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['The email template used to notify users about password reset.']
},
);
has_field 'vat_rate' => (
type => 'Integer',
label => 'VAT Rate',
range_start => 0,
range_end => 100,
default => 0,
element_attr => {
rel => ['tooltip'],
title => ['The VAT rate in percentage (e.g. 20).']
},
);
has_field 'add_vat' => (
type => 'Boolean',
label => 'Charge VAT',
element_attr => {
rel => ['tooltip'],
title => ['Whether to charge VAT in invoices.']
},
default => 0,
);
@ -82,7 +112,7 @@ has_field 'save' => (
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/contact billing_profile status external_id subscriber_email_template passreset_email_template/],
render_list => [qw/contact billing_profile status external_id subscriber_email_template passreset_email_template vat_rate add_vat/],
);
has_block 'actions' => (

@ -22,7 +22,7 @@ has_field 'max_subscribers' => (
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/contact billing_profile product max_subscribers status external_id subscriber_email_template passreset_email_template/],
render_list => [qw/contact billing_profile product max_subscribers status external_id subscriber_email_template passreset_email_template vat_rate add_vat/],
);
1;

@ -22,7 +22,7 @@ has_field 'max_subscribers' => (
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/contact billing_profile product max_subscribers status external_id subscriber_email_template passreset_email_template/],
render_list => [qw/contact billing_profile product max_subscribers status external_id subscriber_email_template passreset_email_template vat_rate add_vat/],
);
1;

@ -205,8 +205,8 @@ sub get_dummy_data {
vat_included => 0,
},
invoice => {
period_start => time - 2592000,
period_end => time,
period_start => NGCP::Panel::Utils::DateTime::current_local()->truncate(to => 'month'),
period_end => NGCP::Panel::Utils::DateTime::current_local()->truncate(to => 'month')->add(months => 1)->subtract(seconds => 1),
serial => '1234567',
amount_net => 12345,
amount_vat => 12345*0.2,

@ -1,12 +1,17 @@
[%
USE date;
USE date(format = '%Y-%M-%DT%h%m%s');
USE Math;
USE String;
aux.page = 1;
MACRO date_format BLOCK;
d = thedate.ymd('/') _ ' ' _ thedate.hms;
date.format(d, format);
END;
MACRO date_now BLOCK;
date.format(date.now(), f);
date.format(date.now(), format);
END;
MACRO svgopen BLOCK;
@ -75,6 +80,13 @@
x = x + f.dx;
format_field(field=f, val=call.${f.name});
val = aux.val;
IF f.prefix.length;
val = f.prefix _ val;
END;
IF f.masklen;
l = f.masklen > val.length ? val.length : f.masklen;
val = val.substr(l - 1, val.length - 1, f.mask);
END;
'<text font-family="' _ fontfamily _ '" font-size="' _ fontsize _ 'pt" x="' _ x _ 'mm" y="' _ y _ 'mm" text-anchor="'_ anc _'">';
val;
'</text>';

@ -10,8 +10,8 @@
money_format(amount=(invoice.amount_vat), comma='.'); vatfee = aux.val;
money_format(amount=(invoice.amount_total), comma='.'); allfee = aux.val;
cur = billprof.currency;
p_start = date.format(invoice.period_start, '%Y-%m-%d');
p_end = date.format(invoice.period_end, '%Y-%m-%d');
p_start = date_format(thedate=invoice.period_start, format='%Y-%m-%d');
p_end = date_format(thedate=invoice.period_end, format='%Y-%m-%d');
-%]
}-->
@ -62,7 +62,7 @@
<tspan x="190mm" dy="4mm" font-weight="bold">Invoice Period</tspan>
<tspan x="190mm" dy="4mm">[% p_start %] - [% p_end %]</tspan>
<tspan x="190mm" dy="4mm" font-weight="bold">Date</tspan>
<tspan x="190mm" dy="4mm">[% date_now(f='%Y-%m-%d') %]</tspan>
<tspan x="190mm" dy="4mm">[% date_now(format='%Y-%m-%d') %]</tspan>
</text>
<text x="20mm" y="100mm" font-family="Verdana" font-size="12pt" font-weight="bold">Your Monthly Statement</text>
@ -152,7 +152,7 @@
</text>
<line x1="22mm" y1="60mm" x2="190mm" y2="60mm" style="stroke:#000000;stroke-width:0.2mm;" />
<!--{ [% calllist(fontfamily='Verdana', fontsize=8, startx=22, starty=65, offsety=5, miny=40, maxy=260, calls=calls, fields=[{name='start_time',dx=0,date_format='%Y-%m-%d %H:%M:%S'},{name='duration',dx=50,timestamp2time=1,anchor='end'},{name='destination_user_in',dx=10},{name='zone',dx=40},{name='source_customer_cost',dx=68,money_cents=1,comma='.',anchor='end'}]) -%] }-->
<!--{ [% calllist(fontfamily='Verdana', fontsize=8, startx=22, starty=65, offsety=5, miny=40, maxy=260, calls=calls, fields=[{name='start_time',dx=0,date_format='%Y-%m-%d %H:%M:%S'},{name='duration',dx=50,timestamp2time=1,anchor='end'},{name='destination_user_in',dx=10,prefix='+',masklen=10,mask='xxx'},{name='zone',dx=40},{name='source_customer_cost',dx=68,money_cents=1,comma='.',anchor='end'}]) -%] }-->
</g>

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Loading…
Cancel
Save