108624154-func_modification

This commit is contained in:
Stas 2015-11-30 15:13:46 +02:00
parent 5f7e4bc77e
commit 7ae2adbb5e

View file

@ -45,12 +45,15 @@ class AddIdentAutofill < ActiveRecord::Migration
END LOOP; END LOOP;
mod := (total % 11); mod := (total % 11);
END IF; END IF;
IF (mod = 10)
IF (mod < 10 AND substring(r.ident, 11, 1) = to_char(mod, 'FM999MI')) THEN
mod := 0;
END IF;
IF (substring(r.ident, 11, 1) = to_char(mod, 'FM999MI'))
THEN THEN
UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id;
END IF; END IF;
total = 0; total := 0;
END IF; END IF;
END LOOP; END LOOP;
@ -66,7 +69,7 @@ class AddIdentAutofill < ActiveRecord::Migration
counter := (counter + 1); counter := (counter + 1);
END LOOP; END LOOP;
mod := total % 11; mod := total % 11;
total = 0; total := 0;
counter := 1; counter := 1;
IF (mod >= 10) IF (mod >= 10)
THEN THEN
@ -78,7 +81,11 @@ class AddIdentAutofill < ActiveRecord::Migration
END LOOP; END LOOP;
mod := (total % 11); mod := (total % 11);
END IF; END IF;
IF (mod < 10 AND (substring(r.ident, 8, 1) = to_char(mod, 'FM999MI'))) IF (mod = 10)
THEN
mod := 0;
END IF;
IF (substring(r.ident, 8, 1) = to_char(mod, 'FM999MI'))
THEN THEN
UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id;
END IF; END IF;