Revision 9557707c
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/IR.pm | ||
---|---|---|
57 | 57 |
# connect to database, turn off autocommit |
58 | 58 |
my $dbh = $provided_dbh ? $provided_dbh : $form->dbconnect_noauto($myconfig); |
59 | 59 |
$form->{defaultcurrency} = $form->get_default_currency($myconfig); |
60 |
my $defaultcurrency = $form->{defaultcurrency}; |
|
61 | 60 |
|
62 | 61 |
my $ic_cvar_configs = CVar->get_configs(module => 'IC', |
63 | 62 |
dbh => $dbh); |
... | ... | |
71 | 70 |
|
72 | 71 |
my $all_units = AM->retrieve_units($myconfig, $form); |
73 | 72 |
|
74 |
#markierung |
|
75 | 73 |
if (!$payments_only) { |
76 | 74 |
if ($form->{id}) { |
77 | 75 |
&reverse_invoice($dbh, $form); |
78 | 76 |
} else { |
79 | 77 |
($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('glid')|); |
80 |
do_query($form, $dbh, qq|INSERT INTO ap (id, invnumber, curr) VALUES (?, '', (SELECT id FROM currencies WHERE curr=?))|, $form->{id}, $form->{currency});
|
|
78 |
do_query($form, $dbh, qq|INSERT INTO ap (id, invnumber) VALUES (?, '')|, $form->{id});
|
|
81 | 79 |
} |
82 | 80 |
} |
83 | 81 |
|
82 |
my ($currencies) = selectfirst_array_query($form, $dbh, qq|SELECT curr FROM defaults|); |
|
83 |
my $defaultcurrency = (split m/:/, $currencies)[0]; |
|
84 |
|
|
84 | 85 |
if ($form->{currency} eq $defaultcurrency) { |
85 | 86 |
$form->{exchangerate} = 1; |
86 | 87 |
} else { |
... | ... | |
685 | 686 |
orddate = ?, quodate = ?, vendor_id = ?, amount = ?, |
686 | 687 |
netamount = ?, paid = ?, duedate = ?, |
687 | 688 |
invoice = ?, taxzone_id = ?, notes = ?, taxincluded = ?, |
688 |
intnotes = ?, storno_id = ?, storno = ?,
|
|
689 |
intnotes = ?, curr = ?, storno_id = ?, storno = ?,
|
|
689 | 690 |
cp_id = ?, employee_id = ?, department_id = ?, |
690 | 691 |
globalproject_id = ?, direct_debit = ? |
691 | 692 |
WHERE id = ?|; |
... | ... | |
694 | 695 |
conv_date($form->{orddate}), conv_date($form->{quodate}), conv_i($form->{vendor_id}), $amount, |
695 | 696 |
$netamount, $form->{paid}, conv_date($form->{duedate}), |
696 | 697 |
'1', $taxzone_id, $form->{notes}, $form->{taxincluded} ? 't' : 'f', |
697 |
$form->{intnotes}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f', |
|
698 |
$form->{intnotes}, $form->{currency}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f',
|
|
698 | 699 |
conv_i($form->{cp_id}), conv_i($form->{employee_id}), conv_i($form->{department_id}), |
699 | 700 |
conv_i($form->{globalproject_id}), |
700 | 701 |
$form->{direct_debit} ? 't' : 'f', |
... | ... | |
923 | 924 |
(SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno, |
924 | 925 |
(SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno, |
925 | 926 |
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno, |
926 |
(SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno |
|
927 |
(SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno, |
|
928 |
d.curr AS currencies |
|
927 | 929 |
$q_invdate |
928 | 930 |
FROM defaults d|; |
929 | 931 |
$ref = selectfirst_hashref_query($form, $dbh, $query); |
... | ... | |
940 | 942 |
$query = qq|SELECT cp_id, invnumber, transdate AS invdate, duedate, |
941 | 943 |
orddate, quodate, globalproject_id, |
942 | 944 |
ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate, |
943 |
intnotes, (SELECT cu.curr FROM currencies cu WHERE cu.id=ap.curr) AS currency, direct_debit
|
|
945 |
intnotes, curr AS currency, direct_debit
|
|
944 | 946 |
FROM ap |
945 | 947 |
WHERE id = ?|; |
946 | 948 |
$ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($form->{id})); |
947 | 949 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
948 | 950 |
|
951 |
# remove any trailing whitespace |
|
952 |
$form->{currency} =~ s/\s*$//; |
|
953 |
|
|
949 | 954 |
$form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "sell"); |
950 | 955 |
|
951 | 956 |
# get shipto |
... | ... | |
1087 | 1092 |
v.id AS vendor_id, v.name AS vendor, v.discount as vendor_discount, |
1088 | 1093 |
v.creditlimit, v.terms, v.notes AS intnotes, |
1089 | 1094 |
v.email, v.cc, v.bcc, v.language_id, v.payment_id, |
1090 |
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,
|
|
1095 |
v.street, v.zipcode, v.city, v.country, v.taxzone_id, v.curr, v.direct_debit,
|
|
1091 | 1096 |
$duedate + COALESCE(pt.terms_netto, 0) AS duedate, |
1092 | 1097 |
b.description AS business |
1093 | 1098 |
FROM vendor v |
... | ... | |
1097 | 1102 |
my $ref = selectfirst_hashref_query($form, $dbh, $query, @values); |
1098 | 1103 |
map { $params->{$_} = $ref->{$_} } keys %$ref; |
1099 | 1104 |
|
1100 |
# use vendor currency |
|
1101 |
$form->{currency} = $form->{curr}; |
|
1105 |
# remove any trailing whitespace |
|
1106 |
$form->{curr} =~ s/\s*$//; |
|
1107 |
|
|
1108 |
# use vendor currency if not empty |
|
1109 |
$form->{currency} = $form->{curr} if $form->{curr}; |
|
1102 | 1110 |
|
1103 | 1111 |
$params->{creditremaining} = $params->{creditlimit}; |
1104 | 1112 |
|
... | ... | |
1384 | 1392 |
# fax and phone and email as vendor* |
1385 | 1393 |
my $query = |
1386 | 1394 |
qq|SELECT ct.*, cp.*, ct.notes as vendornotes, phone as vendorphone, fax as vendorfax, email as vendoremail, |
1387 |
(SELECT cu.curr FROM currencies cu WHERE cu.id=ct.curr) AS currency
|
|
1395 |
ct.curr AS currency
|
|
1388 | 1396 |
FROM vendor ct |
1389 | 1397 |
LEFT JOIN contacts cp ON (ct.id = cp.cp_cv_id) |
1390 | 1398 |
WHERE (ct.id = ?) $contact |
... | ... | |
1403 | 1411 |
} |
1404 | 1412 |
|
1405 | 1413 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
1414 |
# remove any trailing whitespace |
|
1415 |
$form->{currency} =~ s/\s*$// if ($form->{currency}); |
|
1406 | 1416 |
|
1407 | 1417 |
my $custom_variables = CVar->get_custom_variables('dbh' => $dbh, |
1408 | 1418 |
'module' => 'CT', |
Auch abrufbar als: Unified diff
Revert "Nutzung der Tabelle currencies"
This reverts commit be776964b83340e69fa2f02eae59b703c0c95b88.