revtrans => { type => 'boolean', default => 'false' },
rfqnumber => { type => 'text' },
rmanumber => { type => 'text' },
+ rndgain_accno_id => { type => 'integer'},
+ rndloss_accno_id => { type => 'integer'},
sales_delivery_order_show_delete => { type => 'boolean', default => 'true' },
sales_order_show_delete => { type => 'boolean', default => 'true' },
sales_purchase_order_ship_missing_column => { type => 'boolean', default => 'false' },
d.closedto, d.revtrans,
(SELECT cu.name FROM currencies cu WHERE cu.id=d.currency_id) AS defaultcurrency,
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
- (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
+ (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno,
+ (SELECT c.accno FROM chart c WHERE d.rndgain_accno_id = c.id) AS rndgain_accno,
+ (SELECT c.accno FROM chart c WHERE d.rndloss_accno_id = c.id) AS rndloss_accno
FROM defaults d|;
$ref = selectfirst_hashref_query($self, $dbh, $query);
map { $self->{$_} = $ref->{$_} } keys %$ref;
current_date AS transdate, d.closedto, d.revtrans,
(SELECT cu.name FROM currencies cu WHERE cu.id=d.currency_id) AS defaultcurrency,
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
- (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
+ (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno,
+ (SELECT c.accno FROM chart c WHERE d.rndgain_accno_id = c.id) AS rndgain_accno,
+ (SELECT c.accno FROM chart c WHERE d.rndloss_accno_id = c.id) AS rndloss_accno
FROM defaults d|;
$ref = selectfirst_hashref_query($self, $dbh, $query);
map { $self->{$_} = $ref->{$_} } keys %$ref;
}
}
- $form->{amount}{ $form->{id} }{ $form->{AR} } = $netamount + $tax;
+ # Invoice Summary includes Rounding
+ my $rounding = $form->round_amount(
+ $form->round_amount($netamount + $tax, 2, 1) - $form->round_amount($netamount + $tax, 2), 2
+ );
+ my $rnd_accno = $rounding == 0 ? 0
+ : $rounding > 0 ? $form->{rndgain_accno}
+ : $form->{rndloss_accno};
+ $form->{amount}{ $form->{id} }{ $form->{AR} } = $form->round_amount($netamount + $tax, 2, 1);
$form->{paid} =
$form->round_amount($form->{paid} * $form->{exchangerate} + $diff, 2);
do_query($form, $dbh, $query, @values);
}
}
+ if (!$payments_only && ($rnd_accno != 0)) {
+ $query =
+ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link)
+ VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT id FROM tax WHERE taxkey=0), 0, ?, (SELECT link FROM chart WHERE accno = ?))|;
+ @values = (conv_i($trans_id), $rnd_accno, $rounding, conv_date($form->{invdate}), conv_i($project_id), $rnd_accno);
+ do_query($form, $dbh, $query, @values);
+ $rnd_accno = 0;
+ }
}
# deduct payment differences from diff
return;
}
- $amount = $netamount + $tax;
+ $amount = $form->round_amount( $netamount + $tax, 2, 1);
# save AR record
#erweiterung fuer lieferscheinnummer (donumber) 12.02.09 jb
(SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno,
(SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno,
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
- (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
+ (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno,
+ (SELECT c.accno FROM chart c WHERE d.rndgain_accno_id = c.id) AS rndgain_accno,
+ (SELECT c.accno FROM chart c WHERE d.rndloss_accno_id = c.id) AS rndloss_accno
${query_transdate}
FROM defaults d|;
my $tax = 0;
map { $tax += $form->round_amount($taxaccounts{$_}, 2) } keys %taxaccounts;
- $amount = $form->round_amount($netamount + $tax, 2);
+ $amount = $form->round_amount($netamount + $tax, 2, 1);
$netamount = $form->round_amount($netamount, 2);
if ($form->{currency} eq $form->{defaultcurrency}) {
(SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno,
(SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno,
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
- (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
+ (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno,
+ (SELECT c.accno FROM chart c WHERE d.rndgain_accno_id = c.id) AS rndgain_accno,
+ (SELECT c.accno FROM chart c WHERE d.rndloss_accno_id = c.id) AS rndloss_accno
$query_add
FROM defaults d|;
my $ref = selectfirst_hashref_query($form, $dbh, $query);
$form->{title} = $locale->text('Delete Account');
foreach my $id (
- qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
+ qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id rndgain_accno_id rndloss_accno_id)
) {
if ($form->{id} == $form->{$id}) {
$form->error($locale->text('Cannot delete default account!'));
}
}
+ $form->{rounding} = $form->round_amount(
+ $form->round_amount($form->{invtotal}, 2, 1) - $form->round_amount($form->{invtotal}, 2), 2
+ );
+ $form->{invtotal} = $form->round_amount( $form->{invtotal}, 2, 1 );
+
# follow ups
if ($form->{id}) {
$form->{follow_ups} = FU->follow_ups('trans_id' => $form->{id}) || [];
</tr> |;
}
}
-
-# $form->{invsubtotal} = $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0); # template does this
-
} else {
foreach my $item (split / /, $form->{taxaccounts}) {
if ($form->{"${item}_base"}) {
}
}
+ $form->{rounding} = $form->round_amount(
+ $form->round_amount($form->{invtotal}, 2, 1) - $form->round_amount($form->{invtotal}, 2)
+ );
+ $form->{invtotal} = $form->round_amount( $form->{invtotal}, 2, 1);
$form->{oldinvtotal} = $form->{invtotal};
$TMPL_VAR{ALL_DELIVERY_TERMS} = SL::DB::Manager::DeliveryTerm->get_all_sorted();
'Risk' => 'Risiko',
'Risk levels' => 'Risikograde',
'Risks' => 'Risikograde',
+ 'Rounding' => 'Rundung',
+ 'Rounding Gain' => 'Rundungserträge',
+ 'Rounding Loss' => 'Rundungsaufwendungen',
'Row' => 'Zeile',
'Row #1: amount has to be different from zero.' => 'Zeile #1: Der Wert darf nicht 0 sein.',
'Row number' => 'Zeilennummer',
'Revenues EU without UStId' => '',
'Review of Aging list' => '',
'Right' => '',
+ 'Rounding' => '',
+ 'Rounding Gain' => '',
+ 'Rounding Loss' => '',
'Row #1: amount has to be different from zero.' => '',
'Row number' => '',
'Row was created from current record' => '',
--- /dev/null
+-- @tag: defaults_add_rnd_accno_ids
+-- @description: adds new columns 'rndgain_accno_id' and 'rndloss_accno_id' in table defaults, used to book roundings
+-- @depends: release_3_1_0
+ALTER TABLE defaults ADD COLUMN rndgain_accno_id Integer;
+ALTER TABLE defaults ADD COLUMN rndloss_accno_id Integer;
+
<input type="hidden" name="expense_accno_id" value="[% HTML.escape(expense_accno_id) %]">
<input type="hidden" name="fxgain_accno_id" value="[% HTML.escape(fxgain_accno_id) %]">
<input type="hidden" name="fxloss_accno_id" value="[% HTML.escape(fxloss_accno_id) %]">
+<input type="hidden" name="rndgain_accno_id" value="[% HTML.escape(rndgain_accno_id) %]">
+<input type="hidden" name="rndloss_accno_id" value="[% HTML.escape(rndloss_accno_id) %]">
<fieldset>
<legend>
<td>[% L.chart_picker('defaults.fxloss_accno_id', SELF.defaults.fxloss_accno_id, category='E,A', choose=1, style=style) %]<td>
</tr>
+ <tr>
+ <td align="right">[% LxERP.t8("Rounding Gain") %]</td>
+ <td>[% L.chart_picker('defaults.rndgain_accno_id', SELF.defaults.rndgain_accno_id, category='I,A', choose=1, style=style) %]</td>
+ </tr>
+
+ <tr>
+ <td align="right">[% LxERP.t8("Rounding Loss") %]</td>
+ <td>[% L.chart_picker('defaults.rndloss_accno_id', SELF.defaults.rndloss_accno_id, category='E,A', choose=1, style=style) %]</td>
+ </tr>
+
<tr>
<td align="right">[% LxERP.t8("Current assets account") %]</td>
<td>[% L.chart_picker('defaults.ar_paid_accno_id', SELF.defaults.ar_paid_accno_id, type='AR_paid', choose=1, style=style) %]<td>
</tr>
[%- END %]
+[%- IF rounding %]
+ <tr>
+ <th align='right'>[% 'Rounding' | $T8 %]</th>
+ <td align='right'>[% LxERP.format_amount(rounding, 2) %]</td>
+ </tr>
+[%- END %]
+
[%# tax %]
[% FOREACH item = taxaccounts_array %]
[% SET description_ref = item _ '_description' %]
</tr>
[%- END %]
[%- END %]
-
<tr>
<th align="right">[% 'Total' | $T8 %]</th>
<td align="right">[% LxERP.format_amount(invtotal, 2) %]</td>
<td>
<input type="hidden" name="fxgain_accno" value="[% fxgain_accno %]">
<input type="hidden" name="fxloss_accno" value="[% fxloss_accno %]">
+ <input type="hidden" name="rndgain_accno" value="[% rndgain_accno %]">
+ <input type="hidden" name="rndloss_accno" value="[% rndloss_accno %]">
</td>
</tr>
[%- IF show_exchangerate %]
<th align='right'>[% 'Subtotal' | $T8 %]</th>
<td align='right'>[% LxERP.format_amount(invsubtotal, 2) %]</td>
</tr>
+[%- END %]
+[%- IF rounding %]
+ <tr>
+ <th align='right'>[% 'Rounding' | $T8 %]</th>
+ <td align='right'>[% LxERP.format_amount(rounding, 2) %]</td>
+ </tr>
[%- END %]
[% tax %]
<tr>