Revision d1408ca1
Von Niclas Zimmermann vor mehr als 11 Jahren hinzugefügt
SL/AP.pm | ||
---|---|---|
209 | 209 |
# insert detail records in acc_trans |
210 | 210 |
$query = |
211 | 211 |
qq|INSERT INTO acc_trans | . |
212 |
qq| (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id)| . |
|
212 |
qq| (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id, chart_link)| .
|
|
213 | 213 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), | . |
214 |
qq| ?, ?, ?, ?, ?)|; |
|
214 |
qq| ?, ?, ?, ?, ?| . |
|
215 |
qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|; |
|
215 | 216 |
@values = ($form->{id}, $form->{AP_amounts}{"amount_$i"}, |
216 | 217 |
$form->{"amount_$i"}, conv_date($form->{transdate}), |
217 |
$project_id, $form->{"taxkey_$i"}, conv_i($form->{"tax_id_$i"})); |
|
218 |
$project_id, $form->{"taxkey_$i"}, conv_i($form->{"tax_id_$i"}), |
|
219 |
$form->{AP_amounts}{"amount_$i"}); |
|
218 | 220 |
do_query($form, $dbh, $query, @values); |
219 | 221 |
|
220 | 222 |
if ($form->{"tax_$i"} != 0) { |
221 | 223 |
# insert detail records in acc_trans |
222 | 224 |
$query = |
223 | 225 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, | . |
224 |
qq| project_id, taxkey, tax_id) | . |
|
226 |
qq| project_id, taxkey, tax_id, chart_link) | .
|
|
225 | 227 |
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), | . |
226 |
qq| ?, ?, ?, ?, ?)|; |
|
228 |
qq| ?, ?, ?, ?, ?)| . |
|
229 |
qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|; |
|
227 | 230 |
@values = ($form->{id}, $form->{AP_amounts}{"tax_$i"}, |
228 | 231 |
$form->{"tax_$i"}, conv_date($form->{transdate}), |
229 |
$project_id, $form->{"taxkey_$i"}, conv_i($form->{"tax_id_$i"})); |
|
232 |
$project_id, $form->{"taxkey_$i"}, conv_i($form->{"tax_id_$i"}), |
|
233 |
$form->{AP_amounts}{"tax_$i"}); |
|
230 | 234 |
do_query($form, $dbh, $query, @values); |
231 | 235 |
} |
232 | 236 |
|
... | ... | |
235 | 239 |
|
236 | 240 |
# add payables |
237 | 241 |
$query = |
238 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) | . |
|
242 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id, chart_link) | .
|
|
239 | 243 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, | . |
240 | 244 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?),| . |
241 | 245 |
qq| (SELECT tax_id| . |
... | ... | |
244 | 248 |
qq| FROM chart| . |
245 | 249 |
qq| WHERE accno = ?)| . |
246 | 250 |
qq| AND startdate <= ?| . |
247 |
qq| ORDER BY startdate DESC LIMIT 1))|; |
|
251 |
qq| ORDER BY startdate DESC LIMIT 1),| . |
|
252 |
qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|; |
|
248 | 253 |
@values = ($form->{id}, $form->{AP_amounts}{payables}, $form->{payables}, |
249 |
conv_date($form->{transdate}), $form->{AP_amounts}{payables}, $form->{AP_amounts}{payables}, conv_date($form->{transdate})); |
|
254 |
conv_date($form->{transdate}), $form->{AP_amounts}{payables}, $form->{AP_amounts}{payables}, conv_date($form->{transdate}), |
|
255 |
$form->{AP_amounts}{payables}); |
|
250 | 256 |
do_query($form, $dbh, $query, @values); |
251 | 257 |
} |
252 | 258 |
|
... | ... | |
290 | 296 |
2); |
291 | 297 |
if ($form->{payables}) { |
292 | 298 |
$query = |
293 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id) | . |
|
299 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id, chart_link) | .
|
|
294 | 300 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, | . |
295 | 301 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?),| . |
296 | 302 |
qq| (SELECT tax_id| . |
... | ... | |
299 | 305 |
qq| FROM chart| . |
300 | 306 |
qq| WHERE accno = ?)| . |
301 | 307 |
qq| AND startdate <= ?| . |
302 |
qq| ORDER BY startdate DESC LIMIT 1))|; |
|
308 |
qq| ORDER BY startdate DESC LIMIT 1),| . |
|
309 |
qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|; |
|
303 | 310 |
@values = ($form->{id}, $form->{AP_payables}, $amount, |
304 | 311 |
conv_date($form->{"datepaid_$i"}), $project_id, |
305 |
$form->{AP_payables}, $form->{AP_payables}, conv_date($form->{"datepaid_$i"})); |
|
312 |
$form->{AP_payables}, $form->{AP_payables}, conv_date($form->{"datepaid_$i"}), |
|
313 |
$form->{AP_payables}); |
|
306 | 314 |
do_query($form, $dbh, $query, @values); |
307 | 315 |
} |
308 | 316 |
$form->{payables} = $amount; |
... | ... | |
310 | 318 |
# add payment |
311 | 319 |
my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig)); |
312 | 320 |
$query = |
313 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, project_id, taxkey, tax_id) | . |
|
321 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, project_id, taxkey, tax_id, chart_link) | .
|
|
314 | 322 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, ?, | . |
315 | 323 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?), | . |
316 | 324 |
qq| (SELECT tax_id| . |
... | ... | |
319 | 327 |
qq| FROM chart| . |
320 | 328 |
qq| WHERE accno = ?)| . |
321 | 329 |
qq| AND startdate <= ?| . |
322 |
qq| ORDER BY startdate DESC LIMIT 1))|; |
|
330 |
qq| ORDER BY startdate DESC LIMIT 1),| . |
|
331 |
qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|; |
|
323 | 332 |
@values = ($form->{id}, $form->{"AP_paid_account_$i"}, $form->{"paid_$i"}, |
324 | 333 |
conv_date($form->{"datepaid_$i"}), $gldate, $form->{"source_$i"}, |
325 | 334 |
$form->{"memo_$i"}, $project_id, $form->{"AP_paid_account_$i"}, |
326 |
$form->{"AP_paid_account_$i"}, conv_date($form->{"datepaid_$i"})); |
|
335 |
$form->{"AP_paid_account_$i"}, conv_date($form->{"datepaid_$i"}), |
|
336 |
$form->{"AP_paid_account_$i"}); |
|
327 | 337 |
do_query($form, $dbh, $query, @values); |
328 | 338 |
|
329 | 339 |
# add exchange rate difference |
... | ... | |
332 | 342 |
($form->{"exchangerate_$i"} - 1), 2); |
333 | 343 |
if ($amount != 0) { |
334 | 344 |
$query = |
335 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id) | . |
|
345 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id, chart_link) | .
|
|
336 | 346 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . |
337 | 347 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?), | . |
338 | 348 |
qq| (SELECT tax_id| . |
... | ... | |
341 | 351 |
qq| FROM chart| . |
342 | 352 |
qq| WHERE accno = ?)| . |
343 | 353 |
qq| AND startdate <= ?| . |
344 |
qq| ORDER BY startdate DESC LIMIT 1))|; |
|
354 |
qq| ORDER BY startdate DESC LIMIT 1),| . |
|
355 |
qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|; |
|
345 | 356 |
@values = ($form->{id}, $form->{"AP_paid_account_$i"}, $amount, |
346 | 357 |
conv_date($form->{"datepaid_$i"}), $project_id, |
347 | 358 |
$form->{"AP_paid_account_$i"}, |
348 |
$form->{"AP_paid_account_$i"}, conv_date($form->{"datepaid_$i"})); |
|
359 |
$form->{"AP_paid_account_$i"}, conv_date($form->{"datepaid_$i"}), |
|
360 |
$form->{"AP_paid_account_$i"}); |
|
349 | 361 |
do_query($form, $dbh, $query, @values); |
350 | 362 |
} |
351 | 363 |
|
... | ... | |
357 | 369 |
|
358 | 370 |
if ($amount != 0) { |
359 | 371 |
$query = |
360 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id) | . |
|
372 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id, chart_link) | .
|
|
361 | 373 |
qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, | . |
362 | 374 |
qq| (SELECT taxkey_id FROM chart WHERE accno = ?)| . |
363 | 375 |
qq| (SELECT tax_id| . |
... | ... | |
366 | 378 |
qq| FROM chart| . |
367 | 379 |
qq| WHERE accno = ?)| . |
368 | 380 |
qq| AND startdate <= ?| . |
369 |
qq| ORDER BY startdate DESC LIMIT 1))|; |
|
370 |
@values = ($form->{id}, ($amount > 0) ? |
|
371 |
$form->{fxgain_accno} : $form->{fxloss_accno}, |
|
381 |
qq| ORDER BY startdate DESC LIMIT 1),| . |
|
382 |
qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|; |
|
383 |
@values = ($form->{id}, |
|
384 |
($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno}, |
|
372 | 385 |
$amount, conv_date($form->{"datepaid_$i"}), $project_id, |
373 |
($amount > 0) ? |
|
374 |
$form->{fxgain_accno} : $form->{fxloss_accno},
|
|
375 |
($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno}, conv_date($form->{"datepaid_$i"}));
|
|
386 |
($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno},
|
|
387 |
($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno}, conv_date($form->{"datepaid_$i"}),
|
|
388 |
($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno}); |
|
376 | 389 |
do_query($form, $dbh, $query, @values); |
377 | 390 |
} |
378 | 391 |
|
SL/AR.pm | ||
---|---|---|
172 | 172 |
my $project_id = conv_i($form->{"project_id_$i"}); |
173 | 173 |
|
174 | 174 |
# insert detail records in acc_trans |
175 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id) |
|
176 |
VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?)|; |
|
175 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id, chart_link)
|
|
176 |
VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?, (SELECT c.link FROM chart c WHERE c.accno = ?))|;
|
|
177 | 177 |
@values = (conv_i($form->{id}), $form->{AR_amounts}{"amount_$i"}, conv_i($form->{"amount_$i"}), conv_date($form->{transdate}), $project_id, |
178 |
conv_i($form->{"taxkey_$i"}), conv_i($form->{"tax_id_$i"})); |
|
178 |
conv_i($form->{"taxkey_$i"}), conv_i($form->{"tax_id_$i"}), $form->{AR_amounts}{"amount_$i"});
|
|
179 | 179 |
do_query($form, $dbh, $query, @values); |
180 | 180 |
|
181 | 181 |
if ($form->{"tax_$i"} != 0) { |
182 | 182 |
# insert detail records in acc_trans |
183 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id) |
|
184 |
VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?)|; |
|
183 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id, chart_link)
|
|
184 |
VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), ?, ?, ?, ?, ?, (SELECT c.link FROM chart c WHERE c.accno = ?))|;
|
|
185 | 185 |
@values = (conv_i($form->{id}), $form->{AR_amounts}{"tax_$i"}, conv_i($form->{"tax_$i"}), conv_date($form->{transdate}), $project_id, |
186 |
conv_i($form->{"taxkey_$i"}), conv_i($form->{"tax_id_$i"})); |
|
186 |
conv_i($form->{"taxkey_$i"}), conv_i($form->{"tax_id_$i"}), $form->{AR_amounts}{"tax_$i"});
|
|
187 | 187 |
do_query($form, $dbh, $query, @values); |
188 | 188 |
} |
189 | 189 |
} |
190 | 190 |
} |
191 | 191 |
|
192 | 192 |
# add recievables |
193 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) |
|
193 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id, chart_link)
|
|
194 | 194 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?), |
195 | 195 |
(SELECT tax_id |
196 | 196 |
FROM taxkeys |
... | ... | |
198 | 198 |
FROM chart |
199 | 199 |
WHERE accno = ?) |
200 | 200 |
AND startdate <= ? |
201 |
ORDER BY startdate DESC LIMIT 1))|; |
|
201 |
ORDER BY startdate DESC LIMIT 1), |
|
202 |
(SELECT c.link FROM chart c WHERE c.accno = ?))|; |
|
202 | 203 |
@values = (conv_i($form->{id}), $form->{AR_amounts}{receivables}, conv_i($form->{receivables}), conv_date($form->{transdate}), |
203 |
$form->{AR_amounts}{receivables}, $form->{AR_amounts}{receivables}, conv_date($form->{transdate})); |
|
204 |
$form->{AR_amounts}{receivables}, $form->{AR_amounts}{receivables}, conv_date($form->{transdate}), $form->{AR_amounts}{receivables});
|
|
204 | 205 |
do_query($form, $dbh, $query, @values); |
205 | 206 |
|
206 | 207 |
} else { |
... | ... | |
237 | 238 |
|
238 | 239 |
if ($amount != 0) { |
239 | 240 |
# add receivable |
240 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id) |
|
241 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id, chart_link)
|
|
241 | 242 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?), |
242 | 243 |
(SELECT tax_id |
243 | 244 |
FROM taxkeys |
... | ... | |
245 | 246 |
FROM chart |
246 | 247 |
WHERE accno = ?) |
247 | 248 |
AND startdate <= ? |
248 |
ORDER BY startdate DESC LIMIT 1))|; |
|
249 |
@values = (conv_i($form->{id}), $form->{AR}{receivables}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $form->{AR}{receivables}, $form->{AR}{receivables}, conv_date($form->{"datepaid_$i"})); |
|
249 |
ORDER BY startdate DESC LIMIT 1), |
|
250 |
(SELECT c.link FROM chart c WHERE c.accno = ?))|; |
|
251 |
@values = (conv_i($form->{id}), $form->{AR}{receivables}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $form->{AR}{receivables}, $form->{AR}{receivables}, conv_date($form->{"datepaid_$i"}), |
|
252 |
$form->{AR}{receivables}); |
|
253 |
|
|
250 | 254 |
do_query($form, $dbh, $query, @values); |
251 | 255 |
} |
252 | 256 |
|
... | ... | |
255 | 259 |
my $project_id = conv_i($form->{"paid_project_id_$i"}); |
256 | 260 |
my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig)); |
257 | 261 |
$amount = $form->{"paid_$i"} * -1; |
258 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, project_id, taxkey, tax_id) |
|
262 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, project_id, taxkey, tax_id, chart_link)
|
|
259 | 263 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?), |
260 | 264 |
(SELECT tax_id |
261 | 265 |
FROM taxkeys |
... | ... | |
263 | 267 |
FROM chart |
264 | 268 |
WHERE accno = ?) |
265 | 269 |
AND startdate <= ? |
266 |
ORDER BY startdate DESC LIMIT 1))|; |
|
270 |
ORDER BY startdate DESC LIMIT 1), |
|
271 |
(SELECT c.link FROM chart c WHERE c.accno = ?))|; |
|
267 | 272 |
@values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, $amount, conv_date($form->{"datepaid_$i"}), $gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $form->{AR}{"paid_$i"}, |
268 |
$form->{AR}{"paid_$i"}, conv_date($form->{"datepaid_$i"})); |
|
273 |
$form->{AR}{"paid_$i"}, conv_date($form->{"datepaid_$i"}), $form->{AR}{"paid_$i"});
|
|
269 | 274 |
do_query($form, $dbh, $query, @values); |
270 | 275 |
|
271 | 276 |
# exchangerate difference for payment |
272 | 277 |
$amount = $form->round_amount( $form->{"paid_$i"} * ($form->{"exchangerate_$i"} - 1) * -1, 2); |
273 | 278 |
|
274 | 279 |
if ($amount != 0) { |
275 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id) |
|
280 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id, chart_link)
|
|
276 | 281 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, (SELECT taxkey_id FROM chart WHERE accno = ?), |
277 | 282 |
(SELECT tax_id |
278 | 283 |
FROM taxkeys |
... | ... | |
280 | 285 |
FROM chart |
281 | 286 |
WHERE accno = ?) |
282 | 287 |
AND startdate <= ? |
283 |
ORDER BY startdate DESC LIMIT 1))|; |
|
288 |
ORDER BY startdate DESC LIMIT 1), |
|
289 |
(SELECT c.link FROM chart c WHERE c.accno = ?))|; |
|
284 | 290 |
@values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $form->{AR}{"paid_$i"}, |
285 |
$form->{AR}{"paid_$i"}, conv_date($form->{"datepaid_$i"})); |
|
291 |
$form->{AR}{"paid_$i"}, conv_date($form->{"datepaid_$i"}), $form->{AR}{"paid_$i"});
|
|
286 | 292 |
do_query($form, $dbh, $query, @values); |
287 | 293 |
} |
288 | 294 |
|
... | ... | |
291 | 297 |
|
292 | 298 |
if ($amount != 0) { |
293 | 299 |
my $accno = ($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno}; |
294 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id) |
|
300 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id, chart_link)
|
|
295 | 301 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, (SELECT taxkey_id FROM chart WHERE accno = ?), |
296 | 302 |
(SELECT tax_id |
297 | 303 |
FROM taxkeys |
... | ... | |
299 | 305 |
FROM chart |
300 | 306 |
WHERE accno = ?) |
301 | 307 |
AND startdate <= ? |
302 |
ORDER BY startdate DESC LIMIT 1))|; |
|
303 |
@values = (conv_i($form->{id}), $accno, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $accno, $accno, conv_date($form->{"datepaid_$i"})); |
|
308 |
ORDER BY startdate DESC LIMIT 1), |
|
309 |
(SELECT c.link FROM chart c WHERE c.accno = ?))|; |
|
310 |
@values = (conv_i($form->{id}), $accno, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $accno, $accno, conv_date($form->{"datepaid_$i"}), $accno); |
|
304 | 311 |
do_query($form, $dbh, $query, @values); |
305 | 312 |
} |
306 | 313 |
} |
SL/GL.pm | ||
---|---|---|
157 | 157 |
if ($amount != 0) { |
158 | 158 |
$query = |
159 | 159 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, |
160 |
source, memo, project_id, taxkey, ob_transaction, cb_transaction, tax_id) |
|
160 |
source, memo, project_id, taxkey, ob_transaction, cb_transaction, tax_id, chart_link)
|
|
161 | 161 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), |
162 |
?, ?, ?, ?, ?, ?, ?, ?, ?)|; |
|
162 |
?, ?, ?, ?, ?, ?, ?, ?, ?, (SELECT link FROM chart WHERE accno = ?))|;
|
|
163 | 163 |
@values = (conv_i($form->{id}), $accno, $amount, conv_date($form->{transdate}), |
164 |
$form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $taxkey, $form->{ob_transaction} ? 't' : 'f', $form->{cb_transaction} ? 't' : 'f', conv_i($form->{"tax_id_$i"})); |
|
164 |
$form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $taxkey, $form->{ob_transaction} ? 't' : 'f', $form->{cb_transaction} ? 't' : 'f', conv_i($form->{"tax_id_$i"}), $accno);
|
|
165 | 165 |
do_query($form, $dbh, $query, @values); |
166 | 166 |
} |
167 | 167 |
|
... | ... | |
169 | 169 |
# add taxentry |
170 | 170 |
$query = |
171 | 171 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, |
172 |
source, memo, project_id, taxkey, tax_id) |
|
172 |
source, memo, project_id, taxkey, tax_id, chart_link)
|
|
173 | 173 |
VALUES (?, (SELECT chart_id FROM tax WHERE id = ?), |
174 |
?, ?, ?, ?, ?, ?, ?)|; |
|
174 |
?, ?, ?, ?, ?, ?, ?, (SELECT link FROM chart WHERE accno = ?))|;
|
|
175 | 175 |
@values = (conv_i($form->{id}), conv_i($form->{"tax_id_$i"}), |
176 | 176 |
$tax, conv_date($form->{transdate}), $form->{"source_$i"}, |
177 |
$form->{"memo_$i"}, $project_id, $taxkey, conv_i($form->{"tax_id_$i"})); |
|
177 |
$form->{"memo_$i"}, $project_id, $taxkey, conv_i($form->{"tax_id_$i"}), conv_i($form->{"tax_id_$i"}));
|
|
178 | 178 |
do_query($form, $dbh, $query, @values); |
179 | 179 |
} |
180 | 180 |
} |
SL/IR.pm | ||
---|---|---|
270 | 270 |
# allocated >= 0 |
271 | 271 |
# add entry for inventory, this one is for the sold item |
272 | 272 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE id = ?), |
273 |
(SELECT tax_id
|
|
273 |
(SELECT tax_id |
|
274 | 274 |
FROM taxkeys |
275 | 275 |
WHERE chart_id= (SELECT id |
276 | 276 |
FROM chart |
277 | 277 |
WHERE accno = ?) |
278 | 278 |
AND startdate <= ? |
279 |
ORDER BY startdate DESC LIMIT 1))|; |
|
280 |
@values = ($ref->{trans_id}, $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id}, $ref->{inventory_accno_id}, $ref->{transdate}); |
|
279 |
ORDER BY startdate DESC LIMIT 1), |
|
280 |
(SELECT chart_link FROM chart WHERE id = ?))|; |
|
281 |
@values = ($ref->{trans_id}, $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id}, $ref->{inventory_accno_id}, $ref->{transdate}, $ref->{inventory_accno_id}); |
|
281 | 282 |
do_query($form, $dbh, $query, @values); |
282 | 283 |
|
283 | 284 |
# add expense |
... | ... | |
288 | 289 |
FROM chart |
289 | 290 |
WHERE accno = ?) |
290 | 291 |
AND startdate <= ? |
291 |
ORDER BY startdate DESC LIMIT 1))|; |
|
292 |
@values = ($ref->{trans_id}, $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id}, $ref->{expense_accno_id}, $ref->{transdate}); |
|
292 |
ORDER BY startdate DESC LIMIT 1), |
|
293 |
(SELECT chart_link FROM chart WHERE id = ?))|; |
|
294 |
@values = ($ref->{trans_id}, $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id}, $ref->{expense_accno_id}, $ref->{transdate}, $ref->{expense_accno_id}); |
|
293 | 295 |
do_query($form, $dbh, $query, @values); |
294 | 296 |
} |
295 | 297 |
}; |
... | ... | |
492 | 494 |
|
493 | 495 |
next if $payments_only || !$form->{amount}{$trans_id}{$accno}; |
494 | 496 |
|
495 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id) |
|
497 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id, chart_link)
|
|
496 | 498 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
497 | 499 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
498 | 500 |
(SELECT tax_id |
... | ... | |
501 | 503 |
FROM chart |
502 | 504 |
WHERE accno = ?) |
503 | 505 |
AND startdate <= ? |
504 |
ORDER BY startdate DESC LIMIT 1))|; |
|
506 |
ORDER BY startdate DESC LIMIT 1), |
|
507 |
(SELECT link FROM chart WHERE accno = ?))|; |
|
505 | 508 |
@values = ($trans_id, $accno, $form->{amount}{$trans_id}{$accno}, |
506 |
conv_date($form->{invdate}), $accno, $project_id, $accno, conv_date($form->{invdate})); |
|
509 |
conv_date($form->{invdate}), $accno, $project_id, $accno, conv_date($form->{invdate}), $accno);
|
|
507 | 510 |
do_query($form, $dbh, $query, @values); |
508 | 511 |
} |
509 | 512 |
} |
... | ... | |
538 | 541 |
|
539 | 542 |
# record AP |
540 | 543 |
if ($form->{amount}{ $form->{id} }{ $form->{AP} } != 0) { |
541 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id) |
|
544 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id, chart_link)
|
|
542 | 545 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
543 | 546 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
544 | 547 |
(SELECT tax_id |
... | ... | |
547 | 550 |
FROM chart |
548 | 551 |
WHERE accno = ?) |
549 | 552 |
AND startdate <= ? |
550 |
ORDER BY startdate DESC LIMIT 1))|; |
|
553 |
ORDER BY startdate DESC LIMIT 1), |
|
554 |
(SELECT link FROM chart WHERE accno = ?))|; |
|
551 | 555 |
@values = (conv_i($form->{id}), $form->{AP}, $amount, |
552 |
$form->{"datepaid_$i"}, $form->{AP}, $project_id, $form->{AP}, conv_date($form->{"datepaid_$i"})); |
|
556 |
$form->{"datepaid_$i"}, $form->{AP}, $project_id, $form->{AP}, conv_date($form->{"datepaid_$i"}), $form->{AP});
|
|
553 | 557 |
do_query($form, $dbh, $query, @values); |
554 | 558 |
} |
555 | 559 |
|
... | ... | |
557 | 561 |
my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig)); |
558 | 562 |
|
559 | 563 |
$query = |
560 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, taxkey, project_id, tax_id) |
|
564 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, taxkey, project_id, tax_id, chart_link)
|
|
561 | 565 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, |
562 | 566 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
563 | 567 |
(SELECT tax_id |
... | ... | |
565 | 569 |
WHERE chart_id= (SELECT id |
566 | 570 |
FROM chart WHERE accno = ?) |
567 | 571 |
AND startdate <= ? |
568 |
ORDER BY startdate DESC LIMIT 1))|; |
|
572 |
ORDER BY startdate DESC LIMIT 1), |
|
573 |
(SELECT link FROM chart WHERE accno = ?))|; |
|
569 | 574 |
@values = (conv_i($form->{id}), $accno, $form->{"paid_$i"}, $form->{"datepaid_$i"}, |
570 |
$gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, $project_id, $accno, conv_date($form->{"datepaid_$i"})); |
|
575 |
$gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, $project_id, $accno, conv_date($form->{"datepaid_$i"}), $accno);
|
|
571 | 576 |
do_query($form, $dbh, $query, @values); |
572 | 577 |
|
573 | 578 |
$exchangerate = 0; |
... | ... | |
605 | 610 |
$form->{fx}{$accno}{$transdate} = $form->round_amount($form->{fx}{$accno}{$transdate}, 2); |
606 | 611 |
next if ($form->{fx}{$accno}{$transdate} == 0); |
607 | 612 |
|
608 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey, project_id, tax_id) |
|
613 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey, project_id, tax_id, chart_link)
|
|
609 | 614 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, '0', '1', 0, ?, |
610 | 615 |
(SELECT tax_id |
611 | 616 |
FROM taxkeys |
... | ... | |
613 | 618 |
FROM chart |
614 | 619 |
WHERE accno = ?) |
615 | 620 |
AND startdate <= ? |
616 |
ORDER BY startdate DESC LIMIT 1))|; |
|
617 |
@values = (conv_i($form->{id}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $project_id, $accno, $form->{fx}{$accno}{$transdate}); |
|
621 |
ORDER BY startdate DESC LIMIT 1), |
|
622 |
(SELECT link FROM chart WHERE accno = ?))|; |
|
623 |
@values = (conv_i($form->{id}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $project_id, $accno, $form->{fx}{$accno}{$transdate}, $accno); |
|
618 | 624 |
do_query($form, $dbh, $query, @values); |
619 | 625 |
} |
620 | 626 |
} |
SL/IS.pm | ||
---|---|---|
832 | 832 |
|
833 | 833 |
if (!$payments_only && ($form->{amount_cogs}{$trans_id}{$accno} != 0)) { |
834 | 834 |
$query = |
835 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id) |
|
836 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT id FROM tax WHERE taxkey=0), 0, ?)|; |
|
837 |
@values = (conv_i($trans_id), $accno, $form->{amount_cogs}{$trans_id}{$accno}, conv_date($form->{invdate}), conv_i($project_id)); |
|
835 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link)
|
|
836 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT id FROM tax WHERE taxkey=0), 0, ?, (SELECT link FROM chart WHERE accno = ?))|;
|
|
837 |
@values = (conv_i($trans_id), $accno, $form->{amount_cogs}{$trans_id}{$accno}, conv_date($form->{invdate}), conv_i($project_id), $accno);
|
|
838 | 838 |
do_query($form, $dbh, $query, @values); |
839 | 839 |
$form->{amount_cogs}{$trans_id}{$accno} = 0; |
840 | 840 |
} |
... | ... | |
845 | 845 |
|
846 | 846 |
if (!$payments_only && ($form->{amount_cogs}{$trans_id}{$accno} != 0)) { |
847 | 847 |
$query = |
848 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id) |
|
849 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT id FROM tax WHERE taxkey=0), 0, ?)|; |
|
850 |
@values = (conv_i($trans_id), $accno, $form->{amount_cogs}{$trans_id}{$accno}, conv_date($form->{invdate}), conv_i($project_id)); |
|
848 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link)
|
|
849 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT id FROM tax WHERE taxkey=0), 0, ?, (SELECT link FROM chart WHERE accno = ?))|;
|
|
850 |
@values = (conv_i($trans_id), $accno, $form->{amount_cogs}{$trans_id}{$accno}, conv_date($form->{invdate}), conv_i($project_id), $accno);
|
|
851 | 851 |
do_query($form, $dbh, $query, @values); |
852 | 852 |
} |
853 | 853 |
} |
... | ... | |
861 | 861 |
|
862 | 862 |
if (!$payments_only && ($form->{amount}{$trans_id}{$accno} != 0)) { |
863 | 863 |
$query = |
864 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id) |
|
864 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link)
|
|
865 | 865 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
866 | 866 |
(SELECT tax_id |
867 | 867 |
FROM taxkeys |
... | ... | |
870 | 870 |
WHERE accno = ?) |
871 | 871 |
AND startdate <= ? |
872 | 872 |
ORDER BY startdate DESC LIMIT 1), |
873 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; |
|
874 |
@values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_i($project_id)); |
|
873 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
|
874 |
(SELECT link FROM chart WHERE accno = ?))|; |
|
875 |
@values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_i($project_id), $accno); |
|
875 | 876 |
do_query($form, $dbh, $query, @values); |
876 | 877 |
$form->{amount}{$trans_id}{$accno} = 0; |
877 | 878 |
} |
... | ... | |
882 | 883 |
|
883 | 884 |
if (!$payments_only && ($form->{amount}{$trans_id}{$accno} != 0)) { |
884 | 885 |
$query = |
885 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id) |
|
886 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link)
|
|
886 | 887 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
887 | 888 |
(SELECT tax_id |
888 | 889 |
FROM taxkeys |
... | ... | |
891 | 892 |
WHERE accno = ?) |
892 | 893 |
AND startdate <= ? |
893 | 894 |
ORDER BY startdate DESC LIMIT 1), |
894 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; |
|
895 |
@values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_i($project_id)); |
|
895 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
|
896 |
(SELECT link FROM chart WHERE accno = ?))|; |
|
897 |
@values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_i($project_id), $accno); |
|
896 | 898 |
do_query($form, $dbh, $query, @values); |
897 | 899 |
} |
898 | 900 |
} |
... | ... | |
938 | 940 |
|
939 | 941 |
if ($form->{amount}{ $form->{id} }{ $form->{AR} } != 0) { |
940 | 942 |
$query = |
941 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id) |
|
943 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link)
|
|
942 | 944 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
943 | 945 |
(SELECT tax_id |
944 | 946 |
FROM taxkeys |
... | ... | |
947 | 949 |
WHERE accno = ?) |
948 | 950 |
AND startdate <= ? |
949 | 951 |
ORDER BY startdate DESC LIMIT 1), |
950 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; |
|
951 |
@values = (conv_i($form->{"id"}), $form->{AR}, $amount, $form->{"datepaid_$i"}, $form->{AR}, conv_date($taxdate), $form->{AR}, $project_id); |
|
952 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
|
953 |
(SELECT link FROM chart WHERE accno = ?))|; |
|
954 |
@values = (conv_i($form->{"id"}), $form->{AR}, $amount, $form->{"datepaid_$i"}, $form->{AR}, conv_date($taxdate), $form->{AR}, $project_id, $form->{AR}); |
|
952 | 955 |
do_query($form, $dbh, $query, @values); |
953 | 956 |
} |
954 | 957 |
|
... | ... | |
957 | 960 |
my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig)); |
958 | 961 |
|
959 | 962 |
$query = |
960 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, tax_id, taxkey, project_id) |
|
963 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, tax_id, taxkey, project_id, chart_link)
|
|
961 | 964 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, |
962 | 965 |
(SELECT tax_id |
963 | 966 |
FROM taxkeys |
... | ... | |
966 | 969 |
WHERE accno = ?) |
967 | 970 |
AND startdate <= ? |
968 | 971 |
ORDER BY startdate DESC LIMIT 1), |
969 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; |
|
972 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
|
973 |
(SELECT link FROM chart WHERE accno = ?))|; |
|
970 | 974 |
@values = (conv_i($form->{"id"}), $accno, $form->{"paid_$i"}, $form->{"datepaid_$i"}, |
971 |
$gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, conv_date($taxdate), $accno, $project_id); |
|
975 |
$gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, conv_date($taxdate), $accno, $project_id, $accno);
|
|
972 | 976 |
do_query($form, $dbh, $query, @values); |
973 | 977 |
|
974 | 978 |
# exchangerate difference |
... | ... | |
1008 | 1012 |
if ( $form->{fx}{$accno}{$transdate} != 0 ) { |
1009 | 1013 |
|
1010 | 1014 |
$query = |
1011 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, tax_id, taxkey, project_id) |
|
1015 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, tax_id, taxkey, project_id, chart_link)
|
|
1012 | 1016 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, '0', '1', |
1013 | 1017 |
(SELECT tax_id |
1014 | 1018 |
FROM taxkeys |
... | ... | |
1017 | 1021 |
WHERE accno = ?) |
1018 | 1022 |
AND startdate <= ? |
1019 | 1023 |
ORDER BY startdate DESC LIMIT 1), |
1020 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; |
|
1021 |
@values = (conv_i($form->{"id"}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $accno, conv_date($taxdate), $accno, conv_i($project_id)); |
|
1024 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
|
1025 |
(SELECT link FROM chart WHERE accno = ?))|; |
|
1026 |
@values = (conv_i($form->{"id"}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $accno, conv_date($taxdate), $accno, conv_i($project_id), $accno); |
|
1022 | 1027 |
do_query($form, $dbh, $query, @values); |
1023 | 1028 |
} |
1024 | 1029 |
} |
sql/Pg-upgrade2/add_chart_link_to_acc_trans.sql | ||
---|---|---|
1 |
-- @tag: add_chart_link_to_acc_trans |
|
2 |
-- @description: Neue Spalte chart_link in der acc_trans |
|
3 |
-- @depends: release_3_0_0 |
|
4 |
|
|
5 |
--neue Spalte hinzufügen: |
|
6 |
ALTER TABLE acc_trans ADD COLUMN chart_link text; |
|
7 |
|
|
8 |
--Spalte mit Werten füllen: |
|
9 |
UPDATE acc_trans SET chart_link = (SELECT link FROM chart WHERE id=chart_id); |
|
10 |
|
|
11 |
--Spalte als Pflichtfeld definieren: |
|
12 |
ALTER TABLE acc_trans ALTER chart_link SET NOT NULL; |
Auch abrufbar als: Unified diff
chart_link in acc_trans
Erstellt ein neues Pflichtfeld chart_link in der Tabelle acc_trans.
Wird bisher nur beschrieben und noch an keiner Stelle ausgelesen.
Conflicts: