Revision 6af007ae
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/AM.pm | ||
---|---|---|
1050 | 1050 |
return $error; |
1051 | 1051 |
} |
1052 | 1052 |
|
1053 |
sub save_defaults { |
|
1054 |
$main::lxdebug->enter_sub(); |
|
1055 |
|
|
1056 |
my $self = shift; |
|
1057 |
my %params = @_; |
|
1058 |
|
|
1059 |
my $myconfig = \%main::myconfig; |
|
1060 |
my $form = $main::form; |
|
1061 |
|
|
1062 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
1063 |
|
|
1064 |
my %accnos; |
|
1065 |
map { ($accnos{$_}) = split(m/--/, $form->{$_}) } qw(inventory_accno income_accno expense_accno fxgain_accno fxloss_accno ar_paid_accno); |
|
1066 |
|
|
1067 |
# these defaults are database wide |
|
1068 |
|
|
1069 |
my $query = |
|
1070 |
qq|UPDATE defaults SET |
|
1071 |
inventory_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), |
|
1072 |
income_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), |
|
1073 |
expense_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), |
|
1074 |
fxgain_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), |
|
1075 |
fxloss_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), |
|
1076 |
ar_paid_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), |
|
1077 |
invnumber = ?, |
|
1078 |
cnnumber = ?, |
|
1079 |
sonumber = ?, |
|
1080 |
ponumber = ?, |
|
1081 |
sqnumber = ?, |
|
1082 |
rfqnumber = ?, |
|
1083 |
customernumber = ?, |
|
1084 |
vendornumber = ?, |
|
1085 |
articlenumber = ?, |
|
1086 |
servicenumber = ?, |
|
1087 |
assemblynumber = ?, |
|
1088 |
sdonumber = ?, |
|
1089 |
pdonumber = ?, |
|
1090 |
businessnumber = ?, |
|
1091 |
weightunit = ?, |
|
1092 |
language_id = ?|; |
|
1093 |
my @values = ($accnos{inventory_accno}, $accnos{income_accno}, $accnos{expense_accno}, |
|
1094 |
$accnos{fxgain_accno}, $accnos{fxloss_accno}, $accnos{ar_paid_accno}, |
|
1095 |
$form->{invnumber}, $form->{cnnumber}, |
|
1096 |
$form->{sonumber}, $form->{ponumber}, |
|
1097 |
$form->{sqnumber}, $form->{rfqnumber}, |
|
1098 |
$form->{customernumber}, $form->{vendornumber}, |
|
1099 |
$form->{articlenumber}, $form->{servicenumber}, |
|
1100 |
$form->{assemblynumber}, |
|
1101 |
$form->{sdonumber}, $form->{pdonumber}, |
|
1102 |
$form->{businessnumber}, $form->{weightunit}, |
|
1103 |
conv_i($form->{language_id})); |
|
1104 |
do_query($form, $dbh, $query, @values); |
|
1105 |
|
|
1106 |
$main::lxdebug->message(0, "es gibt rowcount: " . $form->{rowcount}); |
|
1107 |
|
|
1108 |
for my $i (1..$form->{rowcount}) { |
|
1109 |
if ($form->{"curr_$i"} ne $form->{"old_curr_$i"}) { |
|
1110 |
$query = qq|UPDATE currencies SET name = ? WHERE name = ?|; |
|
1111 |
do_query($form, $dbh, $query, $form->{"curr_$i"}, $form->{"old_curr_$i"}); |
|
1112 |
} |
|
1113 |
} |
|
1114 |
|
|
1115 |
if (length($form->{new_curr}) > 0) { |
|
1116 |
$query = qq|INSERT INTO currencies (name) VALUES (?)|; |
|
1117 |
do_query($form, $dbh, $query, $form->{new_curr}); |
|
1118 |
} |
|
1119 |
|
|
1120 |
$dbh->commit(); |
|
1121 |
|
|
1122 |
$main::lxdebug->leave_sub(); |
|
1123 |
} |
|
1124 |
|
|
1125 | 1053 |
sub save_preferences { |
1126 | 1054 |
$main::lxdebug->enter_sub(); |
1127 | 1055 |
|
... | ... | |
1162 | 1090 |
return $defaults; |
1163 | 1091 |
} |
1164 | 1092 |
|
1165 |
sub defaultaccounts { |
|
1166 |
$main::lxdebug->enter_sub(); |
|
1167 |
|
|
1168 |
my ($self, $myconfig, $form) = @_; |
|
1169 |
|
|
1170 |
# connect to database |
|
1171 |
my $dbh = $form->dbconnect($myconfig); |
|
1172 |
|
|
1173 |
# get defaults from defaults table |
|
1174 |
my $query = qq|SELECT * FROM defaults|; |
|
1175 |
my $sth = $dbh->prepare($query); |
|
1176 |
$sth->execute || $form->dberror($query); |
|
1177 |
|
|
1178 |
$form->{defaults} = $sth->fetchrow_hashref("NAME_lc"); |
|
1179 |
$form->{defaults}{IC} = $form->{defaults}{inventory_accno_id}; |
|
1180 |
$form->{defaults}{IC_income} = $form->{defaults}{income_accno_id}; |
|
1181 |
$form->{defaults}{IC_expense} = $form->{defaults}{expense_accno_id}; |
|
1182 |
$form->{defaults}{FX_gain} = $form->{defaults}{fxgain_accno_id}; |
|
1183 |
$form->{defaults}{FX_loss} = $form->{defaults}{fxloss_accno_id}; |
|
1184 |
$form->{defaults}{AR_paid} = $form->{defaults}{ar_paid_accno_id}; |
|
1185 |
|
|
1186 |
$form->{defaults}{weightunit} ||= 'kg'; |
|
1187 |
|
|
1188 |
$sth->finish; |
|
1189 |
|
|
1190 |
$query = qq|SELECT c.id, c.accno, c.description, c.link |
|
1191 |
FROM chart c |
|
1192 |
WHERE c.link LIKE '%IC%' |
|
1193 |
ORDER BY c.accno|; |
|
1194 |
$sth = $dbh->prepare($query); |
|
1195 |
$sth->execute || $self->dberror($query); |
|
1196 |
|
|
1197 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { |
|
1198 |
foreach my $key (split(/:/, $ref->{link})) { |
|
1199 |
if ($key =~ /IC/) { |
|
1200 |
my $nkey = $key; |
|
1201 |
if ($key =~ /cogs/) { |
|
1202 |
$nkey = "IC_expense"; |
|
1203 |
} |
|
1204 |
if ($key =~ /sale/) { |
|
1205 |
$nkey = "IC_income"; |
|
1206 |
} |
|
1207 |
%{ $form->{IC}{$nkey}{ $ref->{accno} } } = ( |
|
1208 |
id => $ref->{id}, |
|
1209 |
description => $ref->{description} |
|
1210 |
); |
|
1211 |
} |
|
1212 |
} |
|
1213 |
} |
|
1214 |
$sth->finish; |
|
1215 |
|
|
1216 |
$query = qq|SELECT c.id, c.accno, c.description |
|
1217 |
FROM chart c |
|
1218 |
WHERE c.category = 'I' |
|
1219 |
AND c.charttype = 'A' |
|
1220 |
ORDER BY c.accno|; |
|
1221 |
$sth = $dbh->prepare($query); |
|
1222 |
$sth->execute || $self->dberror($query); |
|
1223 |
|
|
1224 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { |
|
1225 |
%{ $form->{IC}{FX_gain}{ $ref->{accno} } } = ( |
|
1226 |
id => $ref->{id}, |
|
1227 |
description => $ref->{description} |
|
1228 |
); |
|
1229 |
} |
|
1230 |
$sth->finish; |
|
1231 |
|
|
1232 |
$query = qq|SELECT c.id, c.accno, c.description |
|
1233 |
FROM chart c |
|
1234 |
WHERE c.category = 'E' |
|
1235 |
AND c.charttype = 'A' |
|
1236 |
ORDER BY c.accno|; |
|
1237 |
$sth = $dbh->prepare($query); |
|
1238 |
$sth->execute || $self->dberror($query); |
|
1239 |
|
|
1240 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { |
|
1241 |
%{ $form->{IC}{FX_loss}{ $ref->{accno} } } = ( |
|
1242 |
id => $ref->{id}, |
|
1243 |
description => $ref->{description} |
|
1244 |
); |
|
1245 |
} |
|
1246 |
$sth->finish; |
|
1247 |
|
|
1248 |
# now get the tax rates and numbers |
|
1249 |
$query = qq|SELECT c.id, c.accno, c.description, |
|
1250 |
t.rate * 100 AS rate, t.taxnumber |
|
1251 |
FROM chart c, tax t |
|
1252 |
WHERE c.id = t.chart_id|; |
|
1253 |
|
|
1254 |
$sth = $dbh->prepare($query); |
|
1255 |
$sth->execute || $form->dberror($query); |
|
1256 |
|
|
1257 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { |
|
1258 |
$form->{taxrates}{ $ref->{accno} }{id} = $ref->{id}; |
|
1259 |
$form->{taxrates}{ $ref->{accno} }{description} = $ref->{description}; |
|
1260 |
$form->{taxrates}{ $ref->{accno} }{taxnumber} = $ref->{taxnumber} |
|
1261 |
if $ref->{taxnumber}; |
|
1262 |
$form->{taxrates}{ $ref->{accno} }{rate} = $ref->{rate} if $ref->{rate}; |
|
1263 |
} |
|
1264 |
# Abfrage für Standard Umlaufvermögenskonto |
|
1265 |
$query = |
|
1266 |
qq|SELECT id, accno, description, link | . |
|
1267 |
qq|FROM chart | . |
|
1268 |
qq|WHERE link LIKE ? |. |
|
1269 |
qq|ORDER BY accno|; |
|
1270 |
$sth = prepare_execute_query($form, $dbh, $query, '%AR%'); |
|
1271 |
$sth->execute || $form->dberror($query);# |
|
1272 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { |
|
1273 |
foreach my $item (split(/:/, $ref->{link})) { |
|
1274 |
if ($item eq "AR_paid") { |
|
1275 |
%{ $form->{IC}{AR_paid}{ $ref->{accno} } } = ( |
|
1276 |
id => $ref->{id}, |
|
1277 |
description => $ref->{description} |
|
1278 |
); |
|
1279 |
} |
|
1280 |
} |
|
1281 |
} |
|
1282 |
|
|
1283 |
$sth->finish; |
|
1284 |
|
|
1285 |
#Get currencies: |
|
1286 |
$query = qq|SELECT name AS curr FROM currencies ORDER BY id|; |
|
1287 |
$form->{CURRENCIES} = selectall_hashref_query($form, $dbh, $query); |
|
1288 |
|
|
1289 |
#Which of them is the default currency? |
|
1290 |
$query = qq|SELECT name AS defaultcurrency FROM currencies WHERE id = (SELECT currency_id FROM defaults LIMIT 1);|; |
|
1291 |
($form->{defaultcurrency}) = selectrow_query($form, $dbh, $query); |
|
1292 |
|
|
1293 |
$dbh->disconnect; |
|
1294 |
|
|
1295 |
$main::lxdebug->leave_sub(); |
|
1296 |
} |
|
1297 |
|
|
1298 | 1093 |
sub closedto { |
1299 | 1094 |
$main::lxdebug->enter_sub(); |
1300 | 1095 |
|
Auch abrufbar als: Unified diff
Nummernkreise/Standardkonten in Mandantenkonfigurationsdialog verschoben