-
-
-
- | |.$locale->text('Payments').qq| |
-
-|;
+ } else {
- if ($form->{currency} eq $form->{defaultcurrency}) {
- @column_index = qw(datepaid source memo paid AP_paid);
- } else {
- @column_index = qw(datepaid source memo paid exchangerate AP_paid);
- }
+ IR->retrieve_item(\%myconfig, \%$form);
- $column_data{datepaid} = "".$locale->text('Date')." | ";
- $column_data{paid} = "".$locale->text('Amount')." | ";
- $column_data{exchangerate} = "".$locale->text('Exch')." | ";
- $column_data{AP_paid} = "".$locale->text('Account')." | ";
- $column_data{source} = "".$locale->text('Source')." | ";
- $column_data{memo} = "".$locale->text('Memo')." | ";
+ my $rows = scalar @{ $form->{item_list} };
- print qq|
-
-|;
- map { print "$column_data{$_}\n" } @column_index;
- print qq|
-
-|;
+ if ($rows) {
+ $form->{"qty_$i"} = 1 unless $form->parse_amount(\%myconfig, $form->{"qty_$i"});
- $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
- for $i (1 .. $form->{paidaccounts}) {
+ if ($rows > 1) {
- print qq|
-
-|;
+ select_item(mode => 'IR');
+ ::end_of_request();
- $form->{"selectAP_paid_$i"} = $form->{selectAP_paid};
- $form->{"selectAP_paid_$i"} =~ s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/;
+ } else {
+
+ # override sellprice if there is one entered
+ my $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
- # format amounts
- $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
- $form->{"exchangerate_$i"} = $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
+ # ergaenzung fuer bug 736 Lieferanten-Rabatt auch in Einkaufsrechnungen vorbelegen jb
+ $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{vendor_discount} * 100 );
+ map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit);
+ map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
- $exchangerate = qq| |;
- if ($form->{currency} ne $form->{defaultcurrency}) {
- if ($form->{"forex_$i"}) {
- $exchangerate = qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
- } else {
- $exchangerate = qq|{"exchangerate_$i"}>|;
- }
+ $form->{"marge_price_factor_$i"} = $form->{item_list}->[0]->{price_factor};
+
+ ($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/;
+ my $dec_qty = length $1;
+ my $decimalplaces = max 2, $dec_qty;
+
+ if ($sellprice) {
+ $form->{"sellprice_$i"} = $sellprice;
+ } else {
+ # if there is an exchange rate adjust sellprice
+ $form->{"sellprice_$i"} /= $exchangerate;
+ }
+
+ my $amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100);
+ $form->{creditremaining} -= $amount;
+ $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
+ $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
}
- $exchangerate .= qq|
-{"forex_$i"}>
-|;
- $column_data{"paid_$i"} = qq|| {"paid_$i"}> | |;
- $column_data{"exchangerate_$i"} = qq|$exchangerate | |;
- $column_data{"AP_paid_$i"} = qq| | |;
- $column_data{"datepaid_$i"} = qq|{"datepaid_$i"}> | |;
- $column_data{"source_$i"} = qq|{"source_$i"}> | |;
- $column_data{"memo_$i"} = qq|{"memo_$i"}> | |;
+ &display_form;
- map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
+ } else {
- print qq|
-
-|;
- }
-
- print qq|
- {oldinvtotal}>
- {paidaccounts}>
-
-
- |
-
-