Dieser Commmit passt den Code an, um die Tabelle currencies zu nutzen.
my %accnos;
map { ($accnos{$_}) = split(m/--/, $form->{$_}) } qw(inventory_accno income_accno expense_accno fxgain_accno fxloss_accno ar_paid_accno);
- $form->{curr} =~ s/ //g;
- my @currencies = grep { $_ ne '' } split m/:/, $form->{curr};
- my $currency = join ':', @currencies;
-
# these defaults are database wide
my $query =
assemblynumber = ?,
sdonumber = ?,
pdonumber = ?,
- curr = ?,
businessnumber = ?,
weightunit = ?,
language_id = ?|;
$form->{articlenumber}, $form->{servicenumber},
$form->{assemblynumber},
$form->{sdonumber}, $form->{pdonumber},
- $currency,
$form->{businessnumber}, $form->{weightunit},
conv_i($form->{language_id}));
do_query($form, $dbh, $query, @values);
+ $main::lxdebug->message(0, "es gibt rowcount: " . $form->{rowcount});
+
+ for my $i (1..$form->{rowcount}) {
+ if ($form->{"curr_$i"} ne $form->{"old_curr_$i"}) {
+ $query = qq|UPDATE currencies SET curr = '| . $form->{"curr_$i"} . qq|' WHERE curr = '| . $form->{"old_curr_$i"} . qq|'|;
+ do_query($form, $dbh, $query);
+ }
+ }
+
+ if (length($form->{new_curr}) > 0) {
+ $query = qq|INSERT INTO currencies (curr) VALUES ('| . $form->{new_curr} . qq|')|;
+ do_query($form, $dbh, $query);
+ }
+
$dbh->commit();
$main::lxdebug->leave_sub();
my $dbh = $form->get_standard_dbh($myconfig);
- my ($currency, $businessnumber) = selectrow_query($form, $dbh, qq|SELECT curr, businessnumber FROM defaults|);
+ my ($businessnumber) = selectrow_query($form, $dbh, qq|SELECT businessnumber FROM defaults|);
# update name
my $query = qq|UPDATE employee SET name = ? WHERE login = ?|;
my $rc = $dbh->commit();
- # save first currency in myconfig
- $currency =~ s/:.*//;
- $form->{currency} = $currency;
-
$form->{businessnumber} = $businessnumber;
$myconfig = User->new(login => $form->{login});
my $exchangerate = 0;
$form->{defaultcurrency} = $form->get_default_currency($myconfig);
- delete $form->{currency} unless $form->{defaultcurrency};
($null, $form->{department_id}) = split(/--/, $form->{department});
$query = qq|UPDATE ap SET
invnumber = ?, transdate = ?, ordnumber = ?, vendor_id = ?, taxincluded = ?,
amount = ?, duedate = ?, paid = ?, netamount = ?,
- curr = ?, notes = ?, department_id = ?, storno = ?, storno_id = ?,
+ curr = (SELECT id FROM currencies WHERE curr = ?), notes = ?, department_id = ?, storno = ?, storno_id = ?,
globalproject_id = ?, direct_debit = ?
WHERE id = ?|;
@values = ($form->{invnumber}, conv_date($form->{transdate}),
$form->{exchangerate} = $form->format_amount($myconfig, $form->{exchangerate});
$form->{defaultcurrency} = $form->get_default_currency($myconfig);
- delete $form->{currency} unless $form->{defaultcurrency};
# Get the AP accno.
$query =
my $dbh = $provided_dbh ? $provided_dbh : $form->dbconnect_noauto($myconfig);
$form->{defaultcurrency} = $form->get_default_currency($myconfig);
- delete $form->{currency} unless $form->{defaultcurrency};
# set exchangerate
$form->{exchangerate} = ($form->{currency} eq $form->{defaultcurrency}) ? 1 :
} else {
$query = qq|SELECT nextval('glid')|;
($form->{id}) = selectrow_query($form, $dbh, $query);
- $query = qq|INSERT INTO ar (id, invnumber, employee_id) VALUES (?, 'dummy', ?)|;
- do_query($form, $dbh, $query, $form->{id}, $form->{employee_id});
+ $query = qq|INSERT INTO ar (id, invnumber, employee_id, curr) VALUES (?, 'dummy', ?, (SELECT id FROM currencies WHERE curr=?))|;
+ do_query($form, $dbh, $query, $form->{id}, $form->{employee_id}, $form->{currency});
$form->{invnumber} = $form->update_defaults($myconfig, "invnumber", $dbh) unless $form->{invnumber};
}
}
qq|UPDATE ar set
invnumber = ?, ordnumber = ?, transdate = ?, customer_id = ?,
taxincluded = ?, amount = ?, duedate = ?, paid = ?,
- netamount = ?, curr = ?, notes = ?, department_id = ?,
+ netamount = ?, notes = ?, department_id = ?,
employee_id = ?, storno = ?, storno_id = ?, globalproject_id = ?,
direct_debit = ?
WHERE id = ?|;
my @values = ($form->{invnumber}, $form->{ordnumber}, conv_date($form->{transdate}), conv_i($form->{customer_id}), $form->{taxincluded} ? 't' : 'f', $form->{amount},
- conv_date($form->{duedate}), $form->{paid}, $form->{netamount}, $form->{currency}, $form->{notes}, conv_i($form->{department_id}),
+ conv_date($form->{duedate}), $form->{paid}, $form->{netamount}, $form->{notes}, conv_i($form->{department_id}),
conv_i($form->{employee_id}), $form->{storno} ? 't' : 'f', $form->{storno_id},
conv_i($form->{globalproject_id}), $form->{direct_debit} ? 't' : 'f', conv_i($form->{id}));
do_query($form, $dbh, $query, @values);
$form->{exchangerate} = $form->format_amount($myconfig, $form->{exchangerate});
$form->{defaultcurrency} = $form->get_default_currency($myconfig);
- delete $form->{currency} unless $form->{defaultcurrency};
# Get the AR accno (which is normally done by Form::create_links()).
$query =
}
$sth->finish;
- # get currencies and closedto
- $query = qq|SELECT curr, closedto FROM defaults|;
- ($form->{currencies}, $form->{closedto}) =
- selectrow_query($form, $dbh, $query);
+ # get closedto
+ $query = qq|SELECT closedto FROM defaults|;
+ ($form->{closedto}) = selectrow_query($form, $dbh, $query);
$dbh->disconnect;
my $arap = $form->{arap} eq "ar" ? "ar" : "ap";
my $query =
- qq|SELECT a.id, a.invnumber, a.transdate, a.amount, a.paid, a.curr | .
+ qq|SELECT a.id, a.invnumber, a.transdate, a.amount, a.paid, cu.curr | .
qq|FROM $arap a | .
- qq|WHERE (a.${vc}_id = ?) AND (COALESCE(a.curr, '') = ?) AND NOT (a.amount = a.paid)| .
+ qq|LEFT JOIN currencies cu ON (cu.id=a.curr)| .
+ qq|WHERE (a.${vc}_id = ?) AND cu.curr = ? AND NOT (a.amount = a.paid)| .
qq|ORDER BY a.id|;
my $sth = prepare_execute_query($form, $dbh, $query,
conv_i($form->{"${vc}_id"}),
SELECT COUNT(*)
FROM $arap
WHERE (${vc}_id = ?)
- AND (COALESCE(curr, '') <> ?)
+ AND ((SELECT cu.curr FROM currencies cu WHERE cu.id=${arap}.curr) <> ?)
AND (amount <> paid)
SQL
($form->{openinvoices_other_currencies}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{"${vc}_id"}), "$form->{currency}");
qq|SELECT $buysell | .
qq|FROM exchangerate e | .
qq|JOIN ${arap} a ON (a.transdate = e.transdate) | .
- qq|WHERE (e.curr = ?) AND (a.id = ?)|;
+ qq|WHERE (e.curr = (SELECT id FROM currencies WHERE curr = ?)) AND (a.id = ?)|;
my ($exchangerate) =
selectrow_query($form, $dbh, $query,
$form->{currency}, $form->{"id_$i"});
my $ref = $sth->fetchrow_hashref("NAME_lc");
map { $form->{$_} = $ref->{$_} } keys %$ref;
+ $sth->finish;
- # remove any trailing whitespace
- $form->{curr} =~ s/\s*$//;
+ #get name of currency instead of id:
+ $query = qq|SELECT curr FROM currencies WHERE id=?|;
+ ($form->{curr}) = selectrow_query($form, $dbh, $query, conv_i($form->{curr}));
- $sth->finish;
if ( $form->{salesman_id} ) {
my $query =
qq|SELECT ct.name AS salesman | .
qq|user_password = ?, | .
qq|c_vendor_id = ?, | .
qq|klass = ?, | .
- qq|curr = ?, | .
+ qq|curr = (SELECT id FROM currencies WHERE curr = ?), | .
qq|taxincluded_checked = ? | .
qq|WHERE id = ?|;
my @values = (
$form->{user_password},
$form->{c_vendor_id},
conv_i($form->{klass}),
- substr($form->{currency}, 0, 3),
+ $form->{currency},
$form->{taxincluded_checked} ne '' ? $form->{taxincluded_checked} : undef,
$form->{id}
);
qq| username = ?, | .
qq| user_password = ?, | .
qq| v_customer_id = ?, | .
- qq| curr = ? | .
+ qq| curr = (SELECT id FROM currencies WHERE curr = ?) | .
qq|WHERE id = ?|;
my @values = (
$form->{vendornumber},
$form->{username},
$form->{user_password},
$form->{v_customer_id},
- substr($form->{currency}, 0, 3),
+ $form->{currency},
$form->{id}
);
do_query($form, $dbh, $query, @values);
-- duedate:
(SELECT duedate FROM dunning WHERE dunning_id = ? LIMIT 1),
'f', -- invoice
- ?, -- curr
+ (SELECT id FROM currencies WHERE curr = ?), -- curr
?, -- notes
-- employee_id:
(SELECT id FROM employee WHERE login = ?)
ar.transdate, ar.duedate, ar.customer_id,
ar.invnumber, ar.ordnumber, ar.cp_id,
ar.amount, ar.netamount, ar.paid,
- ar.curr,
+ (SELECT cu.curr FROM currencies cu WHERE cu.id=ar.curr) AS curr,
ar.amount - ar.paid AS open_amount,
ar.amount - ar.paid + da.fee + da.interest AS linetotal
shippingpoint = ?, shipvia = ?, notes = ?, intnotes = ?, closed = ?,
delivered = ?, department_id = ?, language_id = ?, shipto_id = ?,
globalproject_id = ?, employee_id = ?, salesman_id = ?, cp_id = ?, transaction_description = ?,
- is_sales = ?, taxzone_id = ?, taxincluded = ?, terms = ?, curr = ?
+ is_sales = ?, taxzone_id = ?, taxincluded = ?, terms = ?, curr = (SELECT id FROM currencies WHERE curr = ?)
WHERE id = ?|;
@values = ($form->{donumber}, $form->{ordnumber},
d.description AS department, dord.language_id,
dord.shipto_id,
dord.globalproject_id, dord.delivered, dord.transaction_description,
- dord.taxzone_id, dord.taxincluded, dord.terms, dord.curr AS currency
+ dord.taxzone_id, dord.taxincluded, dord.terms, (SELECT cu.curr FROM currencies cu WHERE cu.id=dord.curr) AS currency
FROM delivery_orders dord
JOIN ${vc} cv ON (dord.${vc}_id = cv.id)
LEFT JOIN employee e ON (dord.employee_id = e.id)
}
$sth->finish();
- # remove any trailing whitespace
- $form->{currency} =~ s/\s*$//;
-
$form->{donumber_array} =~ s/\s*$//g;
$form->{saved_donumber} = $form->{donumber};
$main::lxdebug->leave_sub();
return;
}
- $query = qq|SELECT curr FROM defaults|;
-
- my ($currency) = selectrow_query($self, $dbh, $query);
- my ($defaultcurrency) = split m/:/, $currency;
+ $query = qq|SELECT curr FROM currencies WHERE id=(SELECT curr FROM defaults)|;
+ my ($defaultcurrency) = selectrow_query($self, $dbh, $query);
if ($curr eq $defaultcurrency) {
$main::lxdebug->leave_sub();
}
$query = qq|SELECT e.curr FROM exchangerate e
- WHERE e.curr = ? AND e.transdate = ?
+ WHERE e.curr = (SELECT cu.id FROM currencies cu WHERE cu.curr=?) AND e.transdate = ?
FOR UPDATE|;
my $sth = prepare_execute_query($self, $dbh, $query, $curr, $transdate);
if ($sth->fetchrow_array) {
$query = qq|UPDATE exchangerate
SET $set
- WHERE curr = ?
+ WHERE curr = (SELECT id FROM currencies WHERE curr = ?)
AND transdate = ?|;
} else {
$query = qq|INSERT INTO exchangerate (curr, buy, sell, transdate)
- VALUES (?, $buy, $sell, ?)|;
+ VALUES ((SELECT id FROM currencies WHERE curr = ?), $buy, $sell, ?)|;
}
$sth->finish;
do_query($self, $dbh, $query, $curr, $transdate);
return 1;
}
- $query = qq|SELECT curr FROM defaults|;
+ $query = qq|SELECT curr FROM currencies WHERE id = (SELECT curr FROM defaults)|;
- my ($currency) = selectrow_query($self, $dbh, $query);
- my ($defaultcurrency) = split m/:/, $currency;
+ my ($defaultcurrency) = selectrow_query($self, $dbh, $query);
- if ($currency eq $defaultcurrency) {
+ if ($curr eq $defaultcurrency) {
$main::lxdebug->leave_sub();
return 1;
}
$query = qq|SELECT e.$fld FROM exchangerate e
- WHERE e.curr = ? AND e.transdate = ?|;
+ WHERE e.curr = (SELECT id FROM currencies WHERE curr = ?) AND e.transdate = ?|;
my ($exchangerate) = selectrow_query($self, $dbh, $query, $curr, $transdate);
my $dbh = $self->get_standard_dbh($myconfig);
my $query = qq|SELECT e.$fld FROM exchangerate e
- WHERE e.curr = ? AND e.transdate = ?|;
+ WHERE e.curr = (SELECT id FROM currencies WHERE curr = ?) AND e.transdate = ?|;
my ($exchangerate) = selectrow_query($self, $dbh, $query, $currency, $transdate);
my $self = shift;
my $myconfig = shift || \%::myconfig;
my $dbh = $self->get_standard_dbh($myconfig);
+ my @currencies =();
- my $query = qq|SELECT curr FROM defaults|;
+ my $query = qq|SELECT curr FROM currencies|;
- my ($curr) = selectrow_query($self, $dbh, $query);
- my @currencies = grep { $_ } map { s/\s//g; $_ } split m/:/, $curr;
+ my $sth = prepare_execute_query($self, $dbh, $query);
+
+ while (my $ref = $sth->fetchrow_hashref()) {
+ push(@currencies, $ref->{curr});
+ }
+ $sth->finish;
$main::lxdebug->leave_sub();
$main::lxdebug->enter_sub();
my ($self, $myconfig) = @_;
- my @currencies = $self->get_all_currencies($myconfig);
+ my $dbh = $self->get_standard_dbh($myconfig);
+ my $query = qq|SELECT curr FROM currencies WHERE id = (SELECT curr FROM defaults)|;
+
+ my ($defaultcurrency) = selectrow_query($self, $dbh, $query);
$main::lxdebug->leave_sub();
- return $currencies[0];
+ return $defaultcurrency;
}
sub set_payment_options {
$key = "all_currencies" unless ($key);
- my $query = qq|SELECT curr AS currency FROM defaults|;
-
- $self->{$key} = [split(/\:/ , selectfirst_hashref_query($self, $dbh, $query)->{currency})];
+ $self->{$key} = [$self->get_all_currencies()];
$main::lxdebug->leave_sub();
}
$query =
qq|SELECT
a.cp_id, a.invnumber, a.transdate, a.${table}_id, a.datepaid,
- a.duedate, a.ordnumber, a.taxincluded, a.curr AS currency, a.notes,
+ a.duedate, a.ordnumber, a.taxincluded, (SELECT cu.curr FROM currencies cu WHERE cu.id=a.curr) AS currency, a.notes,
a.intnotes, a.department_id, a.amount AS oldinvtotal,
a.paid AS oldtotalpaid, a.employee_id, a.gldate, a.type,
a.globalproject_id, ${extra_columns}
$self->{$key} = $ref->{$key};
}
- # remove any trailing whitespace
- $self->{currency} =~ s/\s*$//;
-
my $transdate = "current_date";
if ($self->{transdate}) {
$transdate = $dbh->quote($self->{transdate});
}
$sth->finish;
+ #check das:
$query =
qq|SELECT
- d.curr AS currencies, d.closedto, d.revtrans,
+ d.closedto, d.revtrans,
+ (SELECT cu.curr FROM currencies cu WHERE cu.id=d.curr) AS defaultcurrency,
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
(SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
FROM defaults d|;
# get date
$query =
qq|SELECT
- current_date AS transdate, d.curr AS currencies, d.closedto, d.revtrans,
+ current_date AS transdate, d.closedto, d.revtrans,
+ (SELECT cu.curr FROM currencies cu WHERE cu.id=d.curr) AS defaultcurrency,
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
(SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
FROM defaults d|;
if ($self->{"$self->{vc}_id"}) {
# only setup currency
- ($self->{currency}) = split(/:/, $self->{currencies}) if !$self->{currency};
+ ($self->{currency}) = $self->{defaultcurrency} if !$self->{currency};
} else {
my ($arap, $where);
$table = $table eq "customer" ? "customer" : "vendor";
- my %column_map = ("a.curr" => "currency",
- "a.${table}_id" => "${table}_id",
+ my %column_map = ("a.${table}_id" => "${table}_id",
"a.department_id" => "department_id",
"d.description" => "department",
"ct.name" => $table,
- "ct.curr" => "cv_curr",
+ "cu.curr" => "currency",
"current_date + ct.terms" => "duedate",
);
if ($self->{type} =~ /delivery_order/) {
$arap = 'delivery_orders';
- delete $column_map{"a.curr"};
- delete $column_map{"ct.curr"};
+ delete $column_map{"cu.currency"};
} elsif ($self->{type} =~ /_order/) {
$arap = 'oe';
FROM $arap a
LEFT JOIN $table ct ON (a.${table}_id = ct.id)
LEFT JOIN department d ON (a.department_id = d.id)
+ LEFT JOIN currencies cu ON (cu.id=ct.curr)
WHERE a.id = ?|;
my $ref = selectfirst_hashref_query($self, $dbh, $query, $trans_id);
map { $self->{$_} = $ref->{$_} } values %column_map;
- # remove any trailing whitespace
- $self->{currency} =~ s/\s*$// if $self->{currency};
- $self->{cv_curr} =~ s/\s*$// if $self->{cv_curr};
-
- # if customer/vendor currency is set use this
- $self->{currency} = $self->{cv_curr} if $self->{cv_curr};
-
$main::lxdebug->leave_sub();
}
# connect to database, turn off autocommit
my $dbh = $provided_dbh ? $provided_dbh : $form->dbconnect_noauto($myconfig);
$form->{defaultcurrency} = $form->get_default_currency($myconfig);
+ my $defaultcurrency = $form->{defaultcurrency};
my $ic_cvar_configs = CVar->get_configs(module => 'IC',
dbh => $dbh);
my $all_units = AM->retrieve_units($myconfig, $form);
+#markierung
if (!$payments_only) {
if ($form->{id}) {
&reverse_invoice($dbh, $form);
} else {
($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('glid')|);
- do_query($form, $dbh, qq|INSERT INTO ap (id, invnumber) VALUES (?, '')|, $form->{id});
+ do_query($form, $dbh, qq|INSERT INTO ap (id, invnumber, curr) VALUES (?, '', (SELECT id FROM currencies WHERE curr=?))|, $form->{id}, $form->{currency});
}
}
- my ($currencies) = selectfirst_array_query($form, $dbh, qq|SELECT curr FROM defaults|);
- my $defaultcurrency = (split m/:/, $currencies)[0];
-
if ($form->{currency} eq $defaultcurrency) {
$form->{exchangerate} = 1;
} else {
orddate = ?, quodate = ?, vendor_id = ?, amount = ?,
netamount = ?, paid = ?, duedate = ?,
invoice = ?, taxzone_id = ?, notes = ?, taxincluded = ?,
- intnotes = ?, curr = ?, storno_id = ?, storno = ?,
+ intnotes = ?, storno_id = ?, storno = ?,
cp_id = ?, employee_id = ?, department_id = ?,
globalproject_id = ?, direct_debit = ?
WHERE id = ?|;
conv_date($form->{orddate}), conv_date($form->{quodate}), conv_i($form->{vendor_id}), $amount,
$netamount, $form->{paid}, conv_date($form->{duedate}),
'1', $taxzone_id, $form->{notes}, $form->{taxincluded} ? 't' : 'f',
- $form->{intnotes}, $form->{currency}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f',
+ $form->{intnotes}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f',
conv_i($form->{cp_id}), conv_i($form->{employee_id}), conv_i($form->{department_id}),
conv_i($form->{globalproject_id}),
$form->{direct_debit} ? 't' : 'f',
(SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno,
(SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno,
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
- (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno,
- d.curr AS currencies
+ (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
$q_invdate
FROM defaults d|;
$ref = selectfirst_hashref_query($form, $dbh, $query);
$query = qq|SELECT cp_id, invnumber, transdate AS invdate, duedate,
orddate, quodate, globalproject_id,
ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate,
- intnotes, curr AS currency, direct_debit
+ intnotes, (SELECT cu.curr FROM currencies cu WHERE cu.id=ap.curr) AS currency, direct_debit
FROM ap
WHERE id = ?|;
$ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($form->{id}));
map { $form->{$_} = $ref->{$_} } keys %$ref;
- # remove any trailing whitespace
- $form->{currency} =~ s/\s*$//;
-
$form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "sell");
# get shipto
v.id AS vendor_id, v.name AS vendor, v.discount as vendor_discount,
v.creditlimit, v.terms, v.notes AS intnotes,
v.email, v.cc, v.bcc, v.language_id, v.payment_id,
- v.street, v.zipcode, v.city, v.country, v.taxzone_id, v.curr, v.direct_debit,
+ v.street, v.zipcode, v.city, v.country, v.taxzone_id, (SELECT cu.curr FROM currencies cu WHERE cu.id=v.curr) AS curr, v.direct_debit,
$duedate + COALESCE(pt.terms_netto, 0) AS duedate,
b.description AS business
FROM vendor v
my $ref = selectfirst_hashref_query($form, $dbh, $query, @values);
map { $params->{$_} = $ref->{$_} } keys %$ref;
- # remove any trailing whitespace
- $form->{curr} =~ s/\s*$//;
-
- # use vendor currency if not empty
- $form->{currency} = $form->{curr} if $form->{curr};
+ # use vendor currency
+ $form->{currency} = $form->{curr};
$params->{creditremaining} = $params->{creditlimit};
# fax and phone and email as vendor*
my $query =
qq|SELECT ct.*, cp.*, ct.notes as vendornotes, phone as vendorphone, fax as vendorfax, email as vendoremail,
- ct.curr AS currency
+ (SELECT cu.curr FROM currencies cu WHERE cu.id=ct.curr) AS currency
FROM vendor ct
LEFT JOIN contacts cp ON (ct.id = cp.cp_cv_id)
WHERE (ct.id = ?) $contact
}
map { $form->{$_} = $ref->{$_} } keys %$ref;
- # remove any trailing whitespace
- $form->{currency} =~ s/\s*$// if ($form->{currency});
my $custom_variables = CVar->get_custom_variables('dbh' => $dbh,
'module' => 'CT',
my $query =
qq|SELECT ct.*, cp.*, ct.notes as customernotes,
ct.phone AS customerphone, ct.fax AS customerfax, ct.email AS customeremail,
- ct.curr AS currency
+ (SELECT cu.curr FROM currencies cu WHERE cu.id=ct.curr) AS currency
FROM customer ct
LEFT JOIN contacts cp on ct.id = cp.cp_cv_id
WHERE (ct.id = ?) $where
map { $form->{$_} = $ref->{$_} } keys %$ref;
- # remove any trailing whitespace
- $form->{currency} =~ s/\s*$// if ($form->{currency});
-
if ($form->{delivery_customer_id}) {
$query =
qq|SELECT *, notes as customernotes
}
$form->{defaultcurrency} = $form->get_default_currency($myconfig);
+ my $defaultcurrency = $form->{defaultcurrency};
+
# Seit neuestem wird die department_id schon übergeben UND $form->department nicht mehr
# korrekt zusammengebaut. Sehr wahrscheinlich beim Umstieg auf T8 kaputt gegangen
# Ich lass den Code von 2005 erstmal noch stehen ;-) jb 03-2011
$query = qq|SELECT nextval('glid')|;
($form->{"id"}) = selectrow_query($form, $dbh, $query);
- $query = qq|INSERT INTO ar (id, invnumber) VALUES (?, ?)|;
- do_query($form, $dbh, $query, $form->{"id"}, $form->{"id"});
+ $query = qq|INSERT INTO ar (id, invnumber, curr) VALUES (?, ?, (SELECT id FROM currencies WHERE curr=?))|;
+ do_query($form, $dbh, $query, $form->{"id"}, $form->{"id"}, $form->{currency});
if (!$form->{invnumber}) {
$form->{invnumber} =
my ($netamount, $invoicediff) = (0, 0);
my ($amount, $linetotal, $lastincomeaccno);
- my ($currencies) = selectfirst_array_query($form, $dbh, qq|SELECT curr FROM defaults|);
- my $defaultcurrency = (split m/:/, $currencies)[0];
-
if ($form->{currency} eq $defaultcurrency) {
$form->{exchangerate} = 1;
} else {
amount = ?, netamount = ?, paid = ?,
duedate = ?, deliverydate = ?, invoice = ?, shippingpoint = ?,
shipvia = ?, terms = ?, notes = ?, intnotes = ?,
- curr = ?, department_id = ?, payment_id = ?, taxincluded = ?,
+ curr = (SELECT id FROM currencies WHERE curr= ?),
+ department_id = ?, payment_id = ?, taxincluded = ?,
type = ?, language_id = ?, taxzone_id = ?, shipto_id = ?,
employee_id = ?, salesman_id = ?, storno_id = ?, storno = ?,
cp_id = ?, marge_total = ?, marge_percent = ?,
(SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno,
(SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno,
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
- (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno,
- d.curr AS currencies
+ (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
${query_transdate}
FROM defaults d|;
a.orddate, a.quodate, a.globalproject_id,
a.transdate AS invdate, a.deliverydate, a.paid, a.storno, a.gldate,
a.shippingpoint, a.shipvia, a.terms, a.notes, a.intnotes, a.taxzone_id,
- a.duedate, a.taxincluded, a.curr AS currency, a.shipto_id, a.cp_id,
+ a.duedate, a.taxincluded, (SELECT cu.curr FROM currencies cu WHERE cu.id=a.curr) AS currency, a.shipto_id, a.cp_id,
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.donumber, a.invnumber_for_credit_note,
$ref = selectfirst_hashref_query($form, $dbh, $query, $id);
map { $form->{$_} = $ref->{$_} } keys %{ $ref };
- # remove any trailing whitespace
- $form->{currency} =~ s/\s*$//;
-
$form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "buy");
# get shipto
c.id AS customer_id, c.name AS customer, c.discount as customer_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, c.curr,
+ c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id, (SELECT cu.curr FROM currencies cu WHERE cu.id=c.curr) AS curr,
c.taxincluded_checked, c.direct_debit,
$duedate + COALESCE(pt.terms_netto, 0) AS duedate,
b.discount AS tradediscount, b.description AS business
map { $form->{$_} = $ref->{$_} } keys %$ref;
- # remove any trailing whitespace
- $form->{curr} =~ s/\s*$//;
-
- # use customer currency if not empty
- $form->{currency} = $form->{curr} if $form->{curr};
+ # use customer currency
+ $form->{currency} = $form->{curr};
$query =
qq|SELECT sum(amount - paid) AS dunning_amount
$query = qq|SELECT nextval('id')|;
($form->{id}) = selectrow_query($form, $dbh, $query);
- $query = qq|INSERT INTO oe (id, ordnumber, employee_id) VALUES (?, '', ?)|;
+ $query = qq|INSERT INTO oe (id, ordnumber, employee_id, curr) VALUES (?, '', ?, (SELECT curr FROM defaults))|;
do_query($form, $dbh, $query, $form->{id}, $form->{employee_id});
}
qq|UPDATE oe SET
ordnumber = ?, quonumber = ?, cusordnumber = ?, transdate = ?, vendor_id = ?,
customer_id = ?, amount = ?, netamount = ?, reqdate = ?, taxincluded = ?,
- shippingpoint = ?, shipvia = ?, notes = ?, intnotes = ?, curr = ?, closed = ?,
+ shippingpoint = ?, shipvia = ?, notes = ?, intnotes = ?, curr = (SELECT id FROM currencies WHERE 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 = ?
$amount, $netamount, conv_date($reqdate),
$form->{taxincluded} ? 't' : 'f', $form->{shippingpoint},
$form->{shipvia}, $form->{notes}, $form->{intnotes},
- substr($form->{currency}, 0, 3), $form->{closed} ? 't' : 'f',
+ $form->{currency}, $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}),
(SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno,
(SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno,
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
- (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno,
- d.curr AS currencies
+ (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
$query_add
FROM defaults d|;
my $ref = selectfirst_hashref_query($form, $dbh, $query);
map { $form->{$_} = $ref->{$_} } keys %$ref;
- ($form->{currency}) = split(/:/, $form->{currencies}) unless ($form->{currency});
+ $form->{currency} = $form->get_default_currency($myconfig);
# set reqdate if this is an invoice->order conversion. If someone knows a better check to ensure
# we come from invoices, feel free.
$query =
qq|SELECT o.cp_id, o.ordnumber, o.transdate, o.reqdate,
o.taxincluded, o.shippingpoint, o.shipvia, o.notes, o.intnotes,
- o.curr AS currency, e.name AS employee, o.employee_id, o.salesman_id,
+ (SELECT cu.curr FROM currencies cu WHERE cu.id=o.curr) AS currency, e.name AS employee, o.employee_id, o.salesman_id,
o.${vc}_id, cv.name AS ${vc}, o.amount AS invtotal,
o.closed, o.reqdate, o.quonumber, o.department_id, o.cusordnumber,
d.description AS department, o.payment_id, o.language_id, o.taxzone_id,
if ($ref) {
map { $form->{$_} = $ref->{$_} } 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
# geben und hier reinparsen, oder besser multibox oder html auslagern?
# Antwort: form->currency wird mit oldcurrency oder curr[0] überschrieben
# Wofür macht das Sinn?
- @curr = split(/:/, $form->{currencies});
- chomp $curr[0];
+ @curr = $form->get_all_currencies();
$form->{defaultcurrency} = $form->{currency} = $form->{oldcurrency} =
- $curr[0];
+ $form->get_default_currency(\%myconfig);
# Entsprechend präventiv die Auswahlliste für Währungen
# auch mit value= zusammenbauen (s.a. oben bugfix 1771)
IC->create_links("IC", \%myconfig, \%$form);
# currencies
- map({ $form->{selectcurrency} .= "<option>$_\n" }
- split(/:/, $form->{currencies}));
+ map({ $form->{selectcurrency} .= "<option>$_\n" } $::form->get_all_currencies());
# parts and assemblies have the same links
my $item = $form->{item};
$form->{currency} = $currency;
}
- my @curr = split(/:/, $form->{currencies}); #seems to be missing
+ my @curr = $form->get_all_currencies();
map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
$form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
<input type="hidden" name="rowcount" value="[% CURRENCIES.size %]">
<th align="right">[% 'Currencies' | $T8 %]</th>
<td colspan="3">[% FOREACH row = CURRENCIES %]<input name="curr_[% loop.count %]" size="3" value="[% HTML.escape(row.curr) %]">
- <input type=hidden name="old_curr_[% loop.count %]" value="[% HTML.escape(defaults_curr) %]">
+ <input type=hidden name="old_curr_[% loop.count %]" value="[% HTML.escape(row.curr) %]">
[% END %]
<input name="new_curr" size="3" value="">
</td>