Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision cff9b88d

Von Moritz Bunkus vor fast 2 Jahren hinzugefügt

Buchungsgruppen ungültig setzen können

Unterschiede anzeigen:

SL/Controller/Buchungsgruppen.pm
142 142

  
143 143
    @errors = $self->config->validate; # check for description and inventory_accno_id
144 144

  
145
    if (@errors) {
146
      die "foo" . @errors . "\n";
147
    };
145
    return 0 if @errors;
148 146

  
149 147
    $self->config->save;
150 148

  
......
175 173

  
176 174
    1;
177 175
  })) {
178
    die @errors ? join("\n", @errors) . "\n" : $db->error . "\n";
176
    my $error = @errors ? join("\n", @errors) . "\n" : $db->error . "\n";
177
    $::form->show_generic_error($error);
179 178
    # die with rollback of taxzone save if saving of any of the taxzone_charts fails
180 179
    # only show the $db->error if we haven't already identified the likely error ourselves
181 180
  }
SL/Controller/Part.pm
1176 1176

  
1177 1177
sub init_all_buchungsgruppen {
1178 1178
  my ($self) = @_;
1179
  if ( $self->part->orphaned ) {
1180
    return SL::DB::Manager::Buchungsgruppe->get_all_sorted;
1181
  } else {
1179
  if (!$self->part->orphaned) {
1182 1180
    return SL::DB::Manager::Buchungsgruppe->get_all_sorted(where => [ id => $self->part->buchungsgruppen_id ]);
1183 1181
  }
1182

  
1183
  return SL::DB::Manager::Buchungsgruppe->get_all_sorted(
1184
    where => [
1185
      or => [
1186
        id       => $self->part->buchungsgruppen_id,
1187
        obsolete => 0,
1188
      ],
1189
    ]
1190
  );
1184 1191
}
1185 1192

  
1186 1193
sub init_shops_not_assigned {
......
1324 1331
  return 1;
1325 1332
}
1326 1333

  
1334
sub form_check_buchungsgruppe {
1335
  my ($self) = @_;
1336

  
1337
  return 1 if $::form->{part}->{obsolete};
1338

  
1339
  my $buchungsgruppe = SL::DB::Buchungsgruppe->new(id => $::form->{part}->{buchungsgruppen_id})->load;
1340

  
1341
  return 1 if !$buchungsgruppe->obsolete;
1342

  
1343
  $self->js->flash('error', t8("The booking group '#1' is obsolete and cannot be used with active articles.", $buchungsgruppe->description))
1344
    ->focus('#part_buchungsgruppen_id');
1345

  
1346
  return 0;
1347
}
1348

  
1327 1349
# general checking functions
1328 1350

  
1329 1351
sub check_part_id {
......
1338 1360
  $self->form_check_assortment_items_unique || return 0;
1339 1361
  $self->form_check_assembly_items_exist    || return 0;
1340 1362
  $self->form_check_partnumber_is_unique    || return 0;
1363
  $self->form_check_buchungsgruppe          || return 0;
1341 1364

  
1342 1365
  return 1;
1343 1366
}
SL/DB/Buchungsgruppe.pm
21 21
    push(@errors, $::locale->text('Booking group #1 needs a valid inventory account', $self->description)) unless $inventory_accno;
22 22
  } else {
23 23
    push @errors, $::locale->text('The booking group needs an inventory account.');
24
  };
24
  }
25

  
26
  if ($self->id && $self->obsolete) {
27
    require SL::DB::Part;
28

  
29
    my $in_use = SL::DB::Manager::Part->get_first(
30
      where => [
31
        buchungsgruppen_id => $self->id,
32
        obsolete           => 0,
33
      ]);
34

  
35
    if ($in_use) {
36
      push @errors, $::locale->text('The booking group cannot be marked obsolete while still being used by active parts.');
37
    }
38
  }
25 39

  
26 40
  return @errors;
27 41
}
SL/DB/MetaSetup/Buchungsgruppe.pm
12 12
  description        => { type => 'text' },
13 13
  id                 => { type => 'integer', not_null => 1, sequence => 'id' },
14 14
  inventory_accno_id => { type => 'integer', not_null => 1 },
15
  obsolete           => { type => 'boolean', default => 'false', not_null => 1 },
15 16
  sortkey            => { type => 'integer', not_null => 1 },
16 17
);
17 18

  
SL/DB/MetaSetup/Part.pm
29 29
  mtime              => { type => 'timestamp' },
30 30
  not_discountable   => { type => 'boolean', default => 'false' },
31 31
  notes              => { type => 'text' },
32
  obsolete           => { type => 'boolean', default => 'false' },
32
  obsolete           => { type => 'boolean', default => 'false', not_null => 1 },
33 33
  onhand             => { type => 'numeric', default => '0', precision => 25, scale => 5 },
