qq|INSERT INTO acc_trans | .
qq| (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id, chart_link)| .
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), | .
- qq| ?, ?, ?, ?, ?| .
+ qq| ?, ?, ?, ?, ?,| .
qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|;
@values = ($form->{id}, $form->{AP_amounts}{"amount_$i"},
$form->{"amount_$i"}, conv_date($form->{transdate}),
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, | .
qq| project_id, taxkey, tax_id, chart_link) | .
qq|VALUES (?, (SELECT c.id FROM chart c WHERE c.accno = ?), | .
- qq| ?, ?, ?, ?, ?)| .
+ qq| ?, ?, ?, ?, ?,| .
qq| (SELECT c.link FROM chart c WHERE c.accno = ?))|;
@values = ($form->{id}, $form->{AP_amounts}{"tax_$i"},
$form->{"tax_$i"}, conv_date($form->{transdate}),
my ($self, $entries) = @_;
my $default_tax_id = SL::DB::Manager::Tax->find_by(taxkey => 0)->id;
+ my $chart_link;
while (my ($chart_id, $spec) = each %{ $entries }) {
$spec = { taxkey => 0, tax_id => $default_tax_id, amount => $spec } unless ref $spec;
+ $chart_link = SL::DB::Manager::Chart->find_by(id => $chart_id)->{'link'};
+ $chart_link ||= '';
+
SL::DB::AccTransaction->new(trans_id => $self->id,
chart_id => $chart_id,
amount => $spec->{amount},
tax_id => $spec->{tax_id},
taxkey => $spec->{taxkey},
project_id => $self->globalproject_id,
- transdate => $self->transdate)->save;
+ transdate => $self->transdate,
+ chart_link => $chart_link)->save;
}
}
itime => { type => 'timestamp', default => 'now()' },
mtime => { type => 'timestamp' },
tax_id => { type => 'integer', not_null => 1 },
+ chart_link => { type => 'text', not_null => 1 },
],
primary_key_columns => [ 'acc_trans_id' ],
class => 'SL::DB::Project',
key_columns => { project_id => 'id' },
},
+
+ tax => {
+ class => 'SL::DB::Tax',
+ key_columns => { tax_id => 'id' },
+ },
],
);
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
source, memo, project_id, taxkey, tax_id, chart_link)
VALUES (?, (SELECT chart_id FROM tax WHERE id = ?),
- ?, ?, ?, ?, ?, ?, ?, (SELECT link FROM chart WHERE accno = ?))|;
+ ?, ?, ?, ?, ?, ?, ?, (SELECT link
+ FROM chart
+ WHERE id = (SELECT chart_id
+ FROM tax
+ WHERE id = ?)))|;
@values = (conv_i($form->{id}), conv_i($form->{"tax_id_$i"}),
$tax, conv_date($form->{transdate}), $form->{"source_$i"},
$form->{"memo_$i"}, $project_id, $taxkey, conv_i($form->{"tax_id_$i"}), conv_i($form->{"tax_id_$i"}));
AND ((c.link LIKE '%:${ARAP}') OR (c.link LIKE '${ARAP}:%') OR (c.link = '${ARAP}'))
LIMIT 1| ],
- 'add_acc_trans' => [ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, taxkey, tax_id)
- VALUES (?, ?, ?, ?, current_date, ?, '', 0, (SELECT id FROM tax WHERE taxkey=0 LIMIT 1))| ],
+ 'add_acc_trans' => [ qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, taxkey, tax_id , chart_link)
+ VALUES (?, ?, ?, ?, current_date, ?, '', 0, (SELECT id FROM tax WHERE taxkey=0 LIMIT 1), (SELECT link FROM chart WHERE id=?))| ],
'update_arap' => [ qq|UPDATE ${arap}
SET paid = paid + ?
my ($arap_chart_id) = $handles{get_arap}->[0]->fetchrow_array();
# Record the payment in acc_trans offsetting AR/AP.
- do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $arap_chart_id, -1 * $mult * $orig_item->{amount}, $item->{execution_date}, '');
- do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $orig_item->{chart_id}, $mult * $orig_item->{amount}, $item->{execution_date}, $orig_item->{reference});
+ do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $arap_chart_id, -1 * $mult * $orig_item->{amount}, $item->{execution_date}, '', $arap_chart_id);
+ do_statement($form, @{ $handles{add_acc_trans} }, $orig_item->{"${arap}_id"}, $orig_item->{chart_id}, $mult * $orig_item->{amount}, $item->{execution_date}, $orig_item->{reference},
+ $orig_item->{chart_id});
# Update the invoice to reflect the new paid amount.
do_statement($form, @{ $handles{update_arap} }, $orig_item->{amount}, $orig_item->{"${arap}_id"});