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_datev_check_on_sales_invoice {
53   my ($self) = @_;
54   return $self->{data}->{datev_check_on_sales_invoice};
55 }
56
57 sub get_datev_check_on_purchase_invoice {
58   my ($self) = @_;
59   return $self->{data}->{datev_check_on_purchase_invoice};
60 }
61
62 sub get_datev_check_on_ar_transaction {
63   my ($self) = @_;
64   return $self->{data}->{datev_check_on_ar_transaction};
65 }
66
67 sub get_datev_check_on_ap_transaction {
68   my ($self) = @_;
69   return $self->{data}->{datev_check_on_ap_transaction};
70 }
71
72 sub get_datev_check_on_gl_transaction {
73   my ($self) = @_;
74   return $self->{data}->{datev_check_on_gl_transaction};
75 }
76
77 sub get_show_bestbefore {
78   my ($self) = @_;
79   return $self->{data}->{show_bestbefore};
80 }
81
82 1;
83
84 __END__
85
86 =pod
87
88 =encoding utf8
89
90 =head1 NAME
91
92 SL::InstanceConfiguration - Provide instance-specific configuration data
93
94 =head1 SYNOPSIS
95
96 Lx-Office has two configuration levels: installation specific
97 (provided by the global variable C<%::lx_office_conf>) and instance
98 specific. The latter is provided by a global instance of this class,
99 C<$::instance_conf>.
100
101 =head1 FUNCTIONS
102
103 =over 4
104
105 =item C<new>
106
107 Creates a new instance. Does not read the configuration.
108
109 =item C<init>
110
111 Reads the configuration from the database. Returns C<$self>.
112
113 =item C<get_currencies>
114
115 Returns an array of configured currencies.
116
117 =item C<get_default_currency>
118
119 Returns the default currency or undef if no currency has been
120 configured.
121
122 =item C<get_accounting_method>
123
124 Returns the default accounting method, accrual or cash
125
126 =item C<get_inventory_system>
127
128 Returns the default inventory system, perpetual or periodic
129
130 =item C<get_profit_determination>
131
132 Returns the default profit determination method, balance or income
133
134 =item C<get_datev_check_on_sales_invoice>
135
136 Returns true if datev check should be performed on sales invoices
137
138 =item C<get_datev_check_on_purchase_invoice>
139
140 Returns true if datev check should be performed on purchase invoices
141
142 =item C<get_datev_check_on_ar_transaction>
143
144 Returns true if datev check should be performed on ar transactions
145
146 =item C<get_datev_check_on_ap_transaction>
147
148 Returns true if datev check should be performed on ap transactions
149
150 =item C<get_datev_check_on_gl_transaction>
151
152 Returns true if datev check should be performed on gl transactions
153
154 =item C<get_show_bestbefore>
155
156 Returns the default behavior for showing best before date, true or false
157
158 =back
159
160 =head1 BUGS
161
162 Updates to the I<defaults> table require that the instance
163 configuration is re-read. This has not been implemented yet.
164
165 =head1 AUTHOR
166
167 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
168
169 =cut