Revision 76c486e3
Von Sven Schöling vor etwa 15 Jahren hinzugefügt
SL/IR.pm | ||
---|---|---|
44 | 44 |
use SL::MoreCommon; |
45 | 45 |
use List::Util qw(min); |
46 | 46 |
|
47 |
use strict; |
|
48 |
|
|
47 | 49 |
sub post_invoice { |
48 | 50 |
$main::lxdebug->enter_sub(); |
49 | 51 |
|
... | ... | |
61 | 63 |
my ($amount, $linetotal, $lastinventoryaccno, $lastexpenseaccno); |
62 | 64 |
my ($netamount, $invoicediff, $expensediff) = (0, 0, 0); |
63 | 65 |
my $exchangerate = 0; |
66 |
my ($basefactor, $baseqty, @taxaccounts, $totaltax); |
|
64 | 67 |
|
65 | 68 |
my $all_units = AM->retrieve_units($myconfig, $form); |
66 | 69 |
|
... | ... | |
133 | 136 |
$price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1; |
134 | 137 |
##################################################################### |
135 | 138 |
# das ist aus IS.pm kopiert. schlimm. jb 7.10.2009 |
136 |
# ich würde mir wünschen, dass diese vier stellen zusammengefasst werden
|
|
139 |
# ich würde mir wünschen, dass diese vier stellen zusammengefasst werden |
|
137 | 140 |
# ... vier stellen = (einkauf + verkauf) * (maske + backend) |
138 | 141 |
# ansonsten stolpert man immer wieder viermal statt einmal heftig |
139 | 142 |
# und auch das undo discount formatting ist nicht besonders wartungsfreundlich |
140 |
|
|
143 |
|
|
141 | 144 |
# keep entered selling price |
142 |
my $fxsellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
|
|
145 |
$fxsellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"}); |
|
143 | 146 |
|
144 | 147 |
# keine ahnung wofür das in IS.pm gemacht wird: |
145 | 148 |
# my ($dec) = ($fxsellprice =~ /\.(\d+)/); |
... | ... | |
150 | 153 |
$form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100; |
151 | 154 |
# deduct discount |
152 | 155 |
$form->{"sellprice_$i"} = $fxsellprice * (1 - $form->{"discount_$i"}); |
153 |
|
|
156 |
|
|
154 | 157 |
###################################################################### |
155 | 158 |
if ($form->{"inventory_accno_$i"}) { |
156 | 159 |
|
... | ... | |
218 | 221 |
ORDER BY transdate|; |
219 | 222 |
$sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{"id_$i"})); |
220 | 223 |
|
221 |
my $totalqty = $base_qty;
|
|
224 |
my $totalqty = $baseqty; |
|
222 | 225 |
|
223 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
226 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
224 | 227 |
my $qty = min $totalqty, ($ref->{base_qty} + $ref->{allocated}); |
225 | 228 |
$linetotal = $form->round_amount(($form->{"sellprice_$i"} * $qty) / $basefactor, 2); |
226 | 229 |
|
... | ... | |
631 | 634 |
|
632 | 635 |
my $netamount = 0; |
633 | 636 |
|
634 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
637 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
635 | 638 |
$netamount += $form->round_amount($ref->{sellprice} * $ref->{qty} * -1, 2); |
636 | 639 |
|
637 | 640 |
next unless $ref->{inventory_accno_id}; |
... | ... | |
649 | 652 |
ORDER BY transdate DESC|; |
650 | 653 |
my $sth2 = prepare_execute_query($form, $dbh, $query, $ref->{parts_id}); |
651 | 654 |
|
652 |
while (my $pthref = $sth2->fetchrow_hashref(NAME_lc)) {
|
|
655 |
while (my $pthref = $sth2->fetchrow_hashref("NAME_lc")) {
|
|
653 | 656 |
my $qty = $ref->{allocated}; |
654 | 657 |
if (($ref->{allocated} + $pthref->{allocated}) > 0) { |
655 | 658 |
$qty = $pthref->{allocated} * -1; |
... | ... | |
813 | 816 |
ORDER BY i.id|; |
814 | 817 |
$sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id})); |
815 | 818 |
|
816 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
819 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
817 | 820 |
# Retrieve custom variables. |
818 | 821 |
my $cvars = CVar->get_custom_variables(dbh => $dbh, |
819 | 822 |
module => 'IC', |
... | ... | |
849 | 852 |
$ref->{taxaccounts} = ""; |
850 | 853 |
|
851 | 854 |
my $i = 0; |
852 |
while ($ptr = $stw->fetchrow_hashref(NAME_lc)) {
|
|
855 |
while (my $ptr = $stw->fetchrow_hashref("NAME_lc")) {
|
|
853 | 856 |
if (($ptr->{accno} eq "") && ($ptr->{rate} == 0)) { |
854 | 857 |
$i++; |
855 | 858 |
$ptr->{accno} = $i; |
... | ... | |
923 | 926 |
LEFT JOIN business b ON (b.id = v.business_id) |
924 | 927 |
LEFT JOIN payment_terms pt ON (v.payment_id = pt.id) |
925 | 928 |
WHERE 1=1 $where|; |
926 |
$ref = selectfirst_hashref_query($form, $dbh, $query, @values); |
|
929 |
my $ref = selectfirst_hashref_query($form, $dbh, $query, @values);
|
|
927 | 930 |
map { $params->{$_} = $ref->{$_} } keys %$ref; |
928 | 931 |
|
929 | 932 |
$params->{creditremaining} = $params->{creditlimit}; |
... | ... | |
972 | 975 |
for $ref (@$refs) { |
973 | 976 |
if ($ref->{category} eq 'E') { |
974 | 977 |
$i++; |
975 |
|
|
978 |
my ($tax_id, $rate); |
|
976 | 979 |
if ($params->{initial_transdate}) { |
977 | 980 |
my $tax_query = qq|SELECT tk.tax_id, t.rate FROM taxkeys tk |
978 | 981 |
LEFT JOIN tax t ON (tk.tax_id = t.id) |
979 | 982 |
WHERE (tk.chart_id = ?) AND (startdate <= ?) |
980 | 983 |
ORDER BY tk.startdate DESC |
981 | 984 |
LIMIT 1|; |
982 |
my ($tax_id, $rate) = selectrow_query($form, $dbh, $tax_query, $ref->{id}, $params->{initial_transdate});
|
|
985 |
($tax_id, $rate) = selectrow_query($form, $dbh, $tax_query, $ref->{id}, $params->{initial_transdate}); |
|
983 | 986 |
$params->{"taxchart_$i"} = "${tax_id}--${rate}"; |
984 | 987 |
} |
985 | 988 |
|
... | ... | |
1082 | 1085 |
my $sth = prepare_execute_query($form, $dbh, $query, @values); |
1083 | 1086 |
|
1084 | 1087 |
$form->{item_list} = []; |
1085 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
1088 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
1086 | 1089 |
|
1087 | 1090 |
# In der Buchungsgruppe ist immer ein Bestandskonto verknuepft, auch wenn |
1088 | 1091 |
# es sich um eine Dienstleistung handelt. Bei Dienstleistungen muss das |
... | ... | |
1093 | 1096 |
delete($ref->{inventory_accno_id}); |
1094 | 1097 |
|
1095 | 1098 |
# get tax rates and description |
1096 |
$accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno}; |
|
1099 |
my $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
|
|
1097 | 1100 |
$query = |
1098 | 1101 |
qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber |
1099 | 1102 |
FROM tax t |
... | ... | |
1113 | 1116 |
|
1114 | 1117 |
$ref->{taxaccounts} = ""; |
1115 | 1118 |
my $i = 0; |
1116 |
while ($ptr = $stw->fetchrow_hashref(NAME_lc)) {
|
|
1119 |
while (my $ptr = $stw->fetchrow_hashref("NAME_lc")) {
|
|
1117 | 1120 |
|
1118 | 1121 |
# if ($customertax{$ref->{accno}}) { |
1119 | 1122 |
if (($ptr->{accno} eq "") && ($ptr->{rate} == 0)) { |
... | ... | |
1227 | 1230 |
ORDER BY accno|; |
1228 | 1231 |
my $sth = prepare_execute_query($query, $dbh, $query); |
1229 | 1232 |
|
1230 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
|
|
1233 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
|
|
1231 | 1234 |
foreach my $key (split(/:/, $ref->{link})) { |
1232 | 1235 |
if ($key =~ /IC/) { |
1233 | 1236 |
push @{ $form->{IC_links}{$key} }, |
Auch abrufbar als: Unified diff
Und wieder ein Schwung strict.