$query =
qq|SELECT o.id, o.ordnumber, o.transdate, o.reqdate, | .
- qq| o.amount, ct.name, o.netamount, o.${vc}_id, o.globalproject_id, | .
+ qq| o.amount, ct.${vc}number, 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, | .
}
if ($form->{periodic_invoices_active} ne $form->{periodic_invoices_inactive}) {
- my $not = 'NOT' if ($form->{periodic_invoices_inactive});
+ my $not = $form->{periodic_invoices_inactive} ? 'NOT' : '';
$query .= qq| AND ${not} COALESCE(pcfg.active, 'f')|;
}
my ($query, $query_add, @values, @ids, $sth);
- my $ic_cvar_configs = CVar->get_configs(module => 'IC',
- dbh => $dbh);
-
# translate the ids (given by id_# and trans_id_#) into one array of ids, so we can join them later
map {
push @ids, $form->{"trans_id_$_"}
$sth = prepare_execute_query($form, $dbh, $query, @values);
$ref = $sth->fetchrow_hashref("NAME_lc");
- map { $form->{$_} = $ref->{$_} } keys %$ref;
- $form->{saved_xyznumber} = $form->{$form->{type} =~ /_quotation$/ ?
- "quonumber" : "ordnumber"};
+ if ($ref) {
+ map { $form->{$_} = $ref->{$_} } keys %$ref;
- # set all entries for multiple ids blank that yield different information
- while ($ref = $sth->fetchrow_hashref("NAME_lc")) {
- map { $form->{$_} = '' if ($ref->{$_} ne $form->{$_}) } keys %$ref;
+ # remove any trailing whitespace
+ $form->{currency} =~ s/\s*$//;
+
+ $form->{saved_xyznumber} = $form->{$form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber"};
+
+ # set all entries for multiple ids blank that yield different information
+ while ($ref = $sth->fetchrow_hashref("NAME_lc")) {
+ map { $form->{$_} = '' if ($ref->{$_} ne $form->{$_}) } keys %$ref;
+ }
}
# if not given, fill transdate with current_date
c2.accno AS income_accno, c2.new_chart_id AS income_new_chart, date($transdate) - c2.valid_from as income_valid,
c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from as expense_valid,
oe.ordnumber AS ordnumber_oe, oe.transdate AS transdate_oe, oe.cusordnumber AS cusordnumber_oe,
- p.partnumber, p.assembly, o.description, o.qty,
+ p.partnumber, p.assembly, p.listprice, o.description, o.qty,
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,
o.reqdate, o.project_id, o.serialnumber, o.ship, o.lastcost,
o.ordnumber, o.transdate, o.cusordnumber, o.subtotal, o.longdescription,
$subtotal_header = 0;
} else {
- push @{ $form->{TEMPLATE_ARRAYS}->{discount_sub} }, "";
- push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_sub} }, "";
+ push @{ $form->{TEMPLATE_ARRAYS}->{$_} }, "" for qw(discount_sub nodiscount_sub discount_sub_nofmt nodiscount_sub_nofmt);
}
if (!$form->{"discount_$i"}) {
$sth->finish;
}
- map { push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} }, $form->{"ic_cvar_$_->{name}_$i"} } @{ $ic_cvar_configs };
+ push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} },
+ CVar->format_to_template(CVar->parse($form->{"ic_cvar_$_->{name}_$i"}, $_), $_)
+ for @{ $ic_cvar_configs };
}
}