1 package SL::InstanceConfiguration;
7 use SL::System::Process;
9 use parent qw(Rose::Object);
10 use Rose::Object::MakeMethods::Generic (
11 'scalar --get_set_init' => [ qw(data currencies default_currency _table_currencies_exists crm_installed) ],
15 return {} if !$::auth->client;
16 return SL::DBUtils::selectfirst_hashref_query($::form, $::form->get_standard_dbh, qq|SELECT * FROM defaults|);
19 sub init__table_currencies_exists {
20 return 0 if !$::auth->client;
21 return !!(SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, qq|SELECT tablename FROM pg_tables WHERE (schemaname = 'public') AND (tablename = 'currencies')|))[0];
27 return [] if !$self->_table_currencies_exists;
28 return [ map { $_->{name} } SL::DBUtils::selectall_hashref_query($::form, $::form->get_standard_dbh, qq|SELECT name FROM currencies ORDER BY id ASC|) ];
31 sub init_default_currency {
34 return undef if !$self->_table_currencies_exists || !$self->data->{currency_id};
35 return (SL::DBUtils::selectfirst_array_query($::form, $::form->get_standard_dbh, qq|SELECT name FROM currencies WHERE id = ?|, $self->data->{currency_id}))[0];
38 sub init_crm_installed {
39 return -f (SL::System::Process->exe_dir . '/crm/Changelog');
45 delete @{ $self }{qw(data currencies default_currency)};
52 return @{ $self->currencies };
56 # Compatibility function: back in the day there was only a single
60 my $zipcode_city = join ' ', grep { $_ } ($self->get_address_zipcode, $self->get_address_city);
62 return join "\n", grep { $_ } ($self->get_address_street1, $self->get_address_street2, $zipcode_city, $self->get_address_country);
69 my $method = $AUTOLOAD;
72 return if $method eq 'DESTROY';
74 if ($method =~ m/^get_/) {
75 $method = substr $method, 4;
76 return $self->data->{$method} if exists $self->data->{$method};
77 croak "Invalid method 'get_${method}'";
80 croak "Invalid method '${method}'" if !$self->can($method);
81 return $self->$method(@_);
94 SL::InstanceConfiguration - Provide instance-specific configuration data
98 kivitendo has two configuration levels: installation specific
99 (provided by the global variable C<%::lx_office_conf>) and instance
100 specific. The latter is provided by a global instance of this class,
109 Creates a new instance. Does not read the configuration.
111 =item C<crm_installed>
113 Returns trueish if the CRM component is installed.
115 =item C<get_currencies>
117 Returns an array of configured currencies.
119 =item C<get_default_currency>
121 Returns the default currency or undef if no currency has been
124 =item C<get_accounting_method>
126 Returns the default accounting method, accrual or cash
128 =item C<get_inventory_system>
130 Returns the default inventory system, perpetual or periodic
132 =item C<get_profit_determination>
134 Returns the default profit determination method, balance or income
136 =item C<get_balance_startdate_method>
138 Returns the default method for determining the startdate for the balance
142 closed_to start_of_year all_transactions last_ob_or_all_transactions last_ob_or_start_of_year
144 =item C<get_is_changeable>
146 =item C<get_ir_changeable>
148 =item C<get_ar_changeable>
150 =item C<get_ap_changeable>
152 =item C<get_gl_changeable>
154 Returns if and when these record types are changeable or deleteable after
155 posting. 0 means never, 1 means always and 2 means on the same day.
157 =item C<get_datev_check_on_sales_invoice>
159 Returns true if datev check should be performed on sales invoices
161 =item C<get_datev_check_on_purchase_invoice>
163 Returns true if datev check should be performed on purchase invoices
165 =item C<get_datev_check_on_ar_transaction>
167 Returns true if datev check should be performed on ar transactions
169 =item C<get_datev_check_on_ap_transaction>
171 Returns true if datev check should be performed on ap transactions
173 =item C<get_datev_check_on_gl_transaction>
175 Returns true if datev check should be performed on gl transactions
177 =item C<get_show_bestbefore>
179 Returns the default behavior for showing best before date, true or false
181 =item C<get_is_show_mark_as_paid>
183 =item C<get_ir_show_mark_as_paid>
185 =item C<get_ar_show_mark_as_paid>
187 =item C<get_ap_show_mark_as_paid>
189 Returns the default behavior for showing the "mark as paid" button for the
190 corresponding record type (true or false).
192 =item C<get_sales_order_show_delete>
194 =item C<get_purchase_order_show_delete>
196 =item C<get_sales_delivery_order_show_delete>
198 =item C<get_purchase_delivery_order_show_delete>
200 Returns the default behavior for showing the delete button for the
201 corresponding record type (true or false).
203 =item C<get_warehouse_id>
205 Returns the default warehouse_id
209 Returns the default bin_id
211 =item C<get_warehouse_id_ignore_onhand>
213 Returns the default warehouse_id for transfers without checking the
214 current stock quantity
216 =item C<get_bin_id_ignore_onhand>
218 Returns the default bin_id for transfers without checking the
219 current stock quantity
221 =item C<get_transfer_default>
223 =item C<get_transfer_default_use_master_default_bin>
225 =item C<get_transfer_default_ignore_onhand>
227 Returns the default behavior for the transfer out default feature (true or false)
229 =item C<get_max_future_booking_interval>
231 Returns the maximum interval value for future bookings
235 Returns the configuration for WebDAV
237 =item C<get_webdav_documents>
239 Returns the configuration for storing documents in the corresponding WebDAV folder
241 =item C<get_vertreter>
243 Returns the configuration for "vertreter"
245 =item C<get_feature_experimental_assortment>
247 Returns the configuration for experimental feature "assortment"
249 =item C<get_feature_experimental_order>
251 Returns the configuration for the experimental feature "order"
253 =item C<get_parts_show_image>
255 Returns the configuarion for show image in parts
257 =item C<get_parts_image_css>
259 Returns the css format string for images shown in parts
261 =item C<get_parts_listing_image>
263 Returns the configuration for showing the picture in the results when you search for parts
269 Updates to the I<defaults> table require that the instance
270 configuration is re-read. This has not been implemented yet.
274 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>