]> wagnertech.de Git - mfinanz.git/commitdiff
Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
authorMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 8 Nov 2012 11:41:59 +0000 (12:41 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 8 Nov 2012 11:41:59 +0000 (12:41 +0100)
13 files changed:
SL/DB/MetaSetup/Customer.pm
SL/DB/MetaSetup/DeliveryOrder.pm
SL/DB/MetaSetup/Exchangerate.pm
SL/DB/MetaSetup/Invoice.pm
SL/DB/MetaSetup/PurchaseInvoice.pm
SL/DB/MetaSetup/RMA.pm
SL/DB/MetaSetup/Vendor.pm
SL/DBUpgrade2.pm
SL/Form.pm
locale/de/all
scripts/rose_auto_create_model.pl
sql/Pg-upgrade2/convert_curr_to_text.sql [new file with mode: 0644]
templates/webpages/am/edit_defaults.html

index 51779f377433f8a534fe0053de88592b95028e19..82d808cf958705875a3b265b90ea6fbbba92b268 100644 (file)
@@ -53,7 +53,7 @@ __PACKAGE__->meta->setup(
     iban                => { type => 'varchar', length => 100 },
     bic                 => { type => 'varchar', length => 100 },
     direct_debit        => { type => 'boolean', default => 'false' },
-    curr                => { type => 'character', length => 3 },
+    curr                => { type => 'text' },
     taxincluded_checked => { type => 'boolean' },
   ],
 
index 66596543dcf94c4b2d580ca3e8b780b26bf7d03d..fb4b82818a45a77276d9e3f0f70a5433b52a1ae9 100644 (file)
@@ -39,7 +39,7 @@ __PACKAGE__->meta->setup(
     taxzone_id              => { type => 'integer' },
     taxincluded             => { type => 'boolean' },
     terms                   => { type => 'integer' },
-    curr                    => { type => 'character', length => 3 },
+    curr                    => { type => 'text' },
   ],
 
   primary_key_columns => [ 'id' ],
index 95ea23c172b53ab207388c8262e63182c4ce84c2..44bce842bf322dae1b7fcda5ff322e4314d6223b 100644 (file)
@@ -10,7 +10,7 @@ __PACKAGE__->meta->setup(
   table   => 'exchangerate',
 
   columns => [
-    curr      => { type => 'character', length => 3 },
+    curr      => { type => 'text' },
     transdate => { type => 'date' },
     buy       => { type => 'numeric', precision => 5, scale => 15 },
     sell      => { type => 'numeric', precision => 5, scale => 15 },
index d300a7e6ac344d29b29cd6208c42b354b9fcc9d1..854b9c7e3bd5f7479a2425579be441c13682509d 100644 (file)
@@ -26,7 +26,7 @@ __PACKAGE__->meta->setup(
     shippingpoint             => { type => 'text' },
     terms                     => { type => 'integer', default => '0' },
     notes                     => { type => 'text' },
-    curr                      => { type => 'character', length => 3 },
+    curr                      => { type => 'text' },
     ordnumber                 => { type => 'text' },
     employee_id               => { type => 'integer' },
     quonumber                 => { type => 'text' },
index 448b2a6e087f1b6b9e4559a832dcbecee322f7fa..eb18f7058ca93f1213e0defbc982feb1997da84c 100644 (file)
@@ -23,7 +23,7 @@ __PACKAGE__->meta->setup(
     duedate                 => { type => 'date' },
     invoice                 => { type => 'boolean', default => 'false' },
     ordnumber               => { type => 'text' },
-    curr                    => { type => 'character', length => 3 },
+    curr                    => { type => 'text' },
     notes                   => { type => 'text' },
     employee_id             => { type => 'integer' },
     quonumber               => { type => 'text' },
index 20790e36061f67ee0ecbba4d7ade9106fa6a72e5..beae2322813f6211e29e2b46b8a18abcf43b2ce3 100644 (file)
@@ -21,7 +21,7 @@ __PACKAGE__->meta->setup(
     taxincluded          => { type => 'boolean' },
     shippingpoint        => { type => 'text' },
     notes                => { type => 'text' },
-    curr                 => { type => 'character', length => 3 },
+    curr                 => { type => 'text' },
     employee_id          => { type => 'integer' },
     closed               => { type => 'boolean', default => 'false' },
     quotation            => { type => 'boolean', default => 'false' },
index 387b2d8575c83fa6c108a8666367170b03d2fe07..cc9366339214dd9e04219115c4bbd98955c136f2 100644 (file)
@@ -53,7 +53,7 @@ __PACKAGE__->meta->setup(
     iban           => { type => 'varchar', length => 100 },
     bic            => { type => 'varchar', length => 100 },
     direct_debit   => { type => 'boolean', default => 'false' },
-    curr           => { type => 'character', length => 3 },
+    curr           => { type => 'text' },
   ],
 
   primary_key_columns => [ 'id' ],
index a84f6b13877546b9e4377c1de35ec1fd2f87ed73..83210316c795ea4e718330138172f40cc73bd930 100644 (file)
@@ -169,7 +169,7 @@ sub process_query {
           pop(@quote_chars);
         } elsif (length $quote_chars[-1] > 1
              &&  substr($_, $i, length $quote_chars[-1]) eq $quote_chars[-1]) {
-          $i   += length $quote_chars[-1] - 1;
+          $i   += length($quote_chars[-1]) - 1;
           $char = $quote_chars[-1];
           pop(@quote_chars);
         }
index ce887c34704ece6e24965d1cc68d836654f3876a..3e9704fd241861f0d3b8bc9112a13918bac31d75 100644 (file)
@@ -1607,7 +1607,7 @@ sub get_exchangerate {
   my ($self, $dbh, $curr, $transdate, $fld) = @_;
   my ($query);
 
-  unless ($transdate) {
+  unless ($transdate && $curr) {
     $main::lxdebug->leave_sub();
     return 1;
   }
index b378b34ee2b662c48546aaa99db64f7b3f949660..6ed0ddd6e5d279e1eae714d6be13a7a9bf7a7eac 100644 (file)
@@ -794,8 +794,8 @@ $self->{texts} = {
   'End date'                    => 'Enddatum',
   'Enter a description for this new draft.' => 'Geben Sie eine Beschreibung f&uuml;r diesen Entwurf ein.',
   'Enter longdescription'       => 'Langtext eingeben',
+  'Enter the abbreviations separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies' => 'Geben Sie Ihre und weitere Währungen als Abkürzungen durch Doppelpunkte getrennt ein (z.B. EUR:USD:CAD)',
   'Enter the requested execution date or leave empty for the quickest possible execution:' => 'Geben Sie das jeweils gewünschte Ausführungsdatum an, oder lassen Sie das Feld leer für die schnellstmögliche Ausführung:',
-  'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies' => 'Geben Sie Ihre und weitere Währungen mit bis zu drei Buchstaben pro Währung und Währungen durch Doppelpunkte getrennt ein (z.B. EUR:USD:CAD)',
   'Equity'                      => 'Passiva',
   'Error'                       => 'Fehler',
   'Error in database control file \'%s\': %s' => 'Fehler in Datenbankupgradekontrolldatei \'%s\': %s',
index 14e4ba0fcd5a97cf73f3d98581e95b3b8f038c91..b23a75d29356a1e1d9eb0af79248b3944d796514 100755 (executable)
@@ -162,7 +162,6 @@ sub parse_args {
   GetOptions(
     'login|user=s'      => \ my $login,
     all                 => \ my $all,
-    sugar               => \ my $sugar,
     'no-commit|dry-run' => \ my $nocommit,
     help                => sub { pod2usage(verbose => 99, sections => 'NAME|SYNOPSIS|OPTIONS') },
     verbose             => \ my $verbose,
@@ -170,7 +169,6 @@ sub parse_args {
   );
 
   $options->{login}    = $login if $login;
-  $options->{sugar}    = $sugar;
   $options->{all}      = $all;
   $options->{nocommit} = $nocommit;
   $options->{verbose}  = $verbose;
@@ -205,17 +203,16 @@ sub usage {
 
 sub make_tables {
   my @tables;
-  if ($config{all} || $config{sugar}) {
-    my ($type, $prefix) = $config{sugar} ? ('SUGAR', 'sugar_') : ('LXOFFICE', '');
-    my $db              = SL::DB::create(undef, $type);
-    @tables             =
-      map { $package_names{$type}->{$_} ? "$_=" . $package_names{$type}->{$_} : $prefix ? "$_=$prefix$_" : $_ }
-      grep { my $table = $_; !any { $_ eq $table } @{ $blacklist{$type} } }
+  if ($config{all}) {
+    my $db  = SL::DB::create(undef, 'LXOFFICE');
+    @tables =
+      map { $package_names{LXOFFICE}->{$_} ? "$_=" . $package_names{LXOFFICE}->{$_} : $_ }
+      grep { my $table = $_; !any { $_ eq $table } @{ $blacklist{LXOFFICE} } }
       $db->list_tables;
   } elsif (@ARGV) {
     @tables = @ARGV;
   } else {
-    error("You specified neither --sugar nor --all nor any specific tables.");
+    error("You specified neither --all nor any specific tables.");
     usage();
   }
 
@@ -254,7 +251,7 @@ rose_auto_create_model - mana Rose::DB::Object classes for Lx-Office
 =head1 SYNOPSIS
 
   scripts/rose_create_model.pl --login login table1[=package1] [table2[=package2] ...]
-  scripts/rose_create_model.pl --login login [--all|-a] [--sugar|-s]
+  scripts/rose_create_model.pl --login login [--all|-a]
 
   # updates all models
   scripts/rose_create_model.pl --login login --all
@@ -324,12 +321,8 @@ C<devel/login>. If that too is not found, an error is thrown.
 Process all tables from the database. Only those that are blacklistes in
 L<SL::DB::Helper::Mappings> are excluded.
 
-=item C<--sugar, -s>
-
-Process tables in sugar schema instead of standard schema. Rarely useful unless
-you debug schema awareness of the RDBO layer.
-
 =item C<--no-commit, -n>
+
 =item C<--dry-run>
 
 Do not write back generated files. This will do everything as usual but not
diff --git a/sql/Pg-upgrade2/convert_curr_to_text.sql b/sql/Pg-upgrade2/convert_curr_to_text.sql
new file mode 100644 (file)
index 0000000..90cc034
--- /dev/null
@@ -0,0 +1,108 @@
+-- @tag: convert_curr_to_text
+-- @description: Spalte 'curr' von 'char(3)' nach 'text' konvertieren
+-- @depends: release_2_7_0
+-- @charset: utf-8
+
+-- Zuerst alle Spaltentypen konvertieren.
+ALTER TABLE ap              ALTER COLUMN curr TYPE text;
+ALTER TABLE ar              ALTER COLUMN curr TYPE text;
+ALTER TABLE customer        ALTER COLUMN curr TYPE text;
+ALTER TABLE delivery_orders ALTER COLUMN curr TYPE text;
+ALTER TABLE exchangerate    ALTER COLUMN curr TYPE text;
+ALTER TABLE rma             ALTER COLUMN curr TYPE text;
+ALTER TABLE vendor          ALTER COLUMN curr TYPE text;
+
+-- Eventuell falsche Inhalte (Leerzeichenpadding) auf leere Strings setzen.
+UPDATE ap              SET curr = '' WHERE (curr SIMILAR TO '^ +$') OR (curr IS NULL);
+UPDATE ar              SET curr = '' WHERE (curr SIMILAR TO '^ +$') OR (curr IS NULL);
+UPDATE customer        SET curr = '' WHERE (curr SIMILAR TO '^ +$') OR (curr IS NULL);
+UPDATE delivery_orders SET curr = '' WHERE (curr SIMILAR TO '^ +$') OR (curr IS NULL);
+UPDATE exchangerate    SET curr = '' WHERE (curr SIMILAR TO '^ +$') OR (curr IS NULL);
+UPDATE oe              SET curr = '' WHERE (curr SIMILAR TO '^ +$') OR (curr IS NULL);
+UPDATE rma             SET curr = '' WHERE (curr SIMILAR TO '^ +$') OR (curr IS NULL);
+UPDATE vendor          SET curr = '' WHERE (curr SIMILAR TO '^ +$') OR (curr IS NULL);
+
+-- Nun noch die stored procedures anpassen.
+CREATE OR REPLACE FUNCTION del_exchangerate() RETURNS trigger
+  LANGUAGE plpgsql
+  AS $$
+    DECLARE
+      t_transdate date;
+      t_curr      text;
+      t_id        int;
+      d_curr      text;
+    BEGIN
+      SELECT INTO d_curr substring(curr FROM '[^:]*') FROM DEFAULTS;
+
+      IF TG_RELNAME = 'ar' THEN
+        SELECT INTO t_curr, t_transdate curr, transdate FROM ar WHERE id = old.id;
+      END IF;
+
+      IF TG_RELNAME = 'ap' THEN
+        SELECT INTO t_curr, t_transdate curr, transdate FROM ap WHERE id = old.id;
+      END IF;
+
+      IF TG_RELNAME = 'oe' THEN
+        SELECT INTO t_curr, t_transdate curr, transdate FROM oe WHERE id = old.id;
+      END IF;
+
+      IF TG_RELNAME = 'delivery_orders' THEN
+        SELECT INTO t_curr, t_transdate curr, transdate FROM delivery_orders WHERE id = old.id;
+      END IF;
+
+      IF d_curr != t_curr THEN
+        SELECT INTO t_id a.id FROM acc_trans ac
+          JOIN ar a ON (a.id = ac.trans_id)
+          WHERE (a.curr       = t_curr)
+            AND (ac.transdate = t_transdate)
+        EXCEPT SELECT a.id
+          FROM ar a
+          WHERE (a.id = old.id)
+
+        UNION
+
+        SELECT a.id
+          FROM acc_trans ac
+          JOIN ap a ON (a.id = ac.trans_id)
+          WHERE (a.curr       = t_curr)
+            AND (ac.transdate = t_transdate)
+        EXCEPT SELECT a.id
+          FROM ap a
+          WHERE (a.id = old.id)
+
+        UNION
+
+        SELECT o.id
+          FROM oe o
+          WHERE (o.curr      = t_curr)
+            AND (o.transdate = t_transdate)
+        EXCEPT SELECT o.id
+        FROM oe o
+        WHERE (o.id = old.id)
+
+        UNION
+
+        SELECT dord.id
+          FROM delivery_orders dord
+          WHERE (dord.curr      = t_curr)
+            AND (dord.transdate = t_transdate)
+        EXCEPT SELECT dord.id
+        FROM delivery_orders dord
+        WHERE (dord.id = old.id);
+
+        IF NOT FOUND THEN
+          DELETE FROM exchangerate
+          WHERE (curr      = t_curr)
+            AND (transdate = t_transdate);
+        END IF;
+      END IF;
+
+      RETURN old;
+    END;
+$$;
+
+-- Und die stored procedure auch auf delivery_orders anwenden
+CREATE TRIGGER del_exchangerate
+    BEFORE DELETE ON delivery_orders
+    FOR EACH ROW
+    EXECUTE PROCEDURE del_exchangerate();
index 05351ff29a45ae83c08279ae853c7d002f4a0368..36033dbdf30cb5bf1fbe1951fd05d7cc0ea48e9d 100644 (file)
   <hr height="3" noshade>
 
   <p>
-   (1) [% 'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies' | $T8 %]
+   (1) [% 'Enter the abbreviations separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies' | $T8 %]
        [% 'IMPORTANT NOTE: You cannot safely change currencies, IF you have already booking entries!' | $T8 %]
   </p>
  </form>
-