my ($self, $form, $dbh) = @_;
- my @delete_oids;
+ my @delete_acc_trans_ids;
# Delete old payment entries from acc_trans.
my $query =
- qq|SELECT oid
+ qq|SELECT acc_trans_id
FROM acc_trans
WHERE (trans_id = ?) AND fx_transaction
UNION
- SELECT at.oid
+ SELECT at.acc_trans_id
FROM acc_trans at
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (trans_id = ?) AND (c.link LIKE '%AP_paid%')|;
- push @delete_oids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}), conv_i($form->{id}));
+ push @delete_acc_trans_ids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}), conv_i($form->{id}));
$query =
- qq|SELECT at.oid
+ qq|SELECT at.acc_trans_id
FROM acc_trans at
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (trans_id = ?)
AND ((c.link = 'AP') OR (c.link LIKE '%:AP') OR (c.link LIKE 'AP:%'))
- ORDER BY at.oid
+ ORDER BY at.acc_trans_id
OFFSET 1|;
- push @delete_oids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}));
+ push @delete_acc_trans_ids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}));
- if (@delete_oids) {
- $query = qq|DELETE FROM acc_trans WHERE oid IN (| . join(", ", @delete_oids) . qq|)|;
+ if (@delete_acc_trans_ids) {
+ $query = qq|DELETE FROM acc_trans WHERE acc_trans_id IN (| . join(", ", @delete_acc_trans_ids) . qq|)|;
do_query($form, $dbh, $query);
}
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (trans_id = ?)
AND ((c.link = 'AP') OR (c.link LIKE '%:AP') OR (c.link LIKE 'AP:%'))
- ORDER BY at.oid
+ ORDER BY at.acc_trans_id
LIMIT 1|;
($form->{APselected}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{id}));
do_query($form, $dbh, $query, $id);
# now copy acc_trans entries
- $query = qq|SELECT a.*, c.link FROM acc_trans a LEFT JOIN chart c ON a.chart_id = c.id WHERE a.trans_id = ? ORDER BY a.oid|;
+ $query = qq|SELECT a.*, c.link FROM acc_trans a LEFT JOIN chart c ON a.chart_id = c.id WHERE a.trans_id = ? ORDER BY a.acc_trans_id|;
my $rowref = selectall_hashref_query($form, $dbh, $query, $id);
# kill all entries containing payments, which are the last 2n rows, of which the last has link =~ /paid/
my ($self, $form, $dbh) = @_;
- my @delete_oids;
+ my @delete_acc_trans_ids;
# Delete old payment entries from acc_trans.
my $query =
- qq|SELECT oid
+ qq|SELECT acc_trans_id
FROM acc_trans
WHERE (trans_id = ?) AND fx_transaction
UNION
- SELECT at.oid
+ SELECT at.acc_trans_id
FROM acc_trans at
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (trans_id = ?) AND (c.link LIKE '%AR_paid%')|;
- push @delete_oids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}), conv_i($form->{id}));
+ push @delete_acc_trans_ids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}), conv_i($form->{id}));
$query =
- qq|SELECT at.oid
+ qq|SELECT at.acc_trans_id
FROM acc_trans at
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (trans_id = ?)
AND ((c.link = 'AR') OR (c.link LIKE '%:AR') OR (c.link LIKE 'AR:%'))
- ORDER BY at.oid
+ ORDER BY at.acc_trans_id
OFFSET 1|;
- push @delete_oids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}));
+ push @delete_acc_trans_ids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}));
- if (@delete_oids) {
- $query = qq|DELETE FROM acc_trans WHERE oid IN (| . join(", ", @delete_oids) . qq|)|;
+ if (@delete_acc_trans_ids) {
+ $query = qq|DELETE FROM acc_trans WHERE acc_trans_id IN (| . join(", ", @delete_acc_trans_ids) . qq|)|;
do_query($form, $dbh, $query);
}
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (trans_id = ?)
AND ((c.link = 'AR') OR (c.link LIKE '%:AR') OR (c.link LIKE 'AR:%'))
- ORDER BY at.oid
+ ORDER BY at.acc_trans_id
LIMIT 1|;
($form->{ARselected}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{id}));
do_query($form, $dbh, $query, $id);
# now copy acc_trans entries
- $query = qq|SELECT a.*, c.link FROM acc_trans a LEFT JOIN chart c ON a.chart_id = c.id WHERE a.trans_id = ? ORDER BY a.oid|;
+ $query = qq|SELECT a.*, c.link FROM acc_trans a LEFT JOIN chart c ON a.chart_id = c.id WHERE a.trans_id = ? ORDER BY a.acc_trans_id|;
my $rowref = selectall_hashref_query($form, $dbh, $query, $id);
# kill all entries containing payments, which are the last 2n rows, of which the last has link =~ /paid/
}
my $query = qq!
- SELECT at.oid, at.*,
+ SELECT at.*,
c.accno, c.description AS chartdescription, c.charttype, c.category AS chartcategory, c.link AS chartlink,
COALESCE(gl.reference, COALESCE(ap.invnumber, ar.invnumber)) AS reference,
COALESCE(ap.invoice, COALESCE(ar.invoice, FALSE)) AS invoice,
LEFT JOIN ap ON (at.trans_id = ap.id)
LEFT JOIN ar ON (at.trans_id = ar.id)
$where
- ORDER BY at.trans_id, at.oid
+ ORDER BY at.trans_id, at.acc_trans_id
!;
my @transactions = ();
}
foreach my $entry (@{ $data{$side}->{entries} }) {
- $entry->{actual_tax} = $form->round_amount(abs($entry->{tax_entry} ? $entry->{tax_entry}->{amount} : 0), 2);
- $entry->{expected_tax} = $form->round_amount(abs($entry->{expected_tax}), 2);
- $entry->{taxkey_error} = ( $entry->{taxkey} && !$entry->{tax_entry})
- || (!$entry->{taxkey} && $entry->{tax_entry})
- || (abs($entry->{expected_tax} - $entry->{actual_tax}) >= 0.02);
- $entry->{tax_entry_oid} = $entry->{tax_entry}->{oid};
+ $entry->{actual_tax} = $form->round_amount(abs($entry->{tax_entry} ? $entry->{tax_entry}->{amount} : 0), 2);
+ $entry->{expected_tax} = $form->round_amount(abs($entry->{expected_tax}), 2);
+ $entry->{taxkey_error} = ( $entry->{taxkey} && !$entry->{tax_entry})
+ || (!$entry->{taxkey} && $entry->{tax_entry})
+ || (abs($entry->{expected_tax} - $entry->{actual_tax}) >= 0.02);
+ $entry->{tax_entry_acc_trans_id} = $entry->{tax_entry}->{acc_trans_id};
delete $entry->{tax_entry};
$entry->{display_amount} = $form->round_amount(abs($entry->{amount}) * $storno_mult, 2);
my $tax_info = $all_taxes{taxkeys}->{$taxkey};
- next if ((!$tax_info || (0 == $tax_info->{taxrate} * 1)) && $entry->{tax_entry_oid});
+ next if ((!$tax_info || (0 == $tax_info->{taxrate} * 1)) && $entry->{tax_entry_acc_trans_id});
push @{ $entry->{correct_taxkeys} }, {
'taxkey' => $taxkey,
# $solution->{rows}->[$i]->{taxdescription} .= ' ' . $form->format_amount(\%myconfig, $tax_entry->{taxrate} * 100) . ' %';
# push @{ $solution->{changes} }, {
-# 'oid' => $entry->{oid},
+# 'acc_trans_id' => $entry->{acc_trans_id},
# 'taxkey' => $solution->{taxkeys}->[$i],
# };
# }
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
my $query = qq|SELECT 'ap' AS module,
- at.oid, at.trans_id, at.chart_id, at.amount, at.taxkey, at.transdate,
+ at.acc_trans_id, at.trans_id, at.chart_id, at.amount, at.taxkey, at.transdate,
c.link
FROM acc_trans at
LEFT JOIN chart c ON (at.chart_id = c.id)
UNION
SELECT 'ar' AS module,
- at.oid, at.trans_id, at.chart_id, at.amount, at.taxkey, at.transdate,
+ at.acc_trans_id, at.trans_id, at.chart_id, at.amount, at.taxkey, at.transdate,
c.link
FROM acc_trans at
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (trans_id IN (SELECT id FROM ar WHERE NOT invoice))
AND (taxkey IN (8, 9, 18, 19))
- ORDER BY trans_id, oid|;
+ ORDER BY trans_id, acc_trans_id|;
my $sth = prepare_execute_query($form, $dbh, $query);
my @transactions;
my %all_taxes = $self->{taxkeys}->get_full_tax_info('transdate' => $non_tax->{transdate});
- push @corrections, ({ 'oid' => $non_tax->{oid},
- 'taxkey' => $taxkey_replacements{$non_tax->{taxkey}},
+ push @corrections, ({ 'acc_trans_id' => $non_tax->{acc_trans_id},
+ 'taxkey' => $taxkey_replacements{$non_tax->{taxkey}},
},
{
- 'oid' => $tax->{oid},
- 'taxkey' => $taxkey_replacements{$non_tax->{taxkey}},
- 'chart_id' => $all_taxes{taxkeys}->{ $taxkey_replacements{$non_tax->{taxkey}} }->{taxchart_id},
+ 'acc_trans_id' => $tax->{acc_trans_id},
+ 'taxkey' => $taxkey_replacements{$non_tax->{taxkey}},
+ 'chart_id' => $all_taxes{taxkeys}->{ $taxkey_replacements{$non_tax->{taxkey}} }->{taxchart_id},
});
}
}
if (scalar @corrections) {
- my $q_taxkey_only = qq|UPDATE acc_trans SET taxkey = ? WHERE oid = ?|;
+ my $q_taxkey_only = qq|UPDATE acc_trans SET taxkey = ? WHERE acc_trans_id = ?|;
my $h_taxkey_only = prepare_query($form, $dbh, $q_taxkey_only);
- my $q_taxkey_chart_id = qq|UPDATE acc_trans SET taxkey = ?, chart_id = ? WHERE oid = ?|;
+ my $q_taxkey_chart_id = qq|UPDATE acc_trans SET taxkey = ?, chart_id = ? WHERE acc_trans_id = ?|;
my $h_taxkey_chart_id = prepare_query($form, $dbh, $q_taxkey_chart_id);
foreach my $entry (@corrections) {
if ($entry->{chart_id}) {
- do_statement($form, $h_taxkey_chart_id, $q_taxkey_chart_id, $entry->{taxkey}, $entry->{chart_id}, $entry->{oid});
+ do_statement($form, $h_taxkey_chart_id, $q_taxkey_chart_id, $entry->{taxkey}, $entry->{chart_id}, $entry->{acc_trans_id});
} else {
- do_statement($form, $h_taxkey_only, $q_taxkey_only, $entry->{taxkey}, $entry->{oid});
+ do_statement($form, $h_taxkey_only, $q_taxkey_only, $entry->{taxkey}, $entry->{acc_trans_id});
}
}
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
- my $query = qq|SELECT at.oid, at.*, c.link
+ my $query = qq|SELECT at.*, c.link
FROM acc_trans at
LEFT JOIN ar ON (at.trans_id = ar.id)
LEFT JOIN chart c ON (at.chart_id = c.id)
UNION
- SELECT at.oid, at.*, c.link
+ SELECT at.*, c.link
FROM acc_trans at
LEFT JOIN ap ON (at.trans_id = ap.id)
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (ap.invoice)
- ORDER BY trans_id, oid|;
+ ORDER BY trans_id, acc_trans_id|;
my $sth = prepare_execute_query($form, $dbh, $query);
my @transactions;
foreach my $entry (@{ $sub_transaction }) {
next if ($entry->{taxkey} == 0);
- push @corrections, $entry->{oid};
+ push @corrections, $entry->{acc_trans_id};
}
}
}
if (@corrections) {
- $query = qq|UPDATE acc_trans SET taxkey = 0 WHERE oid = ?|;
+ $query = qq|UPDATE acc_trans SET taxkey = 0 WHERE acc_trans_id = ?|;
$sth = prepare_query($form, $dbh, $query);
- foreach my $oid (@corrections) {
- do_statement($form, $sth, $query, $oid);
+ foreach my $acc_trans_id (@corrections) {
+ do_statement($form, $sth, $query, $acc_trans_id);
}
$sth->finish();
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig);
- my $q_taxkey_only = qq|UPDATE acc_trans SET taxkey = ? WHERE oid = ?|;
+ my $q_taxkey_only = qq|UPDATE acc_trans SET taxkey = ? WHERE acc_trans_id = ?|;
my $h_taxkey_only = prepare_query($form, $dbh, $q_taxkey_only);
- my $q_taxkey_chart = qq|UPDATE acc_trans SET taxkey = ?, chart_id = ? WHERE oid = ?|;
+ my $q_taxkey_chart = qq|UPDATE acc_trans SET taxkey = ?, chart_id = ? WHERE acc_trans_id = ?|;
my $h_taxkey_chart = prepare_query($form, $dbh, $q_taxkey_chart);
- my $q_transdate = qq|SELECT transdate FROM acc_trans WHERE oid = ?|;
+ my $q_transdate = qq|SELECT transdate FROM acc_trans WHERE acc_trans_id = ?|;
my $h_transdate = prepare_query($form, $dbh, $q_transdate);
foreach my $fix (@{ $params{fixes} }) {
- next unless ($fix->{oid});
+ next unless ($fix->{acc_trans_id});
- do_statement($form, $h_taxkey_only, $q_taxkey_only, conv_i($fix->{taxkey}), conv_i($fix->{oid}));
+ do_statement($form, $h_taxkey_only, $q_taxkey_only, conv_i($fix->{taxkey}), conv_i($fix->{acc_trans_id}));
- next unless ($fix->{tax_entry_oid});
+ next unless ($fix->{tax_entry_acc_trans_id});
- do_statement($form, $h_transdate, $q_transdate, conv_i($fix->{tax_entry_oid}));
+ do_statement($form, $h_transdate, $q_transdate, conv_i($fix->{tax_entry_acc_trans_id}));
my ($transdate) = $h_transdate->fetchrow_array();
my %all_taxes = $self->{taxkeys}->get_full_tax_info('transdate' => $transdate);
next unless ($tax_info);
- do_statement($form, $h_taxkey_chart, $q_taxkey_chart, conv_i($fix->{taxkey}), conv_i($tax_info->{taxchart_id}), conv_i($fix->{tax_entry_oid}));
+ do_statement($form, $h_taxkey_chart, $q_taxkey_chart, conv_i($fix->{taxkey}), conv_i($tax_info->{taxchart_id}), conv_i($fix->{tax_entry_acc_trans_id}));
}
$h_taxkey_only->finish();
my %all_taxchart_ids = selectall_as_map($form, $dbh, qq|SELECT DISTINCT chart_id, TRUE AS is_set FROM tax|, 'chart_id', 'is_set');
my $query =
- qq|SELECT ac.oid, ac.transdate, ac.trans_id,ar.id, ac.amount, ac.taxkey,
+ qq|SELECT ac.acc_trans_id, ac.transdate, ac.trans_id,ar.id, ac.amount, ac.taxkey,
ar.invnumber, ar.duedate, ar.amount as umsatz,
ct.name,
c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, c.link,
UNION ALL
- SELECT ac.oid, ac.transdate, ac.trans_id,ap.id, ac.amount, ac.taxkey,
+ SELECT ac.acc_trans_id, ac.transdate, ac.trans_id,ap.id, ac.amount, ac.taxkey,
ap.invnumber, ap.duedate, ap.amount as umsatz,
ct.name,
c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, c.link,
UNION ALL
- SELECT ac.oid, ac.transdate, ac.trans_id,gl.id, ac.amount, ac.taxkey,
+ SELECT ac.acc_trans_id, ac.transdate, ac.trans_id,gl.id, ac.amount, ac.taxkey,
gl.reference AS invnumber, gl.transdate AS duedate, ac.amount as umsatz,
gl.description AS name,
c.accno, c.taxkey_id as charttax, c.datevautomatik, c.id, c.link,
AND $fromto
$filter
- ORDER BY trans_id, oid|;
+ ORDER BY trans_id, acc_trans_id|;
my $sth = prepare_execute_query($form, $dbh, $query);
$ref = selectfirst_hashref_query($form, $dbh, $query, $form->{login});
map { $form->{"employee_${_}"} = $ref->{$_} } keys %{ $ref };
- $query = qq|SELECT * FROM acc_trans WHERE trans_id = ? ORDER BY oid ASC|;
+ $query = qq|SELECT * FROM acc_trans WHERE trans_id = ? ORDER BY acc_trans_id ASC|;
$sth = prepare_execute_query($form, $dbh, $query, $ar_id);
my ($row, $fee, $interest) = (0, 0, 0);
(startdate <= a.transdate) ORDER BY startdate DESC LIMIT 1))
WHERE a.trans_id = ?
AND a.fx_transaction = '0'
- ORDER BY a.oid, a.transdate|;
+ ORDER BY a.acc_trans_id, a.transdate|;
$sth = $dbh->prepare($query);
do_statement($self, $sth, $query, $self->{id});
my $query =
qq|SELECT
- ac.oid AS acoid, g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, c.link,
+ ac.acc_trans_id, g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, c.link,
g.description, ac.transdate, ac.source, ac.trans_id,
- ac.amount, c.accno, g.notes, t.chart_id, ac.oid
+ ac.amount, c.accno, g.notes, t.chart_id,
+ CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee
$project_columns
$columns_for_sorting{gl}
FROM gl g, acc_trans ac $project_join, chart c
UNION
- SELECT ac.oid AS acoid, a.id, 'ar' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
+ SELECT ac.acc_trans_id, a.id, 'ar' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
ct.name, ac.transdate, ac.source, ac.trans_id,
- ac.amount, c.accno, a.notes, t.chart_id, ac.oid
+ ac.amount, c.accno, a.notes, t.chart_id,
+ CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee
$project_columns
$columns_for_sorting{arap}
FROM ar a, acc_trans ac $project_join, customer ct, chart c
UNION
- SELECT ac.oid AS acoid, a.id, 'ap' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
+ SELECT ac.acc_trans_id, a.id, 'ap' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
ct.name, ac.transdate, ac.source, ac.trans_id,
- ac.amount, c.accno, a.notes, t.chart_id, ac.oid
+ ac.amount, c.accno, a.notes, t.chart_id,
+ CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee
$project_columns
$columns_for_sorting{arap}
FROM ap a, acc_trans ac $project_join, vendor ct, chart c
AND (a.vendor_id = ct.id)
AND (a.id = ac.trans_id)
- ORDER BY $sortorder, acoid $sortdir|;
+ ORDER BY $sortorder, acc_trans_id $sortdir|;
my @values = (@glvalues, @arvalues, @apvalues);
ORDER BY startdate DESC LIMIT 1))
WHERE (a.trans_id = ?)
AND (a.fx_transaction = '0')
- ORDER BY a.oid, a.transdate|;
+ ORDER BY a.acc_trans_id, a.transdate|;
$form->{GL} = selectall_hashref_query($form, $dbh, $query, conv_i($form->{id}));
} else {
my ($self, $form, $dbh) = @_;
- my @delete_oids;
+ my @delete_acc_trans_ids;
# Delete old payment entries from acc_trans.
my $query =
- qq|SELECT oid
+ qq|SELECT acc_trans_id
FROM acc_trans
WHERE (trans_id = ?) AND fx_transaction
UNION
- SELECT at.oid
+ SELECT at.acc_trans_id
FROM acc_trans at
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (trans_id = ?) AND (c.link LIKE '%AP_paid%')|;
- push @delete_oids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}), conv_i($form->{id}));
+ push @delete_acc_trans_ids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}), conv_i($form->{id}));
$query =
- qq|SELECT at.oid
+ qq|SELECT at.acc_trans_id
FROM acc_trans at
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (trans_id = ?)
AND ((c.link = 'AP') OR (c.link LIKE '%:AP') OR (c.link LIKE 'AP:%'))
- ORDER BY at.oid
+ ORDER BY at.acc_trans_id
OFFSET 1|;
- push @delete_oids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}));
+ push @delete_acc_trans_ids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}));
- if (@delete_oids) {
- $query = qq|DELETE FROM acc_trans WHERE oid IN (| . join(", ", @delete_oids) . qq|)|;
+ if (@delete_acc_trans_ids) {
+ $query = qq|DELETE FROM acc_trans WHERE acc_trans_id IN (| . join(", ", @delete_acc_trans_ids) . qq|)|;
do_query($form, $dbh, $query);
}
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (trans_id = ?)
AND ((c.link = 'AP') OR (c.link LIKE '%:AP') OR (c.link LIKE 'AP:%'))
- ORDER BY at.oid
+ ORDER BY at.acc_trans_id
LIMIT 1|;
($form->{AP}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{id}));
my ($self, $form, $dbh) = @_;
- my @delete_oids;
+ my @delete_acc_trans_ids;
# Delete old payment entries from acc_trans.
my $query =
- qq|SELECT oid
+ qq|SELECT acc_trans_id
FROM acc_trans
WHERE (trans_id = ?) AND fx_transaction
UNION
- SELECT at.oid
+ SELECT at.acc_trans_id
FROM acc_trans at
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (trans_id = ?) AND (c.link LIKE '%AR_paid%')|;
- push @delete_oids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}), conv_i($form->{id}));
+ push @delete_acc_trans_ids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}), conv_i($form->{id}));
$query =
- qq|SELECT at.oid
+ qq|SELECT at.acc_trans_id
FROM acc_trans at
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (trans_id = ?)
AND ((c.link = 'AR') OR (c.link LIKE '%:AR') OR (c.link LIKE 'AR:%'))
- ORDER BY at.oid
+ ORDER BY at.acc_trans_id
OFFSET 1|;
- push @delete_oids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}));
+ push @delete_acc_trans_ids, selectall_array_query($form, $dbh, $query, conv_i($form->{id}));
- if (@delete_oids) {
- $query = qq|DELETE FROM acc_trans WHERE oid IN (| . join(", ", @delete_oids) . qq|)|;
+ if (@delete_acc_trans_ids) {
+ $query = qq|DELETE FROM acc_trans WHERE acc_trans_id IN (| . join(", ", @delete_acc_trans_ids) . qq|)|;
do_query($form, $dbh, $query);
}
LEFT JOIN chart c ON (at.chart_id = c.id)
WHERE (trans_id = ?)
AND ((c.link = 'AR') OR (c.link LIKE '%:AR') OR (c.link LIKE 'AR:%'))
- ORDER BY at.oid
+ ORDER BY at.acc_trans_id
LIMIT 1|;
($form->{AR}) = selectfirst_array_query($form, $dbh, $query, conv_i($form->{id}));
($form->{beginningbalance}, $form->{category}) =
selectrow_query($form, $dbh, $query, @values);
- my %oid = ('Pg' => 'ac.oid',
+ my %oid = ('Pg' => 'ac.acc_trans_id',
'Oracle' => 'ac.rowid');
@values = ();
$query =
my $dbh = $form->dbconnect($myconfig);
my ($query, $i);
- my %oid = ('Pg' => 'oid',
+ my %oid = ('Pg' => 'acc_trans_id',
'Oracle' => 'rowid');
# clear flags
--- /dev/null
+-- @tag: acc_trans_without_oid
+-- @description: Einführen einer ID-Spalte in acc_trans
+-- @depends: release_2_4_3 cb_ob_transaction
+
+CREATE SEQUENCE acc_trans_id_seq;
+
+CREATE TABLE new_acc_trans (
+ acc_trans_id integer DEFAULT nextval('acc_trans_id_seq'),
+ trans_id integer,
+ chart_id integer,
+ amount numeric(15,5),
+ transdate date DEFAULT date('now'::text),
+ gldate date DEFAULT date('now'::text),
+ source text,
+ cleared boolean DEFAULT false,
+ fx_transaction boolean DEFAULT false,
+ ob_transaction boolean DEFAULT false,
+ cb_transaction boolean DEFAULT false,
+ project_id integer,
+ memo text,
+ taxkey integer,
+ itime timestamp without time zone DEFAULT now(),
+ mtime timestamp without time zone
+);
+
+INSERT INTO new_acc_trans (acc_trans_id, trans_id, chart_id, amount, transdate, gldate, source, cleared,
+ fx_transaction, ob_transaction, cb_transaction, project_id, memo, taxkey, itime, mtime)
+ SELECT oid, trans_id, chart_id, amount, transdate, gldate, source, cleared,
+ fx_transaction, ob_transaction, cb_transaction, project_id, memo, taxkey, itime, mtime
+ FROM acc_trans;
+
+SELECT setval('acc_trans_id_seq', (SELECT COALESCE((SELECT MAX(oid::integer) FROM acc_trans), 0) + 1));
+
+DROP TABLE acc_trans;
+ALTER TABLE new_acc_trans RENAME TO acc_trans;
+
+CREATE INDEX acc_trans_trans_id_key ON acc_trans USING btree (trans_id);
+CREATE INDEX acc_trans_chart_id_key ON acc_trans USING btree (chart_id);
+CREATE INDEX acc_trans_transdate_key ON acc_trans USING btree (transdate);
+CREATE INDEX acc_trans_source_key ON acc_trans USING btree (lower(source));
+
+ALTER TABLE ONLY acc_trans
+ ADD CONSTRAINT "$1" FOREIGN KEY (chart_id) REFERENCES chart(id);
+
+CREATE TRIGGER mtime_acc_trans
+ BEFORE UPDATE ON acc_trans
+ FOR EACH ROW
+ EXECUTE PROCEDURE set_mtime();
</tr>
[%- SET curr_row = 0 %]
- [%- IF (problem.data.module == 'ar') || ((problem.data.module == 'gl') && (problem.acc_trans.credit.entries.first.oid < problem.acc_trans.debit.entries.first.oid)) %]
+ [%- IF (problem.data.module == 'ar') || ((problem.data.module == 'gl') && (problem.acc_trans.credit.entries.first.acc_trans_id < problem.acc_trans.debit.entries.first.acc_trans_id)) %]
[%- SET order = [ 'credit', 'debit' ] %]
[%- SET other_side = 'debit' %]
[%- ELSE %]
<td>
[%- IF row.taxkey_error %]
- <input type="hidden" name="fixes[+].oid" value="[% HTML.escape(row.oid) %]">
- <input type="hidden" name="fixes[].tax_entry_oid" value="[% HTML.escape(row.tax_entry_oid) %]">
+ <input type="hidden" name="fixes[+].acc_trans_id" value="[% HTML.escape(row.acc_trans_id) %]">
+ <input type="hidden" name="fixes[].tax_entry_acc_trans_id" value="[% HTML.escape(row.tax_entry_acc_trans_id) %]">
<select name="fixes[].taxkey" style="width: 250px" onchange="enable_fix_button_maybe()">
<option value="">---bitte auswählen---</option>
[%- FOREACH taxkey = row.correct_taxkeys %]
</tr>
[%- SET curr_row = 0 %]
- [%- IF (problem.data.module == 'ar') || ((problem.data.module == 'gl') && (problem.acc_trans.credit.entries.first.oid < problem.acc_trans.debit.entries.first.oid)) %]
+ [%- IF (problem.data.module == 'ar') || ((problem.data.module == 'gl') && (problem.acc_trans.credit.entries.first.acc_trans_id < problem.acc_trans.debit.entries.first.acc_trans_id)) %]
[%- SET order = [ 'credit', 'debit' ] %]
[%- SET other_side = 'debit' %]
[%- ELSE %]
<td>
[%- IF row.taxkey_error %]
- <input type="hidden" name="fixes[+].oid" value="[% HTML.escape(row.oid) %]">
- <input type="hidden" name="fixes[].tax_entry_oid" value="[% HTML.escape(row.tax_entry_oid) %]">
+ <input type="hidden" name="fixes[+].acc_trans_id" value="[% HTML.escape(row.acc_trans_id) %]">
+ <input type="hidden" name="fixes[].tax_entry_acc_trans_id" value="[% HTML.escape(row.tax_entry_acc_trans_id) %]">
<select name="fixes[].taxkey" style="width: 250px" onchange="enable_fix_button_maybe()">
<option value=""><translate>---please select---</translate></option>
[%- FOREACH taxkey = row.correct_taxkeys %]