From 5cbb82747a350108c64f32f7643bd7bb7cf800a2 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Thu, 5 Jun 2014 12:11:10 +0200 Subject: [PATCH] MT#5879 Align invoice template to clean db schema --- lib/NGCP/Panel/Controller/InvoiceTemplate.pm | 9 +- lib/NGCP/Panel/Form/Contact/Admin.pm | 4 +- lib/NGCP/Panel/Form/Contact/Reseller.pm | 114 +++++++++++++++++- lib/NGCP/Panel/Utils/InvoiceTemplate.pm | 16 +-- .../invoice/default/invoice_template_svg.tt | 13 +- .../widgets/admin_topmenu_settings.tt | 1 + .../widgets/reseller_topmenu_settings.tt | 1 + 7 files changed, 135 insertions(+), 23 deletions(-) diff --git a/lib/NGCP/Panel/Controller/InvoiceTemplate.pm b/lib/NGCP/Panel/Controller/InvoiceTemplate.pm index 37d99000bb..4c01b46032 100644 --- a/lib/NGCP/Panel/Controller/InvoiceTemplate.pm +++ b/lib/NGCP/Panel/Controller/InvoiceTemplate.pm @@ -278,8 +278,8 @@ sub get_content_ajax :Chained('base') :PathPart('editcontent/get/ajax') :Args(0) my $tmpl = $c->stash->{tmpl}; my $content; - if($tmpl->base64_saved) { - $content = $tmpl->base64_saved; + if($tmpl->data) { + $content = $tmpl->data; } else { my $default = 'invoice/default/invoice_template_svg.tt'; my $t = NGCP::Panel::Utils::InvoiceTemplate::get_tt(); @@ -321,8 +321,7 @@ sub set_content_ajax :Chained('base') :PathPart('editcontent/set/ajax') :Args(0) try { $tmpl->update({ - base64_saved => $content, - base64_previewed => undef, + data => $content, }); } catch($e) { @@ -344,7 +343,7 @@ sub preview_content :Chained('base') :PathPart('editcontent/preview') :Args(0) { my ($self, $c, @args) = @_; my $tmpl = $c->stash->{tmpl}; - my $svg = $tmpl->base64_saved; + my $svg = $tmpl->data; unless(defined $svg) { NGCP::Panel::Utils::Message->error( diff --git a/lib/NGCP/Panel/Form/Contact/Admin.pm b/lib/NGCP/Panel/Form/Contact/Admin.pm index 931a87d6cb..52c032918e 100644 --- a/lib/NGCP/Panel/Form/Contact/Admin.pm +++ b/lib/NGCP/Panel/Form/Contact/Admin.pm @@ -17,7 +17,9 @@ has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], render_list => [qw/reseller firstname lastname email company street postcode city - country iban bic vatnum comregnum phonenumber mobilenumber faxnumber/], + country iban bic bankname vatnum comregnum phonenumber mobilenumber faxnumber + gpp0 gpp1 gpp2 gpp3 gpp4 gpp5 gpp6 gpp7 gpp8 gpp9 + /], ); 1; diff --git a/lib/NGCP/Panel/Form/Contact/Reseller.pm b/lib/NGCP/Panel/Form/Contact/Reseller.pm index 88871e7095..574a4f5211 100644 --- a/lib/NGCP/Panel/Form/Contact/Reseller.pm +++ b/lib/NGCP/Panel/Form/Contact/Reseller.pm @@ -108,6 +108,16 @@ has_field 'bic' => ( }, ); +has_field 'bankname' => ( + type => 'Text', + maxlength => 255, + label => 'Bank Name', + element_attr => { + rel => ['tooltip'], + title => ['The bank name of the contact bank details.'] + }, +); + has_field 'vatnum' => ( type => 'Text', label => 'VAT Number', @@ -158,6 +168,106 @@ has_field 'faxnumber' => ( }, ); +has_field 'gpp0' => ( + type => 'Text', + maxlength => 255, + label => 'General Purpose 0', + element_attr => { + rel => ['tooltip'], + title => ['A general purpose field for fee use.'] + }, +); + +has_field 'gpp1' => ( + type => 'Text', + maxlength => 255, + label => 'General Purpose 1', + element_attr => { + rel => ['tooltip'], + title => ['A general purpose field for fee use.'] + }, +); + +has_field 'gpp2' => ( + type => 'Text', + maxlength => 255, + label => 'General Purpose 2', + element_attr => { + rel => ['tooltip'], + title => ['A general purpose field for fee use.'] + }, +); + +has_field 'gpp3' => ( + type => 'Text', + maxlength => 255, + label => 'General Purpose 3', + element_attr => { + rel => ['tooltip'], + title => ['A general purpose field for fee use.'] + }, +); + +has_field 'gpp4' => ( + type => 'Text', + maxlength => 255, + label => 'General Purpose 4', + element_attr => { + rel => ['tooltip'], + title => ['A general purpose field for fee use.'] + }, +); + +has_field 'gpp5' => ( + type => 'Text', + maxlength => 255, + label => 'General Purpose 5', + element_attr => { + rel => ['tooltip'], + title => ['A general purpose field for fee use.'] + }, +); + +has_field 'gpp6' => ( + type => 'Text', + maxlength => 255, + label => 'General Purpose 6', + element_attr => { + rel => ['tooltip'], + title => ['A general purpose field for fee use.'] + }, +); + +has_field 'gpp7' => ( + type => 'Text', + maxlength => 255, + label => 'General Purpose 7', + element_attr => { + rel => ['tooltip'], + title => ['A general purpose field for fee use.'] + }, +); + +has_field 'gpp8' => ( + type => 'Text', + maxlength => 255, + label => 'General Purpose 8', + element_attr => { + rel => ['tooltip'], + title => ['A general purpose field for fee use.'] + }, +); + +has_field 'gpp9' => ( + type => 'Text', + maxlength => 255, + label => 'General Purpose 9', + element_attr => { + rel => ['tooltip'], + title => ['A general purpose field for fee use.'] + }, +); + has_field 'save' => ( type => 'Submit', value => 'Save', @@ -169,7 +279,9 @@ has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], render_list => [qw/firstname lastname email company street postcode city - country iban bic vatnum comregnum phonenumber mobilenumber faxnumber/], + country iban bic bankname vatnum comregnum phonenumber mobilenumber faxnumber + gpp0 gpp1 gpp2 gpp3 gpp4 gpp5 gpp6 gpp7 gpp8 gpp9 + /], ); has_block 'actions' => ( diff --git a/lib/NGCP/Panel/Utils/InvoiceTemplate.pm b/lib/NGCP/Panel/Utils/InvoiceTemplate.pm index 9b5a3414b9..a6b1f6aa18 100644 --- a/lib/NGCP/Panel/Utils/InvoiceTemplate.pm +++ b/lib/NGCP/Panel/Utils/InvoiceTemplate.pm @@ -24,20 +24,15 @@ sub svg_pdf { my $pagefile = "$tempdir/$pagenum.svg"; push @pagefiles, $pagefile; - - print ">>>>>>>>>>>>>>>>>> processing $pagefile\n"; - my $xp = XML::XPath->new($page); my $g = $xp->find('//g[contains(@class,"firsty-") and contains(@class,"lasty")]'); foreach my $node($g->get_nodelist) { my $class = $node->getAttribute('class'); - print ">>>>>>>>>>>>>>>>>> got class $class\n"; my $firsty = $class; my $lasty = $class; $firsty =~ s/^.+firsty\-(\d+).*$/$1/; $lasty =~ s/^.+lasty\-(\d+).*$/$1/; if(length($firsty) && length($lasty)) { - print ">>>>>>>>>>>> we got firsty=$firsty and lasty=$lasty\n"; process_child_nodes($node, $firsty, $lasty); } } @@ -124,7 +119,6 @@ sub process_child_nodes { my $delta = $a - $firsty; my $newy = $y + $delta; - print ">>>>>>>>>>>>>> attr=$attr, firsty=$firsty, a=$a, delta=$delta, new=$newy\n"; $node->removeAttribute($attr); $node->appendAttribute(XML::XPath::Node::Attribute->new($attr, $newy."mm")); } @@ -189,12 +183,12 @@ sub get_dummy_data { vat_included => 0, }, invoice => { - year => '2014', - month => '01', + period_start => time - 2592000, + period_end => time, serial => '1234567', - total_net => 12345, - vat => 12345*0.2, - total => 12345+(12345*0.2), + amount_net => 12345, + amount_vat => 12345*0.2, + amount_total => 12345+(12345*0.2), }, calls => [ map {{ diff --git a/share/templates/invoice/default/invoice_template_svg.tt b/share/templates/invoice/default/invoice_template_svg.tt index 52837287cc..2590bd50d9 100644 --- a/share/templates/invoice/default/invoice_template_svg.tt +++ b/share/templates/invoice/default/invoice_template_svg.tt @@ -6,10 +6,13 @@ money_format(amount=(billprof.interval_charge * 100), comma='.'); fixfee = aux.val; money_format(amount=(zones.totalcost), comma='.'); zonefee = aux.val; - money_format(amount=(invoice.total_net), comma='.'); netfee = aux.val; - money_format(amount=(invoice.vat), comma='.'); vatfee = aux.val; - money_format(amount=(invoice.total), comma='.'); allfee = aux.val; + money_format(amount=(invoice.amount_net), comma='.'); netfee = aux.val; + 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'); + -%] }--> @@ -57,7 +60,7 @@ Customer Nr. [% customer.external_id %] Invoice Period - [% invoice.year %]-[% invoice.month %] + [% p_start %] - [% p_end %] Date [% date_now(f='%Y-%m-%d') %] @@ -66,7 +69,7 @@ Dear Customer, - For our services provided in the month of [%invoice.year%]-[%invoice.month%], we invoice the following items: + For our services provided in the period of [% p_start %] to [% p_end %], we invoice the following items: diff --git a/share/templates/widgets/admin_topmenu_settings.tt b/share/templates/widgets/admin_topmenu_settings.tt index 1c7c5dfb93..344df436aa 100644 --- a/share/templates/widgets/admin_topmenu_settings.tt +++ b/share/templates/widgets/admin_topmenu_settings.tt @@ -28,6 +28,7 @@
  • [% c.loc('Subscribers') %]
  • [% c.loc('Subscriber Profiles') %]
  • [% c.loc('Billing') %]
  • +
  • [% c.loc('Invoice Templates') %]
  • [% c.loc('Peerings') %]
  • [% c.loc('Rewrite Rule Sets') %]
  • [% c.loc('NCOS Levels') %]
  • diff --git a/share/templates/widgets/reseller_topmenu_settings.tt b/share/templates/widgets/reseller_topmenu_settings.tt index 9aa8f1c6bf..92e7588747 100644 --- a/share/templates/widgets/reseller_topmenu_settings.tt +++ b/share/templates/widgets/reseller_topmenu_settings.tt @@ -13,6 +13,7 @@
  • [% c.loc('Subscribers') %]
  • [% c.loc('Subscriber Profiles') %]
  • [% c.loc('Billing') %]
  • +
  • [% c.loc('Invoice Templates') %]
  • [% c.loc('Rewrite Rule Sets') %]
  • [% c.loc('NCOS Levels') %]
  • [% c.loc('Sound Sets') %]