Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6eb84397

Von Moritz Bunkus vor etwa 1 Jahr hinzugefügt

  • ID 6eb843977077aabdf5f9e488916ab3ad0c58fed9
  • Vorgänger 46282860

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
1168 1168

  
1169 1169
sub init_all_buchungsgruppen {
1170 1170
  my ($self) = @_;
1171
  if ( $self->part->orphaned ) {
1172
    return SL::DB::Manager::Buchungsgruppe->get_all_sorted;
1173
  } else {
1171
  if (!$self->part->orphaned) {
1174 1172
    return SL::DB::Manager::Buchungsgruppe->get_all_sorted(where => [ id => $self->part->buchungsgruppen_id ]);
1175 1173
  }
1174

  
1175
  return SL::DB::Manager::Buchungsgruppe->get_all_sorted(
1176
    where => [
1177
      or => [
1178
        id       => $self->part->buchungsgruppen_id,
1179
        obsolete => 0,
1180
      ],
1181
    ]
1182
  );
1176 1183
}
1177 1184

  
1178 1185
sub init_shops_not_assigned {
......
1316 1323
  return 1;
1317 1324
}
1318 1325

  
1326
sub form_check_buchungsgruppe {
1327
  my ($self) = @_;
1328

  
1329
  return 1 if $::form->{part}->{obsolete};
1330

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

  
1333
  return 1 if !$buchungsgruppe->obsolete;
1334

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

  
1338
  return 0;
1339
}
1340

  
1319 1341
# general checking functions
1320 1342

  
1321 1343
sub check_part_id {
......
1330 1352
  $self->form_check_assortment_items_unique || return 0;
1331 1353
  $self->form_check_assembly_items_exist    || return 0;
1332 1354
  $self->form_check_partnumber_is_unique    || return 0;
1355
  $self->form_check_buchungsgruppe          || return 0;
1333 1356

  
1334 1357
  return 1;
1335 1358
}
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
3761 3761
  '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.',
3762 3762
  'The billing period has already been locked.' => 'Die Buchungsperiode wurde bereits abgeschlossen.',
3763 3763
  'The body is missing.'        => 'Der Text fehlt',
3764
  '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.',
3765
  '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.',
3764 3766
  'The booking group has been created.' => 'Die Buchungsgruppe wurde erstellt.',
3765 3767
  'The booking group has been deleted.' => 'Die Buchungsgruppe wurde gelöscht.',
3766 3768
  '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