Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2df98929

Von Sven Schöling vor etwa 1 Jahr hinzugefügt

  • ID 2df989297bbbe91cd98145a613c8eeab2e443548
  • Vorgänger f93fc7dd
  • Nachfolger d57a4596

TypeData: Reclamation

Unterschiede anzeigen:

SL/DB/Reclamation/TypeData.pm
1
package SL::DB::Reclamation::TypeData;
2

  
3
use strict;
4
use Carp;
5
use Exporter qw(import);
6
use SL::Locale::String qw(t8);
7

  
8
use constant {
9
  SALES_RECLAMATION_TYPE    => 'sales_reclamation',
10
  PURCHASE_RECLAMATION_TYPE => 'purchase_reclamation',
11
};
12

  
13
my @export_types = qw(SALES_RECLAMATION_TYPE PURCHASE_RECLAMATION_TYPE);
14
my @export_subs = qw(valid_types validate_type is_valid_type get get3);
15

  
16
our @EXPORT_OK = (@export_types, @export_subs);
17
our %EXPORT_TAGS = (types => \@export_types, subs => \@export_subs);
18

  
19
my %type_data = (
20
  SALES_RECLAMATION_TYPE() => {
21
    text => {
22
      list       => t8("Sales Reclamations"),
23
      add        => t8("Add Sales Reclamation"),
24
      edit       => t8("Edit Sales Reclamation"),
25
    },
26
    show_menu => {
27
      save_and_sales_reclamation       => 0,
28
      save_and_purchase_reclamation    => 1,
29
      save_and_rmy_delivery_order      => 1,
30
      save_and_supplier_delivery_order => 0,
31
      save_and_credit_note             => 1,
32
      delete                           => sub { $::instance_conf->get_sales_reclamation_show_delete },
33
    },
34
    properties => {
35
      customervendor => "customer",
36
      is_customer    => 1,
37
      nr_key         => "record_number",
38
    },
39
    part_classification_query => [ "used_for_sale" => 1 ],
40
    rights => {
41
      edit => "sales_reclamation_edit",
42
    },
43
  },
44
  PURCHASE_RECLAMATION_TYPE() => {
45
    text => {
46
      list       => t8("Purchase Reclamations"),
47
      add        => t8("Add Purchase Reclamation"),
48
      edit       => t8("Edit Purchase Reclamation"),
49
    },
50
    show_menu => {
51
      save_and_sales_reclamation       => 1,
52
      save_and_purchase_reclamation    => 0,
53
      save_and_rma_delivery_order      => 0,
54
      save_and_supplier_delivery_order => 1,
55
      save_and_credit_note             => 0,
56
      delete                           => sub { $::instance_conf->get_purchase_reclamation_show_delete },
57
    },
58
    properties => {
59
      customervendor => "vendor",
60
      is_customer    => 0,
61
      nr_key         => "record_number",
62
    },
63
    part_classification_query => [ "used_for_purchase" => 1 ],
64
    rights => {
65
      edit => "purchase_reclamation_edit",
66
    },
67
  },
68
);
69

  
70
my @valid_types = (
71
  SALES_RECLAMATION_TYPE,
72
  PURCHASE_RECLAMATION_TYPE,
73
);
74

  
75
my %valid_types = map { $_ => $_ } @valid_types;
76

  
77
sub valid_types {
78
  \@valid_types;
79
}
80

  
81
sub is_valid_type {
82
  !!exists $type_data{$_[0]};
83
}
84

  
85
sub validate_type {
86
  my ($type) = @_;
87

  
88
  return $valid_types{$type} // croak "invalid type '$type'";
89
}
90

  
91
sub get {
92
  my ($type, $key) = @_;
93

  
94
  croak "invalid type '$type'" unless exists $type_data{$type};
95

  
96
  my $ret = $type_data{$type}->{$key} // die "unknown property '$key'";
97

  
98
  ref $ret eq 'CODE'
99
    ? $ret->()
100
    : $ret;
101
}
102

  
103
sub get3 {
104
  my ($type, $topic, $key) = @_;
105

  
106
  croak "invalid type '$type'" unless exists $type_data{$type};
107

  
108
  my $ret = $type_data{$type}{$topic}{$key} // croak "unknown property '$key' in topic '$topic' for type '$type'";
109

  
110
  ref $ret eq 'CODE'
111
    ? $ret->()
112
    : $ret;
113
}
114

  
115
1;

Auch abrufbar als: Unified diff