qq| o.amount, ct.name, o.netamount, o.${vc}_id, o.globalproject_id, | .
qq| o.closed, o.delivered, o.quonumber, o.shippingpoint, o.shipvia, | .
qq| o.transaction_description, | .
+ qq| o.marge_total, o.marge_percent, | .
qq| ex.$rate AS exchangerate, | .
qq| pr.projectnumber AS globalprojectnumber, | .
qq| e.name AS employee | .
}
if ($form->{$ordnumber}) {
- $query .= qq| AND $ordnumber ILIKE ?|;
+ $query .= qq| AND o.$ordnumber ILIKE ?|;
push(@values, '%' . $form->{$ordnumber} . '%');
}
do_query($form, $dbh, $query, $form->{id}, $form->{employee_id});
}
- my $amount;
- my $linetotal;
- my $discount;
+ my $amount = 0;
+ my $linetotal = 0;
+ my $discount = 0;
my $project_id;
my $reqdate;
my $taxrate;
- my $taxamount;
+ my $taxamount = 0;
my $fxsellprice;
my %taxbase;
my @taxaccounts;
}
my $baseqty = $form->{"qty_$i"} * $basefactor;
+ $form->{"marge_percent_$i"} = $form->parse_amount($myconfig, $form->{"marge_percent_$i"}) * 1;
+ $form->{"marge_absolut_$i"} = $form->parse_amount($myconfig, $form->{"marge_absolut_$i"}) * 1;
+ $form->{"lastcost_$i"} = $form->{"lastcost_$i"} * 1;
+
# set values to 0 if nothing entered
$form->{"discount_$i"} =
$form->parse_amount($myconfig, $form->{"discount_$i"}) / 100;
# get pricegroup_id and save ist
($null, my $pricegroup_id) = split(/--/, $form->{"sellprice_pg_$i"});
$pricegroup_id *= 1;
- $subtotal = $form->{"subtotal_$i"} * 1;
# save detail record in orderitems table
@values = ();
}
$query .= qq|trans_id, parts_id, description, longdescription, qty, base_qty, | .
qq|sellprice, discount, unit, reqdate, project_id, serialnumber, ship, | .
- qq|pricegroup_id, ordnumber, transdate, cusordnumber, subtotal) | .
+ qq|pricegroup_id, ordnumber, transdate, cusordnumber, subtotal, | .
+ qq|marge_percent, marge_total, lastcost) | .
qq|VALUES (|;
if($form->{"orderitems_id_$i"}) {
$query .= qq|?,|;
push(@values, $form->{"orderitems_id_$i"});
}
- $query .= qq|?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
+ $query .= qq|?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
push(@values,
conv_i($form->{id}), conv_i($form->{"id_$i"}),
$form->{"description_$i"}, $form->{"longdescription_$i"},
$form->{"unit_$i"}, conv_date($reqdate), conv_i($form->{"project_id_$i"}),
$form->{"serialnumber_$i"}, $form->{"ship_$i"}, conv_i($pricegroup_id),
$form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}),
- $form->{"cusordnumber_$i"}, $subtotal);
+ $form->{"cusordnumber_$i"}, $form->{"subtotal_$i"} ? 't' : 'f',
+ $form->{"marge_percent_$i"}, $form->{"marge_absolut_$i"},
+ $form->{"lastcost_$i"});
do_query($form, $dbh, $query, @values);
$form->{"sellprice_$i"} = $fxsellprice;
# fill in subject if there is none
if ($form->{type} =~ /_order$/) {
- $quotation = '0';
+ $quotation = 'f';
$form->{subject} = qq|$form->{label} $form->{ordnumber}|
unless $form->{subject};
} else {
- $quotation = '1';
+ $quotation = 't';
$form->{subject} = qq|$form->{label} $form->{quonumber}|
unless $form->{subject};
}
# save OE record
$query =
- qq|UPDATE oe set | .
- qq|ordnumber = ?, quonumber = ?, cusordnumber = ?, transdate = ?, vendor_id = ?, | .
- qq|customer_id = ?, amount = ?, netamount = ?, reqdate = ?, taxincluded = ?, | .
- qq|shippingpoint = ?, shipvia = ?, notes = ?, intnotes = ?, curr = ?, closed = ?, | .
- qq|delivered = ?, proforma = ?, quotation = ?, department_id = ?, language_id = ?, | .
- qq|taxzone_id = ?, shipto_id = ?, payment_id = ?, delivery_vendor_id = ?, delivery_customer_id = ?, | .
- qq|globalproject_id = ?, employee_id = ?, salesman_id = ?, cp_id = ?, transaction_description = ? | .
- qq|WHERE id = ?|;
+ qq|UPDATE oe SET
+ ordnumber = ?, quonumber = ?, cusordnumber = ?, transdate = ?, vendor_id = ?,
+ customer_id = ?, amount = ?, netamount = ?, reqdate = ?, taxincluded = ?,
+ shippingpoint = ?, shipvia = ?, notes = ?, intnotes = ?, curr = ?, closed = ?,
+ delivered = ?, proforma = ?, quotation = ?, department_id = ?, language_id = ?,
+ taxzone_id = ?, shipto_id = ?, payment_id = ?, delivery_vendor_id = ?, delivery_customer_id = ?,
+ globalproject_id = ?, employee_id = ?, salesman_id = ?, cp_id = ?, transaction_description = ?, marge_total = ?, marge_percent = ?
+ WHERE id = ?|;
@values = ($form->{ordnumber}, $form->{quonumber},
$form->{cusordnumber}, conv_date($form->{transdate}),
$amount, $netamount, conv_date($reqdate),
$form->{taxincluded} ? 't' : 'f', $form->{shippingpoint},
$form->{shipvia}, $form->{notes}, $form->{intnotes},
- $form->{currency}, $form->{closed} ? 't' : 'f',
+ substr($form->{currency}, 0, 3), $form->{closed} ? 't' : 'f',
$form->{delivered} ? "t" : "f", $form->{proforma} ? 't' : 'f',
$quotation, conv_i($form->{department_id}),
conv_i($form->{language_id}), conv_i($form->{taxzone_id}),
conv_i($form->{globalproject_id}), conv_i($form->{employee_id}),
conv_i($form->{salesman_id}), conv_i($form->{cp_id}),
$form->{transaction_description},
+ $form->{marge_total} * 1, $form->{marge_percent} * 1,
conv_i($form->{id}));
do_query($form, $dbh, $query, @values);
qq| oe.ordnumber AS ordnumber_oe, oe.transdate AS transdate_oe, oe.cusordnumber AS cusordnumber_oe, | .
qq| p.partnumber, p.assembly, o.description, o.qty, | .
qq| o.sellprice, o.parts_id AS id, o.unit, o.discount, p.bin, p.notes AS partnotes, p.inventory_accno_id AS part_inventory_accno_id, | .
- qq| o.reqdate, o.project_id, o.serialnumber, o.ship, | .
+ qq| o.reqdate, o.project_id, o.serialnumber, o.ship, o.lastcost, | .
qq| o.ordnumber, o.transdate, o.cusordnumber, o.subtotal, o.longdescription, | .
qq| pr.projectnumber, p.formel, | .
qq| pg.partsgroup, o.pricegroup_id, (SELECT pricegroup FROM pricegroup WHERE id=o.pricegroup_id) as pricegroup | .