diff options
author | Mark Wells <mark@freeside.biz> | 2014-02-27 14:04:52 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2014-02-27 15:08:21 -0800 |
commit | a0e00fa0547e99893c735ab3dbdacdb2bb054f5a (patch) | |
tree | 2784c6564ab363606a606fbbac56539006bb16a1 /httemplate | |
parent | 55190e4a18ff318cf2a0ac2eb6abaf7a3b95e087 (diff) |
package fees and usage-based fees, #27687, #25899
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/edit/part_fee.html | 44 | ||||
-rwxr-xr-x | httemplate/edit/process/part_fee.html | 17 | ||||
-rw-r--r-- | httemplate/elements/tr-part_fee_usage.html | 29 |
3 files changed, 71 insertions, 19 deletions
diff --git a/httemplate/edit/part_fee.html b/httemplate/edit/part_fee.html index b1044c921..e057a752d 100644 --- a/httemplate/edit/part_fee.html +++ b/httemplate/edit/part_fee.html @@ -14,13 +14,11 @@ 'credit_weight' => 'Credit weight', 'agentnum' => 'Agent', 'amount' => 'Flat fee amount', - 'percent' => 'Percentage of invoice amount', 'basis' => 'Based on', 'setuprecur' => 'Report this fee as', 'minimum' => 'Minimum fee', 'maximum' => 'Maximum fee', 'limit_credit' => 'Limit to customer credit balance', - 'nextbill' => 'Hold until the customer\'s next invoice', %locale_labels }, 'fields' => \@fields, @@ -56,8 +54,8 @@ my $n = 0; my (@locale_fields, %locale_labels); foreach (@locales) { push @locale_fields, - { field => 'feepartmsgnum'. $n, type => 'hidden' }, - { field => 'feepartmsgnum'. $n. '_locale', type => 'hidden' }, + { field => 'feepartmsgnum'. $n, type => 'hidden' }, + { field => 'feepartmsgnum'. $n. '_locale', type => 'hidden', value => $_ }, { field => 'feepartmsgnum'. $n. '_itemdesc', type => 'text', size => 40 }, ; $locale_labels{ 'feepartmsgnum'.$n.'_itemdesc' } = @@ -65,6 +63,19 @@ foreach (@locales) { $n++; } +$n = 0; +my %layer_fields = ( + 'charged' => [ + 'percent' => { label => 'Fraction of invoice total', type => 'percentage', }, + ], + 'owed' => [ + 'percent' => { label => 'Fraction of balance', type => 'percentage', }, + ], + 'usage' => [ + 'usage' => { type => 'part_fee_usage' } + ], +); + my @fields = ( { field => 'itemdesc', type => 'text', size => 40, }, @@ -87,11 +98,6 @@ my @fields = ( value => 'Y', }, - { field => 'nextbill', - type => 'checkbox', - value => 'Y', - }, - { field => 'setuprecur', type => 'select', options => [ 'setup', 'recur' ], @@ -101,15 +107,23 @@ my @fields = ( { type => 'justtitle', value => 'Fee calculation' }, { field => 'amount', type => 'money', }, - { field => 'percent', type => 'percentage', }, { field => 'basis', - type => 'select', - options => [ 'charged', 'owed' ], - labels => { 'charged' => 'amount charged', - 'owed' => 'balance due', }, + type => 'selectlayers', + options => [ 'charged', 'owed', 'usage' ], + labels => { 'charged' => 'amount charged', + 'owed' => 'balance due', + 'usage' => 'usage charges' }, + layer_fields => \%layer_fields, + layer_values_callback => sub { + my ($cgi, $obj) = @_; + { + 'charged' => { percent => $obj->percent }, + 'owed' => { percent => $obj->percent }, + 'usage' => { usage => [ $obj->part_fee_usage ] }, + } + }, }, - { field => 'minimum', type => 'money', }, { field => 'maximum', type => 'money', }, { field => 'limit_credit', diff --git a/httemplate/edit/process/part_fee.html b/httemplate/edit/process/part_fee.html index 25656e9b0..6d1786300 100755 --- a/httemplate/edit/process/part_fee.html +++ b/httemplate/edit/process/part_fee.html @@ -4,10 +4,19 @@ 'agent_virt' => 1, 'agent_null_right' => 'Edit global fee definitions', 'viewall_dir' => 'browse', - 'process_o2m' => { - 'table' => 'part_fee_msgcat', - 'fields' => [ 'locale', 'itemdesc' ], - }, + 'process_o2m' => [ + { + 'table' => 'part_fee_msgcat', + 'fields' => [ 'locale', 'itemdesc' ], + }, + { + 'table' => 'part_fee_usage', + 'fields' => [ 'classnum', + 'amount', + 'percent' + ], + }, + ], &> <%init> diff --git a/httemplate/elements/tr-part_fee_usage.html b/httemplate/elements/tr-part_fee_usage.html new file mode 100644 index 000000000..00f4e122a --- /dev/null +++ b/httemplate/elements/tr-part_fee_usage.html @@ -0,0 +1,29 @@ +% my $n = 0; +% foreach my $class (@classes) { +% my $pre = "feepartusagenum$n"; +% my $x = $part_fee_usage{$class->classnum} || FS::part_fee_usage->new({}); +<tr> + <td align="right"> + <input type="hidden" name="<%$pre%>" value="<% $x->partfeeusagenum %>"> + <input type="hidden" name="<%$pre%>_classnum" value="<% $class->classnum %>"> + <% $class->classname %>:</td> + <td> + <%$money_char%><input size=4 name="<%$pre%>_amount" \ + value="<% sprintf("%.2f", $x->amount) %>"> + </td> + <td>per call<b> + </b></td> + <td> + <input size=4 name="<%$pre%>_percent" \ + value="<% sprintf("%.1f", $x->percent) %>">% + </td> +</tr> +% $n++; +% } +<%init> +my %opt = @_; +my $value = $opt{'curr_value'} || $opt{'value'}; +# values is an arrayref of part_fee_usage objects +my %part_fee_usage = map { $_->classnum => $_ } @$value; +my @classes = qsearch('usage_class', { disabled => '' }); +my $money_char = FS::Conf->new->config('money_char') || '$'; +</%init> |