From 945bae4c8dc3846f772642cba692b46b8f70bf6c Mon Sep 17 00:00:00 2001
From: Moritz Bunkus
Date: Wed, 1 Feb 2017 14:03:51 +0100
Subject: [PATCH] =?utf8?q?SimpleSystemSetting:=20Umstellung=20von=20=C2=BB?=
=?utf8?q?Bankkonten=C2=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
---
SL/Controller/BankAccount.pm | 122 ------------------
SL/Controller/SimpleSystemSetting.pm | 19 +++
js/locale/de.js | 2 -
locale/de/all | 4 -
menus/user/00-erp.yaml | 3 +-
templates/webpages/bankaccounts/form.html | 92 -------------
templates/webpages/bankaccounts/list.html | 43 ------
.../_bank_account_form.html | 50 +++++++
8 files changed, 71 insertions(+), 264 deletions(-)
delete mode 100644 SL/Controller/BankAccount.pm
delete mode 100644 templates/webpages/bankaccounts/form.html
delete mode 100644 templates/webpages/bankaccounts/list.html
create mode 100644 templates/webpages/simple_system_setting/_bank_account_form.html
diff --git a/SL/Controller/BankAccount.pm b/SL/Controller/BankAccount.pm
deleted file mode 100644
index dff431282..000000000
--- a/SL/Controller/BankAccount.pm
+++ /dev/null
@@ -1,122 +0,0 @@
-package SL::Controller::BankAccount;
-
-use strict;
-
-use parent qw(SL::Controller::Base);
-
-use SL::Helper::Flash;
-use SL::Locale::String;
-use SL::DB::Default;
-use SL::DB::Manager::BankAccount;
-use SL::DB::Manager::BankTransaction;
-
-use Rose::Object::MakeMethods::Generic (
- scalar => [ qw(bank_account) ],
-);
-
-__PACKAGE__->run_before('check_auth');
-__PACKAGE__->run_before('load_bank_account', only => [ qw(edit update delete) ]);
-
-#
-# actions
-#
-
-sub action_list {
- my ($self) = @_;
-
- $self->render('bankaccounts/list',
- title => t8('Bank accounts'),
- BANKACCOUNTS => SL::DB::Manager::BankAccount->get_all_sorted,
- );
-}
-
-sub action_new {
- my ($self) = @_;
-
- $self->{bank_account} = SL::DB::BankAccount->new;
- $self->render('bankaccounts/form',
- title => t8('Add bank account'));
-}
-
-sub action_edit {
- my ($self) = @_;
-
- $self->render('bankaccounts/form', title => t8('Edit bank account'));
-}
-
-sub action_create {
- my ($self) = @_;
-
- $self->{bank_account} = SL::DB::BankAccount->new;
- $self->create_or_update;
-}
-
-sub action_update {
- my ($self) = @_;
- $self->create_or_update;
-}
-
-sub action_delete {
- my ($self) = @_;
-
- if ( $self->{bank_account}->{number_of_bank_transactions} > 0 ) {
- flash_later('error', $::locale->text('The bank account has been used and cannot be deleted.'));
- } elsif ( eval { $self->{bank_account}->delete; 1; } ) {
- flash_later('info', $::locale->text('The bank account has been deleted.'));
- } else {
- flash_later('error', $::locale->text('The bank account has been used and cannot be deleted.'));
- };
- $self->redirect_to(action => 'list');
-
-}
-
-sub action_reorder {
- my ($self) = @_;
-
- SL::DB::BankAccount->reorder_list(@{ $::form->{account_id} || [] });
- $self->render(\'', { type => 'json' });
-}
-
-#
-# filters
-#
-
-sub check_auth {
- $::auth->assert('config');
-}
-
-sub load_bank_account {
- my ($self) = @_;
-
- $self->{bank_account} = SL::DB::BankAccount->new(id => $::form->{id})->load;
- $self->{bank_account}->{number_of_bank_transactions} = SL::DB::Manager::BankTransaction->get_all_count( query => [ local_bank_account_id => $self->{bank_account}->{id} ] );
-}
-
-#
-# helpers
-#
-
-sub create_or_update {
- my ($self) = @_;
- my $is_new = !$self->{bank_account}->id;
-
- my $params = delete($::form->{bank_account}) || { };
-
- $self->{bank_account}->assign_attributes(%{ $params });
-
- my @errors = $self->{bank_account}->validate;
-
- if (@errors) {
- flash('error', @errors);
- $self->render('bankaccounts/form',
- title => $is_new ? t8('Add bank account') : t8('Edit bank account'));
- return;
- }
-
- $self->{bank_account}->save;
-
- flash_later('info', $is_new ? t8('The bank account has been created.') : t8('The bank account has been saved.'));
- $self->redirect_to(action => 'list');
-}
-
-1;
diff --git a/SL/Controller/SimpleSystemSetting.pm b/SL/Controller/SimpleSystemSetting.pm
index 0c797627b..429d2879b 100644
--- a/SL/Controller/SimpleSystemSetting.pm
+++ b/SL/Controller/SimpleSystemSetting.pm
@@ -21,6 +21,25 @@ __PACKAGE__->run_before('setup_javascript', only => [ qw(add create edit update
# Make locales.pl happy: $self->render("simple_system_setting/_default_form")
my %supported_types = (
+ bank_account => {
+ # Make locales.pl happy: $self->render("simple_system_setting/_bank_account_form")
+ class => 'BankAccount',
+ titles => {
+ list => t8('Bank accounts'),
+ add => t8('Add bank account'),
+ edit => t8('Edit bank account'),
+ },
+ list_attributes => [
+ { method => 'name', title => t8('Name'), },
+ { method => 'iban', title => t8('IBAN'), },
+ { method => 'bank', title => t8('Bank'), },
+ { method => 'bank_code', title => t8('Bank code'), },
+ { method => 'bic', title => t8('BIC'), },
+ { method => 'reconciliation_starting_date_as_date', title => t8('Date'), align => 'right' },
+ { method => 'reconciliation_starting_balance_as_number', title => t8('Balance'), align => 'right' },
+ ],
+ },
+
pricegroup => {
# Make locales.pl happy: $self->render("simple_system_setting/_pricegroup_form")
class => 'Pricegroup',
diff --git a/js/locale/de.js b/js/locale/de.js
index e6c964b89..93a3aff9b 100644
--- a/js/locale/de.js
+++ b/js/locale/de.js
@@ -94,7 +94,6 @@ namespace("kivi").setupLocale({
"Subject":"Betreff",
"Text block actions":"Textblockaktionen",
"Text block picture actions":"Aktionen für Textblockbilder",
-"The IBAN is missing.":"Die IBAN fehlt.",
"The description is missing.":"Die Beschreibung fehlt.",
"The field '#{title}' must be set.":"Das Feld »#{title}« muss gesetzt sein.",
"The name is missing.":"Der Name fehlt.",
@@ -106,7 +105,6 @@ namespace("kivi").setupLocale({
"The uploaded filename still exists.
If you not modify the name this is a new version of the file":"Der Dateiname existiert bereits.
Wenn Sie den Namen nicht ändern gibt dies eine neue Version der Datei",
"There are duplicate parts at positions":"Es gibt doppelte Artikel bei den Positionen",
"There are still transfers not matching the qty of the delivery order. Stock operations can not be changed later. Do you really want to proceed?":"Einige der Lagerbewegungen sind nicht vollständig und Lagerbewegungen können nachträglich nicht mehr verändert werden. Wollen Sie wirklich fortfahren?",
-"There is no connected chart.":"Es fehlt ein verknüpftes Buchungskonto.",
"There is one or more sections for which no part has been assigned yet; therefore creating the new record is not possible yet.":"Es gibt einen oder mehrere Abschnitte ohne Artikelzuweisung; daher kann der neue Beleg noch nicht erstellt werden.",
"This sales order has an active configuration for periodic invoices. If you save then all subsequently created invoices will contain those changes as well, but not those that have already been created. Do you want to continue?":"Dieser Auftrag besitzt eine aktive Konfiguration für wiederkehrende Rechnungen. Wenn Sie jetzt speichern, so werden alle zukünftig hieraus erzeugten Rechnungen die Ãnderungen enthalten, nicht aber die bereits erzeugten Rechnungen. Wollen Sie speichern?",
"Time/cost estimate actions":"Aktionen für Kosten-/Zeitabschätzung",
diff --git a/locale/de/all b/locale/de/all
index 6b6d41d88..55ca59862 100644
--- a/locale/de/all
+++ b/locale/de/all
@@ -2918,10 +2918,6 @@ $self->{texts} = {
'The background job has been deleted.' => 'Der Hintergrund-Job wurde gelöscht.',
'The background job has been saved.' => 'Der Hintergrund-Job wurde gespeichert.',
'The background job was executed successfully.' => 'Der Hintergrund-Job wurde erfolgreich ausgeführt.',
- 'The bank account has been created.' => 'Das Bankkonto wurde erstellt.',
- 'The bank account has been deleted.' => 'Das Bankkonto wurde gelöscht.',
- 'The bank account has been saved.' => 'Das Bankkonto wurde gespeichert',
- 'The bank account has been used and cannot be deleted.' => 'Das Bankkonto wurde benutzt und kann nicht gelöscht werden.',
'The bank information must not be empty.' => 'Die Bankinformationen müssen vollständig ausgefüllt werden.',
'The base file name without a path or an extension to be used for printing for this type of requirement spec.' => 'Der Basisdateiname ohne Pfadanteil oder Erweiterung, der bei Drucken dieses Pflichtenhefttyps verwendet wird.',
'The base unit does not exist or it is about to be deleted in row %d.' => 'Die Basiseinheit in Zeile %d existiert nicht oder soll gelöscht werden.',
diff --git a/menus/user/00-erp.yaml b/menus/user/00-erp.yaml
index 2ca178e73..546891511 100644
--- a/menus/user/00-erp.yaml
+++ b/menus/user/00-erp.yaml
@@ -1065,7 +1065,8 @@
name: Bank accounts
order: 800
params:
- action: BankAccount/list
+ action: SimpleSystemSetting/list
+ type: bank_account
- parent: system
id: system_partsgroups
name: Partsgroups
diff --git a/templates/webpages/bankaccounts/form.html b/templates/webpages/bankaccounts/form.html
deleted file mode 100644
index e1c323ca3..000000000
--- a/templates/webpages/bankaccounts/form.html
+++ /dev/null
@@ -1,92 +0,0 @@
-[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]
-
-[% SET style="width: 400px" %]
-[% SET size=34 %]
-
-[% HTML.escape(title) %]
-
-
diff --git a/templates/webpages/bankaccounts/list.html b/templates/webpages/bankaccounts/list.html
deleted file mode 100644
index a4b6018cc..000000000
--- a/templates/webpages/bankaccounts/list.html
+++ /dev/null
@@ -1,43 +0,0 @@
-[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%][%- INCLUDE 'common/flash.html' %]
-
-[% title %]
-
-
-
-
-
- |
- [% 'Name' | $T8 %] |
- [% 'IBAN' | $T8 %] |
- [% 'Bank' | $T8 %] |
- [% 'Bank code' | $T8 %] |
- [% 'BIC' | $T8 %] |
- [% 'Date' | $T8 %] |
- [% 'Balance' | $T8 %] |
-
-
-
-
- [%- FOREACH account = BANKACCOUNTS %]
-
- |
- [% HTML.escape(account.name) %] |
- [% HTML.escape(account.iban) %] |
- [% HTML.escape(account.bank) %] |
- [% HTML.escape(account.bank_code) %] |
- [% HTML.escape(account.bic) %] |
- [% HTML.escape(account.reconciliation_starting_date.to_kivitendo) %] |
- [% HTML.escape(account.reconciliation_starting_balance_as_number) %] |
-
- [%- END %]
-
-
-
-
-
-
-[% L.sortable_element('#bankaccount_list tbody', url=SELF.url_for(action='reorder'), with='account_id') %]
-
-
- [%- 'Add' | $T8 %]
-
diff --git a/templates/webpages/simple_system_setting/_bank_account_form.html b/templates/webpages/simple_system_setting/_bank_account_form.html
new file mode 100644
index 000000000..63cc87fbf
--- /dev/null
+++ b/templates/webpages/simple_system_setting/_bank_account_form.html
@@ -0,0 +1,50 @@
+[%- USE HTML -%][%- USE LxERP -%][%- USE L -%]
+
+[% SET style="width: 400px" %]
+
+
+
+ [% LxERP.t8('Description') %] |
+ [%- L.input_tag("object.name", SELF.object.name, style=style, "data-validate"="required", "data-title"=LxERP.t8("Description")) %] |
+
+
+ [% LxERP.t8('IBAN') %] |
+ [%- L.input_tag("object.iban", SELF.object.iban, style=style, "data-validate"="required", "data-title"=LxERP.t8("IBAN")) %] |
+
+
+ [% LxERP.t8('Bank') %] |
+ [%- L.input_tag("object.bank", SELF.object.bank, style=style) %] |
+
+
+ [% LxERP.t8('Account number') %] |
+ [%- L.input_tag("object.account_number", SELF.object.account_number, style=style) %] |
+
+
+ [% LxERP.t8('BIC') %] |
+ [%- L.input_tag("object.bic", SELF.object.bic, style=style) %] |
+
+
+ [% LxERP.t8('Bank code') %] |
+ [%- L.input_tag("object.bank_code", SELF.object.bank_code, style=style) %] |
+
+
+ [% LxERP.t8('Chart') %] |
+ [% L.chart_picker('object.chart_id', SELF.object.chart_id, type='AR_paid,AP_paid', category='A,L,Q', choose=1, style=style, "data-validate"="required", "data-title"=LxERP.t8("Chart")) %] |
+
+
+ [% LxERP.t8('Obsolete') %] |
+ [% L.checkbox_tag('object.obsolete', checked = SELF.object.obsolete, for_submit=1) %] |
+
+
+ [% LxERP.t8('Reconciliation') %]: |
+ |
+
+
+ [% LxERP.t8('Starting date') %] |
+ [% L.date_tag('object.reconciliation_starting_date', SELF.object.reconciliation_starting_date) %] |
+
+
+ [% LxERP.t8('Starting balance') %] |
+ [%- L.input_tag('object.reconciliation_starting_balance_as_number', SELF.object.reconciliation_starting_balance_as_number) %] |
+
+
--
2.20.1