Revision d01da6fd
Von Sven Schöling vor etwa 3 Jahren hinzugefügt
SL/Controller/DeliveryOrder/TypeData.pm | ||
---|---|---|
4 | 4 |
use Exporter qw(import); |
5 | 5 |
use Scalar::Util qw(weaken); |
6 | 6 |
use SL::Locale::String qw(t8); |
7 |
|
|
8 |
use constant { |
|
9 |
SALES_DELIVERY_ORDER_TYPE => 'sales_delivery_order', |
|
10 |
PURCHASE_DELIVERY_ORDER_TYPE => 'purchase_delivery_order', |
|
11 |
SUPPLIER_DELIVERY_ORDER_TYPE => 'supplier_delivery_order', |
|
12 |
RMA_DELIVERY_ORDER_TYPE => 'rma_delivery_order', |
|
13 |
}; |
|
14 |
|
|
15 |
our @EXPORT_OK = qw(SALES_DELIVERY_ORDER_TYPE PURCHASE_DELIVERY_ORDER_TYPE SUPPLIER_DELIVERY_ORDER_TYPE RMA_DELIVERY_ORDER_TYPE); |
|
7 |
use SL::DB::DeliveryOrder::TypeData qw(:types :subs); |
|
16 | 8 |
|
17 | 9 |
use Rose::Object::MakeMethods::Generic scalar => [ qw(c) ]; |
18 | 10 |
|
19 |
my %type_data = ( |
|
20 |
SALES_DELIVERY_ORDER_TYPE() => { |
|
21 |
text => { |
|
22 |
delete => t8('Delivery Order has been deleted'), |
|
23 |
saved => t8('Delivery Order has been saved'), |
|
24 |
add => t8("Add Sales Delivery Order"), |
|
25 |
edit => t8("Edit Sales Delivery Order"), |
|
26 |
}, |
|
27 |
show_menu => { |
|
28 |
save_and_quotation => 0, |
|
29 |
save_and_rfq => 0, |
|
30 |
save_and_sales_order => 0, |
|
31 |
save_and_purchase_order => 0, |
|
32 |
save_and_delivery_order => 0, |
|
33 |
save_and_ap_transaction => 0, |
|
34 |
save_and_invoice => 0, |
|
35 |
delete => sub { $::instance_conf->get_sales_delivery_order_show_delete }, |
|
36 |
}, |
|
37 |
properties => { |
|
38 |
customervendor => "customer", |
|
39 |
is_customer => 1, |
|
40 |
nr_key => "donumber", |
|
41 |
transfer => 'out', |
|
42 |
}, |
|
43 |
part_classification_query => [ "used_for_sale" => 1 ], |
|
44 |
right => "sales_delivery_order_edit", |
|
45 |
}, |
|
46 |
PURCHASE_DELIVERY_ORDER_TYPE() => { |
|
47 |
text => { |
|
48 |
delete => t8('Delivery Order has been deleted'), |
|
49 |
saved => t8('Delivery Order has been saved'), |
|
50 |
add => t8("Add Purchase Delivery Order"), |
|
51 |
edit => t8("Edit Purchase Delivery Order"), |
|
52 |
}, |
|
53 |
show_menu => { |
|
54 |
save_and_quotation => 0, |
|
55 |
save_and_rfq => 0, |
|
56 |
save_and_sales_order => 0, |
|
57 |
save_and_purchase_order => 0, |
|
58 |
save_and_delivery_order => 0, |
|
59 |
save_and_ap_transaction => 0, |
|
60 |
save_and_invoice => 0, |
|
61 |
delete => sub { $::instance_conf->get_sales_delivery_order_show_delete }, |
|
62 |
}, |
|
63 |
properties => { |
|
64 |
customervendor => "vendor", |
|
65 |
is_customer => 0, |
|
66 |
nr_key => "donumber", |
|
67 |
transfer => 'in', |
|
68 |
}, |
|
69 |
part_classification_query => [ "used_for_purchase" => 1 ], |
|
70 |
right => "purchase_delivery_order_edit", |
|
71 |
}, |
|
72 |
SUPPLIER_DELIVERY_ORDER_TYPE() => { |
|
73 |
text => { |
|
74 |
delete => t8('Delivery Order has been deleted'), |
|
75 |
saved => t8('Delivery Order has been saved'), |
|
76 |
add => t8("Add Supplier Delivery Order"), |
|
77 |
edit => t8("Edit Supplier Delivery Order"), |
|
78 |
}, |
|
79 |
show_menu => { |
|
80 |
save_and_quotation => 0, |
|
81 |
save_and_rfq => 0, |
|
82 |
save_and_sales_order => 0, |
|
83 |
save_and_purchase_order => 0, |
|
84 |
save_and_delivery_order => 0, |
|
85 |
save_and_ap_transaction => 0, |
|
86 |
save_and_invoice => 0, |
|
87 |
delete => sub { $::instance_conf->get_sales_delivery_order_show_delete }, |
|
88 |
}, |
|
89 |
properties => { |
|
90 |
customervendor => "vendor", |
|
91 |
is_customer => 0, |
|
92 |
nr_key => "donumber", |
|
93 |
transfer => 'out', |
|
94 |
}, |
|
95 |
part_classification_query => [ "used_for_purchase" => 1 ], |
|
96 |
right => "purchase_delivery_order_edit", |
|
97 |
}, |
|
98 |
RMA_DELIVERY_ORDER_TYPE() => { |
|
99 |
text => { |
|
100 |
delete => t8('Delivery Order has been deleted'), |
|
101 |
saved => t8('Delivery Order has been saved'), |
|
102 |
add => t8("Add RMA Delivery Order"), |
|
103 |
edit => t8("Edit RMA Delivery Order"), |
|
104 |
}, |
|
105 |
show_menu => { |
|
106 |
save_and_quotation => 0, |
|
107 |
save_and_rfq => 0, |
|
108 |
save_and_sales_order => 0, |
|
109 |
save_and_purchase_order => 0, |
|
110 |
save_and_delivery_order => 0, |
|
111 |
save_and_ap_transaction => 0, |
|
112 |
save_and_invoice => 0, |
|
113 |
delete => sub { $::instance_conf->get_sales_delivery_order_show_delete }, |
|
114 |
}, |
|
115 |
properties => { |
|
116 |
customervendor => "customer", |
|
117 |
is_customer => 0, |
|
118 |
nr_key => "donumber", |
|
119 |
transfer => 'in', |
|
120 |
}, |
|
121 |
part_classification_query => [ "used_for_sale" => 1 ], |
|
122 |
right => "sales_delivery_order_edit", |
|
123 |
}, |
|
124 |
); |
|
125 |
|
|
126 | 11 |
sub new { |
127 | 12 |
my ($class, $controller) = @_; |
128 | 13 |
my $o = bless {}, $class; |
129 |
$o->c($controller); |
|
130 |
weaken($o->{c}); |
|
131 |
|
|
132 |
return $o; |
|
133 |
} |
|
134 |
|
|
135 |
sub valid_types { |
|
136 |
[ |
|
137 |
SALES_DELIVERY_ORDER_TYPE, |
|
138 |
PURCHASE_DELIVERY_ORDER_TYPE, |
|
139 |
SUPPLIER_DELIVERY_ORDER_TYPE, |
|
140 |
RMA_DELIVERY_ORDER_TYPE, |
|
141 |
]; |
|
142 |
} |
|
143 |
|
|
144 |
sub type { |
|
145 |
$_[0]->c->type; |
|
146 |
} |
|
147 |
|
|
148 |
sub _get { |
|
149 |
my ($self, $key) = @_; |
|
150 |
|
|
151 |
my $ret = $type_data{$self->type}->{$key} // die "unknown property '$key'"; |
|
152 | 14 |
|
153 |
ref $ret eq 'CODE' |
|
154 |
? $ret->() |
|
155 |
: $ret; |
|
156 |
} |
|
157 |
|
|
158 |
sub _get3 { |
|
159 |
my ($self, $topic, $key) = @_; |
|
160 |
|
|
161 |
my $ret = $type_data{$self->type}->{$topic}->{$key} // die "unknown property '$key' in topic '$topic'"; |
|
15 |
if ($controller) { |
|
16 |
$o->c($controller); |
|
17 |
weaken($o->{c}); |
|
18 |
} |
|
162 | 19 |
|
163 |
ref $ret eq 'CODE' |
|
164 |
? $ret->() |
|
165 |
: $ret; |
|
20 |
return $o; |
|
166 | 21 |
} |
167 | 22 |
|
168 | 23 |
sub text { |
169 | 24 |
my ($self, $string) = @_; |
170 |
_get3($self, "text", $string);
|
|
25 |
get3($self->c->type, "text", $string);
|
|
171 | 26 |
} |
172 | 27 |
|
173 | 28 |
sub show_menu { |
174 | 29 |
my ($self, $string) = @_; |
175 |
_get3($self, "show_menu", $string);
|
|
30 |
get3($self->c->type, "show_menu", $string);
|
|
176 | 31 |
} |
177 | 32 |
|
178 | 33 |
sub workflow { |
179 | 34 |
my ($self, $string) = @_; |
180 |
_get3($self, "workflow", $string);
|
|
35 |
get3($self->c->type, "workflow", $string);
|
|
181 | 36 |
} |
182 | 37 |
|
183 | 38 |
sub properties { |
184 | 39 |
my ($self, $string) = @_; |
185 |
_get3($self, "properties", $string); |
|
186 |
} |
|
187 |
|
|
188 |
sub is_valid_type { |
|
189 |
!!exists $type_data{$_[1]}; |
|
190 |
} |
|
191 |
|
|
192 |
sub type_data { |
|
193 |
$type_data{ $_[0]->type } // die "unknown type"; |
|
40 |
get3($self->c->type, "properties", $string); |
|
194 | 41 |
} |
195 | 42 |
|
196 | 43 |
sub access { |
197 |
_get($_[0], "right");
|
|
44 |
get($_[0]->c->type, "right");
|
|
198 | 45 |
} |
199 | 46 |
|
200 | 47 |
sub is_quotation { |
201 |
_get3($_[0], "properties", "is_quotation");
|
|
48 |
get3($_[0]->c->type, "properties", "is_quotation");
|
|
202 | 49 |
} |
203 | 50 |
|
204 | 51 |
sub customervendor { |
205 |
_get3($_[0], "properties", "customervendor"); |
|
52 |
get3($_[0]->c->type, "properties", "customervendor"); |
|
53 |
} |
|
54 |
|
|
55 |
sub is_customer { |
|
56 |
get3($_[0]->c->type, "properties", "is_customer"); |
|
206 | 57 |
} |
207 | 58 |
|
208 | 59 |
sub nr_key { |
209 |
_get3($_[0], "properties", "nr_key");
|
|
60 |
get3($_[0]->c->type, "properties", "nr_key");
|
|
210 | 61 |
} |
211 | 62 |
|
212 | 63 |
sub part_classification_query { |
213 | 64 |
my ($self, $string) = @_; |
214 |
_get($self, "part_classification_query");
|
|
65 |
get($self->c->type, "part_classification_query");
|
|
215 | 66 |
} |
216 | 67 |
|
217 | 68 |
sub set_reqdate_by_type { |
... | ... | |
231 | 82 |
return $reqdate; |
232 | 83 |
} |
233 | 84 |
} |
85 |
|
|
86 |
1; |
SL/DB/DeliveryOrder/TypeData.pm | ||
---|---|---|
1 |
package SL::DB::DeliveryOrder::TypeData; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use Exporter qw(import); |
|
5 |
use Scalar::Util qw(weaken); |
|
6 |
use SL::Locale::String qw(t8); |
|
7 |
|
|
8 |
use constant { |
|
9 |
SALES_DELIVERY_ORDER_TYPE => 'sales_delivery_order', |
|
10 |
PURCHASE_DELIVERY_ORDER_TYPE => 'purchase_delivery_order', |
|
11 |
SUPPLIER_DELIVERY_ORDER_TYPE => 'supplier_delivery_order', |
|
12 |
RMA_DELIVERY_ORDER_TYPE => 'rma_delivery_order', |
|
13 |
}; |
|
14 |
|
|
15 |
my @export_types = qw(SALES_DELIVERY_ORDER_TYPE PURCHASE_DELIVERY_ORDER_TYPE SUPPLIER_DELIVERY_ORDER_TYPE RMA_DELIVERY_ORDER_TYPE); |
|
16 |
my @export_subs = qw(valid_types validate_type is_valid_type get get3); |
|
17 |
|
|
18 |
our @EXPORT_OK = (@export_types, @export_subs); |
|
19 |
our %EXPORT_TAGS = (types => \@export_types, subs => \@export_subs); |
|
20 |
|
|
21 |
my %type_data = ( |
|
22 |
SALES_DELIVERY_ORDER_TYPE() => { |
|
23 |
text => { |
|
24 |
delete => t8('Delivery Order has been deleted'), |
|
25 |
saved => t8('Delivery Order has been saved'), |
|
26 |
add => t8("Add Sales Delivery Order"), |
|
27 |
edit => t8("Edit Sales Delivery Order"), |
|
28 |
}, |
|
29 |
show_menu => { |
|
30 |
save_and_quotation => 0, |
|
31 |
save_and_rfq => 0, |
|
32 |
save_and_sales_order => 0, |
|
33 |
save_and_purchase_order => 0, |
|
34 |
save_and_delivery_order => 0, |
|
35 |
save_and_ap_transaction => 0, |
|
36 |
save_and_invoice => 0, |
|
37 |
delete => sub { $::instance_conf->get_sales_delivery_order_show_delete }, |
|
38 |
}, |
|
39 |
properties => { |
|
40 |
customervendor => "customer", |
|
41 |
is_customer => 1, |
|
42 |
nr_key => "donumber", |
|
43 |
transfer => 'out', |
|
44 |
}, |
|
45 |
part_classification_query => [ "used_for_sale" => 1 ], |
|
46 |
right => "sales_delivery_order_edit", |
|
47 |
}, |
|
48 |
PURCHASE_DELIVERY_ORDER_TYPE() => { |
|
49 |
text => { |
|
50 |
delete => t8('Delivery Order has been deleted'), |
|
51 |
saved => t8('Delivery Order has been saved'), |
|
52 |
add => t8("Add Purchase Delivery Order"), |
|
53 |
edit => t8("Edit Purchase Delivery Order"), |
|
54 |
}, |
|
55 |
show_menu => { |
|
56 |
save_and_quotation => 0, |
|
57 |
save_and_rfq => 0, |
|
58 |
save_and_sales_order => 0, |
|
59 |
save_and_purchase_order => 0, |
|
60 |
save_and_delivery_order => 0, |
|
61 |
save_and_ap_transaction => 0, |
|
62 |
save_and_invoice => 0, |
|
63 |
delete => sub { $::instance_conf->get_sales_delivery_order_show_delete }, |
|
64 |
}, |
|
65 |
properties => { |
|
66 |
customervendor => "vendor", |
|
67 |
is_customer => 0, |
|
68 |
nr_key => "donumber", |
|
69 |
transfer => 'in', |
|
70 |
}, |
|
71 |
part_classification_query => [ "used_for_purchase" => 1 ], |
|
72 |
right => "purchase_delivery_order_edit", |
|
73 |
}, |
|
74 |
SUPPLIER_DELIVERY_ORDER_TYPE() => { |
|
75 |
text => { |
|
76 |
delete => t8('Delivery Order has been deleted'), |
|
77 |
saved => t8('Delivery Order has been saved'), |
|
78 |
add => t8("Add Supplier Delivery Order"), |
|
79 |
edit => t8("Edit Supplier Delivery Order"), |
|
80 |
}, |
|
81 |
show_menu => { |
|
82 |
save_and_quotation => 0, |
|
83 |
save_and_rfq => 0, |
|
84 |
save_and_sales_order => 0, |
|
85 |
save_and_purchase_order => 0, |
|
86 |
save_and_delivery_order => 0, |
|
87 |
save_and_ap_transaction => 0, |
|
88 |
save_and_invoice => 0, |
|
89 |
delete => sub { $::instance_conf->get_sales_delivery_order_show_delete }, |
|
90 |
}, |
|
91 |
properties => { |
|
92 |
customervendor => "vendor", |
|
93 |
is_customer => 0, |
|
94 |
nr_key => "donumber", |
|
95 |
transfer => 'out', |
|
96 |
}, |
|
97 |
part_classification_query => [ "used_for_purchase" => 1 ], |
|
98 |
right => "purchase_delivery_order_edit", |
|
99 |
}, |
|
100 |
RMA_DELIVERY_ORDER_TYPE() => { |
|
101 |
text => { |
|
102 |
delete => t8('Delivery Order has been deleted'), |
|
103 |
saved => t8('Delivery Order has been saved'), |
|
104 |
add => t8("Add RMA Delivery Order"), |
|
105 |
edit => t8("Edit RMA Delivery Order"), |
|
106 |
}, |
|
107 |
show_menu => { |
|
108 |
save_and_quotation => 0, |
|
109 |
save_and_rfq => 0, |
|
110 |
save_and_sales_order => 0, |
|
111 |
save_and_purchase_order => 0, |
|
112 |
save_and_delivery_order => 0, |
|
113 |
save_and_ap_transaction => 0, |
|
114 |
save_and_invoice => 0, |
|
115 |
delete => sub { $::instance_conf->get_sales_delivery_order_show_delete }, |
|
116 |
}, |
|
117 |
properties => { |
|
118 |
customervendor => "customer", |
|
119 |
is_customer => 0, |
|
120 |
nr_key => "donumber", |
|
121 |
transfer => 'in', |
|
122 |
}, |
|
123 |
part_classification_query => [ "used_for_sale" => 1 ], |
|
124 |
right => "sales_delivery_order_edit", |
|
125 |
}, |
|
126 |
); |
|
127 |
|
|
128 |
my @valid_types = ( |
|
129 |
SALES_DELIVERY_ORDER_TYPE, |
|
130 |
PURCHASE_DELIVERY_ORDER_TYPE, |
|
131 |
SUPPLIER_DELIVERY_ORDER_TYPE, |
|
132 |
RMA_DELIVERY_ORDER_TYPE, |
|
133 |
); |
|
134 |
|
|
135 |
my %valid_types = map { $_ => $_ } @valid_types; |
|
136 |
|
|
137 |
sub valid_types { |
|
138 |
\@valid_types; |
|
139 |
} |
|
140 |
|
|
141 |
sub is_valid_type { |
|
142 |
!!exists $type_data{$_[0]}; |
|
143 |
} |
|
144 |
|
|
145 |
sub validate_type { |
|
146 |
my ($self, $type) = @_; |
|
147 |
|
|
148 |
return $valid_types{$type} // die "invalid type"; |
|
149 |
} |
|
150 |
|
|
151 |
sub get { |
|
152 |
my ($type, $key) = @_; |
|
153 |
|
|
154 |
my $ret = $type_data{$type}->{$key} // die "unknown property '$key'"; |
|
155 |
|
|
156 |
ref $ret eq 'CODE' |
|
157 |
? $ret->() |
|
158 |
: $ret; |
|
159 |
} |
|
160 |
|
|
161 |
sub get3 { |
|
162 |
my ($type, $topic, $key) = @_; |
|
163 |
|
|
164 |
my $ret = $type_data{$type}{$topic}{$key} // die "unknown property '$key' in topic '$topic'"; |
|
165 |
|
|
166 |
ref $ret eq 'CODE' |
|
167 |
? $ret->() |
|
168 |
: $ret; |
|
169 |
} |
|
170 |
|
|
171 |
1; |
Auch abrufbar als: Unified diff
DeliveryOrder: type_data nach SL/DB verschoben, damit das model auch drauf zugreifen kann