use SL::DBUtils;
use SL::DO;
use SL::MoreCommon;
+use SL::IC;
use Data::Dumper;
sub invoice_details {
$form->{discount} = [];
+ IC->prepare_parts_for_printing();
+
my @arrays =
qw(runningnumber number description longdescription qty ship unit bin
deliverydate_oe ordnumber_oe transdate_oe licensenumber validuntil
my ($dec) = ($sellprice =~ /\.(\d+)/);
my $decimalplaces = max 2, length($dec);
- my $discount = $form->round_amount($form->{"qty_$i"} * $sellprice * $form->{"discount_$i"} / 100 / $price_factor->{factor}, $decimalplaces);
- my $linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice * (100 - $form->{"discount_$i"}) / 100 / $price_factor->{factor}, 2);
+ my $parsed_discount = $form->parse_amount($myconfig, $form->{"discount_$i"});
+ my $linetotal_exact = $form->{"qty_$i"} * $sellprice * (100 - $parsed_discount) / 100 / $price_factor->{factor};
+ my $linetotal = $form->round_amount($linetotal_exact, 2);
+ my $discount = $form->round_amount($form->{"qty_$i"} * $sellprice * $parsed_discount / 100 / $price_factor->{factor} - ($linetotal - $linetotal_exact),
+ $decimalplaces);
my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice / $price_factor->{factor}, 2);
$form->{"netprice_$i"} = $form->round_amount($form->{"qty_$i"} ? ($linetotal / $form->{"qty_$i"}) : 0, 2);
$linetotal = ($linetotal != 0) ? $linetotal : '';
- push @{ $form->{discount} }, ($discount != 0) ? $form->format_amount($myconfig, $discount * -1, $decimalplaces) : '';
+ push @{ $form->{discount} }, ($discount != 0) ? $form->format_amount($myconfig, $discount * -1, 2) : '';
push @{ $form->{p_discount} }, $form->{"discount_$i"};
$form->{total} += $linetotal;
if ($form->round_amount($taxrate, 7) == 0) {
if ($form->{taxincluded}) {
- foreach $item (@taxaccounts) {
- $taxamount =
- $form->round_amount($linetotal * $form->{"${item}_rate"} /
- (1 + abs($form->{"${item}_rate"})),
- 2);
+ foreach my $accno (@taxaccounts) {
+ $taxamount = $form->round_amount($linetotal * $form->{"${accno}_rate"} / (1 + abs($form->{"${accno}_rate"})), 2);
- $taxaccounts{$item} += $taxamount;
- $taxdiff += $taxamount;
+ $taxaccounts{$accno} += $taxamount;
+ $taxdiff += $taxamount;
- $taxbase{$item} += $taxbase;
+ $taxbase{$accno} += $taxbase;
}
$taxaccounts{ $taxaccounts[0] } += $taxdiff;
} else {
- foreach $item (@taxaccounts) {
- $taxaccounts{$item} += $linetotal * $form->{"${item}_rate"};
- $taxbase{$item} += $taxbase;
+ foreach my $accno (@taxaccounts) {
+ $taxaccounts{$accno} += $linetotal * $form->{"${accno}_rate"};
+ $taxbase{$accno} += $taxbase;
}
}
} else {
- foreach $item (@taxaccounts) {
- $taxaccounts{$item} +=
- $taxamount * $form->{"${item}_rate"} / $taxrate;
- $taxbase{$item} += $taxbase;
+ foreach my $accno (@taxaccounts) {
+ $taxaccounts{$accno} += $taxamount * $form->{"${accno}_rate"} / $taxrate;
+ $taxbase{$accno} += $taxbase;
}
}
$tax_rate = $taxrate * 100;
# get customer
$query =
qq|SELECT
- c.name AS customer, c.discount, c.creditlimit, c.terms,
+ c.id AS customer_id, c.name AS customer, c.discount, c.creditlimit, c.terms,
c.email, c.cc, c.bcc, c.language_id, c.payment_id,
c.street, c.zipcode, c.city, c.country,
c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id,