use strict;
+use SL::DB::Helper::LinkedRecords;
use SL::DB::MetaSetup::GLTransaction;
+use SL::DB::Manager::GLTransaction;
use SL::Locale::String qw(t8);
use List::Util qw(sum);
use SL::DATEV;
use Carp;
use Data::Dumper;
-# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
-__PACKAGE__->meta->make_manager_class;
-
__PACKAGE__->meta->add_relationship(
transactions => {
type => 'one to many',
__PACKAGE__->meta->initialize;
+sub record_type {return 'gl_transaction';}
+sub record_number {goto &id;}
+sub displayable_name {goto &oneline_summary;}
+
sub abbreviation {
my $self = shift;
require SL::DB::Chart;
die "add_chart_booking needs a transdate" unless $self->transdate;
die "add_chart_booking needs taxincluded" unless defined $self->taxincluded;
- die "chart missing" unless $params{chart} && ref($params{chart}) eq 'SL::DB::Chart';
+ die "chart missing" unless $params{chart} && ref($params{chart}) eq 'SL::DB::Chart';
die t8('Booking needs at least one debit and one credit booking!')
unless $params{debit} or $params{credit}; # must exist and not be 0
die t8('Cannot have a value in both Debit and Credit!')
$taxamount *= -1;
};
- next unless $netamount; # skip entries with netamount 0
+ return unless $netamount; # skip entries with netamount 0
# initialise transactions if it doesn't exist yet
$self->transactions([]) unless $self->transactions;
my $sum = sum map { $_->amount } @{ $self->transactions };
# compare rounded amount to 0, to get around floating point problems, e.g.
# $sum = -2.77555756156289e-17
- push @errors, t8('Out of balance transaction!') unless $::form->round_amount($sum,5) == 0;
+ push @errors, t8('Out of balance transaction!') . $sum unless $::form->round_amount($sum,5) == 0;
};
} else {
push @errors, t8('Empty transaction!');