Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
[kivitendo-erp.git] / SL / InstanceConfiguration.pm
1 package SL::InstanceConfiguration;
2
3 use strict;
4
5 use SL::DBUtils;
6
7 sub new {
8   my ($class) = @_;
9
10   return bless {}, $class;
11 }
12
13 sub init {
14   my ($self) = @_;
15
16   $self->{data} = selectfirst_hashref_query($::form, $::form->get_standard_dbh, qq|SELECT * FROM defaults|);
17
18   my $curr            =  $self->{data}->{curr} || '';
19   $curr               =~ s/\s+//g;
20   $self->{currencies} =  [ split m/:/, $curr ];
21
22   return $self;
23 }
24
25 sub get_default_currency {
26   my ($self) = @_;
27
28   return ($self->get_currencies)[0];
29 }
30
31 sub get_currencies {
32   my ($self) = @_;
33
34   return $self->{currencies} ? @{ $self->{currencies} } : ();
35 }
36
37 sub get_accounting_method {
38   my ($self) = @_;
39   return $self->{data}->{accounting_method};
40 }
41
42 sub get_inventory_system {
43   my ($self) = @_;
44   return $self->{data}->{inventory_system};
45 }
46
47 sub get_profit_determination {
48   my ($self) = @_;
49   return $self->{data}->{profit_determination};
50 }
51
52 sub get_is_changeable {
53   my ($self) = @_;
54   return $self->{data}->{is_changeable};
55 }
56
57 sub get_ir_changeable {
58   my ($self) = @_;
59   return $self->{data}->{ir_changeable};
60 }
61
62 sub get_ar_changeable {
63   my ($self) = @_;
64   return $self->{data}->{ar_changeable};
65 }
66
67 sub get_ap_changeable {
68   my ($self) = @_;
69   return $self->{data}->{ap_changeable};
70 }
71
72 sub get_gl_changeable {
73   my ($self) = @_;
74   return $self->{data}->{gl_changeable};
75 }
76
77 sub get_datev_check_on_sales_invoice {
78   my ($self) = @_;
79   return $self->{data}->{datev_check_on_sales_invoice};
80 }
81
82 sub get_datev_check_on_purchase_invoice {
83   my ($self) = @_;
84   return $self->{data}->{datev_check_on_purchase_invoice};
85 }
86
87 sub get_datev_check_on_ar_transaction {
88   my ($self) = @_;
89   return $self->{data}->{datev_check_on_ar_transaction};
90 }
91
92 sub get_datev_check_on_ap_transaction {
93   my ($self) = @_;
94   return $self->{data}->{datev_check_on_ap_transaction};
95 }
96
97 sub get_datev_check_on_gl_transaction {
98   my ($self) = @_;
99   return $self->{data}->{datev_check_on_gl_transaction};
100 }
101
102 sub get_show_bestbefore {
103   my ($self) = @_;
104   return $self->{data}->{show_bestbefore};
105 }
106
107 sub get_is_show_mark_as_paid {
108   my ($self) = @_;
109   return $self->{data}->{is_show_mark_as_paid};
110 }
111
112 sub get_ir_show_mark_as_paid {
113   my ($self) = @_;
114   return $self->{data}->{ir_show_mark_as_paid};
115 }
116
117 sub get_ar_show_mark_as_paid {
118   my ($self) = @_;
119   return $self->{data}->{ar_show_mark_as_paid};
120 }
121
122 sub get_ap_show_mark_as_paid {
123   my ($self) = @_;
124   return $self->{data}->{ap_show_mark_as_paid};
125 }
126
127 sub get_sales_order_show_delete {
128   my ($self) = @_;
129   return $self->{data}->{sales_order_show_delete};
130 }
131
132 sub get_purchase_order_show_delete {
133   my ($self) = @_;
134   return $self->{data}->{purchase_order_show_delete};
135 }
136
137 sub get_sales_delivery_order_show_delete {
138   my ($self) = @_;
139   return $self->{data}->{sales_delivery_order_show_delete};
140 }
141
142 sub get_purchase_delivery_order_show_delete {
143   my ($self) = @_;
144   return $self->{data}->{purchase_delivery_order_show_delete};
145 }
146
147 1;
148
149 __END__
150
151 =pod
152
153 =encoding utf8
154
155 =head1 NAME
156
157 SL::InstanceConfiguration - Provide instance-specific configuration data
158
159 =head1 SYNOPSIS
160
161 kivitendo has two configuration levels: installation specific
162 (provided by the global variable C<%::lx_office_conf>) and instance
163 specific. The latter is provided by a global instance of this class,
164 C<$::instance_conf>.
165
166 =head1 FUNCTIONS
167
168 =over 4
169
170 =item C<new>
171
172 Creates a new instance. Does not read the configuration.
173
174 =item C<init>
175
176 Reads the configuration from the database. Returns C<$self>.
177
178 =item C<get_currencies>
179
180 Returns an array of configured currencies.
181
182 =item C<get_default_currency>
183
184 Returns the default currency or undef if no currency has been
185 configured.
186
187 =item C<get_accounting_method>
188
189 Returns the default accounting method, accrual or cash
190
191 =item C<get_inventory_system>
192
193 Returns the default inventory system, perpetual or periodic
194
195 =item C<get_profit_determination>
196
197 Returns the default profit determination method, balance or income
198
199
200 =item C<get_is_changeable>
201
202 =item C<get_ir_changeable>
203
204 =item C<get_ar_changeable>
205
206 =item C<get_ap_changeable>
207
208 =item C<get_gl_changeable>
209
210 Returns if and when these record types are changeable or deleteable after
211 posting. 0 means never, 1 means always and 2 means on the same day.
212
213 =item C<get_datev_check_on_sales_invoice>
214
215 Returns true if datev check should be performed on sales invoices
216
217 =item C<get_datev_check_on_purchase_invoice>
218
219 Returns true if datev check should be performed on purchase invoices
220
221 =item C<get_datev_check_on_ar_transaction>
222
223 Returns true if datev check should be performed on ar transactions
224
225 =item C<get_datev_check_on_ap_transaction>
226
227 Returns true if datev check should be performed on ap transactions
228
229 =item C<get_datev_check_on_gl_transaction>
230
231 Returns true if datev check should be performed on gl transactions
232
233 =item C<get_show_bestbefore>
234
235 Returns the default behavior for showing best before date, true or false
236
237 =item C<get_is_show_mark_as_paid>
238
239 =item C<get_ir_show_mark_as_paid>
240
241 =item C<get_ar_show_mark_as_paid>
242
243 =item C<get_ap_show_mark_as_paid>
244
245 Returns the default behavior for showing the mark as paid button for the
246 corresponding record type (true or false).
247
248 =item C<get_sales_order_show_delete>
249
250 =item C<get_purchase_order_show_delete>
251
252 =item C<get_sales_delivery_order_show_delete>
253
254 =item C<get_purchase_delivery_order_show_delete>
255
256 Returns the default behavior for showing the delete button for the
257 corresponding record type (true or false).
258
259 =back
260
261 =head1 BUGS
262
263 Updates to the I<defaults> table require that the instance
264 configuration is re-read. This has not been implemented yet.
265
266 =head1 AUTHOR
267
268 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
269
270 =cut