);
__PACKAGE__->make_sorted(
- MODEL => 'OrderItem',
- ONLY => [ qw(list) ],
-
- DEFAULT_BY => 'reqdate',
- DEFAULT_DIR => 1,
-
- reqdate => t8('Reqdate'),
- description => t8('Description'),
- partnumber => t8('Part Number'),
- qty => t8('Qty'),
- shipped_qty => t8('shipped'),
- ordnumber => t8('Order'),
- customer => t8('Customer'),
+ MODEL => 'OrderItem',
+ ONLY => [ qw(list) ],
+
+ DEFAULT_BY => 'reqdate',
+ DEFAULT_DIR => 1,
+
+ reqdate => t8('Reqdate'),
+ description => t8('Description'),
+ partnumber => t8('Part Number'),
+ qty => t8('Qty'),
+ shipped_qty => t8('shipped'),
+ not_shipped_qty => t8('not shipped'),
+ ordnumber => t8('Order'),
+ customer => t8('Customer'),
);
sub action_list {
my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
$self->{report} = $report;
- my @columns = qw(reqdate customer ordnumber partnumber description qty shipped_qty);
+ my @columns = qw(reqdate customer ordnumber partnumber description qty shipped_qty not_shipped_qty);
my @sortable = qw(reqdate customer ordnumber partnumber description );
my %column_defs = (
- reqdate => { sub => sub { $_[0]->reqdate_as_date || $_[0]->order->reqdate_as_date } },
- description => { sub => sub { $_[0]->description },
- obj_link => sub { $self->link_to($_[0]->part) } },
- partnumber => { sub => sub { $_[0]->part->partnumber },
- obj_link => sub { $self->link_to($_[0]->part) } },
- qty => { sub => sub { $_[0]->qty_as_number . ' ' . $_[0]->unit } },
- shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->shipped_qty, 2) . ' ' . $_[0]->unit } },
- ordnumber => { sub => sub { $_[0]->order->ordnumber },
- obj_link => sub { $self->link_to($_[0]->order) } },
- customer => { sub => sub { $_[0]->order->customer->name },
- obj_link => sub { $self->link_to($_[0]->order->customer) } },
+ reqdate => { sub => sub { $_[0]->reqdate_as_date || $_[0]->order->reqdate_as_date } },
+ description => { sub => sub { $_[0]->description },
+ obj_link => sub { $self->link_to($_[0]->part) } },
+ partnumber => { sub => sub { $_[0]->part->partnumber },
+ obj_link => sub { $self->link_to($_[0]->part) } },
+ qty => { sub => sub { $_[0]->qty_as_number . ' ' . $_[0]->unit } },
+ shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->shipped_qty, 2) . ' ' . $_[0]->unit } },
+ not_shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->qty - $_[0]->shipped_qty, 2) . ' ' . $_[0]->unit } },
+ ordnumber => { sub => sub { $_[0]->order->ordnumber },
+ obj_link => sub { $self->link_to($_[0]->order) } },
+ customer => { sub => sub { $_[0]->order->customer->name },
+ obj_link => sub { $self->link_to($_[0]->order->customer) } },
);
map { $column_defs{$_}->{text} = $::locale->text( $self->get_sort_spec->{$_}->{title} ) } keys %column_defs;
# exchangerate difference
$form->{fx}{$accno}{ $form->{"datepaid_$i"} } +=
- $form->{"paid_$i"} * ($form->{"exchangerate_$i"} - 1) + $diff;
+ $form->{"paid_$i"} * ($form->{"exchangerate_$i"} - 1) + $diff;
# gain/loss
$amount =
- $form->{"paid_$i"} * $form->{exchangerate} - $form->{"paid_$i"} *
- $form->{"exchangerate_$i"};
+ $form->{"paid_$i"} * $form->{exchangerate} - $form->{"paid_$i"} *
+ $form->{"exchangerate_$i"};
if ($amount > 0) {
- $form->{fx}{ $form->{fxgain_accno} }{ $form->{"datepaid_$i"} } +=
- $amount;
+ $form->{fx}{ $form->{fxgain_accno} }{ $form->{"datepaid_$i"} } += $amount;
} else {
- $form->{fx}{ $form->{fxloss_accno} }{ $form->{"datepaid_$i"} } +=
- $amount;
+ $form->{fx}{ $form->{fxloss_accno} }{ $form->{"datepaid_$i"} } += $amount;
}
$diff = 0;
IO->set_datepaid(table => 'ar', id => $form->{id}, dbh => $dbh);
- if ($payments_only) {
- $query = qq|UPDATE ar SET paid = ? WHERE id = ?|;
- do_query($form, $dbh, $query, $form->{paid}, conv_i($form->{id}));
-
- $dbh->commit if !$provided_dbh;
-
- $main::lxdebug->leave_sub();
- return;
- }
-
# record exchange rate differences and gains/losses
foreach my $accno (keys %{ $form->{fx} }) {
foreach my $transdate (keys %{ $form->{fx}{$accno} }) {
- if (
- ($form->{fx}{$accno}{$transdate} =
- $form->round_amount($form->{fx}{$accno}{$transdate}, 2)
- ) != 0
- ) {
+ $form->{fx}{$accno}{$transdate} = $form->round_amount($form->{fx}{$accno}{$transdate}, 2);
+ if ( $form->{fx}{$accno}{$transdate} != 0 ) {
$query =
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey, project_id)
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, '0', '1',
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|;
- @values = (conv_i($form->{"id"}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $accno, $project_id);
+ @values = (conv_i($form->{"id"}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $accno, conv_i($project_id));
do_query($form, $dbh, $query, @values);
}
}
}
+ if ($payments_only) {
+ $query = qq|UPDATE ar SET paid = ? WHERE id = ?|;
+ do_query($form, $dbh, $query, $form->{paid}, conv_i($form->{id}));
+
+ $dbh->commit if !$provided_dbh;
+
+ $main::lxdebug->leave_sub();
+ return;
+ }
+
$amount = $netamount + $tax;
# save AR record
}
}
+ if (!$form->{forex}) { # read exchangerate from input field (not hidden)
+ $form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate});
+ }
$form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{datepaid}, $buysell);
$form->{exchangerate} = $form->{forex} if $form->{forex};
my @values = map { $_ } @{ $form->{ALL_CURRENCIES} };
my %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} };
$form->{currency} = $form->{defaultcurrency} unless $form->{currency};
- $TMPL_VAR{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency};
+ # show_exchangerate is also later needed in another template
+ $form->{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency};
$TMPL_VAR{currencies} = NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
'-values' => \@values, '-labels' => \%labels,
'-onchange' => "document.getElementById('update_button').click();"
for my $i (1 .. $form->{paidaccounts}) {
next unless $form->{"paid_$i"};
map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate);
+ if (!$form->{"forex_$i"}) { #read exchangerate from input field (not hidden)
+ $form->{exchangerate} = $form->{"exchangerate_$i"};
+ }
$form->{"forex_$i"} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy');
$form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"};
}
'not logged in' => 'nicht eingeloggt',
'not running' => 'läuft nicht',
'not set' => 'nicht gesetzt',
+ 'not shipped' => 'nicht geliefert',
'not transferred in yet' => 'noch nicht eingelagert',
'not transferred out yet' => 'noch nicht ausgelagert',
'not yet executed' => 'Noch nicht ausgeführt',
<td align="center">
[% SET forex = 'forex_' _ i %]
[% SET exchangerate = 'exchangerate_' _ i %]
- [% IF forex %]
+ [% IF $forex %]
<input type="hidden" name="exchangerate_[% i %]" value="[% LxERP.format_amount($exchangerate, 2) %]">
- [% LxERP.format_amount(exchangerate, 2) %]
+ [% LxERP.format_amount($forex, 2) %]
[% ELSE %]
[% IF $changeable %]
<input name="exchangerate_[% i %]" size="10" value="[% LxERP.format_amount($exchangerate, 2, 1) %]">
[% LxERP.format_amount($exchangerate, 2, 1) %]
[% END %]
[% END %]
- <input type="hidden" name="forex_[% i %]" value="[% $forex %]">;
+ <input type="hidden" name="forex_[% i %]" value="[% $forex %]">
</td>
[% END %]
<td align="center">
[% SET forex = 'forex_' _ i %]
[% SET exchangerate = 'exchangerate_' _ i %]
- [% IF forex %]
+ [% IF $forex %]
<input type="hidden" name="exchangerate_[% i %]" value="[% LxERP.format_amount($exchangerate, 2) %]">
[% LxERP.format_amount($forex, 2) %]
[% ELSE %]