Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 058d70b8

Von Kivitendo Admin vor mehr als 10 Jahren hinzugefügt

  • ID 058d70b8ae5406a40ce5ddba2d11cc8563d06751
  • Vorgänger 1c62d23e
  • Nachfolger 068e2451

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.

Unterschiede anzeigen:

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;
templates/webpages/buchungsgruppen/form.html
1
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]<h1>[% HTML.escape(title) %]</h1>
1
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]
2

  
3
<h1>[% HTML.escape(title) %]</h1>
2 4

  
3 5
<form action="controller.pl" method="post">
4 6
[%- L.hidden_tag("id", SELF.config.id) %]
......
12 14
    <th align="right">[% 'Inventory account' | $T8 %]</th>
13 15
    [%- IF SELF.config.id AND linked_parts != 0 %]
14 16
    <td>[%- CHARTLIST.inventory_accno %] -- [%- CHARTLIST.inventory_accno_description %]</td>
17
    [%- ELSIF NOT SELF.config.id AND linked_parts != 0 %]
18
    <td>[%- L.select_tag("config.inventory_accno_id", ACCOUNTS.ic, title_sub=\account_label, default=SELF.defaults.inventory_accno_id) %]</td>
15 19
    [%- ELSE %]
16 20
    <td>[%- L.select_tag("config.inventory_accno_id", ACCOUNTS.ic, title_sub=\account_label, default=SELF.config.inventory_accno_id) %]</td>
17 21
    [%- END %]
......
21 25
    <th align="right">[% 'Revenue' | $T8 %] [% HTML.escape(tz.description) %]</th>
22 26
    [%- IF SELF.config.id AND linked_parts != 0 %]
23 27
    <td>[% CHARTLIST.${tz.id}.income_accno %] -- [% CHARTLIST.${tz.id}.income_accno_description %]</td>
28
    [%- ELSIF NOT SELF.config.id AND linked_parts != 0 %]
29
    <td>[%- L.select_tag('income_accno_id_' _ tz.id, ACCOUNTS.ic_income, title_sub=\account_label, default=SELF.defaults.income_accno_id) %]</td>
24 30
    [%- ELSE %]
25 31
    <td>[%- L.select_tag('income_accno_id_' _ tz.id, ACCOUNTS.ic_income, title_sub=\account_label, default=CHARTLIST.${tz.id}.income_accno_id) %]</td>
26 32
    [%- END %]
......
29 35
    <th align="right">[% 'Expense' | $T8 %] [% HTML.escape(tz.description) %]</th>
30 36
    [%- IF SELF.config.id AND linked_parts != 0 %]
31 37
    <td>[% CHARTLIST.${tz.id}.expense_accno %] -- [% CHARTLIST.${tz.id}.expense_accno_description %]</td>
38
    [%- ELSIF NOT SELF.config.id AND linked_parts != 0 %]
39
    <td>[%- L.select_tag('expense_accno_id_' _ tz.id, ACCOUNTS.ic_expense, title_sub=\account_label, default=SELF.defaults.expense_accno_id) %]</td>
32 40
    [%- ELSE %]
33 41
    <td>[%- L.select_tag('expense_accno_id_' _ tz.id, ACCOUNTS.ic_expense, title_sub=\account_label, default=CHARTLIST.${tz.id}.expense_accno_id) %]</td>
34 42
    [%- END %]
......
39 47
 <p>
40 48
  [% L.hidden_tag("action", "Buchungsgruppen/dispatch") %]
41 49
  [% L.submit_tag("action_" _  (SELF.config.id ? "update" : "create"), LxERP.t8('Save'), onclick="return check_prerequisites();") %]
42
  <a href="[% SELF.url_for(action='list') %]">[%- LxERP.t8("Cancel") %]</a>
50
  [%- IF SELF.config.id AND linked_parts == 0 %]
51
    [% L.submit_tag("action_delete", LxERP.t8('Delete'), confirm=LxERP.t8('Are you sure?')) %]
52
  [%- END %]
43 53
 </p>
44 54

  
45 55
 <hr>
templates/webpages/buchungsgruppen/list.html
8 8
   <tr class="listheading">
9 9
    <th align="center" width="1%"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></th>
10 10
    <th width="20%">[% 'Description' | $T8 %]</th>
11
    <th width="20%">[% 'Inventory' | $T8 %]</th>
11
    <th width="20%">[% 'Inventory account' | $T8 %]</th>
12 12
     [%- FOREACH tz = TAXZONES %]
13 13
        <th width="20%">[% 'Revenue' | $T8 %] [% HTML.escape(tz.description) %]</th>
14 14
        <th width="20%">[% 'Expense' | $T8 %] [% HTML.escape(tz.description) %]</th>

Auch abrufbar als: Unified diff