conv_i($form->{"cp_id"}), $form->{transaction_description},
conv_i($form->{"id"}));
do_query($form, $dbh, $query, @values);
-
+
+ if($form->{"formname"} eq "credit_note") {
+ for my $i (1 .. $form->{paidaccounts}) {
+ $query = qq|UPDATE parts SET onhand = onhand - ? WHERE id = ?|;
+ @values = (conv_i($form->{"qty_$i"}), conv_i($form->{"id_$i"}));
+ do_query($form, $dbh, $query, @values);
+ }
+ }
+
if ($form->{storno}) {
$query =
qq!UPDATE ar SET
(SELECT tk.tax_id
FROM taxkeys tk
WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?)
- AND startdate <= $transdate
+ AND startdate <= date($transdate)
ORDER BY startdate DESC
LIMIT 1)
ORDER BY c.accno|;
qq|SELECT tk.tax_id, t.rate
FROM taxkeys tk
LEFT JOIN tax t ON tk.tax_id = t.id
- WHERE (tk.chart_id = ?) AND (startdate <= ?)
+ WHERE (tk.chart_id = ?) AND (startdate <= date(?))
ORDER BY tk.startdate DESC
LIMIT 1|;
my ($tax_id, $rate) =
ORDER BY startdate DESC
LIMIT 1)
ORDER BY c.accno|;
- @values = ($accno_id, $transdate);
+ @values = ($accno_id, $transdate eq "current_date" ? "now" : $transdate);
$stw = $dbh->prepare($query);
$stw->execute(@values) || $form->dberror($query);