34 34
  part_type          => { type => 'enum', check_in => [ 'part', 'service', 'assembly', 'assortment' ], db_type => 'part_type_enum', not_null => 1 },
35 35
  partnumber         => { type => 'text', not_null => 1 },
locale/de/all
3774 3774
  'The basic client tables have not been created for this client\'s database yet.' => 'Die grundlegenden Mandantentabellen wurden in der für diesen Mandanten konfigurierten Datenbank noch nicht angelegt.',
3775 3775
  'The billing period has already been locked.' => 'Die Buchungsperiode wurde bereits abgeschlossen.',
3776 3776
  'The body is missing.'        => 'Der Text fehlt',
3777
  'The booking group \'#1\' is obsolete and cannot be used with active articles.' => 'Die Buchungsgruppe "#1" ist ungültig und kann nicht für aktive Artikel genutzt werden.',
3778
  'The booking group cannot be marked obsolete while still being used by active parts.' => 'Die Buchungsgruppe kann nicht auf ungültig gesetzt werden, solange sie von gültigen Artikeln benutzt wird.',
3777 3779
  'The booking group has been created.' => 'Die Buchungsgruppe wurde erstellt.',
3778 3780
  'The booking group has been deleted.' => 'Die Buchungsgruppe wurde gelöscht.',
3779 3781
  'The booking group has been saved.' => 'Die Buchungsgruppe wurde gespeichert.',
sql/Pg-upgrade2/booking_group_obsolete.sql
1
-- @tag: booking_group_obsolete
2
-- @description: Buchungsgruppen ungültig setzen können
3
-- @depends: release_3_7_0
4
ALTER TABLE buchungsgruppen
5
ADD COLUMN obsolete BOOLEAN NOT NULL DEFAULT FALSE;
6

  
7
UPDATE parts
8
SET obsolete = FALSE
9
WHERE obsolete IS NULL;
10

  
11
ALTER TABLE parts
12
ALTER COLUMN obsolete SET NOT NULL;
templates/design40_webpages/buchungsgruppen/form.html
51 51
        [% END %]
52 52
      </tr>
53 53
    [% END %]
54
      <tr>
55
        <th>[% 'Obsolete' | $T8 %]</td>
56
        <td>[% L.checkbox_tag('config.obsolete', checked=SELF.config.obsolete, for_submit=1) %]</td>
57
      </tr>
54 58
    <tbody>
55 59
  </table>
56 60

  
templates/design40_webpages/buchungsgruppen/list.html
16 16
      <th>[% 'Revenue' | $T8 %] [% HTML.escape(tz.description) %]</th>
17 17
      <th>[% 'Expense' | $T8 %] [% HTML.escape(tz.description) %]</th>
18 18
    [% END %]
19
      <th>[% 'Obsolete' | $T8 %]</th>
19 20
    </tr>
20 21
  </thead>
21 22
  <tbody>
......
28 29
      <td>[% HTML.escape(CHARTLIST.${bg.id}.${tz.id}.income_accno) %]</td>
29 30
      <td>[% HTML.escape(CHARTLIST.${bg.id}.${tz.id}.expense_accno) %]</td>
30 31
    [% END %]
32
      <td>[% IF bg.obsolete %][% LxERP.t8("yes") %][% ELSE %][% LxERP.t8("no") %][% END %]</td>
33
    </tr>
31 34
  [% END %]
32 35
  </tbody>
33 36
</table>
templates/webpages/buchungsgruppen/form.html
43 43
    [%- END %]
44 44
  </tr>
45 45
[%- END %]
46

  
47
  <tr>
48
    <th align="right">[% 'Obsolete' | $T8 %]</td>
49
    <td>[% L.checkbox_tag('config.obsolete', checked=SELF.config.obsolete, for_submit=1) %]</td>
50
  </tr>
46 51
</table>
47 52
</form>
templates/webpages/buchungsgruppen/list.html
13 13
        <th width="20%">[% 'Revenue' | $T8 %] [% HTML.escape(tz.description) %]</th>
14 14
        <th width="20%">[% 'Expense' | $T8 %] [% HTML.escape(tz.description) %]</th>
15 15
     [%- END %]
16
    <th>[% 'Obsolete' | $T8 %]</th>
16 17
   </tr>
17 18
  </thead>
18 19

  
......
26 27
        <td>[% HTML.escape(CHARTLIST.${bg.id}.${tz.id}.income_accno) %]</td>
27 28
        <td>[% HTML.escape(CHARTLIST.${bg.id}.${tz.id}.expense_accno) %]</td>
28 29
     [%- END %]
30
     <td>[% IF bg.obsolete %][% LxERP.t8("yes") %][% ELSE %][% LxERP.t8("no") %][% END %]</td>
31
    </tr>
29 32
   [%- END %]
30 33
  </tbody>
31 34
 </table>

Auch abrufbar als: Unified diff