Revision d331a3d7
Von Niclas Zimmermann 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}; |
|
60 | 61 |
|
61 | 62 |
my $ic_cvar_configs = CVar->get_configs(module => 'IC', |
62 | 63 |
dbh => $dbh); |
... | ... | |
70 | 71 |
|
71 | 72 |
my $all_units = AM->retrieve_units($myconfig, $form); |
72 | 73 |
|
74 |
#markierung |
|
73 | 75 |
if (!$payments_only) { |
74 | 76 |
if ($form->{id}) { |
75 | 77 |
&reverse_invoice($dbh, $form); |
76 | 78 |
} else { |
77 | 79 |
($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('glid')|); |
78 |
do_query($form, $dbh, qq|INSERT INTO ap (id, invnumber) VALUES (?, '')|, $form->{id});
|
|
80 |
do_query($form, $dbh, qq|INSERT INTO ap (id, invnumber, curr) VALUES (?, '', (SELECT id FROM currencies WHERE curr=?))|, $form->{id}, $form->{currency});
|
|
79 | 81 |
} |
80 | 82 |
} |
81 | 83 |
|
82 |
my ($currencies) = selectfirst_array_query($form, $dbh, qq|SELECT curr FROM defaults|); |
|
83 |
my $defaultcurrency = (split m/:/, $currencies)[0]; |
|
84 |
|
|
85 | 84 |
if ($form->{currency} eq $defaultcurrency) { |
86 | 85 |
$form->{exchangerate} = 1; |
87 | 86 |
} else { |
... | ... | |
684 | 683 |
orddate = ?, quodate = ?, vendor_id = ?, amount = ?, |
685 | 684 |
netamount = ?, paid = ?, duedate = ?, |
686 | 685 |
invoice = ?, taxzone_id = ?, notes = ?, taxincluded = ?, |
687 |
intnotes = ?, curr = ?, storno_id = ?, storno = ?,
|
|
686 |
intnotes = ?, storno_id = ?, storno = ?,
|
|
688 | 687 |
cp_id = ?, employee_id = ?, department_id = ?, |
689 | 688 |
globalproject_id = ?, direct_debit = ? |
690 | 689 |
WHERE id = ?|; |
... | ... | |
693 | 692 |
conv_date($form->{orddate}), conv_date($form->{quodate}), conv_i($form->{vendor_id}), $amount, |
694 | 693 |
$netamount, $form->{paid}, conv_date($form->{duedate}), |
695 | 694 |
'1', $taxzone_id, $form->{notes}, $form->{taxincluded} ? 't' : 'f', |
696 |
$form->{intnotes}, $form->{currency}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f',
|
|
695 |
$form->{intnotes}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f', |
|
697 | 696 |
conv_i($form->{cp_id}), conv_i($form->{employee_id}), conv_i($form->{department_id}), |
698 | 697 |
conv_i($form->{globalproject_id}), |
699 | 698 |
$form->{direct_debit} ? 't' : 'f', |
... | ... | |
922 | 921 |
(SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno, |
923 | 922 |
(SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno, |
924 | 923 |
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno, |
925 |
(SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno, |
|
926 |
d.curr AS currencies |
|
924 |
(SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno |
|
927 | 925 |
$q_invdate |
928 | 926 |
FROM defaults d|; |
929 | 927 |
$ref = selectfirst_hashref_query($form, $dbh, $query); |
... | ... | |
940 | 938 |
$query = qq|SELECT cp_id, invnumber, transdate AS invdate, duedate, |
941 | 939 |
orddate, quodate, globalproject_id, |
942 | 940 |
ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate, |
943 |
intnotes, curr AS currency, direct_debit
|
|
941 |
intnotes, (SELECT cu.curr FROM currencies cu WHERE cu.id=ap.curr) AS currency, direct_debit
|
|
944 | 942 |
FROM ap |
945 | 943 |
WHERE id = ?|; |
946 | 944 |
$ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($form->{id})); |
947 | 945 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
948 | 946 |
|
949 |
# remove any trailing whitespace |
|
950 |
$form->{currency} =~ s/\s*$//; |
|
951 |
|
|
952 | 947 |
$form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "sell"); |
953 | 948 |
|
954 | 949 |
# get shipto |
... | ... | |
1090 | 1085 |
v.id AS vendor_id, v.name AS vendor, v.discount as vendor_discount, |
1091 | 1086 |
v.creditlimit, v.terms, v.notes AS intnotes, |
1092 | 1087 |
v.email, v.cc, v.bcc, v.language_id, v.payment_id, |
1093 |
v.street, v.zipcode, v.city, v.country, v.taxzone_id, v.curr, v.direct_debit,
|
|
1088 |
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,
|
|
1094 | 1089 |
$duedate + COALESCE(pt.terms_netto, 0) AS duedate, |
1095 | 1090 |
b.description AS business |
1096 | 1091 |
FROM vendor v |
... | ... | |
1100 | 1095 |
my $ref = selectfirst_hashref_query($form, $dbh, $query, @values); |
1101 | 1096 |
map { $params->{$_} = $ref->{$_} } keys %$ref; |
1102 | 1097 |
|
1103 |
# remove any trailing whitespace |
|
1104 |
$form->{curr} =~ s/\s*$//; |
|
1105 |
|
|
1106 |
# use vendor currency if not empty |
|
1107 |
$form->{currency} = $form->{curr} if $form->{curr}; |
|
1098 |
# use vendor currency |
|
1099 |
$form->{currency} = $form->{curr}; |
|
1108 | 1100 |
|
1109 | 1101 |
$params->{creditremaining} = $params->{creditlimit}; |
1110 | 1102 |
|
... | ... | |
1388 | 1380 |
# fax and phone and email as vendor* |
1389 | 1381 |
my $query = |
1390 | 1382 |
qq|SELECT ct.*, cp.*, ct.notes as vendornotes, phone as vendorphone, fax as vendorfax, email as vendoremail, |
1391 |
ct.curr AS currency
|
|
1383 |
(SELECT cu.curr FROM currencies cu WHERE cu.id=ct.curr) AS currency
|
|
1392 | 1384 |
FROM vendor ct |
1393 | 1385 |
LEFT JOIN contacts cp ON (ct.id = cp.cp_cv_id) |
1394 | 1386 |
WHERE (ct.id = ?) $contact |
... | ... | |
1407 | 1399 |
} |
1408 | 1400 |
|
1409 | 1401 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
1410 |
# remove any trailing whitespace |
|
1411 |
$form->{currency} =~ s/\s*$// if ($form->{currency}); |
|
1412 | 1402 |
|
1413 | 1403 |
my $custom_variables = CVar->get_custom_variables('dbh' => $dbh, |
1414 | 1404 |
'module' => 'CT', |
Auch abrufbar als: Unified diff
Nutzung der Tabelle currencies
Dieser Commmit passt den Code an, um die Tabelle currencies zu nutzen.