use SL::DBUtils;
use SL::MoreCommon;
-our (%myconfig, $form);
+use strict;
sub post_transaction {
$main::lxdebug->enter_sub();
$amount = $form->round_amount( $form->{"paid_$i"} * ($form->{exchangerate} - $form->{"exchangerate_$i"}) * -1, 2);
if ($amount != 0) {
- $accno = ($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno};
+ my $accno = ($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno};
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, (SELECT taxkey_id FROM chart WHERE accno = ?))|;
@values = (conv_i($form->{id}), $accno, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $accno);
my ($self, $form) = @_;
- my ($exchangerate, $key, $akey, $i, $j, $k, $index, $taxamount, $totaltax, $taxrate, $diff);
+ my ($exchangerate, $akey, $j, $k, $index, $taxamount, $totaltax, $taxrate, $diff, $totalwithholding, $withholdingrate,
+ $totalamount, $taxincluded, $tax);
# forex
$form->{forex} = $form->{exchangerate};
$exchangerate = $form->{exchangerate} ? $form->{exchangerate} : 1;
- foreach $key (keys %{ $form->{AR_links} }) {
+ foreach my $key (keys %{ $form->{AR_links} }) {
# if there is a value we have an old entry
$j = 0;
$k = 0;
- for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
+ next unless $form->{acc_trans}{$key};
+
+ for my $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
if ($key eq "AR_paid") {
$j++;
$form->{"AR_paid_$j"} = $form->{acc_trans}{$key}->[$i-1]->{accno};
if ($form->{taxincluded} && $form->{taxrate} && $totalamount) {
# add tax to amounts and invtotal
- for $i (1 .. $form->{rowcount}) {
+ for my $i (1 .. $form->{rowcount}) {
$taxamount = ($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount;
$tax = $form->round_amount($taxamount, 2);
$diff += ($taxamount - $tax);