Revision 058d70b8
Von Kivitendo Admin vor mehr als 10 Jahren hinzugefügt
SL/Controller/Buchungsgruppen.pm | ||
---|---|---|
9 | 9 |
use SL::Locale::String; |
10 | 10 |
use SL::DB::TaxzoneChart; |
11 | 11 |
use SL::Controller::ClientConfig; |
12 |
use SL::DB::Default; |
|
12 | 13 |
|
13 | 14 |
use Rose::Object::MakeMethods::Generic ( |
14 | 15 |
scalar => [ qw(config) ], |
16 |
'scalar --get_set_init' => [ qw(defaults) ], |
|
15 | 17 |
); |
16 | 18 |
|
17 | 19 |
__PACKAGE__->run_before('check_auth'); |
18 |
__PACKAGE__->run_before('load_config', only => [ qw(edit update) ]); #destroy
|
|
20 |
__PACKAGE__->run_before('load_config', only => [ qw(edit update delete) ]);
|
|
19 | 21 |
|
20 | 22 |
# |
21 | 23 |
# actions |
... | ... | |
59 | 61 |
sub action_edit { |
60 | 62 |
my ($self) = @_; |
61 | 63 |
|
62 |
# check whether buchungsgruppe is assigned to any parts |
|
64 |
# Allow editing of Buchungsgruppe if it isn't assigned to any parts. The |
|
65 |
# variable is checked in the template, which toggles between L.select_tag and |
|
66 |
# text. |
|
67 |
|
|
63 | 68 |
my $number_of_parts_with_buchungsgruppe = SL::DB::Manager::Part->get_objects_count(where => [ buchungsgruppen_id => $self->config->id]); |
64 | 69 |
|
65 | 70 |
$self->show_form(title => t8('Edit Buchungsgruppe'), |
... | ... | |
79 | 84 |
$self->create_or_update; |
80 | 85 |
} |
81 | 86 |
|
87 |
sub action_delete { |
|
88 |
my ($self) = @_; |
|
89 |
|
|
90 |
# allow deletion of unused Buchungsgruppen. Will fail, due to database |
|
91 |
# constraint, if Buchungsgruppe is connected to a part |
|
92 |
|
|
93 |
my $db = $self->{config}->db; |
|
94 |
$db->do_transaction(sub { |
|
95 |
my $taxzone_charts = SL::DB::Manager::TaxzoneChart->get_all(where => [ buchungsgruppen_id => $self->config->id ]); |
|
96 |
foreach my $taxzonechart ( @{$taxzone_charts} ) { $taxzonechart->delete }; |
|
97 |
$self->config->delete(); |
|
98 |
flash_later('info', $::locale->text('The buchungsgruppe has been deleted.')); |
|
99 |
}) || flash_later('error', $::locale->text('The buchungsgruppe is in use and cannot be deleted.')); |
|
100 |
|
|
101 |
$self->redirect_to(action => 'list'); |
|
102 |
|
|
103 |
} |
|
104 |
|
|
82 | 105 |
sub action_reorder { |
83 | 106 |
my ($self) = @_; |
84 | 107 |
|
... | ... | |
145 | 168 |
$self->redirect_to(action => 'list'); |
146 | 169 |
} |
147 | 170 |
|
171 |
# |
|
172 |
# initializers |
|
173 |
# |
|
174 |
|
|
175 |
sub init_defaults { SL::DB::Default->get } |
|
176 |
|
|
148 | 177 |
1; |
Auch abrufbar als: Unified diff
Buchungsgruppen - löschen und beim Erstellen Standardkonten benutzen
Wenn eine Buchungsgruppe noch nicht einer Waren zugeordnet ist kann
diese noch bearbeitet (Kontenzuordnung) oder gelöscht werden.
Beim neu Erstellen von Buchungsgruppen werden die Standardkonten aus der
Mandantenkonfiguration (Erlös/Aufwand/Bestand) vorausgewählt.