projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Änderung in Commit 1de53c an Finanzamt SQL-Daten zurückgenommen.
[kivitendo-erp.git]
/
SL
/
IR.pm
diff --git
a/SL/IR.pm
b/SL/IR.pm
index
78970e3
..
7fefd41
100644
(file)
--- a/
SL/IR.pm
+++ b/
SL/IR.pm
@@
-41,9
+41,12
@@
use SL::CVar;
use SL::DBUtils;
use SL::DO;
use SL::GenericTranslations;
use SL::DBUtils;
use SL::DO;
use SL::GenericTranslations;
+use SL::IO;
use SL::MoreCommon;
use List::Util qw(min);
use SL::MoreCommon;
use List::Util qw(min);
+use strict;
+
sub post_invoice {
$main::lxdebug->enter_sub();
sub post_invoice {
$main::lxdebug->enter_sub();
@@
-61,6
+64,7
@@
sub post_invoice {
my ($amount, $linetotal, $lastinventoryaccno, $lastexpenseaccno);
my ($netamount, $invoicediff, $expensediff) = (0, 0, 0);
my $exchangerate = 0;
my ($amount, $linetotal, $lastinventoryaccno, $lastexpenseaccno);
my ($netamount, $invoicediff, $expensediff) = (0, 0, 0);
my $exchangerate = 0;
+ my ($basefactor, $baseqty, @taxaccounts, $totaltax);
my $all_units = AM->retrieve_units($myconfig, $form);
my $all_units = AM->retrieve_units($myconfig, $form);
@@
-133,13
+137,10
@@
sub post_invoice {
$price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1;
#####################################################################
# das ist aus IS.pm kopiert. schlimm. jb 7.10.2009
$price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1;
#####################################################################
# das ist aus IS.pm kopiert. schlimm. jb 7.10.2009
- # ich würde mir wünschen, dass diese vier stellen zusammengefasst werden
+ # ich würde mir wünschen, dass diese vier stellen zusammengefasst werden
# ... vier stellen = (einkauf + verkauf) * (maske + backend)
# ansonsten stolpert man immer wieder viermal statt einmal heftig
# und auch das undo discount formatting ist nicht besonders wartungsfreundlich
# ... vier stellen = (einkauf + verkauf) * (maske + backend)
# ansonsten stolpert man immer wieder viermal statt einmal heftig
# und auch das undo discount formatting ist nicht besonders wartungsfreundlich
-
- # keep entered selling price
- my $fxsellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
# keine ahnung wofür das in IS.pm gemacht wird:
# my ($dec) = ($fxsellprice =~ /\.(\d+)/);
# keine ahnung wofür das in IS.pm gemacht wird:
# my ($dec) = ($fxsellprice =~ /\.(\d+)/);
@@
-150,7
+151,7
@@
sub post_invoice {
$form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100;
# deduct discount
$form->{"sellprice_$i"} = $fxsellprice * (1 - $form->{"discount_$i"});
$form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100;
# deduct discount
$form->{"sellprice_$i"} = $fxsellprice * (1 - $form->{"discount_$i"});
-
+
######################################################################
if ($form->{"inventory_accno_$i"}) {
######################################################################
if ($form->{"inventory_accno_$i"}) {
@@
-218,9
+219,9
@@
sub post_invoice {
ORDER BY transdate|;
$sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{"id_$i"}));
ORDER BY transdate|;
$sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{"id_$i"}));
- my $totalqty = $base
_
qty;
+ my $totalqty = $baseqty;
- while (my $ref = $sth->fetchrow_hashref(
NAME_lc
)) {
+ while (my $ref = $sth->fetchrow_hashref(
"NAME_lc"
)) {
my $qty = min $totalqty, ($ref->{base_qty} + $ref->{allocated});
$linetotal = $form->round_amount(($form->{"sellprice_$i"} * $qty) / $basefactor, 2);
my $qty = min $totalqty, ($ref->{base_qty} + $ref->{allocated});
$linetotal = $form->round_amount(($form->{"sellprice_$i"} * $qty) / $basefactor, 2);
@@
-317,12
+318,12
@@
sub post_invoice {
my ($invoice_id) = selectfirst_array_query($form, $dbh, qq|SELECT nextval('invoiceid')|);
$query =
my ($invoice_id) = selectfirst_array_query($form, $dbh, qq|SELECT nextval('invoiceid')|);
$query =
- qq|INSERT INTO invoice (id, trans_id, parts_id, description, qty, base_qty,
+ qq|INSERT INTO invoice (id, trans_id, parts_id, description,
longdescription,
qty, base_qty,
sellprice, fxsellprice, discount, allocated, unit, deliverydate,
project_id, serialnumber, price_factor_id, price_factor, marge_price_factor)
sellprice, fxsellprice, discount, allocated, unit, deliverydate,
project_id, serialnumber, price_factor_id, price_factor, marge_price_factor)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, (SELECT factor FROM price_factors WHERE id = ?), ?)|;
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?,
(SELECT factor FROM price_factors WHERE id = ?), ?)|;
@values = ($invoice_id, conv_i($form->{id}), conv_i($form->{"id_$i"}),
@values = ($invoice_id, conv_i($form->{id}), conv_i($form->{"id_$i"}),
- $form->{"description_$i"}, $form->{"qty_$i"} * -1,
+ $form->{"description_$i"}, $form->{"
longdescription_$i"}, $form->{"
qty_$i"} * -1,
$baseqty * -1, $form->{"sellprice_$i"}, $fxsellprice, $form->{"discount_$i"}, $allocated,
$form->{"unit_$i"}, conv_date($form->{deliverydate}),
conv_i($form->{"project_id_$i"}), $form->{"serialnumber_$i"},
$baseqty * -1, $form->{"sellprice_$i"}, $fxsellprice, $form->{"discount_$i"}, $allocated,
$form->{"unit_$i"}, conv_date($form->{deliverydate}),
conv_i($form->{"project_id_$i"}), $form->{"serialnumber_$i"},
@@
-507,9
+508,11
@@
sub post_invoice {
}
}
}
}
+ IO->set_datepaid(table => 'ap', id => $form->{id}, dbh => $dbh);
+
if ($payments_only) {
if ($payments_only) {
- $query = qq|UPDATE ap SET paid = ?
, datepaid = ?
WHERE id = ?|;
- do_query($form, $dbh, $query,
$form->{paid}, $form->{paid} ? conv_date($form->{datepaid}) : undef
, conv_i($form->{id}));
+ $query = qq|UPDATE ap SET paid = ? WHERE id = ?|;
+ do_query($form, $dbh, $query,
$form->{paid}
, conv_i($form->{id}));
if (!$provided_dbh) {
$dbh->commit();
if (!$provided_dbh) {
$dbh->commit();
@@
-533,7
+536,7
@@
sub post_invoice {
$query = qq|UPDATE ap SET
invnumber = ?, ordnumber = ?, quonumber = ?, transdate = ?,
orddate = ?, quodate = ?, vendor_id = ?, amount = ?,
$query = qq|UPDATE ap SET
invnumber = ?, ordnumber = ?, quonumber = ?, transdate = ?,
orddate = ?, quodate = ?, vendor_id = ?, amount = ?,
- netamount = ?, paid = ?, duedate = ?,
datepaid = ?,
+ netamount = ?, paid = ?, duedate = ?,
invoice = ?, taxzone_id = ?, notes = ?, taxincluded = ?,
intnotes = ?, curr = ?, storno_id = ?, storno = ?,
cp_id = ?, employee_id = ?, department_id = ?,
invoice = ?, taxzone_id = ?, notes = ?, taxincluded = ?,
intnotes = ?, curr = ?, storno_id = ?, storno = ?,
cp_id = ?, employee_id = ?, department_id = ?,
@@
-542,7
+545,7
@@
sub post_invoice {
@values = (
$form->{invnumber}, $form->{ordnumber}, $form->{quonumber}, conv_date($form->{invdate}),
conv_date($form->{orddate}), conv_date($form->{quodate}), conv_i($form->{vendor_id}), $amount,
@values = (
$form->{invnumber}, $form->{ordnumber}, $form->{quonumber}, conv_date($form->{invdate}),
conv_date($form->{orddate}), conv_date($form->{quodate}), conv_i($form->{vendor_id}), $amount,
- $netamount, $form->{paid}, conv_date($form->{duedate}),
$form->{paid} ? conv_date($form->{datepaid}) : undef,
+ $netamount, $form->{paid}, conv_date($form->{duedate}),
'1', $taxzone_id, $form->{notes}, $form->{taxincluded} ? 't' : 'f',
$form->{intnotes}, $form->{currency}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f',
conv_i($form->{cp_id}), conv_i($form->{employee_id}), conv_i($form->{department_id}),
'1', $taxzone_id, $form->{notes}, $form->{taxincluded} ? 't' : 'f',
$form->{intnotes}, $form->{currency}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f',
conv_i($form->{cp_id}), conv_i($form->{employee_id}), conv_i($form->{department_id}),
@@
-631,7
+634,7
@@
sub reverse_invoice {
my $netamount = 0;
my $netamount = 0;
- while (my $ref = $sth->fetchrow_hashref(
NAME_lc
)) {
+ while (my $ref = $sth->fetchrow_hashref(
"NAME_lc"
)) {
$netamount += $form->round_amount($ref->{sellprice} * $ref->{qty} * -1, 2);
next unless $ref->{inventory_accno_id};
$netamount += $form->round_amount($ref->{sellprice} * $ref->{qty} * -1, 2);
next unless $ref->{inventory_accno_id};
@@
-649,7
+652,7
@@
sub reverse_invoice {
ORDER BY transdate DESC|;
my $sth2 = prepare_execute_query($form, $dbh, $query, $ref->{parts_id});
ORDER BY transdate DESC|;
my $sth2 = prepare_execute_query($form, $dbh, $query, $ref->{parts_id});
- while (my $pthref = $sth2->fetchrow_hashref(
NAME_lc
)) {
+ while (my $pthref = $sth2->fetchrow_hashref(
"NAME_lc"
)) {
my $qty = $ref->{allocated};
if (($ref->{allocated} + $pthref->{allocated}) > 0) {
$qty = $pthref->{allocated} * -1;
my $qty = $ref->{allocated};
if (($ref->{allocated} + $pthref->{allocated}) > 0) {
$qty = $pthref->{allocated} * -1;
@@
-796,7
+799,7
@@
sub retrieve_invoice {
c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from AS expense_valid,
i.id AS invoice_id,
c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from AS expense_valid,
i.id AS invoice_id,
- i.description, i.qty, i.fxsellprice AS sellprice, i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber,
+ i.description, i.
longdescription, i.
qty, i.fxsellprice AS sellprice, i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber,
i.price_factor_id, i.price_factor, i.marge_price_factor, i.discount,
p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, pr.projectnumber, pg.partsgroup
i.price_factor_id, i.price_factor, i.marge_price_factor, i.discount,
p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, pr.projectnumber, pg.partsgroup
@@
-813,7
+816,7
@@
sub retrieve_invoice {
ORDER BY i.id|;
$sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id}));
ORDER BY i.id|;
$sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id}));
- while (my $ref = $sth->fetchrow_hashref(
NAME_lc
)) {
+ while (my $ref = $sth->fetchrow_hashref(
"NAME_lc"
)) {
# Retrieve custom variables.
my $cvars = CVar->get_custom_variables(dbh => $dbh,
module => 'IC',
# Retrieve custom variables.
my $cvars = CVar->get_custom_variables(dbh => $dbh,
module => 'IC',
@@
-849,7
+852,7
@@
sub retrieve_invoice {
$ref->{taxaccounts} = "";
my $i = 0;
$ref->{taxaccounts} = "";
my $i = 0;
- while (
$ptr = $stw->fetchrow_hashref(NAME_lc
)) {
+ while (
my $ptr = $stw->fetchrow_hashref("NAME_lc"
)) {
if (($ptr->{accno} eq "") && ($ptr->{rate} == 0)) {
$i++;
$ptr->{accno} = $i;
if (($ptr->{accno} eq "") && ($ptr->{rate} == 0)) {
$i++;
$ptr->{accno} = $i;
@@
-914,7
+917,7
@@
sub get_vendor {
my $query =
qq|SELECT
v.id AS vendor_id, v.name AS vendor, v.discount as vendor_discount,
my $query =
qq|SELECT
v.id AS vendor_id, v.name AS vendor, v.discount as vendor_discount,
- v.creditlimit, v.terms, v.notes AS intnotes,
+
v.creditlimit, v.terms, v.notes AS intnotes,
v.email, v.cc, v.bcc, v.language_id, v.payment_id,
v.street, v.zipcode, v.city, v.country, v.taxzone_id,
$duedate + COALESCE(pt.terms_netto, 0) AS duedate,
v.email, v.cc, v.bcc, v.language_id, v.payment_id,
v.street, v.zipcode, v.city, v.country, v.taxzone_id,
$duedate + COALESCE(pt.terms_netto, 0) AS duedate,
@@
-923,7
+926,7
@@
sub get_vendor {
LEFT JOIN business b ON (b.id = v.business_id)
LEFT JOIN payment_terms pt ON (v.payment_id = pt.id)
WHERE 1=1 $where|;
LEFT JOIN business b ON (b.id = v.business_id)
LEFT JOIN payment_terms pt ON (v.payment_id = pt.id)
WHERE 1=1 $where|;
- $ref = selectfirst_hashref_query($form, $dbh, $query, @values);
+
my
$ref = selectfirst_hashref_query($form, $dbh, $query, @values);
map { $params->{$_} = $ref->{$_} } keys %$ref;
$params->{creditremaining} = $params->{creditlimit};
map { $params->{$_} = $ref->{$_} } keys %$ref;
$params->{creditremaining} = $params->{creditlimit};
@@
-972,14
+975,14
@@
sub get_vendor {
for $ref (@$refs) {
if ($ref->{category} eq 'E') {
$i++;
for $ref (@$refs) {
if ($ref->{category} eq 'E') {
$i++;
-
+ my ($tax_id, $rate);
if ($params->{initial_transdate}) {
my $tax_query = qq|SELECT tk.tax_id, t.rate FROM taxkeys tk
LEFT JOIN tax t ON (tk.tax_id = t.id)
WHERE (tk.chart_id = ?) AND (startdate <= ?)
ORDER BY tk.startdate DESC
LIMIT 1|;
if ($params->{initial_transdate}) {
my $tax_query = qq|SELECT tk.tax_id, t.rate FROM taxkeys tk
LEFT JOIN tax t ON (tk.tax_id = t.id)
WHERE (tk.chart_id = ?) AND (startdate <= ?)
ORDER BY tk.startdate DESC
LIMIT 1|;
-
my
($tax_id, $rate) = selectrow_query($form, $dbh, $tax_query, $ref->{id}, $params->{initial_transdate});
+ ($tax_id, $rate) = selectrow_query($form, $dbh, $tax_query, $ref->{id}, $params->{initial_transdate});
$params->{"taxchart_$i"} = "${tax_id}--${rate}";
}
$params->{"taxchart_$i"} = "${tax_id}--${rate}";
}
@@
-1082,7
+1085,7
@@
sub retrieve_item {
my $sth = prepare_execute_query($form, $dbh, $query, @values);
$form->{item_list} = [];
my $sth = prepare_execute_query($form, $dbh, $query, @values);
$form->{item_list} = [];
- while (my $ref = $sth->fetchrow_hashref(
NAME_lc
)) {
+ while (my $ref = $sth->fetchrow_hashref(
"NAME_lc"
)) {
# In der Buchungsgruppe ist immer ein Bestandskonto verknuepft, auch wenn
# es sich um eine Dienstleistung handelt. Bei Dienstleistungen muss das
# In der Buchungsgruppe ist immer ein Bestandskonto verknuepft, auch wenn
# es sich um eine Dienstleistung handelt. Bei Dienstleistungen muss das
@@
-1093,7
+1096,7
@@
sub retrieve_item {
delete($ref->{inventory_accno_id});
# get tax rates and description
delete($ref->{inventory_accno_id});
# get tax rates and description
- $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
+
my
$accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
$query =
qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber
FROM tax t
$query =
qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber
FROM tax t
@@
-1113,7
+1116,7
@@
sub retrieve_item {
$ref->{taxaccounts} = "";
my $i = 0;
$ref->{taxaccounts} = "";
my $i = 0;
- while (
$ptr = $stw->fetchrow_hashref(NAME_lc
)) {
+ while (
my $ptr = $stw->fetchrow_hashref("NAME_lc"
)) {
# if ($customertax{$ref->{accno}}) {
if (($ptr->{accno} eq "") && ($ptr->{rate} == 0)) {
# if ($customertax{$ref->{accno}}) {
if (($ptr->{accno} eq "") && ($ptr->{rate} == 0)) {
@@
-1227,7
+1230,7
@@
sub item_links {
ORDER BY accno|;
my $sth = prepare_execute_query($query, $dbh, $query);
ORDER BY accno|;
my $sth = prepare_execute_query($query, $dbh, $query);
- while (my $ref = $sth->fetchrow_hashref(
NAME_lc
)) {
+ while (my $ref = $sth->fetchrow_hashref(
"NAME_lc"
)) {
foreach my $key (split(/:/, $ref->{link})) {
if ($key =~ /IC/) {
push @{ $form->{IC_links}{$key} },
foreach my $key (split(/:/, $ref->{link})) {
if ($key =~ /IC/) {
push @{ $form->{IC_links}{$key} },