version 1.4, 2020/10/20 09:23:24 |
version 1.5, 2020/10/20 10:25:47 |
|
|
my ($amount, $text) = ($1, $2); |
my ($amount, $text) = ($1, $2); |
my $cc = $1 if $text =~ s/\[(.*?)\] *//; |
my $cc = $1 if $text =~ s/\[(.*?)\] *//; |
$accounts{$ano} or die "unknown account $ano: $line"; |
$accounts{$ano} or die "unknown account $ano: $line"; |
|
($accounts{$ano}{type} =~ /S/) == |
|
($accounts{$entry{contra}}{type} =~ /S/) |
|
or die "statistical vs. non-statistical account: " . |
|
"$entry{contra} split $line"; |
$amount *= $entry{amount} < 0 ? -1 : +1; |
$amount *= $entry{amount} < 0 ? -1 : +1; |
|
|
# Combine the text on the split side. |
# Combine the text on the split side. |
|
|
); |
); |
if ($debit) { |
if ($debit) { |
$accounts{$debit} or die "unknown debit account $debit: $line"; |
$accounts{$debit} or die "unknown debit account $debit: $line"; |
|
# The credit side may or may not be split. |
my %newentry = (%entry, contra => $credit, amount => $amount); |
my %newentry = (%entry, contra => $credit, amount => $amount); |
make_entry %newentry, $debit; |
make_entry %newentry, $debit; |
} else { |
} else { |
$credit or die "splitting both sides: $line"; |
$credit or die "splitting both sides: $line"; |
# Remember a credit side split. |
# The debit side is split, remember the entry. |
$entry{contra} = $credit; |
$entry{contra} = $credit; |
$entry{amount} = $amount; |
$entry{amount} = $amount; |
} |
} |
if ($credit) { |
if ($credit) { |
$accounts{$credit} |
$accounts{$credit} |
or die "unknown credit account $credit: $line"; |
or die "unknown credit account $credit: $line"; |
|
$debit && ($accounts{$debit}{type} =~ /S/) != |
|
($accounts{$credit}{type} =~ /S/) |
|
and die "statistical vs. non-statistical account: $line"; |
|
# The debit side may or may not be split. |
my %newentry = (%entry, contra => $debit, amount => -$amount); |
my %newentry = (%entry, contra => $debit, amount => -$amount); |
make_entry %newentry, $credit; |
make_entry %newentry, $credit; |
# This entry is not split: clear it after processing. |
# This entry is not split: clear it after processing. |
%entry = () if $debit; |
%entry = () if $debit; |
} else { |
} else { |
# Remember a debit side split. |
# The credit side is split, remember the entry. |
$entry{contra} = $debit; |
$entry{contra} = $debit; |
$entry{amount} = -$amount; |
$entry{amount} = -$amount; |
} |
} |