# get pricegroup_id and save it
($null, my $pricegroup_id) = split(/--/, $form->{"sellprice_pg_$i"});
$pricegroup_id *= 1;
- my $subtotal = $form->{"subtotal_$i"} * 1;
# save detail record in invoice table
$query =
$form->{"unit_$i"}, conv_date($form->{"deliverydate_$i"}), conv_i($form->{"project_id_$i"}),
$form->{"serialnumber_$i"}, conv_i($pricegroup_id),
$form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}),
- $form->{"cusordnumber_$i"}, $baseqty, $subtotal,
+ $form->{"cusordnumber_$i"}, $baseqty, $form->{"subtotal_$i"} ? 't' : 'f',
$form->{"marge_percent_$i"}, $form->{"marge_absolut_$i"},
$form->{"lastcost_$i"});
do_query($form, $dbh, $query, @values);
$form->{"exchangerate_$i"}, 0);
}
}
+
+ } else { # if (!$form->{storno})
+ $form->{marge_total} *= -1;
}
if ($payments_only) {
$amount = $netamount + $tax;
- # fill in subject if there is none
- $form->{subject} = qq|$form->{label} $form->{invnumber}|
- unless $form->{subject};
-
- # if there is a message stuff it into the intnotes
- my $cc = "Cc: $form->{cc}\\r\n" if $form->{cc};
- my $bcc = "Bcc: $form->{bcc}\\r\n" if $form->{bcc};
- my $now = scalar localtime;
- $form->{intnotes} .= qq|\r
-\r| if $form->{intnotes};
-
- $form->{intnotes} .= qq|[email]\r
-Date: $now
-To: $form->{email}\r
-$cc${bcc}Subject: $form->{subject}\r
-\r
-Message: $form->{message}\r| if $form->{message};
-
# save AR record
$query = qq|UPDATE ar set
invnumber = ?,
conv_i($form->{"employee_id"}), conv_i($form->{"salesman_id"}),
$form->{"storno"} ? 't' : 'f', conv_i($form->{storno_id}), conv_i($form->{"globalproject_id"}),
conv_i($form->{"cp_id"}), $form->{transaction_description},
- $form->{marge_total}, $form->{marge_percent},
+ $form->{marge_total} * 1, $form->{marge_percent} * 1,
conv_i($form->{"id"}));
do_query($form, $dbh, $query, @values);
a.employee_id, a.salesman_id, a.payment_id,
a.language_id, a.delivery_customer_id, a.delivery_vendor_id, a.type,
a.transaction_description,
+ a.marge_total, a.marge_percent,
e.name AS employee
FROM ar a
LEFT JOIN employee e ON (e.id = a.employee_id)