From 71ea88b5d89305397e69e6569d97eb7711c46556 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 28 May 2015 12:22:28 +0300 Subject: [PATCH 001/189] add delivery method relation to company --- app/models/company.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/company.rb b/app/models/company.rb index 7d91dbf7e..2c554bceb 100644 --- a/app/models/company.rb +++ b/app/models/company.rb @@ -14,6 +14,7 @@ class Company < ActiveRecord::Base o.has_many :customers o.has_many :cash_registers o.has_many :locations + o.has_many :delivery_methods o.has_many :sum_levels o.has_many :sum_level_internals, class_name: 'SumLevel::Internal' From 577e35248e546c0ad3b29b158bb2bbb16b9a86cb Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 28 May 2015 12:23:19 +0300 Subject: [PATCH 002/189] keyword methods --- app/models/keyword.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/models/keyword.rb b/app/models/keyword.rb index 7836f664d..2b3c2b36d 100644 --- a/app/models/keyword.rb +++ b/app/models/keyword.rb @@ -4,6 +4,26 @@ def self.vat_percents .where("selitetark_2 IN (?) OR laji = 'alv'", Location.countries) end + def self.waybills + where(laji: "RAHTIKIRJA") + end + + def self.mode_of_transports + where(laji: "KM") + end + + def self.nature_of_transactions + where(laji: "KT") + end + + def self.customs + where(laji: "TULLI") + end + + def self.sorting_points + where(laji: "TOIMTAPALP") + end + self.table_name = :avainsana self.primary_key = :tunnus From f380c9ade1f6f4149590d8d3382dfa554b23ac62 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 28 May 2015 12:23:57 +0300 Subject: [PATCH 003/189] delivery method model --- app/models/delivery_method.rb | 363 ++++++++++++++++++++++++++++ test/fixtures/delivery_methods.yml | 21 ++ test/models/delivery_method_test.rb | 17 ++ 3 files changed, 401 insertions(+) create mode 100644 app/models/delivery_method.rb create mode 100644 test/fixtures/delivery_methods.yml create mode 100644 test/models/delivery_method_test.rb diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb new file mode 100644 index 000000000..49cb24107 --- /dev/null +++ b/app/models/delivery_method.rb @@ -0,0 +1,363 @@ +class DeliveryMethod < BaseModel + include Translatable + + validates :tulostustapa, inclusion: { in: %w(H E K L X) } + validates :selite, uniqueness: true + + self.table_name = :toimitustapa + self.primary_key = :tunnus + + def pickup_options + [ + [t("Tilaukset toimitetaan asiakkaalle"), ""], + [t("Asiakas noutaa tilaukset"), "o"] + ] + end + + def saturday_delivery_options + [ + [t("Ei lauantaijakelua"), ""], + [t("Itella lisäpalvelu: Lauantaijakelu"), "o"] + ] + end + + def transport_unit_options + [ + [t("Ei kuljetusyksikkökuljetusta"), ""], + [t("Itella lisäpalvelu: Kuljetusyksikkökuljetus"), "o"] + ] + end + + def carrier_options + #company.carriers.map { |i| [ i.nimi, i.koodi ] } + end + + def print_method_options + [ + [t("Erätulostus"), "E"], + [t("Hetitulostus"), "H"], + [t("Koonti-hetitulostus"), "K"], + [t("Koonti-erätulostus"), "L"] + [t("Rahtikirjansyöttö ja -tulostus ohitetaan"), "X"] + ] + end + + def freight_contract_options + [ + [t("Käytetään lähettäjän rahtisopimusta"), "K"], + [t("Käytetään vastaanottajan rahtisopimusta"), ""] + ] + end + + def logy_waybill_number_options + [ + [t("Ei käytetä LOGY:n rahtikirjanumeroita"), ""], + [t("Käytetään LOGY:n rahtikirjanumeroita"), "K"] + ] + end + + def extranet_options + [ + [t("Toimitustapa näytetään vain myynnissä"), ""], + [t("Toimitustapa näytetään vain extranetissä"), "K"], + [t("Toimitustapa näytetään molemmissa"), "M"] + ] + end + + def waybill_options + company.keywords.waybills.map { |i| i.selitetark, i.selite } + end + + def label_options + options = [] + options << [t("Normaali"), ""] + options << [t("Intrade"), "intrade"] + options << [t("Tiivistetty"), "tiivistetty"] + + if company.parameter.kerayserat == "K" + options << [t("Yksinkertainen, tulostusmedia valitaan kirjoittimen takaa"), "oslap_mg"] + end + + options + end + + def mode_of_transport_options + company.keywords.mode_of_transports.map { |i| i.selitetark, i.selite } + end + + def inland_mode_of_transport_options + mode_of_transport_options + end + + def nature_of_transaction_options + company.keywords.nature_of_transactions.map { |i| i.selitetark, i.selite } + end + + def exit_code_options + company.keywords.customs.map { |i| "#{i.selite} #{i.selitetark}", i.selite } + end + + def sorting_point_options + company.keywords.sorting_points.map { |i| i.selitetark, i.selite } + end + + def container_options + [ + [t("Kyllä"), "1"], + [t("Ei"), "0"] + ] + end + + def cash_on_delivery_prohibition_options + [ + [t("Toimitustavalla saa toimittaa jälkivaatimuksia"), ""], + [t("Toimitustavalla ei saa toimittaa jälkivaatimuksia"), "o"] + ] + end + + def official_legend_options + { + "Ei valintaa": "", + "Pupesoft / Itella": { + "Express City 00": "Itella Express City 00", + "Express Morning 9": "Itella Express Morning 9", + "Express Business Day 14": "Itella Express Business Day 14", + "Express Point 00/16": "Itella Express Point 00/16", + "Express Flex 21": "Itella Express Flex 21", + "Economy 16": "Itella Economy 16", + "Customer Return": "Itella Customer Return", + "Undelivered Shipment": "Itella Undelivered Shipment", + "Lisäarvokuljetus": "Itella Lisäarvokuljetus", + "Priority Ulkomaa": "Itella Priority Ulkomaan lähetys" + }, + "Unifaun / Itella": { + "ITELLAMAILEC": "Itella Economy Letter", + "IT16": "Itella Economy Parcel", + "IT14": "Itella Express Business Day", + "ITKY14": "Itella Express Business Day kuljetusyksikkö", + "ITKY14I": "Itella Express Business Day pallet (Ulkomaa)", + "IT14I": "Itella Express Business Day parcel (Ulkomaa)", + "ITEXPC": "Itella Express City", + "ITKYEXPC": "Itella Express City kuljetusyksikkö", + "IT21": "Itella Express Flex", + "ITKY21": "Itella Express Flex kuljetusyksikkö", + "IT09": "Itella Express Morning", + "ITKY09": "Itella Express Morning kuljetusyksikkö", + "TPSTD": "Itella Logistics Oy, Kappaletavara", + "ITELLALOGKR": "Itella Logistics Oy, Kotimaan Rahti", + "ITELLAMAILPR": "Itella Priority Letter", + "ITPR": "Itella Priority Parcel", + "ITSP": "Itella SmartPOST", + "ITVAK": "Itella VAK/ADR", + "ITKYVAK": "Itella VAK/ADR kuljetusyksikkö" + }, + "Unifaun / Bring": { + "PNL359": "Bring CarryOn Budget", + "PNL330": "Bring CarryOn Business", + "PNL335": "Bring CarryOn Business 09.00", + "PNL333": "Bring CarryOn Business BulkReturn", + "PNL332": "Bring CarryOn Business BulkSplit", + "PNL334": "Bring CarryOn Business BulkSplit 09.00", + "PNL336": "Bring CarryOn Business Pallet", + "PNL339": "Bring CarryOn Business Pallet 09.00", + "PNL331": "Bring CarryOn Business Return", + "PNL340": "Bring CarryOn HomeShopping", + "PNL343": "Bring CarryOn HomeShopping BulkReturn", + "PNL342": "Bring CarryOn HomeShopping BulkSplit", + "PNL349": "Bring CarryOn HomeShopping BulkSplit Home", + "PNL345": "Bring CarryOn HomeShopping BulkSplit Mini", + "PNL341": "Bring CarryOn HomeShopping Return", + "PNLWAY": "Bring CarryOn Waybill", + "BOXBD": "Bring Express Business Distribution", + "BOXBDP": "Bring Express Business Distribution Pallet", + "BOXCA": "Bring Express Courier Ad-Hoc", + "BOXCD": "Bring Express Courier Distribution", + "BOXHD": "Bring Express Home Delivery", + "BOXHDR": "Bring Express Home Delivery Return", + "BOXQP": "Bring Express QuickPack", + "BOXSHD": "Bring Express Store Home Delivery", + "BOXSHDR": "Bring Express Store Home Delivery Return" + }, + "Unifaun / Dachser": { + "DACTFIX": "Dachser Targofix", + "DACTFIX10": "Dachser Targofix 10:00", + "DACTFIX12": "Dachser Targofix 12:00", + "DACTFLEX": "Dachser Targoflex", + "DACTSPEED": "Dachser Targospeed", + "DACTSPEED10": "Dachser Targospeed 10:00", + "DACTSPEED12": "Dachser Targospeed 12:00", + "DACTSPEEDPLUS": "Dachser Targospeed Plus" + }, + "Unifaun / DANX": { + "DANXSTD": "DANX" + }, + "Unifaun / DB Schenker": { + "SBTLFIEXP": "DB SCHENKER Express (Finland)", + "SBTLFISY": "DB SCHENKER Finland System", + "BBU": "DB SCHENKERbudget", + "BCSI": "DB SCHENKERcoldsped - Europa", + "BCS": "DB SCHENKERcoldsped - Sverige", + "BDI": "DB SCHENKERdirect", + "BPA": "DB SCHENKERparcel", + "BPHDP": "DB SCHENKERprivpak - Hem Dag (utan avisering och kvittens)", + "BPHDAP": "DB SCHENKERprivpak - Hem Dag med avisering (och kvittens) (Paket)", + "BPHKAP": "DB SCHENKERprivpak - Hem Kväll med avisering (och kvittens)", + "BHP": "DB SCHENKERprivpak - Ombud Standard (1 kolli, <20 kg)", + "BPOSG": "DB SCHENKERprivpak - Terminal", + "BPTJP": "DB SCHENKERprivpak - Till Jobbet", + "BCF": "DB SCHENKERsystem" + }, + "Unifaun / DHL": { + "ASU": "DHL Euroconnect", + "ASUP": "DHL Euroconnect Plus", + "DASECD": "DHL Express 09:00 (Tullinalainen)", + "DASE": "DHL Express 09:00 (Tullivapaa)", + "DATDM": "DHL Express 10:30 (Tullinalainen)", + "DATDL": "DHL Express 10:30 (Tullivapaa)", + "DAMECD": "DHL Express 12:00 (Tullinalainen)", + "DAME": "DHL Express 12:00 (Tullivapaa)", + "DAXPD": "DHL Express Envelope (Tullivapaa)", + "DADOM": "DHL Express Worldwide (Kotimaa)", + "DAWPX": "DHL Express Worldwide (Tullinalainen)", + "DAECX": "DHL Express Worldwide (Tullivapaa EU: ssa)", + "DADOX": "DHL Express Worldwide (Tullivapaa, Ei-EU)", + "DHLFREIGHTESTDOM": "DHL Freight Domestic EE", + "DHLFREIGHTESTEC": "DHL Freight Euroconnect EE", + "DHLFREIGHTFIEC": "DHL Freight Euroconnect FI", + "DHLFREIGHTFIKT": "DHL Freight Kotimaa", + "DGFAIR": "DHL Global Forwarding Air Freight", + "DGFAIRPLUS": "DHL Global Forwarding Air Freight PLUS", + "AEX": "DHL Paket", + "ASP2": "DHL Pall", + "ASWP2": "DHL Parti", + "ASPO": "DHL Service Point", + "ASPOC": "DHL Service Point C.O.D.", + "ASPOR": "DHL Service Point Retur", + "ASWS2": "DHL Stycke", + "ASWP": "DHL Swednet Partigods", + "ASWS": "DHL Swednet Styckegods" + }, + "Unifaun / DSV": { + "DSVFIGRP": "DSV Road Kappaletavara", + "DSVFIFULL": "DSV Road Osakuorma" + }, + "Unifaun / Fennoway": { + "FENNORAHTI": "Fennoway Fennorahti" + }, + "Unifaun / GLS": { + "GLSFIINT": "GLS Suomi INTERNATIONAL" + }, + "Unifaun / Kaukokiito": { + "KKSTD": "Kaukokiito" + }, + "Unifaun / Kiitolinja": { + "KLGRP": "KIITOLINJA kappaletavara" + }, + "Unifaun / KN Road": { + "KUEHNENAGELROAD": "KN Road" + }, + "Unifaun / Tyvi": { + "KTYVI": "Kuljetusliike Tyvi Oy" + }, + "Unifaun / Matkahuolto": { + "MH68": "Matkahuolto Ahvenanmaan Jakopaketti", + "MH63": "Matkahuolto Baltian Paketti", + "MH10": "Matkahuolto Bussipaketti", + "MH43": "Matkahuolto Dokumenttikuori", + "MH3050": "Matkahuolto Jakopaketti/Paikallispaketti", + "MH57": "Matkahuolto Lavarahti", + "MH81": "Matkahuolto Lähellä-paketin palautus", + "MH80": "Matkahuolto Lähellä-paketti", + "MH75": "Matkahuolto Mannermaan Jakopaketti", + "MH74": "Matkahuolto Mannermaan Paketti", + "MH20": "Matkahuolto Pikapaketti", + "MH82": "Matkahuolto Postaalipaketti", + "MH83": "Matkahuolto Postaalipaketti palautus", + "MH40": "Matkahuolto Rahtipussi", + "MH42": "Matkahuolto Rahtipussi jakopaketti" + }, + "Unifaun / Neutraali": { + "FREEG": "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja)", + "FREEG_793": "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja): Transpori Oy", + "FREEG_794": "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja): AJ Laine Oy", + "FREEB": "Neutraali Kirjepalvelu", + "FREEP": "Neutraali pakettipalvelu (osoitekortti)" + }, + "Unifaun / Posten Brev": { + "PAF": "Posten Brev - Brevpostförskott", + "BEXPD": "Posten Brev - Express (kotimaa)", + "BREV": "Posten Brev - Normaali", + "BEXPI": "Posten Brev - Priority+", + "BVAL": "Posten Brev - Värde", + "BREKD": "Posten Brev Kirjattu kirje (BREKD)", + "BREKI": "Posten Brev Kirjattu kirje (BREKI)", + "EMSD2": "Posten EMS (brev/dokument)", + "EMSP2": "Posten EMS (paket/varor)" + }, + "Unifaun / PostNord": { + "DPDFI": "PostNord DPD Classic (Suomi)", + "P15": "PostNord Logistics DPD Företagspaket", + "P14": "PostNord Logistics DPD Företagspaket 12.00", + "DPD": "PostNord Logistics DPD Utrikes", + "P42": "PostNord Logistics Express - Express 07.00", + "P32": "PostNord Logistics Hempaket", + "DTPGHD": "PostNord Logistics Hjemlevering (Norge)", + "H48": "PostNord Logistics InNight", + "P31": "PostNord Logistics Kundretur", + "P19": "PostNord Logistics MyPack", + "P19FI": "PostNord Logistics MyPack (Suomi)", + "P19NO": "PostNord Logistics MyPack (Norja)", + "P24": "PostNord Logistics MyPack return", + "P24FI": "PostNord Logistics MyPack return (Suomi)", + "P24NO": "PostNord Logistics MyPack Return (Norja)", + "P52": "PostNord Logistics PALL.ETT", + "DTPGPF": "PostNord Logistics Partifrakt (Norja)", + "P91": "PostNord Logistics Postpaket Utrikes", + "DTPGSG": "PostNord Logistics Stykkgods (Norja)" + }, + "Unifaun / Privpak": { + "PPFITRRET": "Privpak Finland (normaali & palautus)", + "PPFITR": "Privpak Finland (normaali)" + }, + "Unifaun / R & P": { + "RPPP": "R & P Kuljetus Pakettipalvelu" + }, + "Unifaun / TK Logistik": { + "TKLOGGODS": "TK Logistik Gods" + }, + "Unifaun / TNT": { + "TNT08DOMD": "TNT 08:00 Express (Domestic Docs)", + "TNT08DOMN": "TNT 08:00 Express (Domestic Non Docs)", + "TNT09D": "TNT 09:00 Express (Docs)", + "TNT09DOMD": "TNT 09:00 Express (Domestic Docs)", + "TNT09DOMN": "TNT 09:00 Express (Domestic Non Docs)", + "TNT09": "TNT 09:00 Express (Domestic)", + "TNT09N": "TNT 09:00 Express (Non Docs)", + "TNT10D": "TNT 10:00 Express (Docs)", + "TNT10DOMD": "TNT 10:00 Express (Domestic Docs)", + "TNT10DOMN": "TNT 10:00 Express (Domestic Non Docs)", + "TNT10": "TNT 10:00 Express (Domestic)", + "TNT10N": "TNT 10:00 Express (Non Docs)", + "TNT412": "TNT 12:00 Economy Express (Non Docs)", + "TNT12D": "TNT 12:00 Express (Docs)", + "TNT12DOMD": "TNT 12:00 Express (Domestic Docs)", + "TNT12DOMN": "TNT 12:00 Express (Domestic Non Docs)", + "TNT12": "TNT 12:00 Express (Domestic)", + "TNT12N": "TNT 12:00 Express (Non Docs)", + "TNT48N": "TNT Economy Express (Non Docs)", + "TNT15D": "TNT Express (Docs)", + "TNT15DOMD": "TNT Express (Domestic Docs)", + "TNT15DOMN": "TNT Express (Domestic Non Docs)", + "TNT15": "TNT Express (Domestic)", + "TNT15N": "TNT Express (Non Docs)", + "TNT728": "TNT Special Economy Express" + }, + "Unifaun / UPK": { + "UPKE": "Uudenmaan Pikakuljetus Oy Erikoisaikataulu", + "UPKK": "Uudenmaan Pikakuljetus Oy Kotijakelu", + "UPK24": "Uudenmaan Pikakuljetus Oy Normal 24h", + "UPK24A": "Uudenmaan Pikakuljetus Oy Normal 24h AVI" + } + } + end +end diff --git a/test/fixtures/delivery_methods.yml b/test/fixtures/delivery_methods.yml new file mode 100644 index 000000000..ce729e68b --- /dev/null +++ b/test/fixtures/delivery_methods.yml @@ -0,0 +1,21 @@ +kaukokiito: + yhtio: acme + selite: Kaukokiito + tulostustapa: H + rahtikirja: rahtikirja_pdf.inc + rahdinkuljettaja: Kaukokiito + laatija: 'joe' + luontiaika: <%= Date.today %> + muutospvm: <%= Date.today %> + muuttaja: 'joe' + +kiitolinja: + yhtio: acme + selite: Kiitolinja + tulostustapa: H + rahtikirja: rahtikirja_pdf.inc + rahdinkuljettaja: Kiitolinja + laatija: 'joe' + luontiaika: <%= Date.today %> + muutospvm: <%= Date.today %> + muuttaja: 'joe' diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb new file mode 100644 index 000000000..810228c3f --- /dev/null +++ b/test/models/delivery_method_test.rb @@ -0,0 +1,17 @@ +require 'test_helper' + +class DeliveryMethodTest < ActiveSupport::TestCase + + def setup + @delivery_method = delivery_methods(:kaukokiito) + end + + test "fixtures should be valid" do + assert @delivery_method.valid?, @delivery_method.errors.messages + end + + test "selite should be unique" do + @delivery_method.selite = "Kiitolinja" + refute @delivery_method.valid?, "Delivery method already exists" + end +end From ee121cedd2e2d0c6562f02838dd6fdc1b9914c7f Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 28 May 2015 15:20:12 +0300 Subject: [PATCH 004/189] adr options --- app/models/delivery_method.rb | 45 +++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 49cb24107..2142e4fda 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -4,6 +4,9 @@ class DeliveryMethod < BaseModel validates :tulostustapa, inclusion: { in: %w(H E K L X) } validates :selite, uniqueness: true + scope :permit_adr, -> { where(vak_kielto: '') } + scope :shipment, -> { where(nouto: '') } + self.table_name = :toimitustapa self.primary_key = :tunnus @@ -37,7 +40,7 @@ def print_method_options [t("Erätulostus"), "E"], [t("Hetitulostus"), "H"], [t("Koonti-hetitulostus"), "K"], - [t("Koonti-erätulostus"), "L"] + [t("Koonti-erätulostus"), "L"], [t("Rahtikirjansyöttö ja -tulostus ohitetaan"), "X"] ] end @@ -65,14 +68,15 @@ def extranet_options end def waybill_options - company.keywords.waybills.map { |i| i.selitetark, i.selite } + company.keywords.waybills.map { |i| [ i.selitetark, i.selite ] } end def label_options - options = [] - options << [t("Normaali"), ""] - options << [t("Intrade"), "intrade"] - options << [t("Tiivistetty"), "tiivistetty"] + options = [ + [t("Normaali"), ""], + [t("Intrade"), "intrade"], + [t("Tiivistetty"), "tiivistetty"] + ] if company.parameter.kerayserat == "K" options << [t("Yksinkertainen, tulostusmedia valitaan kirjoittimen takaa"), "oslap_mg"] @@ -82,7 +86,7 @@ def label_options end def mode_of_transport_options - company.keywords.mode_of_transports.map { |i| i.selitetark, i.selite } + company.keywords.mode_of_transports.map { |i| [ i.selitetark, i.selite ] } end def inland_mode_of_transport_options @@ -90,15 +94,15 @@ def inland_mode_of_transport_options end def nature_of_transaction_options - company.keywords.nature_of_transactions.map { |i| i.selitetark, i.selite } + company.keywords.nature_of_transactions.map { |i| [ i.selitetark, i.selite ] } end def exit_code_options - company.keywords.customs.map { |i| "#{i.selite} #{i.selitetark}", i.selite } + company.keywords.customs.map { |i| [ "#{i.selite} #{i.selitetark}", i.selite ] } end def sorting_point_options - company.keywords.sorting_points.map { |i| i.selitetark, i.selite } + company.keywords.sorting_points.map { |i| [ i.selitetark, i.selite ] } end def container_options @@ -115,6 +119,27 @@ def cash_on_delivery_prohibition_options ] end + def adr_options(text) + DeliveryMethod.permit_adr.shipment.map do |i| + [ "#{text} #{i.selite}", i.selite ] + end + end + + def adr_prohibition_options + [ + [t("Toimitustavalla saa toimittaa VAK-tuotteita"), ""], + [t("Toimitustavalla ei saa toimittaa VAK-tuotteita"), "K"], + adr_options(t("VAK-tuotteet toimitetaan toimitustavalla")) + ].reject {|i,_| i.empty?} + end + + def alternative_adr_delivery_method_options + [ + [t("VAK-tuotteita ei siirretä omalle tilaukselleen"), ""], + adr_options(t("VAK-tuotteet siirretään omalle tilaukselleen toimitustavalla")) + ].reject {|i,_| i.empty?} + end + def official_legend_options { "Ei valintaa": "", From 9567cbe67d79a22f11d7c64357e464a692898962 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 28 May 2015 15:40:47 +0300 Subject: [PATCH 005/189] more dropdown options --- app/models/delivery_method.rb | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 2142e4fda..4080fbfb2 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -140,6 +140,52 @@ def alternative_adr_delivery_method_options ].reject {|i,_| i.empty?} end + def special_packaging_prohibition_options + [ + [t("Toimitustavalla saa toimittaa erikoispakkauksia"), ""], + [t("Toimitustavalla ei saa toimittaa erikoispakkauksia"), "K"] + ] + end + + def packing_area_prohibition_options + [ + [t("Toimitustavan tilaukset varaavat pakkaamolokeron"), "0"], + [t("Toimitustavan tilaukaset eivät varaa pakkaamolokeroa"), "1"] + ] + end + + def waybill_specification_options + [ + [t("Toimitustavalle ei tulosteta rahtikirjaerittelyä"), ""], + [t("Toimitustavalle tulostetaan rahtikirjaerittely"), "t"], + [t("Toimitustavalle tulostetaan rahtikirjaerittely per asiakas"), "k"] + ] + end + + def new_packaging_information_options + [ + [t("Koonti-erätulostuksessa ei voi syöttää uusia pakkaustietoja ennen tulostusta"), ""], + [t("Koonti-erätulostuksessa voi syöttää uudet pakkaustiedot ennen tulostusta"), "K"] + ] + end + + def permitted_packaging_options + [] + end + + def transportation_insurance_type_options + [ + [t("Yhtiön oletus"), ""], + [t("Ei kuljetusvakuutusta"), "E"], + [t("Valuuttamääräinen kuljetusvakuutus lisätään"), "A"], + [t("Prosentuaalinen kuljetusvakuutus lisätään"), "B"], + [t("Valuuttamääräinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen + asiakashintaa ja alennusta"), "F"], + [t("Prosentuaalinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen + asiakasalennusta"), "G"] + ] + end + def official_legend_options { "Ei valintaa": "", From 0e3c3d3b6e011ace095b5666bffd9102b2df49d2 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 28 May 2015 16:31:25 +0300 Subject: [PATCH 006/189] unifaun validation --- app/models/delivery_method.rb | 16 ++++++++++++++++ test/models/delivery_method_test.rb | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 4080fbfb2..afbad72d3 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -4,12 +4,18 @@ class DeliveryMethod < BaseModel validates :tulostustapa, inclusion: { in: %w(H E K L X) } validates :selite, uniqueness: true + validate :check_unifaun, if: :build_patch_print? + scope :permit_adr, -> { where(vak_kielto: '') } scope :shipment, -> { where(nouto: '') } self.table_name = :toimitustapa self.primary_key = :tunnus + def build_patch_print? + tulostustapa == "L" + end + def pickup_options [ [t("Tilaukset toimitetaan asiakkaalle"), ""], @@ -431,4 +437,14 @@ def official_legend_options } } end + + private + + def check_unifaun + true + if self.rahtikirja.index("rahtikirja_unifaun").present? + errors.add(:base, t("Koontierätulostus ei toimi Unifaun Online rahtikirjan kanssa")) + false + end + end end diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 810228c3f..01a02f02c 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -14,4 +14,17 @@ def setup @delivery_method.selite = "Kiitolinja" refute @delivery_method.valid?, "Delivery method already exists" end + + test "should not allow unifaun with build patch print" do + @delivery_method.tulostustapa = "L" + @delivery_method.rahtikirja = "rahtikirja_unifaun_foo_bar" + + refute @delivery_method.valid?, @delivery_method.errors.messages + end + + test "should allow unifaun" do + @delivery_method.tulostustapa = "H" + @delivery_method.rahtikirja = "rahtikirja_unifaun_foo_bar" + assert @delivery_method.valid?, @delivery_method.errors.messages + end end From 2b8daf37def2853106c90a28e55e85a281cfbb82 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 19 Aug 2015 15:29:23 +0300 Subject: [PATCH 007/189] remove translation function --- app/models/delivery_method.rb | 99 +++++++++++++++++------------------ 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index afbad72d3..7380aabf3 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -1,5 +1,4 @@ class DeliveryMethod < BaseModel - include Translatable validates :tulostustapa, inclusion: { in: %w(H E K L X) } validates :selite, uniqueness: true @@ -18,22 +17,22 @@ def build_patch_print? def pickup_options [ - [t("Tilaukset toimitetaan asiakkaalle"), ""], - [t("Asiakas noutaa tilaukset"), "o"] + ["Tilaukset toimitetaan asiakkaalle", ""], + ["Asiakas noutaa tilaukset", "o"] ] end def saturday_delivery_options [ - [t("Ei lauantaijakelua"), ""], - [t("Itella lisäpalvelu: Lauantaijakelu"), "o"] + ["Ei lauantaijakelua", ""], + ["Itella lisäpalvelu: Lauantaijakelu", "o"] ] end def transport_unit_options [ - [t("Ei kuljetusyksikkökuljetusta"), ""], - [t("Itella lisäpalvelu: Kuljetusyksikkökuljetus"), "o"] + ["Ei kuljetusyksikkökuljetusta", ""], + ["Itella lisäpalvelu: Kuljetusyksikkökuljetus", "o"] ] end @@ -43,33 +42,33 @@ def carrier_options def print_method_options [ - [t("Erätulostus"), "E"], - [t("Hetitulostus"), "H"], - [t("Koonti-hetitulostus"), "K"], - [t("Koonti-erätulostus"), "L"], - [t("Rahtikirjansyöttö ja -tulostus ohitetaan"), "X"] + ["Erätulostus", "E"], + ["Hetitulostus", "H"], + ["Koonti-hetitulostus", "K"], + ["Koonti-erätulostus", "L"], + ["Rahtikirjansyöttö ja -tulostus ohitetaan", "X"] ] end def freight_contract_options [ - [t("Käytetään lähettäjän rahtisopimusta"), "K"], - [t("Käytetään vastaanottajan rahtisopimusta"), ""] + ["Käytetään lähettäjän rahtisopimusta", "K"], + ["Käytetään vastaanottajan rahtisopimusta", ""] ] end def logy_waybill_number_options [ - [t("Ei käytetä LOGY:n rahtikirjanumeroita"), ""], - [t("Käytetään LOGY:n rahtikirjanumeroita"), "K"] + ["Ei käytetä LOGY:n rahtikirjanumeroita", ""], + ["Käytetään LOGY:n rahtikirjanumeroita", "K"] ] end def extranet_options [ - [t("Toimitustapa näytetään vain myynnissä"), ""], - [t("Toimitustapa näytetään vain extranetissä"), "K"], - [t("Toimitustapa näytetään molemmissa"), "M"] + ["Toimitustapa näytetään vain myynnissä", ""], + ["Toimitustapa näytetään vain extranetissä", "K"], + ["Toimitustapa näytetään molemmissa", "M"] ] end @@ -79,13 +78,13 @@ def waybill_options def label_options options = [ - [t("Normaali"), ""], - [t("Intrade"), "intrade"], - [t("Tiivistetty"), "tiivistetty"] + ["Normaali", ""], + ["Intrade", "intrade"], + ["Tiivistetty", "tiivistetty"] ] if company.parameter.kerayserat == "K" - options << [t("Yksinkertainen, tulostusmedia valitaan kirjoittimen takaa"), "oslap_mg"] + options << ["Yksinkertainen, tulostusmedia valitaan kirjoittimen takaa", "oslap_mg"] end options @@ -113,15 +112,15 @@ def sorting_point_options def container_options [ - [t("Kyllä"), "1"], - [t("Ei"), "0"] + ["Kyllä", "1"], + ["Ei", "0"] ] end def cash_on_delivery_prohibition_options [ - [t("Toimitustavalla saa toimittaa jälkivaatimuksia"), ""], - [t("Toimitustavalla ei saa toimittaa jälkivaatimuksia"), "o"] + ["Toimitustavalla saa toimittaa jälkivaatimuksia", ""], + ["Toimitustavalla ei saa toimittaa jälkivaatimuksia", "o"] ] end @@ -133,45 +132,45 @@ def adr_options(text) def adr_prohibition_options [ - [t("Toimitustavalla saa toimittaa VAK-tuotteita"), ""], - [t("Toimitustavalla ei saa toimittaa VAK-tuotteita"), "K"], - adr_options(t("VAK-tuotteet toimitetaan toimitustavalla")) + ["Toimitustavalla saa toimittaa VAK-tuotteita", ""], + ["Toimitustavalla ei saa toimittaa VAK-tuotteita", "K"], + adr_options("VAK-tuotteet toimitetaan toimitustavalla") ].reject {|i,_| i.empty?} end def alternative_adr_delivery_method_options [ - [t("VAK-tuotteita ei siirretä omalle tilaukselleen"), ""], - adr_options(t("VAK-tuotteet siirretään omalle tilaukselleen toimitustavalla")) + ["VAK-tuotteita ei siirretä omalle tilaukselleen", ""], + adr_options("VAK-tuotteet siirretään omalle tilaukselleen toimitustavalla") ].reject {|i,_| i.empty?} end def special_packaging_prohibition_options [ - [t("Toimitustavalla saa toimittaa erikoispakkauksia"), ""], - [t("Toimitustavalla ei saa toimittaa erikoispakkauksia"), "K"] + ["Toimitustavalla saa toimittaa erikoispakkauksia", ""], + ["Toimitustavalla ei saa toimittaa erikoispakkauksia", "K"] ] end def packing_area_prohibition_options [ - [t("Toimitustavan tilaukset varaavat pakkaamolokeron"), "0"], - [t("Toimitustavan tilaukaset eivät varaa pakkaamolokeroa"), "1"] + ["Toimitustavan tilaukset varaavat pakkaamolokeron", "0"], + ["Toimitustavan tilaukaset eivät varaa pakkaamolokeroa", "1"] ] end def waybill_specification_options [ - [t("Toimitustavalle ei tulosteta rahtikirjaerittelyä"), ""], - [t("Toimitustavalle tulostetaan rahtikirjaerittely"), "t"], - [t("Toimitustavalle tulostetaan rahtikirjaerittely per asiakas"), "k"] + ["Toimitustavalle ei tulosteta rahtikirjaerittelyä", ""], + ["Toimitustavalle tulostetaan rahtikirjaerittely", "t"], + ["Toimitustavalle tulostetaan rahtikirjaerittely per asiakas", "k"] ] end def new_packaging_information_options [ - [t("Koonti-erätulostuksessa ei voi syöttää uusia pakkaustietoja ennen tulostusta"), ""], - [t("Koonti-erätulostuksessa voi syöttää uudet pakkaustiedot ennen tulostusta"), "K"] + ["Koonti-erätulostuksessa ei voi syöttää uusia pakkaustietoja ennen tulostusta", ""], + ["Koonti-erätulostuksessa voi syöttää uudet pakkaustiedot ennen tulostusta", "K"] ] end @@ -181,14 +180,14 @@ def permitted_packaging_options def transportation_insurance_type_options [ - [t("Yhtiön oletus"), ""], - [t("Ei kuljetusvakuutusta"), "E"], - [t("Valuuttamääräinen kuljetusvakuutus lisätään"), "A"], - [t("Prosentuaalinen kuljetusvakuutus lisätään"), "B"], - [t("Valuuttamääräinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen - asiakashintaa ja alennusta"), "F"], - [t("Prosentuaalinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen - asiakasalennusta"), "G"] + ["Yhtiön oletus", ""], + ["Ei kuljetusvakuutusta", "E"], + ["Valuuttamääräinen kuljetusvakuutus lisätään", "A"], + ["Prosentuaalinen kuljetusvakuutus lisätään", "B"], + ["Valuuttamääräinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen + asiakashintaa ja alennusta", "F"], + ["Prosentuaalinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen + asiakasalennusta", "G"] ] end @@ -443,7 +442,7 @@ def official_legend_options def check_unifaun true if self.rahtikirja.index("rahtikirja_unifaun").present? - errors.add(:base, t("Koontierätulostus ei toimi Unifaun Online rahtikirjan kanssa")) + errors.add(:base, "Koontierätulostus ei toimi Unifaun Online rahtikirjan kanssa") false end end From 38f494f9413a44059505fa597311c483423a98b9 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 19 Aug 2015 15:34:20 +0300 Subject: [PATCH 008/189] remove unnecessary validation --- app/models/delivery_method.rb | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 7380aabf3..811550419 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -3,18 +3,12 @@ class DeliveryMethod < BaseModel validates :tulostustapa, inclusion: { in: %w(H E K L X) } validates :selite, uniqueness: true - validate :check_unifaun, if: :build_patch_print? - scope :permit_adr, -> { where(vak_kielto: '') } scope :shipment, -> { where(nouto: '') } self.table_name = :toimitustapa self.primary_key = :tunnus - def build_patch_print? - tulostustapa == "L" - end - def pickup_options [ ["Tilaukset toimitetaan asiakkaalle", ""], @@ -436,14 +430,4 @@ def official_legend_options } } end - - private - - def check_unifaun - true - if self.rahtikirja.index("rahtikirja_unifaun").present? - errors.add(:base, "Koontierätulostus ei toimi Unifaun Online rahtikirjan kanssa") - false - end - end end From e3575029036892f60f45df27de9daf52fada96d8 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 10:25:14 +0300 Subject: [PATCH 009/189] view options helper --- app/helpers/delivery_methods_helper.rb | 87 ++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 app/helpers/delivery_methods_helper.rb diff --git a/app/helpers/delivery_methods_helper.rb b/app/helpers/delivery_methods_helper.rb new file mode 100644 index 000000000..e5eb2f06a --- /dev/null +++ b/app/helpers/delivery_methods_helper.rb @@ -0,0 +1,87 @@ +module DeliveryMethodsHelper + ROOT = 'administration.delivery_methods' + + def pickup_options + DeliveryMethod.noutos.map do |key,_| + [ t("#{ROOT}.pickup_options.#{key}"), key ] + end + end + + def saturday_delivery_options + DeliveryMethod.lauantais.map do |key,_| + [ t("#{ROOT}.saturday_delivery_options.#{key}"), key ] + end + end + + def transport_unit_options + DeliveryMethod.kuljyksikkos.map do |key,_| + [ t("#{ROOT}.transport_unit_options.#{key}"), key ] + end + end + + def print_method_options + DeliveryMethod.tulostustapas.map do |key,_| + [ t("#{ROOT}.print_method_options.#{key}"), key ] + end + end + + def freight_contract_options + DeliveryMethod.merahtis.map do |key,_| + [ t("#{ROOT}.freight_contract_options.#{key}"), key ] + end + end + + def logy_waybill_number_options + DeliveryMethod.logy_rahtikirjanumerots.map do |key,_| + [ t("#{ROOT}.logy_waybill_number_options.#{key}"), key ] + end + end + + def extranet_options + DeliveryMethod.extranets.map do |key,_| + [ t("#{ROOT}.extranet_options.#{key}"), key ] + end + end + + def container_options + DeliveryMethod.konttis.map do |key,_| + [ t("#{ROOT}.container_options.#{key}"), key ] + end + end + + def cash_on_delivery_prohibition_options + DeliveryMethod.jvkieltos.map do |key,_| + [ t("#{ROOT}.cash_on_delivery_prohibition_options.#{key}"), key ] + end + end + + def special_packaging_prohibition_options + DeliveryMethod.erikoispakkaus_kieltos.map do |key,_| + [ t("#{ROOT}.special_packaging_prohibition_options.#{key}"), key ] + end + end + + def packing_line_prohibition_options + DeliveryMethod.ei_pakkaamoas.map do |key,_| + [ t("#{ROOT}.packing_line_prohibition_options.#{key}"), key ] + end + end + + def waybill_specification_options + DeliveryMethod.erittelys.map do |key,_| + [ t("#{ROOT}.waybill_specification_options.#{key}"), key ] + end + end + + def new_packaging_information_options + DeliveryMethod.uudet_pakkaustiedots.map do |key,_| + [ t("#{ROOT}.new_packaging_information_options.#{key}"), key ] + end + end + + def transportation_insurance_type_options + DeliveryMethod.kuljetusvakuutus_tyyppis.map do |key,_| + [ t("#{ROOT}.transportation_insurance_type_options.#{key}"), key ] + end + end +end From 3fab74fdd38284ca065e8d922d4faa4584ebf014 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 10:25:56 +0300 Subject: [PATCH 010/189] change some of the option methods to enumerable --- app/models/delivery_method.rb | 192 ++++++++++++++-------------------- 1 file changed, 80 insertions(+), 112 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 811550419..0ff462e5b 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -1,6 +1,4 @@ class DeliveryMethod < BaseModel - - validates :tulostustapa, inclusion: { in: %w(H E K L X) } validates :selite, uniqueness: true scope :permit_adr, -> { where(vak_kielto: '') } @@ -9,62 +7,84 @@ class DeliveryMethod < BaseModel self.table_name = :toimitustapa self.primary_key = :tunnus - def pickup_options - [ - ["Tilaukset toimitetaan asiakkaalle", ""], - ["Asiakas noutaa tilaukset", "o"] - ] - end - - def saturday_delivery_options - [ - ["Ei lauantaijakelua", ""], - ["Itella lisäpalvelu: Lauantaijakelu", "o"] - ] - end - - def transport_unit_options - [ - ["Ei kuljetusyksikkökuljetusta", ""], - ["Itella lisäpalvelu: Kuljetusyksikkökuljetus", "o"] - ] - end - - def carrier_options - #company.carriers.map { |i| [ i.nimi, i.koodi ] } - end - - def print_method_options - [ - ["Erätulostus", "E"], - ["Hetitulostus", "H"], - ["Koonti-hetitulostus", "K"], - ["Koonti-erätulostus", "L"], - ["Rahtikirjansyöttö ja -tulostus ohitetaan", "X"] - ] - end - - def freight_contract_options - [ - ["Käytetään lähettäjän rahtisopimusta", "K"], - ["Käytetään vastaanottajan rahtisopimusta", ""] - ] - end - - def logy_waybill_number_options - [ - ["Ei käytetä LOGY:n rahtikirjanumeroita", ""], - ["Käytetään LOGY:n rahtikirjanumeroita", "K"] - ] - end - - def extranet_options - [ - ["Toimitustapa näytetään vain myynnissä", ""], - ["Toimitustapa näytetään vain extranetissä", "K"], - ["Toimitustapa näytetään molemmissa", "M"] - ] - end + enum nouto: { + not_pickup: '', + pickup: 'o' + } + + enum lauantai: { + not_saturday_delivery: '', + saturday_delivery: 'o' + } + + enum kuljyksikko: { + not_transport_unit: '', + transport_unit: 'o' + } + + enum tulostustapa: { + batch: 'E', + instant: 'H', + collective_instant: 'K', + collective_batch: 'L', + skip_print: 'X' + } + + enum merahti: { + sender_freight_contract: 'K', + receiver_freight_contract: '' + } + + enum logy_rahtikirjanumerot: { + not_using_logy_waybill_numbers: '', + use_logy_waybill_numbers: 'K' + } + + enum extranet: { + only_in_sales: '', + only_in_extranet: 'K', + both_in_sales_and_extranet: 'M' + } + + enum kontti: { + includes_container: '1', + not_including_container: '0' + } + + enum jvkielto: { + cash_on_delivery_permitted: '', + cash_on_delivery_prohibition: 'o' + } + + enum erikoispakkaus_kielto: { + special_packaging_permitted: '', + special_packaging_prohibition: 'K' + } + + enum ei_pakkaamoa: { + reserve_packing_line: '0', + not_reserving_packing_line: '1' + } + + enum erittely: { + no_waybill_specification: '', + print_waybill_specification: 't', + print_waybill_specification_per_customer: 'k' + } + + enum uudet_pakkaustiedot: { + package_info_entry_denied: '', + package_info_entry_allowed: 'K' + } + + enum kuljetusvakuutus_tyyppi: { + use_company_default: '', + no_transportation_insurance: 'E', + currency_based_insurance: 'A', + percentage_based_insurance: 'B', + currency_based_insurance_with_discount: 'F', + percentage_based_insurance_with_discount: 'G' + } def waybill_options company.keywords.waybills.map { |i| [ i.selitetark, i.selite ] } @@ -104,20 +124,6 @@ def sorting_point_options company.keywords.sorting_points.map { |i| [ i.selitetark, i.selite ] } end - def container_options - [ - ["Kyllä", "1"], - ["Ei", "0"] - ] - end - - def cash_on_delivery_prohibition_options - [ - ["Toimitustavalla saa toimittaa jälkivaatimuksia", ""], - ["Toimitustavalla ei saa toimittaa jälkivaatimuksia", "o"] - ] - end - def adr_options(text) DeliveryMethod.permit_adr.shipment.map do |i| [ "#{text} #{i.selite}", i.selite ] @@ -139,50 +145,12 @@ def alternative_adr_delivery_method_options ].reject {|i,_| i.empty?} end - def special_packaging_prohibition_options - [ - ["Toimitustavalla saa toimittaa erikoispakkauksia", ""], - ["Toimitustavalla ei saa toimittaa erikoispakkauksia", "K"] - ] - end - - def packing_area_prohibition_options - [ - ["Toimitustavan tilaukset varaavat pakkaamolokeron", "0"], - ["Toimitustavan tilaukaset eivät varaa pakkaamolokeroa", "1"] - ] - end - - def waybill_specification_options - [ - ["Toimitustavalle ei tulosteta rahtikirjaerittelyä", ""], - ["Toimitustavalle tulostetaan rahtikirjaerittely", "t"], - ["Toimitustavalle tulostetaan rahtikirjaerittely per asiakas", "k"] - ] - end - - def new_packaging_information_options - [ - ["Koonti-erätulostuksessa ei voi syöttää uusia pakkaustietoja ennen tulostusta", ""], - ["Koonti-erätulostuksessa voi syöttää uudet pakkaustiedot ennen tulostusta", "K"] - ] - end - def permitted_packaging_options [] end - def transportation_insurance_type_options - [ - ["Yhtiön oletus", ""], - ["Ei kuljetusvakuutusta", "E"], - ["Valuuttamääräinen kuljetusvakuutus lisätään", "A"], - ["Prosentuaalinen kuljetusvakuutus lisätään", "B"], - ["Valuuttamääräinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen - asiakashintaa ja alennusta", "F"], - ["Prosentuaalinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen - asiakasalennusta", "G"] - ] + def carrier_options + #company.carriers.map { |i| [ i.nimi, i.koodi ] } end def official_legend_options From ae94abca534b10a583445f34ba5d810b072dcdfe Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 10:26:38 +0300 Subject: [PATCH 011/189] add translations --- config/locales/fi.yml | 56 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/config/locales/fi.yml b/config/locales/fi.yml index b1a0a8340..61bd55e35 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -381,6 +381,58 @@ fi: not_cumulative: Ei update: update_success: Taso päivitettiin onnistuneesti + deliver_methods: + pickup_options: + not_pickup: Tilaukset toimitetaan asiakkaalle + pickup: Asiakas noutaa tilaukset + saturday_delivery_options: + not_saturday_delivery: Ei lauantaijakelua + saturday_delivery: Itella lisäpalvelu - Lauantaijakelu + transport_unit_options: + not_transport_unit: Ei kuljetusyksikkökuljetusta + transport_unit: Itella lisäpalvelu - Kuljetusyksikkökuljetus + print_method_options: + batch: Erätulostus + instant: Hetitulostus + collective_instant: Koonti-hetitulostus + collective_batch: Koonti-erätulostus + skip_print: Rahtikirjansyöttö ja -tulostus ohitetaan + freight_contract_options: + sender_freight_contract: Käytetään lähettäjän rahtisopimusta + receiver_freight_contract: Käytetään vastaanottajan rahtisopimusta + logy_waybill_number_options: + not_using_logy_waybill_numbers: Ei käytetä LOGY-rahtikirjanumeroita + use_logy_waybill_numbers: Käytetään LOGY-rahtikirjanumeroita + extranet_options: + only_in_sales: Toimitustapa näytetään vain myynnissä + only_in_extranet: Toimitustapa näytetään vain extranetissä + both_in_sales_and_extranet: Toimitustapa näytetään molemmissa + container_options: + includes_container: Kyllä + not_including_container: Ei + cash_on_delivery_prohibition_options: + cash_on_delivery_permitted: Toimitustavalla saa toimittaa jälkivaatimuksia + cash_on_delivery_prohibition: Toimitustavalla ei saa toimittaa jälkivaatimuksia + special_packaging_prohibition_options: + special_packaging_permitted: Toimitustavalla saa toimittaa erikoispakkauksia + special_packaging_prohibition: Toimitustavalla ei saa toimittaa erikoispakkauksia + packing_line_prohibition_options: + reserve_packing_line: Toimitustavan tilaukset varaavat pakkaamolokeron + not_reserving_packing_line: Toimitustavan tilaukaset eivät varaa pakkaamolokeroa + waybill_specification_options: + no_waybill_specification: Toimitustavalle ei tulosteta rahtikirjaerittelyä + print_waybill_specification: Toimitustavalle tulostetaan rahtikirjaerittely + print_waybill_specification_per_customer: Toimitustavalle tulostetaan rahtikirjaerittely per asiakas + new_packaging_information_options: + package_info_entry_denied: Koonti-erätulostuksessa ei voi syöttää uusia pakkaustietoja ennen tulostusta + package_info_entry_allowed: Koonti-erätulostuksessa voi syöttää uudet pakkaustiedot ennen tulostusta + transportation_insurance_type_options: + use_company_default: Yhtiön oletus + no_transportation_insurance: Ei kuljetusvakuutusta + currency_based_insurance: Valuuttamääräinen kuljetusvakuutus lisätään + percentage_based_insurance: Prosentuaalinen kuljetusvakuutus lisätään + currency_based_insurance_with_discount: Valuuttamääräinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen asiakashintaa ja alennusta + percentage_based_insurance_with_discount: Prosentuaalinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen asiakasalennusta terms_of_payments: cash_options: cash: Käteismaksuehto, käteinen pyöristetään @@ -421,7 +473,7 @@ fi: - pe - la abbr_month_names: - - + - - tammi - helmi - maalis @@ -447,7 +499,7 @@ fi: long: "%A %e. %Bta %Y" short: "%d %b" month_names: - - + - - tammikuu - helmikuu - maaliskuu From ac238adb63d11c074e837d89322af3062d3fd9a1 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 10:26:58 +0300 Subject: [PATCH 012/189] remove unnecessary tests --- test/models/delivery_method_test.rb | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 01a02f02c..810228c3f 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -14,17 +14,4 @@ def setup @delivery_method.selite = "Kiitolinja" refute @delivery_method.valid?, "Delivery method already exists" end - - test "should not allow unifaun with build patch print" do - @delivery_method.tulostustapa = "L" - @delivery_method.rahtikirja = "rahtikirja_unifaun_foo_bar" - - refute @delivery_method.valid?, @delivery_method.errors.messages - end - - test "should allow unifaun" do - @delivery_method.tulostustapa = "H" - @delivery_method.rahtikirja = "rahtikirja_unifaun_foo_bar" - assert @delivery_method.valid?, @delivery_method.errors.messages - end end From 183853d9a17da8da3a46d4cff35f0c1b6aedff0b Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 11:31:15 +0300 Subject: [PATCH 013/189] fix typo --- config/locales/fi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 61bd55e35..b27d2bd95 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -381,7 +381,7 @@ fi: not_cumulative: Ei update: update_success: Taso päivitettiin onnistuneesti - deliver_methods: + delivery_methods: pickup_options: not_pickup: Tilaukset toimitetaan asiakkaalle pickup: Asiakas noutaa tilaukset From d10ff1dd6b1c9cd988856a1eb9390c4624007b7f Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 11:32:00 +0300 Subject: [PATCH 014/189] move official legends to separate class --- app/classes/postal_official_legend.rb | 247 ++++++++++++++++++++ app/models/delivery_method.rb | 246 ------------------- test/classes/postal_official_legend_test.rb | 8 + 3 files changed, 255 insertions(+), 246 deletions(-) create mode 100644 app/classes/postal_official_legend.rb create mode 100644 test/classes/postal_official_legend_test.rb diff --git a/app/classes/postal_official_legend.rb b/app/classes/postal_official_legend.rb new file mode 100644 index 000000000..ee961922e --- /dev/null +++ b/app/classes/postal_official_legend.rb @@ -0,0 +1,247 @@ +class PostalOfficialLegend + def self.options + { + "Ei valintaa": "", + "Pupesoft / Itella": { + "Express City 00": "Itella Express City 00", + "Express Morning 9": "Itella Express Morning 9", + "Express Business Day 14": "Itella Express Business Day 14", + "Express Point 00/16": "Itella Express Point 00/16", + "Express Flex 21": "Itella Express Flex 21", + "Economy 16": "Itella Economy 16", + "Customer Return": "Itella Customer Return", + "Undelivered Shipment": "Itella Undelivered Shipment", + "Lisäarvokuljetus": "Itella Lisäarvokuljetus", + "Priority Ulkomaa": "Itella Priority Ulkomaan lähetys" + }, + "Unifaun / Itella": { + "ITELLAMAILEC": "Itella Economy Letter", + "IT16": "Itella Economy Parcel", + "IT14": "Itella Express Business Day", + "ITKY14": "Itella Express Business Day kuljetusyksikkö", + "ITKY14I": "Itella Express Business Day pallet (Ulkomaa)", + "IT14I": "Itella Express Business Day parcel (Ulkomaa)", + "ITEXPC": "Itella Express City", + "ITKYEXPC": "Itella Express City kuljetusyksikkö", + "IT21": "Itella Express Flex", + "ITKY21": "Itella Express Flex kuljetusyksikkö", + "IT09": "Itella Express Morning", + "ITKY09": "Itella Express Morning kuljetusyksikkö", + "TPSTD": "Itella Logistics Oy, Kappaletavara", + "ITELLALOGKR": "Itella Logistics Oy, Kotimaan Rahti", + "ITELLAMAILPR": "Itella Priority Letter", + "ITPR": "Itella Priority Parcel", + "ITSP": "Itella SmartPOST", + "ITVAK": "Itella VAK/ADR", + "ITKYVAK": "Itella VAK/ADR kuljetusyksikkö" + }, + "Unifaun / Bring": { + "PNL359": "Bring CarryOn Budget", + "PNL330": "Bring CarryOn Business", + "PNL335": "Bring CarryOn Business 09.00", + "PNL333": "Bring CarryOn Business BulkReturn", + "PNL332": "Bring CarryOn Business BulkSplit", + "PNL334": "Bring CarryOn Business BulkSplit 09.00", + "PNL336": "Bring CarryOn Business Pallet", + "PNL339": "Bring CarryOn Business Pallet 09.00", + "PNL331": "Bring CarryOn Business Return", + "PNL340": "Bring CarryOn HomeShopping", + "PNL343": "Bring CarryOn HomeShopping BulkReturn", + "PNL342": "Bring CarryOn HomeShopping BulkSplit", + "PNL349": "Bring CarryOn HomeShopping BulkSplit Home", + "PNL345": "Bring CarryOn HomeShopping BulkSplit Mini", + "PNL341": "Bring CarryOn HomeShopping Return", + "PNLWAY": "Bring CarryOn Waybill", + "BOXBD": "Bring Express Business Distribution", + "BOXBDP": "Bring Express Business Distribution Pallet", + "BOXCA": "Bring Express Courier Ad-Hoc", + "BOXCD": "Bring Express Courier Distribution", + "BOXHD": "Bring Express Home Delivery", + "BOXHDR": "Bring Express Home Delivery Return", + "BOXQP": "Bring Express QuickPack", + "BOXSHD": "Bring Express Store Home Delivery", + "BOXSHDR": "Bring Express Store Home Delivery Return" + }, + "Unifaun / Dachser": { + "DACTFIX": "Dachser Targofix", + "DACTFIX10": "Dachser Targofix 10:00", + "DACTFIX12": "Dachser Targofix 12:00", + "DACTFLEX": "Dachser Targoflex", + "DACTSPEED": "Dachser Targospeed", + "DACTSPEED10": "Dachser Targospeed 10:00", + "DACTSPEED12": "Dachser Targospeed 12:00", + "DACTSPEEDPLUS": "Dachser Targospeed Plus" + }, + "Unifaun / DANX": { + "DANXSTD": "DANX" + }, + "Unifaun / DB Schenker": { + "SBTLFIEXP": "DB SCHENKER Express (Finland)", + "SBTLFISY": "DB SCHENKER Finland System", + "BBU": "DB SCHENKERbudget", + "BCSI": "DB SCHENKERcoldsped - Europa", + "BCS": "DB SCHENKERcoldsped - Sverige", + "BDI": "DB SCHENKERdirect", + "BPA": "DB SCHENKERparcel", + "BPHDP": "DB SCHENKERprivpak - Hem Dag (utan avisering och kvittens)", + "BPHDAP": "DB SCHENKERprivpak - Hem Dag med avisering (och kvittens) (Paket)", + "BPHKAP": "DB SCHENKERprivpak - Hem Kväll med avisering (och kvittens)", + "BHP": "DB SCHENKERprivpak - Ombud Standard (1 kolli, <20 kg)", + "BPOSG": "DB SCHENKERprivpak - Terminal", + "BPTJP": "DB SCHENKERprivpak - Till Jobbet", + "BCF": "DB SCHENKERsystem" + }, + "Unifaun / DHL": { + "ASU": "DHL Euroconnect", + "ASUP": "DHL Euroconnect Plus", + "DASECD": "DHL Express 09:00 (Tullinalainen)", + "DASE": "DHL Express 09:00 (Tullivapaa)", + "DATDM": "DHL Express 10:30 (Tullinalainen)", + "DATDL": "DHL Express 10:30 (Tullivapaa)", + "DAMECD": "DHL Express 12:00 (Tullinalainen)", + "DAME": "DHL Express 12:00 (Tullivapaa)", + "DAXPD": "DHL Express Envelope (Tullivapaa)", + "DADOM": "DHL Express Worldwide (Kotimaa)", + "DAWPX": "DHL Express Worldwide (Tullinalainen)", + "DAECX": "DHL Express Worldwide (Tullivapaa EU: ssa)", + "DADOX": "DHL Express Worldwide (Tullivapaa, Ei-EU)", + "DHLFREIGHTESTDOM": "DHL Freight Domestic EE", + "DHLFREIGHTESTEC": "DHL Freight Euroconnect EE", + "DHLFREIGHTFIEC": "DHL Freight Euroconnect FI", + "DHLFREIGHTFIKT": "DHL Freight Kotimaa", + "DGFAIR": "DHL Global Forwarding Air Freight", + "DGFAIRPLUS": "DHL Global Forwarding Air Freight PLUS", + "AEX": "DHL Paket", + "ASP2": "DHL Pall", + "ASWP2": "DHL Parti", + "ASPO": "DHL Service Point", + "ASPOC": "DHL Service Point C.O.D.", + "ASPOR": "DHL Service Point Retur", + "ASWS2": "DHL Stycke", + "ASWP": "DHL Swednet Partigods", + "ASWS": "DHL Swednet Styckegods" + }, + "Unifaun / DSV": { + "DSVFIGRP": "DSV Road Kappaletavara", + "DSVFIFULL": "DSV Road Osakuorma" + }, + "Unifaun / Fennoway": { + "FENNORAHTI": "Fennoway Fennorahti" + }, + "Unifaun / GLS": { + "GLSFIINT": "GLS Suomi INTERNATIONAL" + }, + "Unifaun / Kaukokiito": { + "KKSTD": "Kaukokiito" + }, + "Unifaun / Kiitolinja": { + "KLGRP": "KIITOLINJA kappaletavara" + }, + "Unifaun / KN Road": { + "KUEHNENAGELROAD": "KN Road" + }, + "Unifaun / Tyvi": { + "KTYVI": "Kuljetusliike Tyvi Oy" + }, + "Unifaun / Matkahuolto": { + "MH68": "Matkahuolto Ahvenanmaan Jakopaketti", + "MH63": "Matkahuolto Baltian Paketti", + "MH10": "Matkahuolto Bussipaketti", + "MH43": "Matkahuolto Dokumenttikuori", + "MH3050": "Matkahuolto Jakopaketti/Paikallispaketti", + "MH57": "Matkahuolto Lavarahti", + "MH81": "Matkahuolto Lähellä-paketin palautus", + "MH80": "Matkahuolto Lähellä-paketti", + "MH75": "Matkahuolto Mannermaan Jakopaketti", + "MH74": "Matkahuolto Mannermaan Paketti", + "MH20": "Matkahuolto Pikapaketti", + "MH82": "Matkahuolto Postaalipaketti", + "MH83": "Matkahuolto Postaalipaketti palautus", + "MH40": "Matkahuolto Rahtipussi", + "MH42": "Matkahuolto Rahtipussi jakopaketti" + }, + "Unifaun / Neutraali": { + "FREEG": "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja)", + "FREEG_793": "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja): Transpori Oy", + "FREEG_794": "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja): AJ Laine Oy", + "FREEB": "Neutraali Kirjepalvelu", + "FREEP": "Neutraali pakettipalvelu (osoitekortti)" + }, + "Unifaun / Posten Brev": { + "PAF": "Posten Brev - Brevpostförskott", + "BEXPD": "Posten Brev - Express (kotimaa)", + "BREV": "Posten Brev - Normaali", + "BEXPI": "Posten Brev - Priority+", + "BVAL": "Posten Brev - Värde", + "BREKD": "Posten Brev Kirjattu kirje (BREKD)", + "BREKI": "Posten Brev Kirjattu kirje (BREKI)", + "EMSD2": "Posten EMS (brev/dokument)", + "EMSP2": "Posten EMS (paket/varor)" + }, + "Unifaun / PostNord": { + "DPDFI": "PostNord DPD Classic (Suomi)", + "P15": "PostNord Logistics DPD Företagspaket", + "P14": "PostNord Logistics DPD Företagspaket 12.00", + "DPD": "PostNord Logistics DPD Utrikes", + "P42": "PostNord Logistics Express - Express 07.00", + "P32": "PostNord Logistics Hempaket", + "DTPGHD": "PostNord Logistics Hjemlevering (Norge)", + "H48": "PostNord Logistics InNight", + "P31": "PostNord Logistics Kundretur", + "P19": "PostNord Logistics MyPack", + "P19FI": "PostNord Logistics MyPack (Suomi)", + "P19NO": "PostNord Logistics MyPack (Norja)", + "P24": "PostNord Logistics MyPack return", + "P24FI": "PostNord Logistics MyPack return (Suomi)", + "P24NO": "PostNord Logistics MyPack Return (Norja)", + "P52": "PostNord Logistics PALL.ETT", + "DTPGPF": "PostNord Logistics Partifrakt (Norja)", + "P91": "PostNord Logistics Postpaket Utrikes", + "DTPGSG": "PostNord Logistics Stykkgods (Norja)" + }, + "Unifaun / Privpak": { + "PPFITRRET": "Privpak Finland (normaali & palautus)", + "PPFITR": "Privpak Finland (normaali)" + }, + "Unifaun / R & P": { + "RPPP": "R & P Kuljetus Pakettipalvelu" + }, + "Unifaun / TK Logistik": { + "TKLOGGODS": "TK Logistik Gods" + }, + "Unifaun / TNT": { + "TNT08DOMD": "TNT 08:00 Express (Domestic Docs)", + "TNT08DOMN": "TNT 08:00 Express (Domestic Non Docs)", + "TNT09D": "TNT 09:00 Express (Docs)", + "TNT09DOMD": "TNT 09:00 Express (Domestic Docs)", + "TNT09DOMN": "TNT 09:00 Express (Domestic Non Docs)", + "TNT09": "TNT 09:00 Express (Domestic)", + "TNT09N": "TNT 09:00 Express (Non Docs)", + "TNT10D": "TNT 10:00 Express (Docs)", + "TNT10DOMD": "TNT 10:00 Express (Domestic Docs)", + "TNT10DOMN": "TNT 10:00 Express (Domestic Non Docs)", + "TNT10": "TNT 10:00 Express (Domestic)", + "TNT10N": "TNT 10:00 Express (Non Docs)", + "TNT412": "TNT 12:00 Economy Express (Non Docs)", + "TNT12D": "TNT 12:00 Express (Docs)", + "TNT12DOMD": "TNT 12:00 Express (Domestic Docs)", + "TNT12DOMN": "TNT 12:00 Express (Domestic Non Docs)", + "TNT12": "TNT 12:00 Express (Domestic)", + "TNT12N": "TNT 12:00 Express (Non Docs)", + "TNT48N": "TNT Economy Express (Non Docs)", + "TNT15D": "TNT Express (Docs)", + "TNT15DOMD": "TNT Express (Domestic Docs)", + "TNT15DOMN": "TNT Express (Domestic Non Docs)", + "TNT15": "TNT Express (Domestic)", + "TNT15N": "TNT Express (Non Docs)", + "TNT728": "TNT Special Economy Express" + }, + "Unifaun / UPK": { + "UPKE": "Uudenmaan Pikakuljetus Oy Erikoisaikataulu", + "UPKK": "Uudenmaan Pikakuljetus Oy Kotijakelu", + "UPK24": "Uudenmaan Pikakuljetus Oy Normal 24h", + "UPK24A": "Uudenmaan Pikakuljetus Oy Normal 24h AVI" + } + } + end +end diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 0ff462e5b..3ae4471ad 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -152,250 +152,4 @@ def permitted_packaging_options def carrier_options #company.carriers.map { |i| [ i.nimi, i.koodi ] } end - - def official_legend_options - { - "Ei valintaa": "", - "Pupesoft / Itella": { - "Express City 00": "Itella Express City 00", - "Express Morning 9": "Itella Express Morning 9", - "Express Business Day 14": "Itella Express Business Day 14", - "Express Point 00/16": "Itella Express Point 00/16", - "Express Flex 21": "Itella Express Flex 21", - "Economy 16": "Itella Economy 16", - "Customer Return": "Itella Customer Return", - "Undelivered Shipment": "Itella Undelivered Shipment", - "Lisäarvokuljetus": "Itella Lisäarvokuljetus", - "Priority Ulkomaa": "Itella Priority Ulkomaan lähetys" - }, - "Unifaun / Itella": { - "ITELLAMAILEC": "Itella Economy Letter", - "IT16": "Itella Economy Parcel", - "IT14": "Itella Express Business Day", - "ITKY14": "Itella Express Business Day kuljetusyksikkö", - "ITKY14I": "Itella Express Business Day pallet (Ulkomaa)", - "IT14I": "Itella Express Business Day parcel (Ulkomaa)", - "ITEXPC": "Itella Express City", - "ITKYEXPC": "Itella Express City kuljetusyksikkö", - "IT21": "Itella Express Flex", - "ITKY21": "Itella Express Flex kuljetusyksikkö", - "IT09": "Itella Express Morning", - "ITKY09": "Itella Express Morning kuljetusyksikkö", - "TPSTD": "Itella Logistics Oy, Kappaletavara", - "ITELLALOGKR": "Itella Logistics Oy, Kotimaan Rahti", - "ITELLAMAILPR": "Itella Priority Letter", - "ITPR": "Itella Priority Parcel", - "ITSP": "Itella SmartPOST", - "ITVAK": "Itella VAK/ADR", - "ITKYVAK": "Itella VAK/ADR kuljetusyksikkö" - }, - "Unifaun / Bring": { - "PNL359": "Bring CarryOn Budget", - "PNL330": "Bring CarryOn Business", - "PNL335": "Bring CarryOn Business 09.00", - "PNL333": "Bring CarryOn Business BulkReturn", - "PNL332": "Bring CarryOn Business BulkSplit", - "PNL334": "Bring CarryOn Business BulkSplit 09.00", - "PNL336": "Bring CarryOn Business Pallet", - "PNL339": "Bring CarryOn Business Pallet 09.00", - "PNL331": "Bring CarryOn Business Return", - "PNL340": "Bring CarryOn HomeShopping", - "PNL343": "Bring CarryOn HomeShopping BulkReturn", - "PNL342": "Bring CarryOn HomeShopping BulkSplit", - "PNL349": "Bring CarryOn HomeShopping BulkSplit Home", - "PNL345": "Bring CarryOn HomeShopping BulkSplit Mini", - "PNL341": "Bring CarryOn HomeShopping Return", - "PNLWAY": "Bring CarryOn Waybill", - "BOXBD": "Bring Express Business Distribution", - "BOXBDP": "Bring Express Business Distribution Pallet", - "BOXCA": "Bring Express Courier Ad-Hoc", - "BOXCD": "Bring Express Courier Distribution", - "BOXHD": "Bring Express Home Delivery", - "BOXHDR": "Bring Express Home Delivery Return", - "BOXQP": "Bring Express QuickPack", - "BOXSHD": "Bring Express Store Home Delivery", - "BOXSHDR": "Bring Express Store Home Delivery Return" - }, - "Unifaun / Dachser": { - "DACTFIX": "Dachser Targofix", - "DACTFIX10": "Dachser Targofix 10:00", - "DACTFIX12": "Dachser Targofix 12:00", - "DACTFLEX": "Dachser Targoflex", - "DACTSPEED": "Dachser Targospeed", - "DACTSPEED10": "Dachser Targospeed 10:00", - "DACTSPEED12": "Dachser Targospeed 12:00", - "DACTSPEEDPLUS": "Dachser Targospeed Plus" - }, - "Unifaun / DANX": { - "DANXSTD": "DANX" - }, - "Unifaun / DB Schenker": { - "SBTLFIEXP": "DB SCHENKER Express (Finland)", - "SBTLFISY": "DB SCHENKER Finland System", - "BBU": "DB SCHENKERbudget", - "BCSI": "DB SCHENKERcoldsped - Europa", - "BCS": "DB SCHENKERcoldsped - Sverige", - "BDI": "DB SCHENKERdirect", - "BPA": "DB SCHENKERparcel", - "BPHDP": "DB SCHENKERprivpak - Hem Dag (utan avisering och kvittens)", - "BPHDAP": "DB SCHENKERprivpak - Hem Dag med avisering (och kvittens) (Paket)", - "BPHKAP": "DB SCHENKERprivpak - Hem Kväll med avisering (och kvittens)", - "BHP": "DB SCHENKERprivpak - Ombud Standard (1 kolli, <20 kg)", - "BPOSG": "DB SCHENKERprivpak - Terminal", - "BPTJP": "DB SCHENKERprivpak - Till Jobbet", - "BCF": "DB SCHENKERsystem" - }, - "Unifaun / DHL": { - "ASU": "DHL Euroconnect", - "ASUP": "DHL Euroconnect Plus", - "DASECD": "DHL Express 09:00 (Tullinalainen)", - "DASE": "DHL Express 09:00 (Tullivapaa)", - "DATDM": "DHL Express 10:30 (Tullinalainen)", - "DATDL": "DHL Express 10:30 (Tullivapaa)", - "DAMECD": "DHL Express 12:00 (Tullinalainen)", - "DAME": "DHL Express 12:00 (Tullivapaa)", - "DAXPD": "DHL Express Envelope (Tullivapaa)", - "DADOM": "DHL Express Worldwide (Kotimaa)", - "DAWPX": "DHL Express Worldwide (Tullinalainen)", - "DAECX": "DHL Express Worldwide (Tullivapaa EU: ssa)", - "DADOX": "DHL Express Worldwide (Tullivapaa, Ei-EU)", - "DHLFREIGHTESTDOM": "DHL Freight Domestic EE", - "DHLFREIGHTESTEC": "DHL Freight Euroconnect EE", - "DHLFREIGHTFIEC": "DHL Freight Euroconnect FI", - "DHLFREIGHTFIKT": "DHL Freight Kotimaa", - "DGFAIR": "DHL Global Forwarding Air Freight", - "DGFAIRPLUS": "DHL Global Forwarding Air Freight PLUS", - "AEX": "DHL Paket", - "ASP2": "DHL Pall", - "ASWP2": "DHL Parti", - "ASPO": "DHL Service Point", - "ASPOC": "DHL Service Point C.O.D.", - "ASPOR": "DHL Service Point Retur", - "ASWS2": "DHL Stycke", - "ASWP": "DHL Swednet Partigods", - "ASWS": "DHL Swednet Styckegods" - }, - "Unifaun / DSV": { - "DSVFIGRP": "DSV Road Kappaletavara", - "DSVFIFULL": "DSV Road Osakuorma" - }, - "Unifaun / Fennoway": { - "FENNORAHTI": "Fennoway Fennorahti" - }, - "Unifaun / GLS": { - "GLSFIINT": "GLS Suomi INTERNATIONAL" - }, - "Unifaun / Kaukokiito": { - "KKSTD": "Kaukokiito" - }, - "Unifaun / Kiitolinja": { - "KLGRP": "KIITOLINJA kappaletavara" - }, - "Unifaun / KN Road": { - "KUEHNENAGELROAD": "KN Road" - }, - "Unifaun / Tyvi": { - "KTYVI": "Kuljetusliike Tyvi Oy" - }, - "Unifaun / Matkahuolto": { - "MH68": "Matkahuolto Ahvenanmaan Jakopaketti", - "MH63": "Matkahuolto Baltian Paketti", - "MH10": "Matkahuolto Bussipaketti", - "MH43": "Matkahuolto Dokumenttikuori", - "MH3050": "Matkahuolto Jakopaketti/Paikallispaketti", - "MH57": "Matkahuolto Lavarahti", - "MH81": "Matkahuolto Lähellä-paketin palautus", - "MH80": "Matkahuolto Lähellä-paketti", - "MH75": "Matkahuolto Mannermaan Jakopaketti", - "MH74": "Matkahuolto Mannermaan Paketti", - "MH20": "Matkahuolto Pikapaketti", - "MH82": "Matkahuolto Postaalipaketti", - "MH83": "Matkahuolto Postaalipaketti palautus", - "MH40": "Matkahuolto Rahtipussi", - "MH42": "Matkahuolto Rahtipussi jakopaketti" - }, - "Unifaun / Neutraali": { - "FREEG": "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja)", - "FREEG_793": "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja): Transpori Oy", - "FREEG_794": "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja): AJ Laine Oy", - "FREEB": "Neutraali Kirjepalvelu", - "FREEP": "Neutraali pakettipalvelu (osoitekortti)" - }, - "Unifaun / Posten Brev": { - "PAF": "Posten Brev - Brevpostförskott", - "BEXPD": "Posten Brev - Express (kotimaa)", - "BREV": "Posten Brev - Normaali", - "BEXPI": "Posten Brev - Priority+", - "BVAL": "Posten Brev - Värde", - "BREKD": "Posten Brev Kirjattu kirje (BREKD)", - "BREKI": "Posten Brev Kirjattu kirje (BREKI)", - "EMSD2": "Posten EMS (brev/dokument)", - "EMSP2": "Posten EMS (paket/varor)" - }, - "Unifaun / PostNord": { - "DPDFI": "PostNord DPD Classic (Suomi)", - "P15": "PostNord Logistics DPD Företagspaket", - "P14": "PostNord Logistics DPD Företagspaket 12.00", - "DPD": "PostNord Logistics DPD Utrikes", - "P42": "PostNord Logistics Express - Express 07.00", - "P32": "PostNord Logistics Hempaket", - "DTPGHD": "PostNord Logistics Hjemlevering (Norge)", - "H48": "PostNord Logistics InNight", - "P31": "PostNord Logistics Kundretur", - "P19": "PostNord Logistics MyPack", - "P19FI": "PostNord Logistics MyPack (Suomi)", - "P19NO": "PostNord Logistics MyPack (Norja)", - "P24": "PostNord Logistics MyPack return", - "P24FI": "PostNord Logistics MyPack return (Suomi)", - "P24NO": "PostNord Logistics MyPack Return (Norja)", - "P52": "PostNord Logistics PALL.ETT", - "DTPGPF": "PostNord Logistics Partifrakt (Norja)", - "P91": "PostNord Logistics Postpaket Utrikes", - "DTPGSG": "PostNord Logistics Stykkgods (Norja)" - }, - "Unifaun / Privpak": { - "PPFITRRET": "Privpak Finland (normaali & palautus)", - "PPFITR": "Privpak Finland (normaali)" - }, - "Unifaun / R & P": { - "RPPP": "R & P Kuljetus Pakettipalvelu" - }, - "Unifaun / TK Logistik": { - "TKLOGGODS": "TK Logistik Gods" - }, - "Unifaun / TNT": { - "TNT08DOMD": "TNT 08:00 Express (Domestic Docs)", - "TNT08DOMN": "TNT 08:00 Express (Domestic Non Docs)", - "TNT09D": "TNT 09:00 Express (Docs)", - "TNT09DOMD": "TNT 09:00 Express (Domestic Docs)", - "TNT09DOMN": "TNT 09:00 Express (Domestic Non Docs)", - "TNT09": "TNT 09:00 Express (Domestic)", - "TNT09N": "TNT 09:00 Express (Non Docs)", - "TNT10D": "TNT 10:00 Express (Docs)", - "TNT10DOMD": "TNT 10:00 Express (Domestic Docs)", - "TNT10DOMN": "TNT 10:00 Express (Domestic Non Docs)", - "TNT10": "TNT 10:00 Express (Domestic)", - "TNT10N": "TNT 10:00 Express (Non Docs)", - "TNT412": "TNT 12:00 Economy Express (Non Docs)", - "TNT12D": "TNT 12:00 Express (Docs)", - "TNT12DOMD": "TNT 12:00 Express (Domestic Docs)", - "TNT12DOMN": "TNT 12:00 Express (Domestic Non Docs)", - "TNT12": "TNT 12:00 Express (Domestic)", - "TNT12N": "TNT 12:00 Express (Non Docs)", - "TNT48N": "TNT Economy Express (Non Docs)", - "TNT15D": "TNT Express (Docs)", - "TNT15DOMD": "TNT Express (Domestic Docs)", - "TNT15DOMN": "TNT Express (Domestic Non Docs)", - "TNT15": "TNT Express (Domestic)", - "TNT15N": "TNT Express (Non Docs)", - "TNT728": "TNT Special Economy Express" - }, - "Unifaun / UPK": { - "UPKE": "Uudenmaan Pikakuljetus Oy Erikoisaikataulu", - "UPKK": "Uudenmaan Pikakuljetus Oy Kotijakelu", - "UPK24": "Uudenmaan Pikakuljetus Oy Normal 24h", - "UPK24A": "Uudenmaan Pikakuljetus Oy Normal 24h AVI" - } - } - end end diff --git a/test/classes/postal_official_legend_test.rb b/test/classes/postal_official_legend_test.rb new file mode 100644 index 000000000..831929c2d --- /dev/null +++ b/test/classes/postal_official_legend_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class PostalOfficialLegendTest < ActiveSupport::TestCase + test 'should get proper legend' do + legends = PostalOfficialLegend.options + assert_equal 'Itella Express City 00', legends[:"Pupesoft / Itella"][:"Express City 00"] + end +end From e82047e379ee6a86d41cf0769c347dece4006758 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 11:33:07 +0300 Subject: [PATCH 015/189] helper tests --- ...ds_helper.rb => delivery_method_helper.rb} | 4 +- test/helpers/delivery_method_helper_test.rb | 115 ++++++++++++++++++ 2 files changed, 117 insertions(+), 2 deletions(-) rename app/helpers/{delivery_methods_helper.rb => delivery_method_helper.rb} (96%) create mode 100644 test/helpers/delivery_method_helper_test.rb diff --git a/app/helpers/delivery_methods_helper.rb b/app/helpers/delivery_method_helper.rb similarity index 96% rename from app/helpers/delivery_methods_helper.rb rename to app/helpers/delivery_method_helper.rb index e5eb2f06a..4747a63d3 100644 --- a/app/helpers/delivery_methods_helper.rb +++ b/app/helpers/delivery_method_helper.rb @@ -1,4 +1,4 @@ -module DeliveryMethodsHelper +module DeliveryMethodHelper ROOT = 'administration.delivery_methods' def pickup_options @@ -68,7 +68,7 @@ def packing_line_prohibition_options end def waybill_specification_options - DeliveryMethod.erittelys.map do |key,_| + DeliveryMethod.erittelies.map do |key,_| [ t("#{ROOT}.waybill_specification_options.#{key}"), key ] end end diff --git a/test/helpers/delivery_method_helper_test.rb b/test/helpers/delivery_method_helper_test.rb new file mode 100644 index 000000000..eefa9d7ae --- /dev/null +++ b/test/helpers/delivery_method_helper_test.rb @@ -0,0 +1,115 @@ +require 'test_helper' + +class DeliveryMethodHelperTest < ActionView::TestCase + test "returns translated pickup options valid for collection" do + assert pickup_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.pickup_options.not_pickup', :fi + assert_equal text, pickup_options.first.first + assert_equal 'not_pickup', pickup_options.first.second + end + + test "returns translated saturday delivery options valid for collection" do + assert saturday_delivery_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.saturday_delivery_options.saturday_delivery', :fi + assert_equal text, saturday_delivery_options.second.first + assert_equal 'saturday_delivery', saturday_delivery_options.second.second + end + + test "returns translated transport unit options valid for collection" do + assert transport_unit_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.transport_unit_options.transport_unit', :fi + assert_equal text, transport_unit_options.second.first + assert_equal 'transport_unit', transport_unit_options.second.second + end + + test "returns translated print method options valid for collection" do + assert print_method_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.print_method_options.batch', :fi + assert_equal text, print_method_options.first.first + assert_equal 'batch', print_method_options.first.second + end + + test "returns translated freight contract options valid for collection" do + assert freight_contract_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.freight_contract_options.sender_freight_contract', :fi + assert_equal text, freight_contract_options.first.first + assert_equal 'sender_freight_contract', freight_contract_options.first.second + end + + test "returns translated logy waybill number options valid for collection" do + assert logy_waybill_number_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.logy_waybill_number_options.use_logy_waybill_numbers', :fi + assert_equal text, logy_waybill_number_options.second.first + assert_equal 'use_logy_waybill_numbers', logy_waybill_number_options.second.second + end + + test "returns translated extranet options valid for collection" do + assert extranet_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.extranet_options.only_in_sales', :fi + assert_equal text, extranet_options.first.first + assert_equal 'only_in_sales', extranet_options.first.second + end + + test "returns translated container options valid for collection" do + assert container_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.container_options.includes_container', :fi + assert_equal text, container_options.first.first + assert_equal 'includes_container', container_options.first.second + end + + test "returns translated cash on delivery prohibition options valid for collection" do + assert cash_on_delivery_prohibition_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.cash_on_delivery_prohibition_options.cash_on_delivery_permitted', :fi + assert_equal text, cash_on_delivery_prohibition_options.first.first + assert_equal 'cash_on_delivery_permitted', cash_on_delivery_prohibition_options.first.second + end + + test "returns translated special packaging prohibition options valid for collection" do + assert special_packaging_prohibition_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.special_packaging_prohibition_options.special_packaging_permitted', :fi + assert_equal text, special_packaging_prohibition_options.first.first + assert_equal 'special_packaging_permitted', special_packaging_prohibition_options.first.second + end + + test "returns translated packing line prohibition options valid for collection" do + assert packing_line_prohibition_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.packing_line_prohibition_options.reserve_packing_line', :fi + assert_equal text, packing_line_prohibition_options.first.first + assert_equal 'reserve_packing_line', packing_line_prohibition_options.first.second + end + + test "returns translated waybill specification options valid for collection" do + assert waybill_specification_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.waybill_specification_options.print_waybill_specification', :fi + assert_equal text, waybill_specification_options.second.first + assert_equal 'print_waybill_specification', waybill_specification_options.second.second + end + + test "returns translated new packaging information options for collection" do + assert new_packaging_information_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.new_packaging_information_options.package_info_entry_denied', :fi + assert_equal text, new_packaging_information_options.first.first + assert_equal 'package_info_entry_denied', new_packaging_information_options.first.second + end + + test "returns translated transportation insurance type options for collection" do + assert transportation_insurance_type_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.transportation_insurance_type_options.currency_based_insurance', :fi + assert_equal text, transportation_insurance_type_options.third.first + assert_equal 'currency_based_insurance', transportation_insurance_type_options.third.second + end +end From cc40d11b6774e164ed351d5332f260a44032ca38 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 12:45:02 +0300 Subject: [PATCH 016/189] use STI for waybill keywords --- app/models/keyword.rb | 7 ++----- app/models/keyword/waybill.rb | 6 ++++++ 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 app/models/keyword/waybill.rb diff --git a/app/models/keyword.rb b/app/models/keyword.rb index 4f147f3d9..f4ffa1bb4 100644 --- a/app/models/keyword.rb +++ b/app/models/keyword.rb @@ -1,10 +1,6 @@ class Keyword < BaseModel include PupenextSingleTableInheritance - def self.waybills - where(laji: "RAHTIKIRJA") - end - def self.mode_of_transports where(laji: "KM") end @@ -35,7 +31,8 @@ def self.child_class_names { 'ALV' => Keyword::Vat, 'ALVULK' => Keyword::ForeignVat, - 'MAKSUEHTOKV' => Keyword::TermsOfPaymentTranslation + 'MAKSUEHTOKV' => Keyword::TermsOfPaymentTranslation, + 'RAHTIKIRJA' => Keyword::Waybill } end end diff --git a/app/models/keyword/waybill.rb b/app/models/keyword/waybill.rb new file mode 100644 index 000000000..a7dfe17e0 --- /dev/null +++ b/app/models/keyword/waybill.rb @@ -0,0 +1,6 @@ +class Keyword::Waybill < Keyword + # Rails requires sti_name method to return type column (laji) value + def self.sti_name + 'RAHTIKIRJA' + end +end From 66bf709512145632a9b3f9f5c92dca0fd0c55e52 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 12:46:19 +0300 Subject: [PATCH 017/189] add waybill keyword --- test/fixtures/keywords.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/fixtures/keywords.yml b/test/fixtures/keywords.yml index 55e96f99b..43c426052 100644 --- a/test/fixtures/keywords.yml +++ b/test/fixtures/keywords.yml @@ -17,6 +17,16 @@ foreign_vat: luontiaika: <%= Time.now %> muutospvm: <%= Time.now %> +foreign_vat: + yhtio: acme + selite: rahtikirja.inc + selitetark: Yleisrahtikirja A4 teksti + laji: RAHTIKIRJA + muuttaja: joe + laatija: joe + luontiaika: <%= Time.now %> + muutospvm: <%= Time.now %> + top_locale_se: yhtio: acme selite: <%= ActiveRecord::FixtureSet.identify(:sixty_days_net) %> From d701dc9e4e3193d525bea00fb27ca19480e4dc70 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 12:47:00 +0300 Subject: [PATCH 018/189] fix waybill keyword options --- app/models/delivery_method.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 3ae4471ad..624fc203a 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -87,7 +87,7 @@ class DeliveryMethod < BaseModel } def waybill_options - company.keywords.waybills.map { |i| [ i.selitetark, i.selite ] } + Keyword::Waybill.all.map { |i| [ i.selitetark, i.selite ] } end def label_options From f3f09b7b796f2e14494d837e9a81ad30b47b1f84 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 12:47:30 +0300 Subject: [PATCH 019/189] test waybill keyword --- test/models/delivery_method_test.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 810228c3f..a53f052a3 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -14,4 +14,9 @@ def setup @delivery_method.selite = "Kiitolinja" refute @delivery_method.valid?, "Delivery method already exists" end + + test "should get waybill options" do + assert_kind_of Array, @delivery_method.waybill_options + assert_operator 0, '<', @delivery_method.waybill_options.count + end end From e43e9051d2c2eb0200f17eee0e32fcaa180640d7 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 13:02:26 +0300 Subject: [PATCH 020/189] fix fixtures --- test/fixtures/delivery_methods.yml | 2 +- test/fixtures/keywords.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/fixtures/delivery_methods.yml b/test/fixtures/delivery_methods.yml index ce729e68b..262ad439a 100644 --- a/test/fixtures/delivery_methods.yml +++ b/test/fixtures/delivery_methods.yml @@ -2,7 +2,7 @@ kaukokiito: yhtio: acme selite: Kaukokiito tulostustapa: H - rahtikirja: rahtikirja_pdf.inc + rahtikirja: rahtikirja.inc rahdinkuljettaja: Kaukokiito laatija: 'joe' luontiaika: <%= Date.today %> diff --git a/test/fixtures/keywords.yml b/test/fixtures/keywords.yml index 43c426052..6d2ff9910 100644 --- a/test/fixtures/keywords.yml +++ b/test/fixtures/keywords.yml @@ -17,10 +17,10 @@ foreign_vat: luontiaika: <%= Time.now %> muutospvm: <%= Time.now %> -foreign_vat: +waybill: yhtio: acme selite: rahtikirja.inc - selitetark: Yleisrahtikirja A4 teksti + selitetark: laji: RAHTIKIRJA muuttaja: joe laatija: joe From 61cce444ac4965df6f3af83136f44cd2091be0c1 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 13:02:47 +0300 Subject: [PATCH 021/189] add validation --- app/models/keyword/waybill.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/keyword/waybill.rb b/app/models/keyword/waybill.rb index a7dfe17e0..ee45bd93e 100644 --- a/app/models/keyword/waybill.rb +++ b/app/models/keyword/waybill.rb @@ -1,4 +1,6 @@ class Keyword::Waybill < Keyword + validates :selitetark, presence: true + # Rails requires sti_name method to return type column (laji) value def self.sti_name 'RAHTIKIRJA' From 911d726599497f3ff5c3fafb99f20791f033a232 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 13:03:01 +0300 Subject: [PATCH 022/189] fix waybill relation --- app/models/delivery_method.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 624fc203a..556f6cb36 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -1,4 +1,6 @@ class DeliveryMethod < BaseModel + has_many :waybills, foreign_key: :selite, primary_key: :rahtikirja, class_name: 'Keyword::Waybill' + validates :selite, uniqueness: true scope :permit_adr, -> { where(vak_kielto: '') } @@ -87,7 +89,7 @@ class DeliveryMethod < BaseModel } def waybill_options - Keyword::Waybill.all.map { |i| [ i.selitetark, i.selite ] } + waybills.map { |i| [ i.selitetark, i.selite ] } end def label_options From 42485e305679b5fb5b340c87cdde2001060d3e2a Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 13:19:25 +0300 Subject: [PATCH 023/189] add mode of transport keyword --- app/models/keyword.rb | 5 +---- app/models/keyword/mode_of_transport.rb | 8 ++++++++ test/fixtures/keywords.yml | 10 ++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 app/models/keyword/mode_of_transport.rb diff --git a/app/models/keyword.rb b/app/models/keyword.rb index f4ffa1bb4..a54c216ff 100644 --- a/app/models/keyword.rb +++ b/app/models/keyword.rb @@ -1,10 +1,6 @@ class Keyword < BaseModel include PupenextSingleTableInheritance - def self.mode_of_transports - where(laji: "KM") - end - def self.nature_of_transactions where(laji: "KT") end @@ -31,6 +27,7 @@ def self.child_class_names { 'ALV' => Keyword::Vat, 'ALVULK' => Keyword::ForeignVat, + 'KM' => Keyword::ModeOfTransport, 'MAKSUEHTOKV' => Keyword::TermsOfPaymentTranslation, 'RAHTIKIRJA' => Keyword::Waybill } diff --git a/app/models/keyword/mode_of_transport.rb b/app/models/keyword/mode_of_transport.rb new file mode 100644 index 000000000..60152afa3 --- /dev/null +++ b/app/models/keyword/mode_of_transport.rb @@ -0,0 +1,8 @@ +class Keyword::ModeOfTransport < Keyword + validates :selitetark, presence: true + + # Rails requires sti_name method to return type column (laji) value + def self.sti_name + 'KM' + end +end diff --git a/test/fixtures/keywords.yml b/test/fixtures/keywords.yml index 6d2ff9910..88ca817aa 100644 --- a/test/fixtures/keywords.yml +++ b/test/fixtures/keywords.yml @@ -27,6 +27,16 @@ waybill: luontiaika: <%= Time.now %> muutospvm: <%= Time.now %> +mode_of_transport: + yhtio: acme + selite: 1 + selitetark: 1 - Merikuljetus (ml. auto- ja junalauttakuljetus) + laji: KM + muuttaja: joe + laatija: joe + luontiaika: <%= Time.now %> + muutospvm: <%= Time.now %> + top_locale_se: yhtio: acme selite: <%= ActiveRecord::FixtureSet.identify(:sixty_days_net) %> From aab297c22ba8de8b030182533540f00664c5de75 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 13:20:12 +0300 Subject: [PATCH 024/189] add mode of transport keyword relation --- app/models/delivery_method.rb | 9 +++++---- test/fixtures/delivery_methods.yml | 1 + test/models/delivery_method_test.rb | 5 +++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 556f6cb36..9e4e9fe93 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -1,5 +1,6 @@ class DeliveryMethod < BaseModel has_many :waybills, foreign_key: :selite, primary_key: :rahtikirja, class_name: 'Keyword::Waybill' + has_many :mode_of_transports, foreign_key: :selite, primary_key: :kuljetusmuoto, class_name: 'Keyword::ModeOfTransport' validates :selite, uniqueness: true @@ -92,6 +93,10 @@ def waybill_options waybills.map { |i| [ i.selitetark, i.selite ] } end + def mode_of_transport_options + mode_of_transports.map { |i| [ i.selitetark, i.selite ] } + end + def label_options options = [ ["Normaali", ""], @@ -106,10 +111,6 @@ def label_options options end - def mode_of_transport_options - company.keywords.mode_of_transports.map { |i| [ i.selitetark, i.selite ] } - end - def inland_mode_of_transport_options mode_of_transport_options end diff --git a/test/fixtures/delivery_methods.yml b/test/fixtures/delivery_methods.yml index 262ad439a..ed816fff8 100644 --- a/test/fixtures/delivery_methods.yml +++ b/test/fixtures/delivery_methods.yml @@ -4,6 +4,7 @@ kaukokiito: tulostustapa: H rahtikirja: rahtikirja.inc rahdinkuljettaja: Kaukokiito + kuljetusmuoto: 1 laatija: 'joe' luontiaika: <%= Date.today %> muutospvm: <%= Date.today %> diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index a53f052a3..fbf46206b 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -19,4 +19,9 @@ def setup assert_kind_of Array, @delivery_method.waybill_options assert_operator 0, '<', @delivery_method.waybill_options.count end + + test "should get mode of transport options" do + assert_kind_of Array, @delivery_method.mode_of_transport_options + assert_operator 0, '<', @delivery_method.mode_of_transport_options.count + end end From 8b3dfd85831db515082e4d3a52606cc1bd4f1264 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 15:17:09 +0300 Subject: [PATCH 025/189] fix fixtures --- test/fixtures/keywords.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixtures/keywords.yml b/test/fixtures/keywords.yml index 88ca817aa..cf508704a 100644 --- a/test/fixtures/keywords.yml +++ b/test/fixtures/keywords.yml @@ -20,7 +20,7 @@ foreign_vat: waybill: yhtio: acme selite: rahtikirja.inc - selitetark: + selitetark: Yleisrahtikirja A4 teksti laji: RAHTIKIRJA muuttaja: joe laatija: joe From 77bff637c26b7dd3d650d2f3ad6dcaf62ff73710 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 15:20:30 +0300 Subject: [PATCH 026/189] move options from model to helper --- app/helpers/delivery_method_helper.rb | 8 ++++++++ app/models/delivery_method.rb | 8 -------- test/helpers/delivery_method_helper_test.rb | 10 ++++++++++ test/models/delivery_method_test.rb | 11 ----------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/app/helpers/delivery_method_helper.rb b/app/helpers/delivery_method_helper.rb index 4747a63d3..4bf63ac13 100644 --- a/app/helpers/delivery_method_helper.rb +++ b/app/helpers/delivery_method_helper.rb @@ -1,6 +1,14 @@ module DeliveryMethodHelper ROOT = 'administration.delivery_methods' + def waybill_options + Keyword::Waybill.all.map { |i| [ i.selitetark, i.selite ] } + end + + def mode_of_transport_options + Keyword::ModeOfTransport.all.map { |i| [ i.selitetark, i.selite ] } + end + def pickup_options DeliveryMethod.noutos.map do |key,_| [ t("#{ROOT}.pickup_options.#{key}"), key ] diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 9e4e9fe93..3b3d4314f 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -89,14 +89,6 @@ class DeliveryMethod < BaseModel percentage_based_insurance_with_discount: 'G' } - def waybill_options - waybills.map { |i| [ i.selitetark, i.selite ] } - end - - def mode_of_transport_options - mode_of_transports.map { |i| [ i.selitetark, i.selite ] } - end - def label_options options = [ ["Normaali", ""], diff --git a/test/helpers/delivery_method_helper_test.rb b/test/helpers/delivery_method_helper_test.rb index eefa9d7ae..13e78e7c5 100644 --- a/test/helpers/delivery_method_helper_test.rb +++ b/test/helpers/delivery_method_helper_test.rb @@ -112,4 +112,14 @@ class DeliveryMethodHelperTest < ActionView::TestCase assert_equal text, transportation_insurance_type_options.third.first assert_equal 'currency_based_insurance', transportation_insurance_type_options.third.second end + + test "should get waybill options" do + assert_kind_of Array, waybill_options + assert_equal 'rahtikirja.inc', waybill_options.first.second + end + + test "should get mode of transport options" do + assert_kind_of Array, mode_of_transport_options + assert_equal '1 - Merikuljetus (ml. auto- ja junalauttakuljetus)', mode_of_transport_options.first.first + end end diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index fbf46206b..e62537798 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -1,7 +1,6 @@ require 'test_helper' class DeliveryMethodTest < ActiveSupport::TestCase - def setup @delivery_method = delivery_methods(:kaukokiito) end @@ -14,14 +13,4 @@ def setup @delivery_method.selite = "Kiitolinja" refute @delivery_method.valid?, "Delivery method already exists" end - - test "should get waybill options" do - assert_kind_of Array, @delivery_method.waybill_options - assert_operator 0, '<', @delivery_method.waybill_options.count - end - - test "should get mode of transport options" do - assert_kind_of Array, @delivery_method.mode_of_transport_options - assert_operator 0, '<', @delivery_method.mode_of_transport_options.count - end end From 7a19d5b0b195658c52480809c1d105ffdfdf395b Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 18:00:32 +0300 Subject: [PATCH 027/189] move label options to helper module --- app/helpers/delivery_method_helper.rb | 8 ++++++++ app/models/delivery_method.rb | 22 +++++++-------------- app/models/parameter.rb | 4 ++++ config/locales/fi.yml | 7 ++++++- test/fixtures/delivery_methods.yml | 1 + test/fixtures/parameters.yml | 1 + test/helpers/delivery_method_helper_test.rb | 17 ++++++++++++++-- 7 files changed, 42 insertions(+), 18 deletions(-) diff --git a/app/helpers/delivery_method_helper.rb b/app/helpers/delivery_method_helper.rb index 4bf63ac13..2b5a56a94 100644 --- a/app/helpers/delivery_method_helper.rb +++ b/app/helpers/delivery_method_helper.rb @@ -9,6 +9,14 @@ def mode_of_transport_options Keyword::ModeOfTransport.all.map { |i| [ i.selitetark, i.selite ] } end + def label_options + options = DeliveryMethod.osoitelappus.map do |key,_| + [ t("#{ROOT}.label_options.#{key}"), key ] + end + + options.reject { |_,key| !Current.company.parameter.use_kerayserat? && key == 'simple_label' } + end + def pickup_options DeliveryMethod.noutos.map do |key,_| [ t("#{ROOT}.pickup_options.#{key}"), key ] diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 3b3d4314f..e77e9c5c1 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -5,13 +5,12 @@ class DeliveryMethod < BaseModel validates :selite, uniqueness: true scope :permit_adr, -> { where(vak_kielto: '') } - scope :shipment, -> { where(nouto: '') } self.table_name = :toimitustapa self.primary_key = :tunnus enum nouto: { - not_pickup: '', + shipment: '', pickup: 'o' } @@ -89,19 +88,12 @@ class DeliveryMethod < BaseModel percentage_based_insurance_with_discount: 'G' } - def label_options - options = [ - ["Normaali", ""], - ["Intrade", "intrade"], - ["Tiivistetty", "tiivistetty"] - ] - - if company.parameter.kerayserat == "K" - options << ["Yksinkertainen, tulostusmedia valitaan kirjoittimen takaa", "oslap_mg"] - end - - options - end + enum osoitelappu: { + normal_label: '', + intrade_label: 'intrade', + compact_label: 'tiivistetty', + simple_label: 'oslap_mg' + } def inland_mode_of_transport_options mode_of_transport_options diff --git a/app/models/parameter.rb b/app/models/parameter.rb index 376b0535c..ea5eb614b 100644 --- a/app/models/parameter.rb +++ b/app/models/parameter.rb @@ -1,4 +1,8 @@ class Parameter < BaseModel self.table_name = :yhtion_parametrit self.primary_key = :tunnus + + def use_kerayserat? + kerayserat == 'K' + end end diff --git a/config/locales/fi.yml b/config/locales/fi.yml index d5ad66720..04be899b7 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -409,7 +409,7 @@ fi: update_success: Taso päivitettiin onnistuneesti delivery_methods: pickup_options: - not_pickup: Tilaukset toimitetaan asiakkaalle + shipment: Tilaukset toimitetaan asiakkaalle pickup: Asiakas noutaa tilaukset saturday_delivery_options: not_saturday_delivery: Ei lauantaijakelua @@ -459,6 +459,11 @@ fi: percentage_based_insurance: Prosentuaalinen kuljetusvakuutus lisätään currency_based_insurance_with_discount: Valuuttamääräinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen asiakashintaa ja alennusta percentage_based_insurance_with_discount: Prosentuaalinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen asiakasalennusta + label_options: + normal_label: Normaali + intrade_label: Intrade + compact_label: Tiivistetty + simple_label: Yksinkertainen, tulostusmedia valitaan kirjoittimen takaa terms_of_payments: cash_options: cash: Käteismaksuehto, käteinen pyöristetään diff --git a/test/fixtures/delivery_methods.yml b/test/fixtures/delivery_methods.yml index ed816fff8..3591dddef 100644 --- a/test/fixtures/delivery_methods.yml +++ b/test/fixtures/delivery_methods.yml @@ -5,6 +5,7 @@ kaukokiito: rahtikirja: rahtikirja.inc rahdinkuljettaja: Kaukokiito kuljetusmuoto: 1 + osoitelappu: tiivistetty laatija: 'joe' luontiaika: <%= Date.today %> muutospvm: <%= Date.today %> diff --git a/test/fixtures/parameters.yml b/test/fixtures/parameters.yml index cb309291e..8d12dab20 100644 --- a/test/fixtures/parameters.yml +++ b/test/fixtures/parameters.yml @@ -2,6 +2,7 @@ acme: yhtio: acme css: "* { font-family: sans-serif }" maventa_aikaleima: <%= Time.now %> + kerayserat: K muuttaja: joe laatija: joe luontiaika: <%= Time.now %> diff --git a/test/helpers/delivery_method_helper_test.rb b/test/helpers/delivery_method_helper_test.rb index 13e78e7c5..2102d05c8 100644 --- a/test/helpers/delivery_method_helper_test.rb +++ b/test/helpers/delivery_method_helper_test.rb @@ -4,9 +4,9 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated pickup options valid for collection" do assert pickup_options.is_a? Array - text = I18n.t 'administration.delivery_methods.pickup_options.not_pickup', :fi + text = I18n.t 'administration.delivery_methods.pickup_options.shipment', :fi assert_equal text, pickup_options.first.first - assert_equal 'not_pickup', pickup_options.first.second + assert_equal 'shipment', pickup_options.first.second end test "returns translated saturday delivery options valid for collection" do @@ -122,4 +122,17 @@ class DeliveryMethodHelperTest < ActionView::TestCase assert_kind_of Array, mode_of_transport_options assert_equal '1 - Merikuljetus (ml. auto- ja junalauttakuljetus)', mode_of_transport_options.first.first end + + test "should get label options" do + Current.company.parameter.kerayserat = '' + + assert_kind_of Array, label_options + assert_equal 'Tiivistetty', label_options.third.first + refute label_options.any? { |_,key| key == 'simple_label' } + + Current.company.parameter.kerayserat = 'K' + + assert_kind_of Array, label_options + assert label_options.any? { |_,key| key == 'simple_label' } + end end From 34c5d5486d50166cf096b1f4a40bc7a3d253a8f0 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 18:06:00 +0300 Subject: [PATCH 028/189] remove unnecessary method --- app/models/delivery_method.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index e77e9c5c1..e1e8e6cf5 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -95,10 +95,6 @@ class DeliveryMethod < BaseModel simple_label: 'oslap_mg' } - def inland_mode_of_transport_options - mode_of_transport_options - end - def nature_of_transaction_options company.keywords.nature_of_transactions.map { |i| [ i.selitetark, i.selite ] } end From 75adeed876078d1fbbd262202ed33759ddd954fd Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 18:14:12 +0300 Subject: [PATCH 029/189] nature of transaction options helper --- app/helpers/delivery_method_helper.rb | 4 ++++ app/models/delivery_method.rb | 5 +---- app/models/keyword.rb | 1 + app/models/keyword/nature_of_transaction.rb | 8 ++++++++ test/fixtures/keywords.yml | 10 ++++++++++ test/helpers/delivery_method_helper_test.rb | 5 +++++ 6 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 app/models/keyword/nature_of_transaction.rb diff --git a/app/helpers/delivery_method_helper.rb b/app/helpers/delivery_method_helper.rb index 2b5a56a94..d7e9a292b 100644 --- a/app/helpers/delivery_method_helper.rb +++ b/app/helpers/delivery_method_helper.rb @@ -9,6 +9,10 @@ def mode_of_transport_options Keyword::ModeOfTransport.all.map { |i| [ i.selitetark, i.selite ] } end + def nature_of_transaction_options + Keyword::NatureOfTransaction.all.map { |i| [ i.selitetark, i.selite ] } + end + def label_options options = DeliveryMethod.osoitelappus.map do |key,_| [ t("#{ROOT}.label_options.#{key}"), key ] diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index e1e8e6cf5..9d69b8b9d 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -1,6 +1,7 @@ class DeliveryMethod < BaseModel has_many :waybills, foreign_key: :selite, primary_key: :rahtikirja, class_name: 'Keyword::Waybill' has_many :mode_of_transports, foreign_key: :selite, primary_key: :kuljetusmuoto, class_name: 'Keyword::ModeOfTransport' + has_many :nature_of_transactions, foreign_key: :selite, primary_key: :kauppatapahtuman_luonne, class_name: 'Keyword::NatureOfTransaction' validates :selite, uniqueness: true @@ -95,10 +96,6 @@ class DeliveryMethod < BaseModel simple_label: 'oslap_mg' } - def nature_of_transaction_options - company.keywords.nature_of_transactions.map { |i| [ i.selitetark, i.selite ] } - end - def exit_code_options company.keywords.customs.map { |i| [ "#{i.selite} #{i.selitetark}", i.selite ] } end diff --git a/app/models/keyword.rb b/app/models/keyword.rb index a54c216ff..2eb8327d0 100644 --- a/app/models/keyword.rb +++ b/app/models/keyword.rb @@ -28,6 +28,7 @@ def self.child_class_names 'ALV' => Keyword::Vat, 'ALVULK' => Keyword::ForeignVat, 'KM' => Keyword::ModeOfTransport, + 'KT' => Keyword::NatureOfTransaction, 'MAKSUEHTOKV' => Keyword::TermsOfPaymentTranslation, 'RAHTIKIRJA' => Keyword::Waybill } diff --git a/app/models/keyword/nature_of_transaction.rb b/app/models/keyword/nature_of_transaction.rb new file mode 100644 index 000000000..91b2a1a4b --- /dev/null +++ b/app/models/keyword/nature_of_transaction.rb @@ -0,0 +1,8 @@ +class Keyword::NatureOfTransaction < Keyword + validates :selitetark, presence: true + + # Rails requires sti_name method to return type column (laji) value + def self.sti_name + 'KT' + end +end diff --git a/test/fixtures/keywords.yml b/test/fixtures/keywords.yml index cf508704a..7623c3f95 100644 --- a/test/fixtures/keywords.yml +++ b/test/fixtures/keywords.yml @@ -37,6 +37,16 @@ mode_of_transport: luontiaika: <%= Time.now %> muutospvm: <%= Time.now %> +nature_of_transaction: + yhtio: acme + selite: 11 + selitetark: 11 - Suora osto/myynti + laji: KT + muuttaja: joe + laatija: joe + luontiaika: <%= Time.now %> + muutospvm: <%= Time.now %> + top_locale_se: yhtio: acme selite: <%= ActiveRecord::FixtureSet.identify(:sixty_days_net) %> diff --git a/test/helpers/delivery_method_helper_test.rb b/test/helpers/delivery_method_helper_test.rb index 2102d05c8..bb299e20c 100644 --- a/test/helpers/delivery_method_helper_test.rb +++ b/test/helpers/delivery_method_helper_test.rb @@ -135,4 +135,9 @@ class DeliveryMethodHelperTest < ActionView::TestCase assert_kind_of Array, label_options assert label_options.any? { |_,key| key == 'simple_label' } end + + test "should get nature of transaction options" do + assert_kind_of Array, nature_of_transaction_options + assert_equal '11 - Suora osto/myynti', nature_of_transaction_options.first.first + end end From cc5f177f1f0f19e1fcc10a91c8d815285b76f682 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 18:16:43 +0300 Subject: [PATCH 030/189] remove unnecessary method --- app/models/keyword.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/keyword.rb b/app/models/keyword.rb index 2eb8327d0..d4760c545 100644 --- a/app/models/keyword.rb +++ b/app/models/keyword.rb @@ -1,10 +1,6 @@ class Keyword < BaseModel include PupenextSingleTableInheritance - def self.nature_of_transactions - where(laji: "KT") - end - def self.customs where(laji: "TULLI") end From 0d792771a336cb374189c202e8d46e74600cb12a Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 20 Aug 2015 18:24:17 +0300 Subject: [PATCH 031/189] customs options helper method --- app/helpers/delivery_method_helper.rb | 4 ++++ app/models/delivery_method.rb | 5 +---- app/models/keyword.rb | 7 ++----- app/models/keyword/customs.rb | 8 ++++++++ test/fixtures/keywords.yml | 10 ++++++++++ test/helpers/delivery_method_helper_test.rb | 5 +++++ 6 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 app/models/keyword/customs.rb diff --git a/app/helpers/delivery_method_helper.rb b/app/helpers/delivery_method_helper.rb index d7e9a292b..ad58702bc 100644 --- a/app/helpers/delivery_method_helper.rb +++ b/app/helpers/delivery_method_helper.rb @@ -13,6 +13,10 @@ def nature_of_transaction_options Keyword::NatureOfTransaction.all.map { |i| [ i.selitetark, i.selite ] } end + def customs_options + Keyword::Customs.all.map { |i| [ "#{i.selite} #{i.selitetark}", i.selite ] } + end + def label_options options = DeliveryMethod.osoitelappus.map do |key,_| [ t("#{ROOT}.label_options.#{key}"), key ] diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 9d69b8b9d..9dead496d 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -2,6 +2,7 @@ class DeliveryMethod < BaseModel has_many :waybills, foreign_key: :selite, primary_key: :rahtikirja, class_name: 'Keyword::Waybill' has_many :mode_of_transports, foreign_key: :selite, primary_key: :kuljetusmuoto, class_name: 'Keyword::ModeOfTransport' has_many :nature_of_transactions, foreign_key: :selite, primary_key: :kauppatapahtuman_luonne, class_name: 'Keyword::NatureOfTransaction' + has_many :customs, foreign_key: :selite, primary_key: :poistumistoimipaikka_koodi, class_name: 'Keyword::Customs' validates :selite, uniqueness: true @@ -96,10 +97,6 @@ class DeliveryMethod < BaseModel simple_label: 'oslap_mg' } - def exit_code_options - company.keywords.customs.map { |i| [ "#{i.selite} #{i.selitetark}", i.selite ] } - end - def sorting_point_options company.keywords.sorting_points.map { |i| [ i.selitetark, i.selite ] } end diff --git a/app/models/keyword.rb b/app/models/keyword.rb index d4760c545..e95b32be4 100644 --- a/app/models/keyword.rb +++ b/app/models/keyword.rb @@ -1,10 +1,6 @@ class Keyword < BaseModel include PupenextSingleTableInheritance - def self.customs - where(laji: "TULLI") - end - def self.sorting_points where(laji: "TOIMTAPALP") end @@ -26,7 +22,8 @@ def self.child_class_names 'KM' => Keyword::ModeOfTransport, 'KT' => Keyword::NatureOfTransaction, 'MAKSUEHTOKV' => Keyword::TermsOfPaymentTranslation, - 'RAHTIKIRJA' => Keyword::Waybill + 'RAHTIKIRJA' => Keyword::Waybill, + 'TULLI' => Keyword::Customs } end end diff --git a/app/models/keyword/customs.rb b/app/models/keyword/customs.rb new file mode 100644 index 000000000..2502c4147 --- /dev/null +++ b/app/models/keyword/customs.rb @@ -0,0 +1,8 @@ +class Keyword::Customs < Keyword + validates :selitetark, presence: true + + # Rails requires sti_name method to return type column (laji) value + def self.sti_name + 'TULLI' + end +end diff --git a/test/fixtures/keywords.yml b/test/fixtures/keywords.yml index 7623c3f95..2ae484968 100644 --- a/test/fixtures/keywords.yml +++ b/test/fixtures/keywords.yml @@ -47,6 +47,16 @@ nature_of_transaction: luontiaika: <%= Time.now %> muutospvm: <%= Time.now %> +customs: + yhtio: acme + selite: FI001000 + selitetark: Helsinki Postitulli + laji: TULLI + muuttaja: joe + laatija: joe + luontiaika: <%= Time.now %> + muutospvm: <%= Time.now %> + top_locale_se: yhtio: acme selite: <%= ActiveRecord::FixtureSet.identify(:sixty_days_net) %> diff --git a/test/helpers/delivery_method_helper_test.rb b/test/helpers/delivery_method_helper_test.rb index bb299e20c..5d3297d9e 100644 --- a/test/helpers/delivery_method_helper_test.rb +++ b/test/helpers/delivery_method_helper_test.rb @@ -140,4 +140,9 @@ class DeliveryMethodHelperTest < ActionView::TestCase assert_kind_of Array, nature_of_transaction_options assert_equal '11 - Suora osto/myynti', nature_of_transaction_options.first.first end + + test "should get customs options" do + assert_kind_of Array, customs_options + assert_equal 'FI001000', customs_options.first.second + end end From ff9a8ec5495eae21e7bdfd18971a83fa63f84641 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 25 Aug 2015 09:59:13 +0300 Subject: [PATCH 032/189] sorting point options --- app/helpers/delivery_method_helper.rb | 4 ++++ app/models/delivery_method.rb | 4 ---- app/models/keyword.rb | 5 +---- app/models/keyword/sorting_point.rb | 8 ++++++++ test/fixtures/keywords.yml | 10 ++++++++++ test/helpers/delivery_method_helper_test.rb | 5 +++++ 6 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 app/models/keyword/sorting_point.rb diff --git a/app/helpers/delivery_method_helper.rb b/app/helpers/delivery_method_helper.rb index ad58702bc..a76da52e0 100644 --- a/app/helpers/delivery_method_helper.rb +++ b/app/helpers/delivery_method_helper.rb @@ -17,6 +17,10 @@ def customs_options Keyword::Customs.all.map { |i| [ "#{i.selite} #{i.selitetark}", i.selite ] } end + def sorting_point_options + Keyword::SortingPoint.all.map { |i| [ i.selitetark, i.selite ] } + end + def label_options options = DeliveryMethod.osoitelappus.map do |key,_| [ t("#{ROOT}.label_options.#{key}"), key ] diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 9dead496d..50f2d024a 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -97,10 +97,6 @@ class DeliveryMethod < BaseModel simple_label: 'oslap_mg' } - def sorting_point_options - company.keywords.sorting_points.map { |i| [ i.selitetark, i.selite ] } - end - def adr_options(text) DeliveryMethod.permit_adr.shipment.map do |i| [ "#{text} #{i.selite}", i.selite ] diff --git a/app/models/keyword.rb b/app/models/keyword.rb index e95b32be4..31f13eb73 100644 --- a/app/models/keyword.rb +++ b/app/models/keyword.rb @@ -1,10 +1,6 @@ class Keyword < BaseModel include PupenextSingleTableInheritance - def self.sorting_points - where(laji: "TOIMTAPALP") - end - self.table_name = :avainsana self.primary_key = :tunnus self.inheritance_column = :laji @@ -23,6 +19,7 @@ def self.child_class_names 'KT' => Keyword::NatureOfTransaction, 'MAKSUEHTOKV' => Keyword::TermsOfPaymentTranslation, 'RAHTIKIRJA' => Keyword::Waybill, + 'TOIMTAPALP' => Keyword::SortingPoint, 'TULLI' => Keyword::Customs } end diff --git a/app/models/keyword/sorting_point.rb b/app/models/keyword/sorting_point.rb new file mode 100644 index 000000000..69705b3b3 --- /dev/null +++ b/app/models/keyword/sorting_point.rb @@ -0,0 +1,8 @@ +class Keyword::SortingPoint < Keyword + validates :selitetark, presence: true + + # Rails requires sti_name method to return type column (laji) value + def self.sti_name + 'TOIMTAPALP' + end +end diff --git a/test/fixtures/keywords.yml b/test/fixtures/keywords.yml index 2ae484968..879e14309 100644 --- a/test/fixtures/keywords.yml +++ b/test/fixtures/keywords.yml @@ -57,6 +57,16 @@ customs: luontiaika: <%= Time.now %> muutospvm: <%= Time.now %> +sorting_point: + yhtio: acme + selite: FIVAT + selitetark: FIVAT + laji: TOIMTAPALP + muuttaja: joe + laatija: joe + luontiaika: <%= Time.now %> + muutospvm: <%= Time.now %> + top_locale_se: yhtio: acme selite: <%= ActiveRecord::FixtureSet.identify(:sixty_days_net) %> diff --git a/test/helpers/delivery_method_helper_test.rb b/test/helpers/delivery_method_helper_test.rb index 5d3297d9e..84a504142 100644 --- a/test/helpers/delivery_method_helper_test.rb +++ b/test/helpers/delivery_method_helper_test.rb @@ -145,4 +145,9 @@ class DeliveryMethodHelperTest < ActionView::TestCase assert_kind_of Array, customs_options assert_equal 'FI001000', customs_options.first.second end + + test "should get sorting point options" do + assert_kind_of Array, sorting_point_options + assert_equal 'FIVAT', sorting_point_options.first.second + end end From 158fdb1aec52bfacc8ea5eb2c3e9a5c66f8757bd Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 25 Aug 2015 11:48:33 +0300 Subject: [PATCH 033/189] normalize delivery method translations --- config/locales/fi.yml | 122 ++++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 59 deletions(-) diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 9efac23c3..b8f7ac691 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -313,6 +313,67 @@ fi: header: Valuutat update: update_success: Valuutta päivitettiin onnistuneesti + delivery_methods: + adr_prohibition_options: + adr_prohibition: Toimitustavalla ei saa toimittaa VAK-tuotteita + adr_shipment: VAK-tuotteet toimitetaan toimitustavalla + permit_adr: Toimitustavalla saa toimittaa VAK-tuotteita + cash_on_delivery_prohibition_options: + cash_on_delivery_permitted: Toimitustavalla saa toimittaa jälkivaatimuksia + cash_on_delivery_prohibition: Toimitustavalla ei saa toimittaa jälkivaatimuksia + container_options: + includes_container: Kyllä + not_including_container: Ei + extranet_options: + both_in_sales_and_extranet: Toimitustapa näytetään molemmissa + only_in_extranet: Toimitustapa näytetään vain extranetissä + only_in_sales: Toimitustapa näytetään vain myynnissä + freight_contract_options: + receiver_freight_contract: Käytetään vastaanottajan rahtisopimusta + sender_freight_contract: Käytetään lähettäjän rahtisopimusta + label_options: + compact_label: Tiivistetty + intrade_label: Intrade + normal_label: Normaali + simple_label: Yksinkertainen, tulostusmedia valitaan kirjoittimen takaa + logy_waybill_number_options: + not_using_logy_waybill_numbers: Ei käytetä LOGY-rahtikirjanumeroita + use_logy_waybill_numbers: Käytetään LOGY-rahtikirjanumeroita + new_packaging_information_options: + package_info_entry_allowed: Koonti-erätulostuksessa voi syöttää uudet pakkaustiedot ennen tulostusta + package_info_entry_denied: Koonti-erätulostuksessa ei voi syöttää uusia pakkaustietoja ennen tulostusta + packing_line_prohibition_options: + not_reserving_packing_line: Toimitustavan tilaukaset eivät varaa pakkaamolokeroa + reserve_packing_line: Toimitustavan tilaukset varaavat pakkaamolokeron + pickup_options: + pickup: Asiakas noutaa tilaukset + shipment: Tilaukset toimitetaan asiakkaalle + print_method_options: + batch: Erätulostus + collective_batch: Koonti-erätulostus + collective_instant: Koonti-hetitulostus + instant: Hetitulostus + skip_print: Rahtikirjansyöttö ja -tulostus ohitetaan + saturday_delivery_options: + not_saturday_delivery: Ei lauantaijakelua + saturday_delivery: Itella lisäpalvelu - Lauantaijakelu + special_packaging_prohibition_options: + special_packaging_permitted: Toimitustavalla saa toimittaa erikoispakkauksia + special_packaging_prohibition: Toimitustavalla ei saa toimittaa erikoispakkauksia + transport_unit_options: + not_transport_unit: Ei kuljetusyksikkökuljetusta + transport_unit: Itella lisäpalvelu - Kuljetusyksikkökuljetus + transportation_insurance_type_options: + currency_based_insurance: Valuuttamääräinen kuljetusvakuutus lisätään + currency_based_insurance_with_discount: Valuuttamääräinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen asiakashintaa ja alennusta + no_transportation_insurance: Ei kuljetusvakuutusta + percentage_based_insurance: Prosentuaalinen kuljetusvakuutus lisätään + percentage_based_insurance_with_discount: Prosentuaalinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen asiakasalennusta + use_company_default: Yhtiön oletus + waybill_specification_options: + no_waybill_specification: Toimitustavalle ei tulosteta rahtikirjaerittelyä + print_waybill_specification: Toimitustavalle tulostetaan rahtikirjaerittely + print_waybill_specification_per_customer: Toimitustavalle tulostetaan rahtikirjaerittely per asiakas fiscal_years: create: create_success: Tilikausi perustettiin onnistuneesti @@ -408,63 +469,6 @@ fi: not_cumulative: Ei update: update_success: Taso päivitettiin onnistuneesti - delivery_methods: - pickup_options: - shipment: Tilaukset toimitetaan asiakkaalle - pickup: Asiakas noutaa tilaukset - saturday_delivery_options: - not_saturday_delivery: Ei lauantaijakelua - saturday_delivery: Itella lisäpalvelu - Lauantaijakelu - transport_unit_options: - not_transport_unit: Ei kuljetusyksikkökuljetusta - transport_unit: Itella lisäpalvelu - Kuljetusyksikkökuljetus - print_method_options: - batch: Erätulostus - instant: Hetitulostus - collective_instant: Koonti-hetitulostus - collective_batch: Koonti-erätulostus - skip_print: Rahtikirjansyöttö ja -tulostus ohitetaan - freight_contract_options: - sender_freight_contract: Käytetään lähettäjän rahtisopimusta - receiver_freight_contract: Käytetään vastaanottajan rahtisopimusta - logy_waybill_number_options: - not_using_logy_waybill_numbers: Ei käytetä LOGY-rahtikirjanumeroita - use_logy_waybill_numbers: Käytetään LOGY-rahtikirjanumeroita - extranet_options: - only_in_sales: Toimitustapa näytetään vain myynnissä - only_in_extranet: Toimitustapa näytetään vain extranetissä - both_in_sales_and_extranet: Toimitustapa näytetään molemmissa - container_options: - includes_container: Kyllä - not_including_container: Ei - cash_on_delivery_prohibition_options: - cash_on_delivery_permitted: Toimitustavalla saa toimittaa jälkivaatimuksia - cash_on_delivery_prohibition: Toimitustavalla ei saa toimittaa jälkivaatimuksia - special_packaging_prohibition_options: - special_packaging_permitted: Toimitustavalla saa toimittaa erikoispakkauksia - special_packaging_prohibition: Toimitustavalla ei saa toimittaa erikoispakkauksia - packing_line_prohibition_options: - reserve_packing_line: Toimitustavan tilaukset varaavat pakkaamolokeron - not_reserving_packing_line: Toimitustavan tilaukaset eivät varaa pakkaamolokeroa - waybill_specification_options: - no_waybill_specification: Toimitustavalle ei tulosteta rahtikirjaerittelyä - print_waybill_specification: Toimitustavalle tulostetaan rahtikirjaerittely - print_waybill_specification_per_customer: Toimitustavalle tulostetaan rahtikirjaerittely per asiakas - new_packaging_information_options: - package_info_entry_denied: Koonti-erätulostuksessa ei voi syöttää uusia pakkaustietoja ennen tulostusta - package_info_entry_allowed: Koonti-erätulostuksessa voi syöttää uudet pakkaustiedot ennen tulostusta - transportation_insurance_type_options: - use_company_default: Yhtiön oletus - no_transportation_insurance: Ei kuljetusvakuutusta - currency_based_insurance: Valuuttamääräinen kuljetusvakuutus lisätään - percentage_based_insurance: Prosentuaalinen kuljetusvakuutus lisätään - currency_based_insurance_with_discount: Valuuttamääräinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen asiakashintaa ja alennusta - percentage_based_insurance_with_discount: Prosentuaalinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen asiakasalennusta - label_options: - normal_label: Normaali - intrade_label: Intrade - compact_label: Tiivistetty - simple_label: Yksinkertainen, tulostusmedia valitaan kirjoittimen takaa terms_of_payments: cash_options: cash: Käteismaksuehto, käteinen pyöristetään @@ -507,7 +511,7 @@ fi: - pe - la abbr_month_names: - - + - - tammi - helmi - maalis @@ -533,7 +537,7 @@ fi: long: "%A %e. %Bta %Y" short: "%d %b" month_names: - - + - - tammikuu - helmikuu - maaliskuu From c014a344ade80cdaff2b102cd0dc2d4bed983114 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 25 Aug 2015 11:57:54 +0300 Subject: [PATCH 034/189] adr prohibition options and validation --- app/helpers/delivery_method_helper.rb | 17 ++++++++ app/models/delivery_method.rb | 46 ++++++++++----------- test/helpers/delivery_method_helper_test.rb | 9 ++++ test/models/delivery_method_test.rb | 11 +++++ 4 files changed, 59 insertions(+), 24 deletions(-) diff --git a/app/helpers/delivery_method_helper.rb b/app/helpers/delivery_method_helper.rb index a76da52e0..172a50feb 100644 --- a/app/helpers/delivery_method_helper.rb +++ b/app/helpers/delivery_method_helper.rb @@ -21,6 +21,23 @@ def sorting_point_options Keyword::SortingPoint.all.map { |i| [ i.selitetark, i.selite ] } end + def adr_prohibition_options + options = [ + [ t("#{ROOT}.adr_prohibition_options.permit_adr"), "" ], + [ t("#{ROOT}.adr_prohibition_options.adr_prohibition"), "K" ] + ] + + options = options + adr_options + options.reject { |i,_| i.empty? } + end + + def adr_options + text = t("#{ROOT}.adr_prohibition_options.adr_shipment") + DeliveryMethod.permit_adr.shipment.map do |i| + [ "#{text} #{i.selite}", i.selite ] + end + end + def label_options options = DeliveryMethod.osoitelappus.map do |key,_| [ t("#{ROOT}.label_options.#{key}"), key ] diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 50f2d024a..21ada0dde 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -1,10 +1,13 @@ class DeliveryMethod < BaseModel - has_many :waybills, foreign_key: :selite, primary_key: :rahtikirja, class_name: 'Keyword::Waybill' - has_many :mode_of_transports, foreign_key: :selite, primary_key: :kuljetusmuoto, class_name: 'Keyword::ModeOfTransport' - has_many :nature_of_transactions, foreign_key: :selite, primary_key: :kauppatapahtuman_luonne, class_name: 'Keyword::NatureOfTransaction' - has_many :customs, foreign_key: :selite, primary_key: :poistumistoimipaikka_koodi, class_name: 'Keyword::Customs' + with_options foreign_key: :selite do |o| + o.has_many :waybills, primary_key: :rahtikirja, class_name: 'Keyword::Waybill' + o.has_many :mode_of_transports, primary_key: :kuljetusmuoto, class_name: 'Keyword::ModeOfTransport' + o.has_many :nature_of_transactions, primary_key: :kauppatapahtuman_luonne, class_name: 'Keyword::NatureOfTransaction' + o.has_many :customs, primary_key: :poistumistoimipaikka_koodi, class_name: 'Keyword::Customs' + end validates :selite, uniqueness: true + validate :vak_kielto_validation scope :permit_adr, -> { where(vak_kielto: '') } @@ -97,26 +100,12 @@ class DeliveryMethod < BaseModel simple_label: 'oslap_mg' } - def adr_options(text) - DeliveryMethod.permit_adr.shipment.map do |i| - [ "#{text} #{i.selite}", i.selite ] - end - end - - def adr_prohibition_options - [ - ["Toimitustavalla saa toimittaa VAK-tuotteita", ""], - ["Toimitustavalla ei saa toimittaa VAK-tuotteita", "K"], - adr_options("VAK-tuotteet toimitetaan toimitustavalla") - ].reject {|i,_| i.empty?} - end - - def alternative_adr_delivery_method_options - [ - ["VAK-tuotteita ei siirretä omalle tilaukselleen", ""], - adr_options("VAK-tuotteet siirretään omalle tilaukselleen toimitustavalla") - ].reject {|i,_| i.empty?} - end + # def alternative_adr_delivery_method_options + # [ + # ["VAK-tuotteita ei siirretä omalle tilaukselleen", ""], + # adr_options("VAK-tuotteet siirretään omalle tilaukselleen toimitustavalla") + # ].reject {|i,_| i.empty?} + # end def permitted_packaging_options [] @@ -125,4 +114,13 @@ def permitted_packaging_options def carrier_options #company.carriers.map { |i| [ i.nimi, i.koodi ] } end + + private + + def vak_kielto_validation + allowed = DeliveryMethod.permit_adr.shipment.pluck(:selite) + allowed += [ '', 'K' ] + + errors.add :vak_kielto, I18n.t('errors.messages.inclusion') unless allowed.include? vak_kielto + end end diff --git a/test/helpers/delivery_method_helper_test.rb b/test/helpers/delivery_method_helper_test.rb index 84a504142..058c332c3 100644 --- a/test/helpers/delivery_method_helper_test.rb +++ b/test/helpers/delivery_method_helper_test.rb @@ -150,4 +150,13 @@ class DeliveryMethodHelperTest < ActionView::TestCase assert_kind_of Array, sorting_point_options assert_equal 'FIVAT', sorting_point_options.first.second end + + test "should get adr prohibition options" do + assert_kind_of Array, adr_prohibition_options + assert_operator 2, '<', adr_prohibition_options.count + assert_equal 'Kaukokiito', adr_prohibition_options.third.second + + text = I18n.t 'administration.delivery_methods.adr_prohibition_options.permit_adr', :fi + assert_equal text, adr_prohibition_options.first.first + end end diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index e62537798..151063505 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -13,4 +13,15 @@ def setup @delivery_method.selite = "Kiitolinja" refute @delivery_method.valid?, "Delivery method already exists" end + + test 'should validate adr prohibition' do + @delivery_method.vak_kielto = '' + assert @delivery_method.valid? + + @delivery_method.vak_kielto = 'K' + assert @delivery_method.valid? + + @delivery_method.vak_kielto = 'neko' + refute @delivery_method.valid?, "Invalid vak_kielto value" + end end From 23b68642b909c1b9aa4c054bcde5305db804b020 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 25 Aug 2015 13:36:30 +0300 Subject: [PATCH 035/189] ignore delivery method options --- config/i18n-tasks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 3d026840c..d227c5b02 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -38,3 +38,4 @@ ignore_unused: - 'administration.printers.{mediatyyppi_options,merkisto_options}.*' - 'administration.sum_levels.{kayttotarkoitus_options,kumulatiivinen_options}.*' - 'administration.qualifiers.{kaytossa_options}.*' +- 'administration.delivery_methods.{*_options}.*' From 05c691dd058047a96f6510ef268090ed46601b2f Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 25 Aug 2015 13:40:12 +0300 Subject: [PATCH 036/189] alternative adr delivery method option --- app/helpers/delivery_method_helper.rb | 22 +++++++++--- app/models/delivery_method.rb | 21 +++++------ config/locales/fi.yml | 7 ++-- test/helpers/delivery_method_helper_test.rb | 39 +++++++++++++-------- test/models/delivery_method_test.rb | 8 +++++ 5 files changed, 65 insertions(+), 32 deletions(-) diff --git a/app/helpers/delivery_method_helper.rb b/app/helpers/delivery_method_helper.rb index 172a50feb..2545a4a9f 100644 --- a/app/helpers/delivery_method_helper.rb +++ b/app/helpers/delivery_method_helper.rb @@ -23,16 +23,28 @@ def sorting_point_options def adr_prohibition_options options = [ - [ t("#{ROOT}.adr_prohibition_options.permit_adr"), "" ], - [ t("#{ROOT}.adr_prohibition_options.adr_prohibition"), "K" ] + [ t("administration.delivery_methods.adr_prohibition_options.permit_adr"), "" ], + [ t("administration.delivery_methods.adr_prohibition_options.adr_prohibition"), "K" ] ] - options = options + adr_options + text = t("administration.delivery_methods.adr_prohibition_options.adr_shipment") + + options = options + adr_options(text) + options.reject { |i,_| i.empty? } + end + + def alternative_adr_delivery_method_options + options = [ + [ t("administration.delivery_methods.alternative_adr_delivery_method_options.adr_products_transfer_prohibition"), "" ], + ] + + text = t("administration.delivery_methods.alternative_adr_delivery_method_options.adr_products_transfer_permit") + + options = options + adr_options(text) options.reject { |i,_| i.empty? } end - def adr_options - text = t("#{ROOT}.adr_prohibition_options.adr_shipment") + def adr_options(text) DeliveryMethod.permit_adr.shipment.map do |i| [ "#{text} #{i.selite}", i.selite ] end diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 21ada0dde..5cb969399 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -7,6 +7,7 @@ class DeliveryMethod < BaseModel end validates :selite, uniqueness: true + validate :vaihtoehtoinen_vak_toimitustapa_validation validate :vak_kielto_validation scope :permit_adr, -> { where(vak_kielto: '') } @@ -100,13 +101,6 @@ class DeliveryMethod < BaseModel simple_label: 'oslap_mg' } - # def alternative_adr_delivery_method_options - # [ - # ["VAK-tuotteita ei siirretä omalle tilaukselleen", ""], - # adr_options("VAK-tuotteet siirretään omalle tilaukselleen toimitustavalla") - # ].reject {|i,_| i.empty?} - # end - def permitted_packaging_options [] end @@ -117,10 +111,17 @@ def carrier_options private - def vak_kielto_validation - allowed = DeliveryMethod.permit_adr.shipment.pluck(:selite) - allowed += [ '', 'K' ] + def permit_adr_shipments + DeliveryMethod.permit_adr.shipment.pluck(:selite) + end + def vak_kielto_validation + allowed = DeliveryMethod.permit_adr.shipment.pluck(:selite) + [ '', 'K' ] errors.add :vak_kielto, I18n.t('errors.messages.inclusion') unless allowed.include? vak_kielto end + + def vaihtoehtoinen_vak_toimitustapa_validation + allowed = permit_adr_shipments + [ '' ] + errors.add :vaihtoehtoinen_vak_toimitustapa, I18n.t('errors.messages.inclusion') unless allowed.include? vaihtoehtoinen_vak_toimitustapa + end end diff --git a/config/locales/fi.yml b/config/locales/fi.yml index b8f7ac691..4c9c04ded 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -318,6 +318,9 @@ fi: adr_prohibition: Toimitustavalla ei saa toimittaa VAK-tuotteita adr_shipment: VAK-tuotteet toimitetaan toimitustavalla permit_adr: Toimitustavalla saa toimittaa VAK-tuotteita + alternative_adr_delivery_method_options: + adr_products_transfer_permit: VAK-tuotteet siirretään omalle tilaukselleen toimitustavalla + adr_products_transfer_prohibition: VAK-tuotteita ei siirretä omalle tilaukselleen cash_on_delivery_prohibition_options: cash_on_delivery_permitted: Toimitustavalla saa toimittaa jälkivaatimuksia cash_on_delivery_prohibition: Toimitustavalla ei saa toimittaa jälkivaatimuksia @@ -511,7 +514,7 @@ fi: - pe - la abbr_month_names: - - + - - tammi - helmi - maalis @@ -537,7 +540,7 @@ fi: long: "%A %e. %Bta %Y" short: "%d %b" month_names: - - + - - tammikuu - helmikuu - maaliskuu diff --git a/test/helpers/delivery_method_helper_test.rb b/test/helpers/delivery_method_helper_test.rb index 058c332c3..762b0172d 100644 --- a/test/helpers/delivery_method_helper_test.rb +++ b/test/helpers/delivery_method_helper_test.rb @@ -4,7 +4,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated pickup options valid for collection" do assert pickup_options.is_a? Array - text = I18n.t 'administration.delivery_methods.pickup_options.shipment', :fi + text = I18n.t 'administration.delivery_methods.pickup_options.shipment' assert_equal text, pickup_options.first.first assert_equal 'shipment', pickup_options.first.second end @@ -12,7 +12,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated saturday delivery options valid for collection" do assert saturday_delivery_options.is_a? Array - text = I18n.t 'administration.delivery_methods.saturday_delivery_options.saturday_delivery', :fi + text = I18n.t 'administration.delivery_methods.saturday_delivery_options.saturday_delivery' assert_equal text, saturday_delivery_options.second.first assert_equal 'saturday_delivery', saturday_delivery_options.second.second end @@ -20,7 +20,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated transport unit options valid for collection" do assert transport_unit_options.is_a? Array - text = I18n.t 'administration.delivery_methods.transport_unit_options.transport_unit', :fi + text = I18n.t 'administration.delivery_methods.transport_unit_options.transport_unit' assert_equal text, transport_unit_options.second.first assert_equal 'transport_unit', transport_unit_options.second.second end @@ -28,7 +28,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated print method options valid for collection" do assert print_method_options.is_a? Array - text = I18n.t 'administration.delivery_methods.print_method_options.batch', :fi + text = I18n.t 'administration.delivery_methods.print_method_options.batch' assert_equal text, print_method_options.first.first assert_equal 'batch', print_method_options.first.second end @@ -36,7 +36,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated freight contract options valid for collection" do assert freight_contract_options.is_a? Array - text = I18n.t 'administration.delivery_methods.freight_contract_options.sender_freight_contract', :fi + text = I18n.t 'administration.delivery_methods.freight_contract_options.sender_freight_contract' assert_equal text, freight_contract_options.first.first assert_equal 'sender_freight_contract', freight_contract_options.first.second end @@ -44,7 +44,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated logy waybill number options valid for collection" do assert logy_waybill_number_options.is_a? Array - text = I18n.t 'administration.delivery_methods.logy_waybill_number_options.use_logy_waybill_numbers', :fi + text = I18n.t 'administration.delivery_methods.logy_waybill_number_options.use_logy_waybill_numbers' assert_equal text, logy_waybill_number_options.second.first assert_equal 'use_logy_waybill_numbers', logy_waybill_number_options.second.second end @@ -52,7 +52,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated extranet options valid for collection" do assert extranet_options.is_a? Array - text = I18n.t 'administration.delivery_methods.extranet_options.only_in_sales', :fi + text = I18n.t 'administration.delivery_methods.extranet_options.only_in_sales' assert_equal text, extranet_options.first.first assert_equal 'only_in_sales', extranet_options.first.second end @@ -60,7 +60,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated container options valid for collection" do assert container_options.is_a? Array - text = I18n.t 'administration.delivery_methods.container_options.includes_container', :fi + text = I18n.t 'administration.delivery_methods.container_options.includes_container' assert_equal text, container_options.first.first assert_equal 'includes_container', container_options.first.second end @@ -68,7 +68,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated cash on delivery prohibition options valid for collection" do assert cash_on_delivery_prohibition_options.is_a? Array - text = I18n.t 'administration.delivery_methods.cash_on_delivery_prohibition_options.cash_on_delivery_permitted', :fi + text = I18n.t 'administration.delivery_methods.cash_on_delivery_prohibition_options.cash_on_delivery_permitted' assert_equal text, cash_on_delivery_prohibition_options.first.first assert_equal 'cash_on_delivery_permitted', cash_on_delivery_prohibition_options.first.second end @@ -76,7 +76,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated special packaging prohibition options valid for collection" do assert special_packaging_prohibition_options.is_a? Array - text = I18n.t 'administration.delivery_methods.special_packaging_prohibition_options.special_packaging_permitted', :fi + text = I18n.t 'administration.delivery_methods.special_packaging_prohibition_options.special_packaging_permitted' assert_equal text, special_packaging_prohibition_options.first.first assert_equal 'special_packaging_permitted', special_packaging_prohibition_options.first.second end @@ -84,7 +84,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated packing line prohibition options valid for collection" do assert packing_line_prohibition_options.is_a? Array - text = I18n.t 'administration.delivery_methods.packing_line_prohibition_options.reserve_packing_line', :fi + text = I18n.t 'administration.delivery_methods.packing_line_prohibition_options.reserve_packing_line' assert_equal text, packing_line_prohibition_options.first.first assert_equal 'reserve_packing_line', packing_line_prohibition_options.first.second end @@ -92,7 +92,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated waybill specification options valid for collection" do assert waybill_specification_options.is_a? Array - text = I18n.t 'administration.delivery_methods.waybill_specification_options.print_waybill_specification', :fi + text = I18n.t 'administration.delivery_methods.waybill_specification_options.print_waybill_specification' assert_equal text, waybill_specification_options.second.first assert_equal 'print_waybill_specification', waybill_specification_options.second.second end @@ -100,7 +100,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated new packaging information options for collection" do assert new_packaging_information_options.is_a? Array - text = I18n.t 'administration.delivery_methods.new_packaging_information_options.package_info_entry_denied', :fi + text = I18n.t 'administration.delivery_methods.new_packaging_information_options.package_info_entry_denied' assert_equal text, new_packaging_information_options.first.first assert_equal 'package_info_entry_denied', new_packaging_information_options.first.second end @@ -108,7 +108,7 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated transportation insurance type options for collection" do assert transportation_insurance_type_options.is_a? Array - text = I18n.t 'administration.delivery_methods.transportation_insurance_type_options.currency_based_insurance', :fi + text = I18n.t 'administration.delivery_methods.transportation_insurance_type_options.currency_based_insurance' assert_equal text, transportation_insurance_type_options.third.first assert_equal 'currency_based_insurance', transportation_insurance_type_options.third.second end @@ -156,7 +156,16 @@ class DeliveryMethodHelperTest < ActionView::TestCase assert_operator 2, '<', adr_prohibition_options.count assert_equal 'Kaukokiito', adr_prohibition_options.third.second - text = I18n.t 'administration.delivery_methods.adr_prohibition_options.permit_adr', :fi + text = I18n.t 'administration.delivery_methods.adr_prohibition_options.permit_adr' assert_equal text, adr_prohibition_options.first.first end + + test "should get alternative adr delivery method options" do + assert_kind_of Array, alternative_adr_delivery_method_options + assert_operator 2, '<', alternative_adr_delivery_method_options.count + assert_equal 'Kaukokiito', alternative_adr_delivery_method_options.second.second + + text = I18n.t 'administration.delivery_methods.alternative_adr_delivery_method_options.adr_products_transfer_prohibition' + assert_equal text, alternative_adr_delivery_method_options.first.first + end end diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 151063505..935218ffa 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -24,4 +24,12 @@ def setup @delivery_method.vak_kielto = 'neko' refute @delivery_method.valid?, "Invalid vak_kielto value" end + + test 'should validate alternative adr prohibition' do + @delivery_method.vaihtoehtoinen_vak_toimitustapa = '' + assert @delivery_method.valid? + + @delivery_method.vaihtoehtoinen_vak_toimitustapa = 'neko' + refute @delivery_method.valid?, "Invalid vaihtoehtoinen_vak_toimitustapa value" + end end From 9925183c3734a42120611920e8880faa1c3f5765 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 25 Aug 2015 13:44:53 +0300 Subject: [PATCH 037/189] add sorting point relation --- app/models/delivery_method.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 5cb969399..d56ce2746 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -4,6 +4,7 @@ class DeliveryMethod < BaseModel o.has_many :mode_of_transports, primary_key: :kuljetusmuoto, class_name: 'Keyword::ModeOfTransport' o.has_many :nature_of_transactions, primary_key: :kauppatapahtuman_luonne, class_name: 'Keyword::NatureOfTransaction' o.has_many :customs, primary_key: :poistumistoimipaikka_koodi, class_name: 'Keyword::Customs' + o.has_many :sorting_point, primary_key: :lajittelupiste, class_name: 'Keyword::SortingPoint' end validates :selite, uniqueness: true From b4f344fc9bfe46831c87e94138152b0b4e13b53f Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 25 Aug 2015 15:06:57 +0300 Subject: [PATCH 038/189] keyword helper and tests --- app/helpers/delivery_method_helper.rb | 20 --------------- app/helpers/keyword_helper.rb | 20 +++++++++++++++ test/helpers/delivery_method_helper_test.rb | 25 ------------------ test/helpers/keyword_helper_test.rb | 28 +++++++++++++++++++++ 4 files changed, 48 insertions(+), 45 deletions(-) create mode 100644 test/helpers/keyword_helper_test.rb diff --git a/app/helpers/delivery_method_helper.rb b/app/helpers/delivery_method_helper.rb index 2545a4a9f..a48762e46 100644 --- a/app/helpers/delivery_method_helper.rb +++ b/app/helpers/delivery_method_helper.rb @@ -1,26 +1,6 @@ module DeliveryMethodHelper ROOT = 'administration.delivery_methods' - def waybill_options - Keyword::Waybill.all.map { |i| [ i.selitetark, i.selite ] } - end - - def mode_of_transport_options - Keyword::ModeOfTransport.all.map { |i| [ i.selitetark, i.selite ] } - end - - def nature_of_transaction_options - Keyword::NatureOfTransaction.all.map { |i| [ i.selitetark, i.selite ] } - end - - def customs_options - Keyword::Customs.all.map { |i| [ "#{i.selite} #{i.selitetark}", i.selite ] } - end - - def sorting_point_options - Keyword::SortingPoint.all.map { |i| [ i.selitetark, i.selite ] } - end - def adr_prohibition_options options = [ [ t("administration.delivery_methods.adr_prohibition_options.permit_adr"), "" ], diff --git a/app/helpers/keyword_helper.rb b/app/helpers/keyword_helper.rb index 9bb385985..93bbefc6a 100644 --- a/app/helpers/keyword_helper.rb +++ b/app/helpers/keyword_helper.rb @@ -28,4 +28,24 @@ def translatable_locales_options [ 'Venäjä', 'ru' ], ] end + + def waybill_options + Keyword::Waybill.pluck(:selitetark, :selite) + end + + def mode_of_transport_options + Keyword::ModeOfTransport.pluck(:selitetark, :selite) + end + + def nature_of_transaction_options + Keyword::NatureOfTransaction.pluck(:selitetark, :selite) + end + + def customs_options + Keyword::Customs.pluck("CONCAT(selite, ' ', selitetark)", :selite) + end + + def sorting_point_options + Keyword::SortingPoint.pluck(:selitetark, :selite) + end end diff --git a/test/helpers/delivery_method_helper_test.rb b/test/helpers/delivery_method_helper_test.rb index 762b0172d..41b5da072 100644 --- a/test/helpers/delivery_method_helper_test.rb +++ b/test/helpers/delivery_method_helper_test.rb @@ -113,16 +113,6 @@ class DeliveryMethodHelperTest < ActionView::TestCase assert_equal 'currency_based_insurance', transportation_insurance_type_options.third.second end - test "should get waybill options" do - assert_kind_of Array, waybill_options - assert_equal 'rahtikirja.inc', waybill_options.first.second - end - - test "should get mode of transport options" do - assert_kind_of Array, mode_of_transport_options - assert_equal '1 - Merikuljetus (ml. auto- ja junalauttakuljetus)', mode_of_transport_options.first.first - end - test "should get label options" do Current.company.parameter.kerayserat = '' @@ -136,21 +126,6 @@ class DeliveryMethodHelperTest < ActionView::TestCase assert label_options.any? { |_,key| key == 'simple_label' } end - test "should get nature of transaction options" do - assert_kind_of Array, nature_of_transaction_options - assert_equal '11 - Suora osto/myynti', nature_of_transaction_options.first.first - end - - test "should get customs options" do - assert_kind_of Array, customs_options - assert_equal 'FI001000', customs_options.first.second - end - - test "should get sorting point options" do - assert_kind_of Array, sorting_point_options - assert_equal 'FIVAT', sorting_point_options.first.second - end - test "should get adr prohibition options" do assert_kind_of Array, adr_prohibition_options assert_operator 2, '<', adr_prohibition_options.count diff --git a/test/helpers/keyword_helper_test.rb b/test/helpers/keyword_helper_test.rb new file mode 100644 index 000000000..64e7bc1a6 --- /dev/null +++ b/test/helpers/keyword_helper_test.rb @@ -0,0 +1,28 @@ +require 'test_helper' + +class KeywordHelperTest < ActionView::TestCase + test "should get waybill options" do + assert_kind_of Array, waybill_options + assert_equal 'rahtikirja.inc', waybill_options.first.second + end + + test "should get mode of transport options" do + assert_kind_of Array, mode_of_transport_options + assert_equal '1 - Merikuljetus (ml. auto- ja junalauttakuljetus)', mode_of_transport_options.first.first + end + + test "should get nature of transaction options" do + assert_kind_of Array, nature_of_transaction_options + assert_equal '11 - Suora osto/myynti', nature_of_transaction_options.first.first + end + + test "should get customs options" do + assert_kind_of Array, customs_options + assert_equal 'FI001000', customs_options.first.second + end + + test "should get sorting point options" do + assert_kind_of Array, sorting_point_options + assert_equal 'FIVAT', sorting_point_options.first.second + end +end From 214b91f6f5eb48cee44e48ca5ed9fc45af985048 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 25 Aug 2015 15:15:27 +0300 Subject: [PATCH 039/189] carrier options --- app/helpers/carrier_helper.rb | 4 ++++ app/models/delivery_method.rb | 4 ---- test/helpers/carrier_helper_test.rb | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/helpers/carrier_helper.rb b/app/helpers/carrier_helper.rb index 1c7ef98c6..2c0fa14af 100644 --- a/app/helpers/carrier_helper.rb +++ b/app/helpers/carrier_helper.rb @@ -6,4 +6,8 @@ def neutraali_options [ t("#{ROOT}.neutraali_options.#{key}"), key ] end end + + def carrier_options + Carrier.pluck(:nimi, :koodi) + end end diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index d56ce2746..f987a57e9 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -106,10 +106,6 @@ def permitted_packaging_options [] end - def carrier_options - #company.carriers.map { |i| [ i.nimi, i.koodi ] } - end - private def permit_adr_shipments diff --git a/test/helpers/carrier_helper_test.rb b/test/helpers/carrier_helper_test.rb index 60e1eb9db..17df23ef3 100644 --- a/test/helpers/carrier_helper_test.rb +++ b/test/helpers/carrier_helper_test.rb @@ -8,4 +8,9 @@ class CarrierHelperTest < ActionView::TestCase assert_equal text, neutraali_options.first.first assert_equal 'neutral', neutraali_options.first.second end + + test "should get carrier options" do + assert_kind_of Array, carrier_options + assert_equal 'HIT', carrier_options.first.second + end end From 9dff496284fcf1f21780deb9ca51010634b712f8 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 25 Aug 2015 18:23:38 +0300 Subject: [PATCH 040/189] from hash to array --- app/classes/postal_official_legend.rb | 486 +++++++++++++------------- 1 file changed, 243 insertions(+), 243 deletions(-) diff --git a/app/classes/postal_official_legend.rb b/app/classes/postal_official_legend.rb index ee961922e..e67b6a9bc 100644 --- a/app/classes/postal_official_legend.rb +++ b/app/classes/postal_official_legend.rb @@ -1,247 +1,247 @@ class PostalOfficialLegend def self.options - { - "Ei valintaa": "", - "Pupesoft / Itella": { - "Express City 00": "Itella Express City 00", - "Express Morning 9": "Itella Express Morning 9", - "Express Business Day 14": "Itella Express Business Day 14", - "Express Point 00/16": "Itella Express Point 00/16", - "Express Flex 21": "Itella Express Flex 21", - "Economy 16": "Itella Economy 16", - "Customer Return": "Itella Customer Return", - "Undelivered Shipment": "Itella Undelivered Shipment", - "Lisäarvokuljetus": "Itella Lisäarvokuljetus", - "Priority Ulkomaa": "Itella Priority Ulkomaan lähetys" - }, - "Unifaun / Itella": { - "ITELLAMAILEC": "Itella Economy Letter", - "IT16": "Itella Economy Parcel", - "IT14": "Itella Express Business Day", - "ITKY14": "Itella Express Business Day kuljetusyksikkö", - "ITKY14I": "Itella Express Business Day pallet (Ulkomaa)", - "IT14I": "Itella Express Business Day parcel (Ulkomaa)", - "ITEXPC": "Itella Express City", - "ITKYEXPC": "Itella Express City kuljetusyksikkö", - "IT21": "Itella Express Flex", - "ITKY21": "Itella Express Flex kuljetusyksikkö", - "IT09": "Itella Express Morning", - "ITKY09": "Itella Express Morning kuljetusyksikkö", - "TPSTD": "Itella Logistics Oy, Kappaletavara", - "ITELLALOGKR": "Itella Logistics Oy, Kotimaan Rahti", - "ITELLAMAILPR": "Itella Priority Letter", - "ITPR": "Itella Priority Parcel", - "ITSP": "Itella SmartPOST", - "ITVAK": "Itella VAK/ADR", - "ITKYVAK": "Itella VAK/ADR kuljetusyksikkö" - }, - "Unifaun / Bring": { - "PNL359": "Bring CarryOn Budget", - "PNL330": "Bring CarryOn Business", - "PNL335": "Bring CarryOn Business 09.00", - "PNL333": "Bring CarryOn Business BulkReturn", - "PNL332": "Bring CarryOn Business BulkSplit", - "PNL334": "Bring CarryOn Business BulkSplit 09.00", - "PNL336": "Bring CarryOn Business Pallet", - "PNL339": "Bring CarryOn Business Pallet 09.00", - "PNL331": "Bring CarryOn Business Return", - "PNL340": "Bring CarryOn HomeShopping", - "PNL343": "Bring CarryOn HomeShopping BulkReturn", - "PNL342": "Bring CarryOn HomeShopping BulkSplit", - "PNL349": "Bring CarryOn HomeShopping BulkSplit Home", - "PNL345": "Bring CarryOn HomeShopping BulkSplit Mini", - "PNL341": "Bring CarryOn HomeShopping Return", - "PNLWAY": "Bring CarryOn Waybill", - "BOXBD": "Bring Express Business Distribution", - "BOXBDP": "Bring Express Business Distribution Pallet", - "BOXCA": "Bring Express Courier Ad-Hoc", - "BOXCD": "Bring Express Courier Distribution", - "BOXHD": "Bring Express Home Delivery", - "BOXHDR": "Bring Express Home Delivery Return", - "BOXQP": "Bring Express QuickPack", - "BOXSHD": "Bring Express Store Home Delivery", - "BOXSHDR": "Bring Express Store Home Delivery Return" - }, - "Unifaun / Dachser": { - "DACTFIX": "Dachser Targofix", - "DACTFIX10": "Dachser Targofix 10:00", - "DACTFIX12": "Dachser Targofix 12:00", - "DACTFLEX": "Dachser Targoflex", - "DACTSPEED": "Dachser Targospeed", - "DACTSPEED10": "Dachser Targospeed 10:00", - "DACTSPEED12": "Dachser Targospeed 12:00", - "DACTSPEEDPLUS": "Dachser Targospeed Plus" - }, - "Unifaun / DANX": { - "DANXSTD": "DANX" - }, - "Unifaun / DB Schenker": { - "SBTLFIEXP": "DB SCHENKER Express (Finland)", - "SBTLFISY": "DB SCHENKER Finland System", - "BBU": "DB SCHENKERbudget", - "BCSI": "DB SCHENKERcoldsped - Europa", - "BCS": "DB SCHENKERcoldsped - Sverige", - "BDI": "DB SCHENKERdirect", - "BPA": "DB SCHENKERparcel", - "BPHDP": "DB SCHENKERprivpak - Hem Dag (utan avisering och kvittens)", - "BPHDAP": "DB SCHENKERprivpak - Hem Dag med avisering (och kvittens) (Paket)", - "BPHKAP": "DB SCHENKERprivpak - Hem Kväll med avisering (och kvittens)", - "BHP": "DB SCHENKERprivpak - Ombud Standard (1 kolli, <20 kg)", - "BPOSG": "DB SCHENKERprivpak - Terminal", - "BPTJP": "DB SCHENKERprivpak - Till Jobbet", - "BCF": "DB SCHENKERsystem" - }, - "Unifaun / DHL": { - "ASU": "DHL Euroconnect", - "ASUP": "DHL Euroconnect Plus", - "DASECD": "DHL Express 09:00 (Tullinalainen)", - "DASE": "DHL Express 09:00 (Tullivapaa)", - "DATDM": "DHL Express 10:30 (Tullinalainen)", - "DATDL": "DHL Express 10:30 (Tullivapaa)", - "DAMECD": "DHL Express 12:00 (Tullinalainen)", - "DAME": "DHL Express 12:00 (Tullivapaa)", - "DAXPD": "DHL Express Envelope (Tullivapaa)", - "DADOM": "DHL Express Worldwide (Kotimaa)", - "DAWPX": "DHL Express Worldwide (Tullinalainen)", - "DAECX": "DHL Express Worldwide (Tullivapaa EU: ssa)", - "DADOX": "DHL Express Worldwide (Tullivapaa, Ei-EU)", - "DHLFREIGHTESTDOM": "DHL Freight Domestic EE", - "DHLFREIGHTESTEC": "DHL Freight Euroconnect EE", - "DHLFREIGHTFIEC": "DHL Freight Euroconnect FI", - "DHLFREIGHTFIKT": "DHL Freight Kotimaa", - "DGFAIR": "DHL Global Forwarding Air Freight", - "DGFAIRPLUS": "DHL Global Forwarding Air Freight PLUS", - "AEX": "DHL Paket", - "ASP2": "DHL Pall", - "ASWP2": "DHL Parti", - "ASPO": "DHL Service Point", - "ASPOC": "DHL Service Point C.O.D.", - "ASPOR": "DHL Service Point Retur", - "ASWS2": "DHL Stycke", - "ASWP": "DHL Swednet Partigods", - "ASWS": "DHL Swednet Styckegods" - }, - "Unifaun / DSV": { - "DSVFIGRP": "DSV Road Kappaletavara", - "DSVFIFULL": "DSV Road Osakuorma" - }, - "Unifaun / Fennoway": { - "FENNORAHTI": "Fennoway Fennorahti" - }, - "Unifaun / GLS": { - "GLSFIINT": "GLS Suomi INTERNATIONAL" - }, - "Unifaun / Kaukokiito": { - "KKSTD": "Kaukokiito" - }, - "Unifaun / Kiitolinja": { - "KLGRP": "KIITOLINJA kappaletavara" - }, - "Unifaun / KN Road": { - "KUEHNENAGELROAD": "KN Road" - }, - "Unifaun / Tyvi": { - "KTYVI": "Kuljetusliike Tyvi Oy" - }, - "Unifaun / Matkahuolto": { - "MH68": "Matkahuolto Ahvenanmaan Jakopaketti", - "MH63": "Matkahuolto Baltian Paketti", - "MH10": "Matkahuolto Bussipaketti", - "MH43": "Matkahuolto Dokumenttikuori", - "MH3050": "Matkahuolto Jakopaketti/Paikallispaketti", - "MH57": "Matkahuolto Lavarahti", - "MH81": "Matkahuolto Lähellä-paketin palautus", - "MH80": "Matkahuolto Lähellä-paketti", - "MH75": "Matkahuolto Mannermaan Jakopaketti", - "MH74": "Matkahuolto Mannermaan Paketti", - "MH20": "Matkahuolto Pikapaketti", - "MH82": "Matkahuolto Postaalipaketti", - "MH83": "Matkahuolto Postaalipaketti palautus", - "MH40": "Matkahuolto Rahtipussi", - "MH42": "Matkahuolto Rahtipussi jakopaketti" - }, - "Unifaun / Neutraali": { - "FREEG": "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja)", - "FREEG_793": "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja): Transpori Oy", - "FREEG_794": "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja): AJ Laine Oy", - "FREEB": "Neutraali Kirjepalvelu", - "FREEP": "Neutraali pakettipalvelu (osoitekortti)" - }, - "Unifaun / Posten Brev": { - "PAF": "Posten Brev - Brevpostförskott", - "BEXPD": "Posten Brev - Express (kotimaa)", - "BREV": "Posten Brev - Normaali", - "BEXPI": "Posten Brev - Priority+", - "BVAL": "Posten Brev - Värde", - "BREKD": "Posten Brev Kirjattu kirje (BREKD)", - "BREKI": "Posten Brev Kirjattu kirje (BREKI)", - "EMSD2": "Posten EMS (brev/dokument)", - "EMSP2": "Posten EMS (paket/varor)" - }, - "Unifaun / PostNord": { - "DPDFI": "PostNord DPD Classic (Suomi)", - "P15": "PostNord Logistics DPD Företagspaket", - "P14": "PostNord Logistics DPD Företagspaket 12.00", - "DPD": "PostNord Logistics DPD Utrikes", - "P42": "PostNord Logistics Express - Express 07.00", - "P32": "PostNord Logistics Hempaket", - "DTPGHD": "PostNord Logistics Hjemlevering (Norge)", - "H48": "PostNord Logistics InNight", - "P31": "PostNord Logistics Kundretur", - "P19": "PostNord Logistics MyPack", - "P19FI": "PostNord Logistics MyPack (Suomi)", - "P19NO": "PostNord Logistics MyPack (Norja)", - "P24": "PostNord Logistics MyPack return", - "P24FI": "PostNord Logistics MyPack return (Suomi)", - "P24NO": "PostNord Logistics MyPack Return (Norja)", - "P52": "PostNord Logistics PALL.ETT", - "DTPGPF": "PostNord Logistics Partifrakt (Norja)", - "P91": "PostNord Logistics Postpaket Utrikes", - "DTPGSG": "PostNord Logistics Stykkgods (Norja)" - }, - "Unifaun / Privpak": { - "PPFITRRET": "Privpak Finland (normaali & palautus)", - "PPFITR": "Privpak Finland (normaali)" - }, - "Unifaun / R & P": { - "RPPP": "R & P Kuljetus Pakettipalvelu" - }, - "Unifaun / TK Logistik": { - "TKLOGGODS": "TK Logistik Gods" - }, - "Unifaun / TNT": { - "TNT08DOMD": "TNT 08:00 Express (Domestic Docs)", - "TNT08DOMN": "TNT 08:00 Express (Domestic Non Docs)", - "TNT09D": "TNT 09:00 Express (Docs)", - "TNT09DOMD": "TNT 09:00 Express (Domestic Docs)", - "TNT09DOMN": "TNT 09:00 Express (Domestic Non Docs)", - "TNT09": "TNT 09:00 Express (Domestic)", - "TNT09N": "TNT 09:00 Express (Non Docs)", - "TNT10D": "TNT 10:00 Express (Docs)", - "TNT10DOMD": "TNT 10:00 Express (Domestic Docs)", - "TNT10DOMN": "TNT 10:00 Express (Domestic Non Docs)", - "TNT10": "TNT 10:00 Express (Domestic)", - "TNT10N": "TNT 10:00 Express (Non Docs)", - "TNT412": "TNT 12:00 Economy Express (Non Docs)", - "TNT12D": "TNT 12:00 Express (Docs)", - "TNT12DOMD": "TNT 12:00 Express (Domestic Docs)", - "TNT12DOMN": "TNT 12:00 Express (Domestic Non Docs)", - "TNT12": "TNT 12:00 Express (Domestic)", - "TNT12N": "TNT 12:00 Express (Non Docs)", - "TNT48N": "TNT Economy Express (Non Docs)", - "TNT15D": "TNT Express (Docs)", - "TNT15DOMD": "TNT Express (Domestic Docs)", - "TNT15DOMN": "TNT Express (Domestic Non Docs)", - "TNT15": "TNT Express (Domestic)", - "TNT15N": "TNT Express (Non Docs)", - "TNT728": "TNT Special Economy Express" - }, - "Unifaun / UPK": { - "UPKE": "Uudenmaan Pikakuljetus Oy Erikoisaikataulu", - "UPKK": "Uudenmaan Pikakuljetus Oy Kotijakelu", - "UPK24": "Uudenmaan Pikakuljetus Oy Normal 24h", - "UPK24A": "Uudenmaan Pikakuljetus Oy Normal 24h AVI" - } - } + [ + [ "Ei valintaa" , [ "Ei valintaa" ]], + [ "Pupesoft / Itella", [ + [ "Itella Express City 00", "Express City 00" ], + [ "Itella Express Morning 9", "Express Morning 9" ], + [ "Itella Express Business Day 14", "Express Business Day 14" ], + [ "Itella Express Point 00/16", "Express Point 00/16" ], + [ "Itella Express Flex 21", "Express Flex 21" ], + [ "Itella Economy 16", "Economy 16" ], + [ "Itella Customer Return", "Customer Return" ], + [ "Itella Undelivered Shipment", "Undelivered Shipment" ], + [ "Itella Lisäarvokuljetus", "Lisäarvokuljetus" ], + [ "Itella Priority Ulkomaan lähetys", "Priority Ulkomaa" ] + ]], + [ "Unifaun / Itella", [ + [ "Itella Economy Letter", "ITELLAMAILEC" ], + [ "Itella Economy Parcel", "IT16" ], + [ "Itella Express Business Day", "IT14" ], + [ "Itella Express Business Day kuljetusyksikkö", "ITKY14" ], + [ "Itella Express Business Day pallet (Ulkomaa)", "ITKY14I" ], + [ "Itella Express Business Day parcel (Ulkomaa)", "IT14I" ], + [ "Itella Express City", "ITEXPC" ], + [ "Itella Express City kuljetusyksikkö", "ITKYEXPC" ], + [ "Itella Express Flex", "IT21" ], + [ "Itella Express Flex kuljetusyksikkö", "ITKY21" ], + [ "Itella Express Morning", "IT09" ], + [ "Itella Express Morning kuljetusyksikkö", "ITKY09" ], + [ "Itella Logistics Oy, Kappaletavara", "TPSTD" ], + [ "Itella Logistics Oy, Kotimaan Rahti", "ITELLALOGKR" ], + [ "Itella Priority Letter", "ITELLAMAILPR" ], + [ "Itella Priority Parcel", "ITPR" ], + [ "Itella SmartPOST", "ITSP" ], + [ "Itella VAK/ADR", "ITVAK" ], + [ "Itella VAK/ADR kuljetusyksikkö", "ITKYVAK" ] + ]], + [ "Unifaun / Bring", [ + [ "Bring CarryOn Budget", "PNL359" ], + [ "Bring CarryOn Business", "PNL330" ], + [ "Bring CarryOn Business 09.00", "PNL335" ], + [ "Bring CarryOn Business BulkReturn", "PNL333" ], + [ "Bring CarryOn Business BulkSplit", "PNL332" ], + [ "Bring CarryOn Business BulkSplit 09.00", "PNL334" ], + [ "Bring CarryOn Business Pallet", "PNL336" ], + [ "Bring CarryOn Business Pallet 09.00", "PNL339" ], + [ "Bring CarryOn Business Return", "PNL331" ], + [ "Bring CarryOn HomeShopping", "PNL340" ], + [ "Bring CarryOn HomeShopping BulkReturn", "PNL343" ], + [ "Bring CarryOn HomeShopping BulkSplit", "PNL342" ], + [ "Bring CarryOn HomeShopping BulkSplit Home", "PNL349" ], + [ "Bring CarryOn HomeShopping BulkSplit Mini", "PNL345" ], + [ "Bring CarryOn HomeShopping Return", "PNL341" ], + [ "Bring CarryOn Waybill", "PNLWAY" ], + [ "Bring Express Business Distribution", "BOXBD" ], + [ "Bring Express Business Distribution Pallet", "BOXBDP" ], + [ "Bring Express Courier Ad-Hoc", "BOXCA" ], + [ "Bring Express Courier Distribution", "BOXCD" ], + [ "Bring Express Home Delivery", "BOXHD" ], + [ "Bring Express Home Delivery Return", "BOXHDR" ], + [ "Bring Express QuickPack", "BOXQP" ], + [ "Bring Express Store Home Delivery", "BOXSHD" ], + [ "Bring Express Store Home Delivery Return", "BOXSHDR" ] + ]], + [ "Unifaun / Dachser", [ + [ "Dachser Targofix", "DACTFIX" ], + [ "Dachser Targofix 10:00", "DACTFIX10" ], + [ "Dachser Targofix 12:00", "DACTFIX12" ], + [ "Dachser Targoflex", "DACTFLEX" ], + [ "Dachser Targospeed", "DACTSPEED" ], + [ "Dachser Targospeed 10:00", "DACTSPEED10" ], + [ "Dachser Targospeed 12:00", "DACTSPEED12" ], + [ "Dachser Targospeed Plus", "DACTSPEEDPLUS" ] + ]], + [ "Unifaun / DANX", [ + [ "DANX", "DANXSTD" ] + ]], + [ "Unifaun / DB Schenker", [ + [ "DB SCHENKER Express (Finland)", "SBTLFIEXP" ], + [ "DB SCHENKER Finland System", "SBTLFISY" ], + [ "DB SCHENKERbudget", "BBU" ], + [ "DB SCHENKERcoldsped - Europa", "BCSI" ], + [ "DB SCHENKERcoldsped - Sverige", "BCS" ], + [ "DB SCHENKERdirect", "BDI" ], + [ "DB SCHENKERparcel", "BPA" ], + [ "DB SCHENKERprivpak - Hem Dag (utan avisering och kvittens)", "BPHDP" ], + [ "DB SCHENKERprivpak - Hem Dag med avisering (och kvittens) (Paket)", "BPHDAP" ], + [ "DB SCHENKERprivpak - Hem Kväll med avisering (och kvittens)", "BPHKAP" ], + [ "DB SCHENKERprivpak - Ombud Standard (1 kolli, <20 kg)", "BHP" ], + [ "DB SCHENKERprivpak - Terminal", "BPOSG" ], + [ "DB SCHENKERprivpak - Till Jobbet", "BPTJP" ], + [ "DB SCHENKERsystem", "BCF" ] + ]], + [ "Unifaun / DHL", [ + [ "DHL Euroconnect", "ASU" ], + [ "DHL Euroconnect Plus", "ASUP" ], + [ "DHL Express 09:00 (Tullinalainen)", "DASECD" ], + [ "DHL Express 09:00 (Tullivapaa)", "DASE" ], + [ "DHL Express 10:30 (Tullinalainen)", "DATDM" ], + [ "DHL Express 10:30 (Tullivapaa)", "DATDL" ], + [ "DHL Express 12:00 (Tullinalainen)", "DAMECD" ], + [ "DHL Express 12:00 (Tullivapaa)", "DAME" ], + [ "DHL Express Envelope (Tullivapaa)", "DAXPD" ], + [ "DHL Express Worldwide (Kotimaa)", "DADOM" ], + [ "DHL Express Worldwide (Tullinalainen)", "DAWPX" ], + [ "DHL Express Worldwide (Tullivapaa EU:ssa)", "DAECX" ], + [ "DHL Express Worldwide (Tullivapaa, Ei-EU)", "DADOX" ], + [ "DHL Freight Domestic EE", "DHLFREIGHTESTDOM" ], + [ "DHL Freight Euroconnect EE", "DHLFREIGHTESTEC" ], + [ "DHL Freight Euroconnect FI", "DHLFREIGHTFIEC" ], + [ "DHL Freight Kotimaa", "DHLFREIGHTFIKT" ], + [ "DHL Global Forwarding Air Freight", "DGFAIR" ], + [ "DHL Global Forwarding Air Freight PLUS", "DGFAIRPLUS" ], + [ "DHL Paket", "AEX" ], + [ "DHL Pall", "ASP2" ], + [ "DHL Parti", "ASWP2" ], + [ "DHL Service Point", "ASPO" ], + [ "DHL Service Point C.O.D.", "ASPOC" ], + [ "DHL Service Point Retur", "ASPOR" ], + [ "DHL Stycke", "ASWS2" ], + [ "DHL Swednet Partigods", "ASWP" ], + [ "DHL Swednet Styckegods", "ASWS" ] + ]], + [ "Unifaun / DSV", [ + [ "DSV Road Kappaletavara", "DSVFIGRP" ], + [ "DSV Road Osakuorma", "DSVFIFULL" ] + ]], + [ "Unifaun / Fennoway", [ + [ "Fennoway Fennorahti", "FENNORAHTI" ] + ]], + [ "Unifaun / GLS", [ + [ "GLS Suomi INTERNATIONAL", "GLSFIINT" ] + ]], + [ "Unifaun / Kaukokiito", [ + [ "Kaukokiito", "KKSTD" ] + ]], + [ "Unifaun / Kiitolinja", [ + [ "KIITOLINJA kappaletavara", "KLGRP" ] + ]], + [ "Unifaun / KN Road", [ + [ "KN Road", "KUEHNENAGELROAD" ] + ]], + [ "Unifaun / Tyvi", [ + [ "Kuljetusliike Tyvi Oy", "KTYVI" ] + ]], + [ "Unifaun / Matkahuolto", [ + [ "Matkahuolto Ahvenanmaan Jakopaketti", "MH68" ], + [ "Matkahuolto Baltian Paketti", "MH63" ], + [ "Matkahuolto Bussipaketti", "MH10" ], + [ "Matkahuolto Dokumenttikuori", "MH43" ], + [ "Matkahuolto Jakopaketti/Paikallispaketti", "MH3050" ], + [ "Matkahuolto Lavarahti", "MH57" ], + [ "Matkahuolto Lähellä-paketin palautus", "MH81" ], + [ "Matkahuolto Lähellä-paketti", "MH80" ], + [ "Matkahuolto Mannermaan Jakopaketti", "MH75" ], + [ "Matkahuolto Mannermaan Paketti", "MH74" ], + [ "Matkahuolto Pikapaketti", "MH20" ], + [ "Matkahuolto Postaalipaketti", "MH82" ], + [ "Matkahuolto Postaalipaketti palautus", "MH83" ], + [ "Matkahuolto Rahtipussi", "MH40" ], + [ "Matkahuolto Rahtipussi jakopaketti", "MH42" ] + ]], + [ "Unifaun / Neutraali", [ + [ "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja)", "FREEG" ], + [ "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja): Transpori Oy", "FREEG_793" ], + [ "Neutraali Kappaletavarapalvelu (osoitekortti + rahtikirja): AJ Laine Oy", "FREEG_794" ], + [ "Neutraali Kirjepalvelu", "FREEB" ], + [ "Neutraali pakettipalvelu (osoitekortti)", "FREEP" ] + ]], + [ "Unifaun / Posten Brev", [ + [ "Posten Brev - Brevpostförskott", "PAF" ], + [ "Posten Brev - Express (kotimaa)", "BEXPD" ], + [ "Posten Brev - Normaali", "BREV" ], + [ "Posten Brev - Priority+", "BEXPI" ], + [ "Posten Brev - Värde", "BVAL" ], + [ "Posten Brev Kirjattu kirje (BREKD)", "BREKD" ], + [ "Posten Brev Kirjattu kirje (BREKI)", "BREKI" ], + [ "Posten EMS (brev/dokument)", "EMSD2" ], + [ "Posten EMS (paket/varor)", "EMSP2" ] + ]], + [ "Unifaun / PostNord", [ + [ "PostNord DPD Classic (Suomi)", "DPDFI" ], + [ "PostNord Logistics DPD Företagspaket", "P15" ], + [ "PostNord Logistics DPD Företagspaket 12.00", "P14" ], + [ "PostNord Logistics DPD Utrikes", "DPD" ], + [ "PostNord Logistics Express - Express 07.00", "P42" ], + [ "PostNord Logistics Hempaket", "P32" ], + [ "PostNord Logistics Hjemlevering (Norge)", "DTPGHD" ], + [ "PostNord Logistics InNight", "H48" ], + [ "PostNord Logistics Kundretur", "P31" ], + [ "PostNord Logistics MyPack", "P19" ], + [ "PostNord Logistics MyPack (Suomi)", "P19FI" ], + [ "PostNord Logistics MyPack (Norja)", "P19NO" ], + [ "PostNord Logistics MyPack return", "P24" ], + [ "PostNord Logistics MyPack return (Suomi)", "P24FI" ], + [ "PostNord Logistics MyPack Return (Norja)", "P24NO" ], + [ "PostNord Logistics PALL.ETT", "P52" ], + [ "PostNord Logistics Partifrakt (Norja)", "DTPGPF" ], + [ "PostNord Logistics Postpaket Utrikes", "P91" ], + [ "PostNord Logistics Stykkgods (Norja)", "DTPGSG" ] + ]], + [ "Unifaun / Privpak", [ + [ "Privpak Finland (normaali & palautus)", "PPFITRRET" ], + [ "Privpak Finland (normaali)", "PPFITR" ] + ]], + [ "Unifaun / R & P", [ + [ "R & P Kuljetus Pakettipalvelu", "RPPP" ] + ]], + [ "Unifaun / TK Logistik", [ + [ "TK Logistik Gods", "TKLOGGODS" ] + ]], + [ "Unifaun / TNT", [ + [ "TNT 08:00 Express (Domestic Docs)", "TNT08DOMD" ], + [ "TNT 08:00 Express (Domestic Non Docs)", "TNT08DOMN" ], + [ "TNT 09:00 Express (Docs)", "TNT09D" ], + [ "TNT 09:00 Express (Domestic Docs)", "TNT09DOMD" ], + [ "TNT 09:00 Express (Domestic Non Docs)", "TNT09DOMN" ], + [ "TNT 09:00 Express (Domestic)", "TNT09" ], + [ "TNT 09:00 Express (Non Docs)", "TNT09N" ], + [ "TNT 10:00 Express (Docs)", "TNT10D" ], + [ "TNT 10:00 Express (Domestic Docs)", "TNT10DOMD" ], + [ "TNT 10:00 Express (Domestic Non Docs)", "TNT10DOMN" ], + [ "TNT 10:00 Express (Domestic)", "TNT10" ], + [ "TNT 10:00 Express (Non Docs)", "TNT10N" ], + [ "TNT 12:00 Economy Express (Non Docs)", "TNT412" ], + [ "TNT 12:00 Express (Docs)", "TNT12D" ], + [ "TNT 12:00 Express (Domestic Docs)", "TNT12DOMD" ], + [ "TNT 12:00 Express (Domestic Non Docs)", "TNT12DOMN" ], + [ "TNT 12:00 Express (Domestic)", "TNT12" ], + [ "TNT 12:00 Express (Non Docs)", "TNT12N" ], + [ "TNT Economy Express (Non Docs)", "TNT48N" ], + [ "TNT Express (Docs)", "TNT15D" ], + [ "TNT Express (Domestic Docs)", "TNT15DOMD" ], + [ "TNT Express (Domestic Non Docs)", "TNT15DOMN" ], + [ "TNT Express (Domestic)", "TNT15" ], + [ "TNT Express (Non Docs)", "TNT15N" ], + [ "TNT Special Economy Express", "TNT728" ] + ]], + [ "Unifaun / UPK", [ + [ "Uudenmaan Pikakuljetus Oy Erikoisaikataulu", "UPKE" ], + [ "Uudenmaan Pikakuljetus Oy Kotijakelu", "UPKK" ], + [ "Uudenmaan Pikakuljetus Oy Normal 24h", "UPK24" ], + [ "Uudenmaan Pikakuljetus Oy Normal 24h AVI", "UPK24A" ] + ]] + ] end end From c4b4bb0214e20768b629d35d7b94a806c6b7b27d Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 25 Aug 2015 18:24:01 +0300 Subject: [PATCH 041/189] route for delivery method --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index 453d634c1..a00d6733b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -23,6 +23,7 @@ resources :carriers resources :cash_registers resources :currencies, except: :destroy + resources :delivery_methods resources :fiscal_years, except: :destroy resources :packing_areas resources :printers From 8b2647ec30d9ed23bc23e18b9a9551af98a6bf53 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 25 Aug 2015 18:24:59 +0300 Subject: [PATCH 042/189] permissions for delivery method --- test/fixtures/permissions.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/test/fixtures/permissions.yml b/test/fixtures/permissions.yml index 960de934a..cbe43d173 100644 --- a/test/fixtures/permissions.yml +++ b/test/fixtures/permissions.yml @@ -7,6 +7,7 @@ companies currencies customers + delivery_methods fiscal_years packing_areas printers From 46090e5e8f1285f916a288c3b545bbcea4e68e04 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 25 Aug 2015 18:26:15 +0300 Subject: [PATCH 043/189] delivery method controller and view --- .../delivery_methods_controller.rb | 40 ++++++ app/models/delivery_method.rb | 2 + .../delivery_methods/_form.html.erb | 26 ++++ .../delivery_methods/edit.html.erb | 6 + .../delivery_methods/index.html.erb | 117 ++++++++++++++++++ config/locales/fi.yml | 6 + .../delivery_method_controller_test.rb | 15 +++ 7 files changed, 212 insertions(+) create mode 100644 app/controllers/administration/delivery_methods_controller.rb create mode 100644 app/views/administration/delivery_methods/_form.html.erb create mode 100644 app/views/administration/delivery_methods/edit.html.erb create mode 100644 app/views/administration/delivery_methods/index.html.erb create mode 100644 test/controllers/administration/delivery_method_controller_test.rb diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb new file mode 100644 index 000000000..1911ed830 --- /dev/null +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -0,0 +1,40 @@ +class Administration::DeliveryMethodsController < AdministrationController + def index + @delivery_methods = DeliveryMethod.search_like(search_params).order(order_params) + end + + private + def delivery_method_params + params.require(:delivery_method).permit( + :selite, + :tulostustapa, + :sopimusnro, + :nouto, + :ei_pakkaamoa, + :extranet, + :rahtikirja, + :jarjestys, + ) + end + + def searchable_columns + [ + :selite, + :tulostustapa, + :sopimusnro, + :nouto, + :ei_pakkaamoa, + :extranet, + :rahtikirja, + :jarjestys, + ] + end + + def find_resource + @delivery_method = DeliveryMethod.find params[:id] + end + + def sortable_columns + searchable_columns + end +end diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index f987a57e9..139bc9ed3 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -1,4 +1,6 @@ class DeliveryMethod < BaseModel + include Searchable + with_options foreign_key: :selite do |o| o.has_many :waybills, primary_key: :rahtikirja, class_name: 'Keyword::Waybill' o.has_many :mode_of_transports, primary_key: :kuljetusmuoto, class_name: 'Keyword::ModeOfTransport' diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb new file mode 100644 index 000000000..24a95a6bb --- /dev/null +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -0,0 +1,26 @@ +<%= render "administration/form_errors", resource: @delivery_method %> + +<%= form_for @delivery_method do |f| %> + + + + + + + + + + + + + + + + + + +
<%= f.label :selite %><%= f.text_field :selite %>
<%= f.label :lahdon_selite %><%= f.text_field :lahdon_selite %>
<%= f.label :virallinen_selite %><%= f.select :virallinen_selite, grouped_options_for_select(PostalOfficialLegend.options, @delivery_method.virallinen_selite) %>
<%= f.label :tulostustapa %><%= f.text_field :tulostustapa %>
+ + <%= render 'administration/actions', f: f %> + +<% end %> diff --git a/app/views/administration/delivery_methods/edit.html.erb b/app/views/administration/delivery_methods/edit.html.erb new file mode 100644 index 000000000..67d687399 --- /dev/null +++ b/app/views/administration/delivery_methods/edit.html.erb @@ -0,0 +1,6 @@ +<%= return_link t('administration.delivery_methods.index.header'), delivery_methods_path %> + +
+ +<%= render "administration/header", text: t('administration.delivery_methods.edit.header') %> +<%= render 'form' %> diff --git a/app/views/administration/delivery_methods/index.html.erb b/app/views/administration/delivery_methods/index.html.erb new file mode 100644 index 000000000..f6ca03975 --- /dev/null +++ b/app/views/administration/delivery_methods/index.html.erb @@ -0,0 +1,117 @@ +<%= render "administration/header", text: t('.header') %> + +<%= button_to t('.button_new'), new_delivery_method_path, method: :get if update_access? %> + +

+ +<%= form_tag delivery_methods_path, method: :get do %> + + + + + + + + + + + + + + + + + + + + + + + <% @delivery_methods.each do |delivery_method| %> + + + + + + + + + + + + + + + + + + + + <% end %> + +
+ <%= sortable "selite", DeliveryMethod.human_attribute_name(:selite) %> +
+ <%= text_field_tag :selite, params[:selite] %> +
+ <%= sortable "tulostustapa", DeliveryMethod.human_attribute_name(:tulostustapa) %> +
+ <%= text_field_tag :tulostustapa, params[:tulostustapa] %> +
+ <%= sortable "sopimusnro", DeliveryMethod.human_attribute_name(:sopimusnro) %> +
+ <%= text_field_tag :sopimusnro, params[:sopimusnro] %> +
+ <%= sortable "nouto", DeliveryMethod.human_attribute_name(:nouto) %> +
+ <%= text_field_tag :nouto, params[:nouto] %> +
+ <%= sortable "ei_pakkaamoa", DeliveryMethod.human_attribute_name(:ei_pakkaamoa) %> +
+ <%= text_field_tag :ei_pakkaamoa, params[:ei_pakkaamoa] %> +
+ <%= sortable "extranet", DeliveryMethod.human_attribute_name(:extranet) %> +
+ <%= text_field_tag :extranet, params[:extranet] %> +
+ <%= sortable "rahtikirja", DeliveryMethod.human_attribute_name(:rahtikirja) %> +
+ <%= text_field_tag :rahtikirja, params[:rahtikirja] %> +
+ <%= sortable "jarjestys", DeliveryMethod.human_attribute_name(:jarjestys) %> +
+ <%= text_field_tag :jarjestys, params[:jarjestys] %> +
+ <%= submit_tag t('.button_search') %> +
+ <%= link_to delivery_method.selite, edit_delivery_method_path(delivery_method.id) %> + + <%= t("administration.delivery_methods.print_method_options.batch") if delivery_method.batch? %> + <%= t("administration.delivery_methods.print_method_options.collective_batch") if delivery_method.collective_batch? %> + <%= t("administration.delivery_methods.print_method_options.collective_instant") if delivery_method.collective_instant? %> + <%= t("administration.delivery_methods.print_method_options.instant") if delivery_method.instant? %> + <%= t("administration.delivery_methods.print_method_options.skip_print") if delivery_method.skip_print? %> + + <%= delivery_method.sopimusnro %> + + <%= t("administration.delivery_methods.pickup_options.pickup") if delivery_method.pickup? %> + <%= t("administration.delivery_methods.pickup_options.shipment") if delivery_method.shipment? %> + + <%= t("administration.delivery_methods.packing_line_prohibition_options.not_reserving_packing_line") if delivery_method.not_reserving_packing_line? %> + <%= t("administration.delivery_methods.packing_line_prohibition_options.reserve_packing_line") if delivery_method.reserve_packing_line? %> + + <%= t("administration.delivery_methods.extranet_options.both_in_sales_and_extranet") if delivery_method.both_in_sales_and_extranet? %> + <%= t("administration.delivery_methods.extranet_options.only_in_extranet") if delivery_method.only_in_extranet? %> + <%= t("administration.delivery_methods.extranet_options.only_in_sales") if delivery_method.only_in_sales? %> + + <%= delivery_method.rahtikirja %> + + <%= delivery_method.jarjestys %> + +
+ +<% end %> + +
+ +<%= button_to t('.button_new'), new_delivery_method_path, method: :get if update_access? %> diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 4c9c04ded..dc1c6cf87 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -327,6 +327,8 @@ fi: container_options: includes_container: Kyllä not_including_container: Ei + edit: + header: Toimitustapa extranet_options: both_in_sales_and_extranet: Toimitustapa näytetään molemmissa only_in_extranet: Toimitustapa näytetään vain extranetissä @@ -334,6 +336,10 @@ fi: freight_contract_options: receiver_freight_contract: Käytetään vastaanottajan rahtisopimusta sender_freight_contract: Käytetään lähettäjän rahtisopimusta + index: + button_new: Uusi toimitustapa + button_search: Etsi + header: Toimitustavat label_options: compact_label: Tiivistetty intrade_label: Intrade diff --git a/test/controllers/administration/delivery_method_controller_test.rb b/test/controllers/administration/delivery_method_controller_test.rb new file mode 100644 index 000000000..06005170a --- /dev/null +++ b/test/controllers/administration/delivery_method_controller_test.rb @@ -0,0 +1,15 @@ +require 'test_helper' + +class Administration::DeliveryMethodsControllerTest < ActionController::TestCase + def setup + login users(:joe) + @delivery_method = delivery_methods(:kaukokiito) + end + + test 'should get index' do + get :index + assert_response :success + + assert_template "index", "Template should be index" + end +end From ccc42b8522293eba5a1a6381c787bf6cad6e334e Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 25 Aug 2015 18:32:23 +0300 Subject: [PATCH 044/189] fix test --- test/classes/postal_official_legend_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/classes/postal_official_legend_test.rb b/test/classes/postal_official_legend_test.rb index 831929c2d..f09cc5b05 100644 --- a/test/classes/postal_official_legend_test.rb +++ b/test/classes/postal_official_legend_test.rb @@ -3,6 +3,6 @@ class PostalOfficialLegendTest < ActiveSupport::TestCase test 'should get proper legend' do legends = PostalOfficialLegend.options - assert_equal 'Itella Express City 00', legends[:"Pupesoft / Itella"][:"Express City 00"] + assert_equal 'Itella Express City 00', legends.second.second.first.first end end From b48f3ddd36ed4c2ed4b54a35cce22a8916f4d7a2 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 26 Aug 2015 09:33:40 +0300 Subject: [PATCH 045/189] work on edit view --- app/helpers/carrier_helper.rb | 2 +- .../delivery_methods/_form.html.erb | 19 ++++++++++++++++++- config/locales/fi.yml | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/helpers/carrier_helper.rb b/app/helpers/carrier_helper.rb index 2c0fa14af..43ba7db49 100644 --- a/app/helpers/carrier_helper.rb +++ b/app/helpers/carrier_helper.rb @@ -8,6 +8,6 @@ def neutraali_options end def carrier_options - Carrier.pluck(:nimi, :koodi) + Carrier.order(:nimi, :koodi).pluck(:nimi, :koodi) end end diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 24a95a6bb..72afb3f83 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -17,7 +17,24 @@ <%= f.label :tulostustapa %> - <%= f.text_field :tulostustapa %> + <%= f.select :tulostustapa, print_method_options %> + + + <%= f.label :rahtikirja %> + <%= f.select :rahtikirja, waybill_options %> + + + <%= f.label :logy_rahtikirjanumerot %> + <%= f.select :logy_rahtikirjanumerot, logy_waybill_number_options %> + + + <%= f.label :osoitelappu %> + <%= f.select :osoitelappu, label_options %> + + + <%= f.label :rahdinkuljettaja %> + <%= f.select :rahdinkuljettaja, carrier_options, + { include_blank: t('administration.delivery_methods.edit.no_select') } %> diff --git a/config/locales/fi.yml b/config/locales/fi.yml index dc1c6cf87..904d4fd24 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -329,6 +329,7 @@ fi: not_including_container: Ei edit: header: Toimitustapa + no_select: Ei valintaa extranet_options: both_in_sales_and_extranet: Toimitustapa näytetään molemmissa only_in_extranet: Toimitustapa näytetään vain extranetissä From 73e6e0d74b9b9e9023fefa517036954b1a9c6644 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 26 Aug 2015 09:41:51 +0300 Subject: [PATCH 046/189] update edit view --- .../delivery_methods/_form.html.erb | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 72afb3f83..fb30129a0 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -36,6 +36,26 @@ <%= f.select :rahdinkuljettaja, carrier_options, { include_blank: t('administration.delivery_methods.edit.no_select') } %> + + <%= f.label :rahti_tuotenumero %> + <%= f.text_field :rahti_tuotenumero %> + + + <%= f.label :sopimusnro %> + <%= f.text_field :sopimusnro %> + + + <%= f.label :rahtikirjakopio_email %> + <%= f.text_field :rahtikirjakopio_email %> + + + <%= f.label :jvkulu %> + <%= f.text_field :jvkulu %> + + + <%= f.label :jvkielto %> + <%= f.select :jvkielto, cash_on_delivery_prohibition_options %> + <%= render 'administration/actions', f: f %> From 6ddbce731924e78087709a82c8b30b8270e11d67 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 26 Aug 2015 10:06:15 +0300 Subject: [PATCH 047/189] update edit view --- .../delivery_methods/_form.html.erb | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index fb30129a0..eb631a8e1 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -56,6 +56,103 @@ <%= f.label :jvkielto %> <%= f.select :jvkielto, cash_on_delivery_prohibition_options %> + + <%= f.label :vak_kielto %> + <%= f.select :vak_kielto, adr_prohibition_options %> + + + <%= f.label :vaihtoehtoinen_vak_toimitustapa %> + <%= f.select :vaihtoehtoinen_vak_toimitustapa, alternative_adr_delivery_method_options %> + + + <%= f.label :erikoispakkaus_kielto %> + <%= f.select :erikoispakkaus_kielto, special_packaging_prohibition_options %> + + + <%= f.label :nouto %> + <%= f.select :nouto, pickup_options %> + + + <%= f.label :lauantai %> + <%= f.select :lauantai, saturday_delivery_options %> + + + <%= f.label :kuljyksikko %> + <%= f.select :kuljyksikko, transport_unit_options %> + + + <%= f.label :erilliskasiteltavakulu %> + <%= f.text_field :erilliskasiteltavakulu %> + + + <%= f.label :merahti %> + <%= f.select :merahti, freight_contract_options %> + + + <%= f.label :kuljetusvakuutus_tuotenumero %> + <%= f.text_field :kuljetusvakuutus_tuotenumero %> + + + <%= f.label :kuljetusvakuutus %> + <%= f.text_field :kuljetusvakuutus %> + + + <%= f.label :kuljetusvakuutus_tyyppi %> + <%= f.select :kuljetusvakuutus_tyyppi, transportation_insurance_type_options %> + + + <%= f.label :extranet %> + <%= f.select :extranet, extranet_options %> + + + <%= f.label :ei_pakkaamoa %> + <%= f.select :ei_pakkaamoa, packing_line_prohibition_options %> + + + <%= f.label :erittely %> + <%= f.select :erittely, waybill_specification_options %> + + + <%= f.label :uudet_pakkaustiedot %> + <%= f.select :uudet_pakkaustiedot, new_packaging_information_options %> + + + <%= f.label :lajittelupiste %> + <%= f.select :lajittelupiste, sorting_point_options, + { include_blank: t('administration.delivery_methods.edit.no_select') } %> + + + <%= f.label :kuluprosentti %> + <%= f.text_field :kuluprosentti %> + + + <%= f.label :toim_ovttunnus %> + <%= f.text_field :toim_ovttunnus %> + + + <%= f.label :toim_nimi %> + <%= f.text_field :toim_nimi %> + + + <%= f.label :toim_nimitark %> + <%= f.text_field :toim_nimitark %> + + + <%= f.label :toim_osoite %> + <%= f.text_field :toim_osoite %> + + + <%= f.label :toim_postino %> + <%= f.text_field :toim_postino %> + + + <%= f.label :toim_postitp %> + <%= f.text_field :toim_postitp %> + + + <%= f.label :toim_maa %> + <%= f.text_field :toim_maa %> + <%= render 'administration/actions', f: f %> From 050a77c811a489b8f86453dabb82875079004f6f Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 26 Aug 2015 10:21:31 +0300 Subject: [PATCH 048/189] update edit view --- .../delivery_methods/_form.html.erb | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index eb631a8e1..185b01a77 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -153,6 +153,78 @@ <%= f.label :toim_maa %> <%= f.text_field :toim_maa %> + + <%= f.label :maa_maara %> + <%= f.text_field :maa_maara %> + + + <%= f.label :sisamaan_kuljetus %> + <%= f.text_field :sisamaan_kuljetus %> + + + <%= f.label :sisamaan_kuljetus_kansallisuus %> + <%= f.text_field :sisamaan_kuljetus_kansallisuus %> + + + <%= f.label :sisamaan_kuljetusmuoto %> + <%= f.select :sisamaan_kuljetusmuoto, mode_of_transport_options, + { include_blank: t('administration.delivery_methods.edit.no_select') } %> + + + <%= f.label :kontti %> + <%= f.select :kontti, container_options, + { include_blank: t('administration.delivery_methods.edit.no_select') } %> + + + <%= f.label :aktiivinen_kuljetus %> + <%= f.text_field :aktiivinen_kuljetus %> + + + <%= f.label :aktiivinen_kuljetus_kansallisuus %> + <%= f.text_field :aktiivinen_kuljetus_kansallisuus %> + + + <%= f.label :kauppatapahtuman_luonne %> + <%= f.select :kauppatapahtuman_luonne, nature_of_transaction_options, + { include_blank: t('administration.delivery_methods.edit.no_select') } %> + + + <%= f.label :kuljetusmuoto %> + <%= f.select :kuljetusmuoto, mode_of_transport_options, + { include_blank: t('administration.delivery_methods.edit.no_select') } %> + + + <%= f.label :poistumistoimipaikka_koodi %> + <%= f.select :poistumistoimipaikka_koodi, customs_options, + { include_blank: t('administration.delivery_methods.edit.no_select') } %> + + + <%= f.label :ulkomaanlisa %> + <%= f.text_field :ulkomaanlisa %> + + + <%= f.label :sallitut_maat %> + <%= f.text_field :sallitut_maat %> + + + <%= f.label :sallitut_alustat %> + <%= f.text_field :sallitut_alustat %> + + + <%= f.label :lisakulu %> + <%= f.text_field :lisakulu %> + + + <%= f.label :lisakulu_summa %> + <%= f.text_field :lisakulu_summa %> + + + <%= f.label :jarjestys %> + <%= f.text_field :jarjestys %> + + + <%= render 'administration/resource_timestamps_and_users', resource: @delivery_method %> + <%= render 'administration/actions', f: f %> From 50c3b7f0a31edd0b68aa5eaf2865e9722d6ee41c Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 26 Aug 2015 10:49:54 +0300 Subject: [PATCH 049/189] validations --- app/models/delivery_method.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 139bc9ed3..a78a74d1a 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -9,7 +9,22 @@ class DeliveryMethod < BaseModel o.has_many :sorting_point, primary_key: :lajittelupiste, class_name: 'Keyword::SortingPoint' end - validates :selite, uniqueness: true + validates :selite, uniqueness: true, length: { within: 1..50 } + validates :lahdon_selite, :sallitut_alustat, length: { within: 1..150 }, allow_blank: true + validates :rahti_tuotenumero, :rahtikirjakopio_email, :kuljetusvakuutus_tuotenumero, :toim_nimi, + :toim_nimitark, length: { within: 1..60 }, allow_blank: true + validates :sopimusnro, :sallitut_maat, length: { within: 1..50 }, allow_blank: true + validates :jvkulu, :erilliskasiteltavakulu, :kuljetusvakuutus, :kuluprosentti, :ulkomaanlisa, + :lisakulu, :lisakulu_summa, numericality: true, allow_blank: true + validates :jarjestys, numericality: { only_integer: true }, allow_blank: true + validates :toim_ovttunnus, length: { within: 1..25 }, allow_blank: true + validates :toim_osoite, length: { within: 1..55 }, allow_blank: true + validates :toim_postino, length: { within: 1..15 }, allow_blank: true + validates :toim_postitp, :toim_maa, length: { within: 1..35 }, allow_blank: true + validates :maa_maara, :sisamaan_kuljetus_kansallisuus, :aktiivinen_kuljetus_kansallisuus, + length: { within: 1..2 }, allow_blank: true + validates :sisamaan_kuljetus, :aktiivinen_kuljetus, length: { within: 1..30 }, allow_blank: true + validate :vaihtoehtoinen_vak_toimitustapa_validation validate :vak_kielto_validation From 549c93b2a1991d40060c50247244e07c10cfa525 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 26 Aug 2015 11:47:08 +0300 Subject: [PATCH 050/189] delivery method controller & controller tests --- .../delivery_methods_controller.rb | 30 ++++++++++ config/locales/fi.yml | 4 ++ .../delivery_method_controller_test.rb | 58 ++++++++++++++++++- 3 files changed, 91 insertions(+), 1 deletion(-) diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index 1911ed830..97837deb3 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -3,6 +3,36 @@ def index @delivery_methods = DeliveryMethod.search_like(search_params).order(order_params) end + def show + render :edit + end + + def edit + end + + def new + @delivery_method = DeliveryMethod.new + render :edit + end + + def create + @delivery_method = DeliveryMethod.new delivery_method_params + + if @delivery_method.save + redirect_to delivery_methods_path, notice: t('.create_success') + else + render :edit + end + end + + def update + if @delivery_method.update delivery_method_params + redirect_to delivery_methods_path, notice: t('.update_success') + else + render :edit + end + end + private def delivery_method_params params.require(:delivery_method).permit( diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 904d4fd24..4b2fd52ed 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -327,6 +327,8 @@ fi: container_options: includes_container: Kyllä not_including_container: Ei + create: + create_success: Toimitustapa luotiin onnistuneesti edit: header: Toimitustapa no_select: Ei valintaa @@ -380,6 +382,8 @@ fi: percentage_based_insurance: Prosentuaalinen kuljetusvakuutus lisätään percentage_based_insurance_with_discount: Prosentuaalinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen asiakasalennusta use_company_default: Yhtiön oletus + update: + update_success: Toimitustapa päivitettiin onnistuneesti waybill_specification_options: no_waybill_specification: Toimitustavalle ei tulosteta rahtikirjaerittelyä print_waybill_specification: Toimitustavalle tulostetaan rahtikirjaerittely diff --git a/test/controllers/administration/delivery_method_controller_test.rb b/test/controllers/administration/delivery_method_controller_test.rb index 06005170a..bec8f469b 100644 --- a/test/controllers/administration/delivery_method_controller_test.rb +++ b/test/controllers/administration/delivery_method_controller_test.rb @@ -2,7 +2,7 @@ class Administration::DeliveryMethodsControllerTest < ActionController::TestCase def setup - login users(:joe) + login users(:bob) @delivery_method = delivery_methods(:kaukokiito) end @@ -12,4 +12,60 @@ def setup assert_template "index", "Template should be index" end + + test 'should get edit' do + get :edit, id: @delivery_method.tunnus + assert_response :success + end + + test 'show should be edit' do + get :show, id: @delivery_method.tunnus + assert_response :success + end + + test 'should create delivery method' do + assert_difference('DeliveryMethod.count', 1, response.body) do + + params = { + selite: "Random delivery method", + tulostustapa: 'H', + sopimusnro: '', + nouto: :shipment, + ei_pakkaamoa: '1', + extranet: :only_in_sales, + rahtikirja: 'rahtikirja.inc', + jarjestys: 1 + } + + post :create, delivery_method: params + assert_redirected_to delivery_methods_path + end + end + + test 'should not create delivery method' do + assert_no_difference('DeliveryMethod.count') do + + params = { + not_existing_column: true, + nouto: '' + } + + post :create, delivery_method: params + assert_template "edit", "Template should be edit" + end + end + + test 'should update delivery method' do + params = { tulostustapa: :collective_batch } + + patch :update, id: @delivery_method.id, delivery_method: params + assert_redirected_to delivery_methods_path + end + + test 'should not update delivery method' do + params = { selite: 'Kiitolinja' } + + patch :update, id: @delivery_method.id, delivery_method: params + assert_template "edit", "Template should be edit" + end end From c899b4e15dfa3546424cc88cd50eb7def9cb2bef Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 26 Aug 2015 12:10:42 +0300 Subject: [PATCH 051/189] use attribute sanitator and define float columns --- app/models/delivery_method.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index a78a74d1a..aea192efb 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -1,4 +1,5 @@ class DeliveryMethod < BaseModel + include AttributeSanitator include Searchable with_options foreign_key: :selite do |o| @@ -14,8 +15,6 @@ class DeliveryMethod < BaseModel validates :rahti_tuotenumero, :rahtikirjakopio_email, :kuljetusvakuutus_tuotenumero, :toim_nimi, :toim_nimitark, length: { within: 1..60 }, allow_blank: true validates :sopimusnro, :sallitut_maat, length: { within: 1..50 }, allow_blank: true - validates :jvkulu, :erilliskasiteltavakulu, :kuljetusvakuutus, :kuluprosentti, :ulkomaanlisa, - :lisakulu, :lisakulu_summa, numericality: true, allow_blank: true validates :jarjestys, numericality: { only_integer: true }, allow_blank: true validates :toim_ovttunnus, length: { within: 1..25 }, allow_blank: true validates :toim_osoite, length: { within: 1..55 }, allow_blank: true @@ -28,6 +27,9 @@ class DeliveryMethod < BaseModel validate :vaihtoehtoinen_vak_toimitustapa_validation validate :vak_kielto_validation + float_columns :jvkulu, :erilliskasiteltavakulu, :kuljetusvakuutus, :kuluprosentti, :ulkomaanlisa, + :lisakulu, :lisakulu_summa + scope :permit_adr, -> { where(vak_kielto: '') } self.table_name = :toimitustapa From 228dc94a47f6936b1a3c8f4683c72ff07a0567e6 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 26 Aug 2015 12:15:09 +0300 Subject: [PATCH 052/189] add customer relation for delivery method --- app/models/customer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/customer.rb b/app/models/customer.rb index 5cc09452f..10714008c 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,5 +1,6 @@ class Customer < BaseModel - belongs_to :terms_of_payment, foreign_key: :maksuehto, primary_key: :tunnus + belongs_to :terms_of_payment, foreign_key: :maksuehto, primary_key: :tunnus + belongs_to :delivery_method, foreign_key: :toimitustapa, primary_key: :selite default_scope { where.not(laji: %w(P R)) } From 83cfad2345109c85f965de3a6965413c04ed204b Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 26 Aug 2015 12:44:19 +0300 Subject: [PATCH 053/189] fix tests --- .../delivery_method_controller_test.rb | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/controllers/administration/delivery_method_controller_test.rb b/test/controllers/administration/delivery_method_controller_test.rb index bec8f469b..d04d80486 100644 --- a/test/controllers/administration/delivery_method_controller_test.rb +++ b/test/controllers/administration/delivery_method_controller_test.rb @@ -2,7 +2,7 @@ class Administration::DeliveryMethodsControllerTest < ActionController::TestCase def setup - login users(:bob) + login users(:joe) @delivery_method = delivery_methods(:kaukokiito) end @@ -24,6 +24,8 @@ def setup end test 'should create delivery method' do + login users(:bob) + assert_difference('DeliveryMethod.count', 1, response.body) do params = { @@ -43,6 +45,8 @@ def setup end test 'should not create delivery method' do + login users(:bob) + assert_no_difference('DeliveryMethod.count') do params = { @@ -56,6 +60,8 @@ def setup end test 'should update delivery method' do + login users(:bob) + params = { tulostustapa: :collective_batch } patch :update, id: @delivery_method.id, delivery_method: params @@ -63,9 +69,21 @@ def setup end test 'should not update delivery method' do + login users(:bob) + params = { selite: 'Kiitolinja' } patch :update, id: @delivery_method.id, delivery_method: params assert_template "edit", "Template should be edit" end + + test "should delete delivery method" do + login users(:bob) + + assert_difference("DeliveryMethod.count", -1) do + delete :destroy, id: @delivery_method.id + end + + assert_redirected_to delivery_methods_path + end end From 4b85d453b270ea4451486a56878d9df6de76795a Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 26 Aug 2015 12:44:45 +0300 Subject: [PATCH 054/189] add translations --- config/locales/fi.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 4b2fd52ed..b52ea5929 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -330,12 +330,16 @@ fi: create: create_success: Toimitustapa luotiin onnistuneesti edit: + button_remove: Poista toimitustapa + confirm_remove: Oletko varma, että haluat poistaa toimitustavan? header: Toimitustapa no_select: Ei valintaa extranet_options: both_in_sales_and_extranet: Toimitustapa näytetään molemmissa only_in_extranet: Toimitustapa näytetään vain extranetissä only_in_sales: Toimitustapa näytetään vain myynnissä + destroy: + destroy_success: Toimitustapa poistettiin onnistuneesti freight_contract_options: receiver_freight_contract: Käytetään vastaanottajan rahtisopimusta sender_freight_contract: Käytetään lähettäjän rahtisopimusta @@ -669,6 +673,8 @@ fi: in_use_customers: 'HUOM: Maksuehtoa ei voi poistaa, koska se on käytössä %{count} asiakkaalla' in_use_sales_order_drafts: 'HUOM: Maksuehtoa ei voi poistaa, koska se on käytössä %{count} keskeneräisellä myyntitilauksella' in_use_sales_orders: 'HUOM: Maksuehtoa ei voi poistaa, koska se on käytössä %{count} toimittamattomalla myyntitilauksella' + delivery_method: + in_use_customers: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaalla' fixed_assets: commodities: activate: From 8eb42980ffaa0660bdcd92cbc1da8f6c1529e770 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 26 Aug 2015 12:45:25 +0300 Subject: [PATCH 055/189] add destroy method --- .../administration/delivery_methods_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index 97837deb3..e7d8bacb7 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -33,6 +33,11 @@ def update end end + def destroy + @delivery_method.destroy + redirect_to delivery_methods_path, notice: t('.destroy_success') + end + private def delivery_method_params params.require(:delivery_method).permit( From 4c6cc4bb01373ccb6201fc66be847a19bb354252 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 26 Aug 2015 12:45:56 +0300 Subject: [PATCH 056/189] add remove button --- app/views/administration/delivery_methods/edit.html.erb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/views/administration/delivery_methods/edit.html.erb b/app/views/administration/delivery_methods/edit.html.erb index 67d687399..d9c3619de 100644 --- a/app/views/administration/delivery_methods/edit.html.erb +++ b/app/views/administration/delivery_methods/edit.html.erb @@ -4,3 +4,12 @@ <%= render "administration/header", text: t('administration.delivery_methods.edit.header') %> <%= render 'form' %> + +<% if @delivery_method.persisted? && update_access? %> +
+ + <%= button_to(t('.button_remove'), + delivery_method_path(@delivery_method.id), + data: { confirm: t('administration.delivery_methods.edit.confirm_remove') }, + method: "delete") %> +<% end %> From 0e3d6f3b8fecbd03c363ebfd8facf7a8a943a813 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 27 Aug 2015 11:58:04 +0300 Subject: [PATCH 057/189] load fixtures --- .../administration/delivery_method_controller_test.rb | 2 ++ test/models/delivery_method_test.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/test/controllers/administration/delivery_method_controller_test.rb b/test/controllers/administration/delivery_method_controller_test.rb index d04d80486..0f5d08dc3 100644 --- a/test/controllers/administration/delivery_method_controller_test.rb +++ b/test/controllers/administration/delivery_method_controller_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class Administration::DeliveryMethodsControllerTest < ActionController::TestCase + fixtures %w(delivery_methods) + def setup login users(:joe) @delivery_method = delivery_methods(:kaukokiito) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 935218ffa..b0fc2a79f 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class DeliveryMethodTest < ActiveSupport::TestCase + fixtures %w(delivery_methods) + def setup @delivery_method = delivery_methods(:kaukokiito) end From cf525cf772c7c3b5dd0592f20b177e17037c24e5 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 27 Aug 2015 13:02:53 +0300 Subject: [PATCH 058/189] add validations for destroy method --- .../delivery_methods_controller.rb | 7 +++-- app/models/delivery_method.rb | 30 +++++++++++++++++++ app/models/head/sales_order.rb | 2 +- config/locales/fi.yml | 2 ++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index e7d8bacb7..b273da023 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -34,8 +34,11 @@ def update end def destroy - @delivery_method.destroy - redirect_to delivery_methods_path, notice: t('.destroy_success') + if @delivery_method.destroy + redirect_to delivery_methods_path, notice: t('.destroy_success') + else + render :edit + end end private diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index aea192efb..ee1ad9ee9 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -27,6 +27,8 @@ class DeliveryMethod < BaseModel validate :vaihtoehtoinen_vak_toimitustapa_validation validate :vak_kielto_validation + before_destroy :check_relations + float_columns :jvkulu, :erilliskasiteltavakulu, :kuljetusvakuutus, :kuluprosentti, :ulkomaanlisa, :lisakulu, :lisakulu_summa @@ -140,4 +142,32 @@ def vaihtoehtoinen_vak_toimitustapa_validation allowed = permit_adr_shipments + [ '' ] errors.add :vaihtoehtoinen_vak_toimitustapa, I18n.t('errors.messages.inclusion') unless allowed.include? vaihtoehtoinen_vak_toimitustapa end + + def check_relations + root = 'errors.delivery_method' + allow_delete = true + + count = company.customers.where(toimitustapa: selite).count + + if count.nonzero? + errors.add(:base, I18n.t("#{root}.in_use_customers", count: count)) + allow_delete = false + end + + count = company.sales_orders.not_delivered.where(toimitustapa: selite).count + + if count.nonzero? + errors.add(:base, I18n.t("#{root}.in_use_sales_orders", count: count)) + allow_delete = false + end + + count = company.sales_order_drafts.where(toimitustapa: selite).count + + if count.nonzero? + errors.add(:base, I18n.t("#{root}.in_use_sales_order_drafts", count: count)) + allow_delete = false + end + + return allow_delete + end end diff --git a/app/models/head/sales_order.rb b/app/models/head/sales_order.rb index 4306d7693..7fb9ee2c2 100644 --- a/app/models/head/sales_order.rb +++ b/app/models/head/sales_order.rb @@ -1,7 +1,7 @@ class Head::SalesOrder < Head validates :tila, inclusion: { in: ['L'] } - scope :not_delivered, -> { where(alatila: %w(A C)) } + scope :not_delivered, -> { where(alatila: %w(A B C)) } # Rails requires sti_name method to return type column (tyyppi) value def self.sti_name diff --git a/config/locales/fi.yml b/config/locales/fi.yml index af9cc4c37..a2c91388a 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -801,6 +801,8 @@ fi: in_use_sales_orders: 'HUOM: Maksuehtoa ei voi poistaa, koska se on käytössä %{count} toimittamattomalla myyntitilauksella' delivery_method: in_use_customers: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaalla' + in_use_sales_order_drafts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} keskeneräisellä myyntitilauksella' + in_use_sales_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} toimittamattomalla myyntitilauksella' fixed_assets: commodities: activate: From ed7b0d4464442bd799404b06b6570fd795ce12d8 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 27 Aug 2015 13:13:58 +0300 Subject: [PATCH 059/189] add freight & freight contract models --- app/models/company.rb | 2 ++ app/models/freight.rb | 6 ++++++ app/models/freight_contract.rb | 6 ++++++ 3 files changed, 14 insertions(+) create mode 100644 app/models/freight.rb create mode 100644 app/models/freight_contract.rb diff --git a/app/models/company.rb b/app/models/company.rb index 78ce4115f..c405df76a 100644 --- a/app/models/company.rb +++ b/app/models/company.rb @@ -12,6 +12,8 @@ class Company < ActiveRecord::Base o.has_many :delivery_methods o.has_many :factorings o.has_many :fiscal_years + o.has_many :freight_contracts + o.has_many :freights o.has_many :keywords o.has_many :locations o.has_many :package_codes diff --git a/app/models/freight.rb b/app/models/freight.rb new file mode 100644 index 000000000..e101d6753 --- /dev/null +++ b/app/models/freight.rb @@ -0,0 +1,6 @@ +class Freight < BaseModel + belongs_to :delivery_method, foreign_key: :toimitustapa, primary_key: :selite + + self.table_name = :rahtimaksut + self.primary_key = :tunnus +end diff --git a/app/models/freight_contract.rb b/app/models/freight_contract.rb new file mode 100644 index 000000000..ab9c8f7a0 --- /dev/null +++ b/app/models/freight_contract.rb @@ -0,0 +1,6 @@ +class FreightContract < BaseModel + belongs_to :delivery_method, foreign_key: :toimitustapa, primary_key: :selite + + self.table_name = :rahtisopimukset + self.primary_key = :tunnus +end From 5204e93f82cb224ea57c8a6a2b6c53670928a98e Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 27 Aug 2015 13:15:16 +0300 Subject: [PATCH 060/189] add freight & freight contract validations for destroy method --- app/models/delivery_method.rb | 14 ++++++++++++++ config/locales/fi.yml | 1 + 2 files changed, 15 insertions(+) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index ee1ad9ee9..56bf45b2e 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -168,6 +168,20 @@ def check_relations allow_delete = false end + count = company.freights.where(toimitustapa: selite).count + + if count.nonzero? + errors.add(:base, I18n.t("#{root}.in_use_freights", count: count)) + allow_delete = false + end + + count = company.freight_contracts.where(toimitustapa: selite).count + + if count.nonzero? + errors.add(:base, I18n.t("#{root}.in_use_freights", count: count)) + allow_delete = false + end + return allow_delete end end diff --git a/config/locales/fi.yml b/config/locales/fi.yml index a2c91388a..e5f22ac15 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -803,6 +803,7 @@ fi: in_use_customers: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaalla' in_use_sales_order_drafts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} keskeneräisellä myyntitilauksella' in_use_sales_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} toimittamattomalla myyntitilauksella' + in_use_freights: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtimaksulla' fixed_assets: commodities: activate: From b7637cb07d5631ada04d0718cec97092ad6846f1 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 27 Aug 2015 13:23:58 +0300 Subject: [PATCH 061/189] add customer keywords --- app/models/company.rb | 1 + app/models/customer_keyword.rb | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 app/models/customer_keyword.rb diff --git a/app/models/company.rb b/app/models/company.rb index c405df76a..0b08d37ca 100644 --- a/app/models/company.rb +++ b/app/models/company.rb @@ -8,6 +8,7 @@ class Company < ActiveRecord::Base o.has_many :carriers o.has_many :cash_registers o.has_many :currencies + o.has_many :customer_keywords o.has_many :customers o.has_many :delivery_methods o.has_many :factorings diff --git a/app/models/customer_keyword.rb b/app/models/customer_keyword.rb new file mode 100644 index 000000000..6a21e903b --- /dev/null +++ b/app/models/customer_keyword.rb @@ -0,0 +1,6 @@ +class CustomerKeyword < BaseModel + belongs_to :delivery_method, foreign_key: :toimitustapa, primary_key: :avainsana + + self.table_name = :asiakkaan_avainsanat + self.primary_key = :tunnus +end From 94dcf2d87dacb92a009e0c5198f30571a7fa978e Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 27 Aug 2015 13:24:25 +0300 Subject: [PATCH 062/189] add customer keywords validation for destroy method --- app/models/delivery_method.rb | 7 +++++++ config/locales/fi.yml | 1 + 2 files changed, 8 insertions(+) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 56bf45b2e..ca1df14fa 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -182,6 +182,13 @@ def check_relations allow_delete = false end + count = company.customer_keywords.where(avainsana: selite).count + + if count.nonzero? + errors.add(:base, I18n.t("#{root}.in_use_customer_keywords", count: count)) + allow_delete = false + end + return allow_delete end end diff --git a/config/locales/fi.yml b/config/locales/fi.yml index e5f22ac15..891826f0b 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -804,6 +804,7 @@ fi: in_use_sales_order_drafts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} keskeneräisellä myyntitilauksella' in_use_sales_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} toimittamattomalla myyntitilauksella' in_use_freights: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtimaksulla' + in_use_customer_keywords: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaan avainsanassa' fixed_assets: commodities: activate: From 3adfcc25ea4904d91310017e81c94d3d626f8571 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 27 Aug 2015 14:00:57 +0300 Subject: [PATCH 063/189] mandatory new packaging info with unifaun online --- app/models/delivery_method.rb | 6 ++++++ config/locales/fi.yml | 1 + 2 files changed, 7 insertions(+) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index ca1df14fa..f95689f91 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -26,6 +26,7 @@ class DeliveryMethod < BaseModel validate :vaihtoehtoinen_vak_toimitustapa_validation validate :vak_kielto_validation + validate :mandatory_new_packaging_information if :package_info_entry_denied && :collective_batch before_destroy :check_relations @@ -133,6 +134,11 @@ def permit_adr_shipments DeliveryMethod.permit_adr.shipment.pluck(:selite) end + def mandatory_new_packaging_information + root = 'errors.delivery_method' + errors.add(:base, I18n.t("#{root}.mandatory_new_packaging_info_with_unifaun_waybill")) if rahtikirja.include? 'rahtikirja_unifaun' + end + def vak_kielto_validation allowed = DeliveryMethod.permit_adr.shipment.pluck(:selite) + [ '', 'K' ] errors.add :vak_kielto, I18n.t('errors.messages.inclusion') unless allowed.include? vak_kielto diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 891826f0b..8581c40a8 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -805,6 +805,7 @@ fi: in_use_sales_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} toimittamattomalla myyntitilauksella' in_use_freights: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtimaksulla' in_use_customer_keywords: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaan avainsanassa' + mandatory_new_packaging_info_with_unifaun_waybill: 'HUOM: Koontierätulostus ei toimi Unifaun Online rahtikirjan kanssa ilman koontirahtikirjan pakkaustietoja' fixed_assets: commodities: activate: From 4b31f8900136f27bf5d76e9b903496a49c19540a Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Fri, 28 Aug 2015 14:53:10 +0300 Subject: [PATCH 064/189] tests and fixtures --- app/models/delivery_method.rb | 2 +- config/locales/fi.yml | 1 + .../delivery_method_controller_test.rb | 3 ++ test/fixtures/customers.yml | 1 + test/fixtures/freights.yml | 7 +++++ test/fixtures/heads.yml | 31 +++++++++++++++++++ test/models/company_test.rb | 4 +-- test/models/delivery_method_test.rb | 16 +++++++++- test/models/terms_of_payment_test.rb | 2 +- 9 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 test/fixtures/freights.yml diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index f95689f91..507873075 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -184,7 +184,7 @@ def check_relations count = company.freight_contracts.where(toimitustapa: selite).count if count.nonzero? - errors.add(:base, I18n.t("#{root}.in_use_freights", count: count)) + errors.add(:base, I18n.t("#{root}.in_use_freight_contracts", count: count)) allow_delete = false end diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 8581c40a8..a278855cd 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -803,6 +803,7 @@ fi: in_use_customers: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaalla' in_use_sales_order_drafts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} keskeneräisellä myyntitilauksella' in_use_sales_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} toimittamattomalla myyntitilauksella' + in_use_freight_contracts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtisopimuksella' in_use_freights: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtimaksulla' in_use_customer_keywords: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaan avainsanassa' mandatory_new_packaging_info_with_unifaun_waybill: 'HUOM: Koontierätulostus ei toimi Unifaun Online rahtikirjan kanssa ilman koontirahtikirjan pakkaustietoja' diff --git a/test/controllers/administration/delivery_method_controller_test.rb b/test/controllers/administration/delivery_method_controller_test.rb index 0f5d08dc3..1a3b9158f 100644 --- a/test/controllers/administration/delivery_method_controller_test.rb +++ b/test/controllers/administration/delivery_method_controller_test.rb @@ -82,6 +82,9 @@ def setup test "should delete delivery method" do login users(:bob) + @delivery_method.selite = 'Random delivery method' + @delivery_method.save + assert_difference("DeliveryMethod.count", -1) do delete :destroy, id: @delivery_method.id end diff --git a/test/fixtures/customers.yml b/test/fixtures/customers.yml index 98616c5c3..144b176f0 100644 --- a/test/fixtures/customers.yml +++ b/test/fixtures/customers.yml @@ -12,6 +12,7 @@ stubborn_customer: kieli: fi valkoodi: eur terms_of_payment: sixty_days_net + toimitustapa: Kaukokiito laatija: joe luontiaika: <%= Date.today %> muutospvm: <%= Date.today %> diff --git a/test/fixtures/freights.yml b/test/fixtures/freights.yml new file mode 100644 index 000000000..d7ee4c6c3 --- /dev/null +++ b/test/fixtures/freights.yml @@ -0,0 +1,7 @@ +kaukokiito_freight: + yhtio: acme + toimitustapa: Kaukokiito + laatija: joe + luontiaika: <%= Date.today %> + muutospvm: <%= Date.today %> + muuttaja: joe diff --git a/test/fixtures/heads.yml b/test/fixtures/heads.yml index 7267408f9..1cb6e07c6 100644 --- a/test/fixtures/heads.yml +++ b/test/fixtures/heads.yml @@ -187,6 +187,7 @@ not_finished_order: tila: N alatila: '' terms_of_payment: hundred_days_net + toimitustapa: Kaukokiito luontiaika: <%= Time.now %> laatija: joe muutospvm: <%= Time.now %> @@ -235,6 +236,7 @@ not_delivered_order_1: h5time: <%= Time.now %> mapvm: <%= Time.now %> popvm: <%= Time.now %> + toimitustapa: Kaukokiito not_delivered_order_2: yhtio: acme @@ -262,3 +264,32 @@ not_delivered_order_2: h5time: <%= Time.now %> mapvm: <%= Time.now %> popvm: <%= Time.now %> + toimitustapa: Kaukokiito + +not_delivered_order_3: + yhtio: acme + tila: L + alatila: B + terms_of_payment: ninety_days_net + luontiaika: <%= Time.now %> + laatija: joe + muutospvm: <%= Time.now %> + muuttaja: joe + tapvm: <%= Time.now %> + lapvm: <%= Time.now %> + kapvm: <%= Time.now %> + erpcm: <%= Time.now %> + olmapvm: <%= Time.now %> + kerayspvm: <%= Time.now %> + toimaika: <%= Time.now %> + maksuaika: <%= Time.now %> + lahetepvm: <%= Time.now %> + laskutettu: <%= Time.now %> + h1time: <%= Time.now %> + h2time: <%= Time.now %> + h3time: <%= Time.now %> + h4time: <%= Time.now %> + h5time: <%= Time.now %> + mapvm: <%= Time.now %> + popvm: <%= Time.now %> + toimitustapa: Kaukokiito diff --git a/test/models/company_test.rb b/test/models/company_test.rb index 1c652fedb..1abd02f22 100644 --- a/test/models/company_test.rb +++ b/test/models/company_test.rb @@ -28,7 +28,7 @@ class CompanyTest < ActiveSupport::TestCase test "company has working STI headings" do assert_not_nil @acme.heads - assert_equal 14, @acme.heads.count + assert_equal 15, @acme.heads.count assert_not_nil @acme.purchase_orders assert_equal Head::PurchaseOrder.new.class, @acme.purchase_orders.first.class @@ -62,7 +62,7 @@ class CompanyTest < ActiveSupport::TestCase assert_not_nil @acme.sales_orders assert_equal Head::SalesOrder.new.class, @acme.sales_orders.first.class - assert_equal 3, @acme.sales_orders.count + assert_equal 4, @acme.sales_orders.count assert_equal ['L'], @acme.sales_orders.collect(&:tila).uniq assert_not_nil @acme.sales_order_drafts diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index b0fc2a79f..d7d908d4f 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -1,7 +1,7 @@ require 'test_helper' class DeliveryMethodTest < ActiveSupport::TestCase - fixtures %w(delivery_methods) + fixtures %w(delivery_methods heads customers) def setup @delivery_method = delivery_methods(:kaukokiito) @@ -34,4 +34,18 @@ def setup @delivery_method.vaihtoehtoinen_vak_toimitustapa = 'neko' refute @delivery_method.valid?, "Invalid vaihtoehtoinen_vak_toimitustapa value" end + + test 'mandatory new packaging information' do + @delivery_method.tulostustapa = 'L' + @delivery_method.uudet_pakkaustiedot = '' + @delivery_method.rahtikirja = 'rahtikirja_unifaun_uo_siirto.inc' + + refute @delivery_method.valid?, "New packaging info is mandatory with collective batch and Unifaun Online" + end + + test 'should be in use' do + assert_no_difference('DeliveryMethod.count') do + @delivery_method.destroy + end + end end diff --git a/test/models/terms_of_payment_test.rb b/test/models/terms_of_payment_test.rb index 5e18a7915..39996bc41 100644 --- a/test/models/terms_of_payment_test.rb +++ b/test/models/terms_of_payment_test.rb @@ -50,7 +50,7 @@ class TermsOfPaymentTest < ActiveSupport::TestCase top_fourth.kaytossa = 'E' refute top_fourth.valid?, "This terms of payment is used by a undelivered sales order" - message = I18n.t 'errors.terms_of_payment.in_use_sales_orders', count: 1 + message = I18n.t 'errors.terms_of_payment.in_use_sales_orders', count: 2 assert_equal message, top_fourth.errors.full_messages.first end From 888d995a62f81214ad39836376ba081079ce0bd8 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Wed, 16 Sep 2015 16:27:52 +0300 Subject: [PATCH 065/189] load fixtures --- test/helpers/delivery_method_helper_test.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/helpers/delivery_method_helper_test.rb b/test/helpers/delivery_method_helper_test.rb index 41b5da072..4805a7360 100644 --- a/test/helpers/delivery_method_helper_test.rb +++ b/test/helpers/delivery_method_helper_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class DeliveryMethodHelperTest < ActionView::TestCase + fixtures %w(delivery_methods) + test "returns translated pickup options valid for collection" do assert pickup_options.is_a? Array From 6c4af1ebbc39d44c1c27465154efa7f490b1ffbf Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Wed, 16 Sep 2015 16:45:02 +0300 Subject: [PATCH 066/189] update delivery method permissions --- ...4159_update_delivery_method_permissions.rb | 21 +++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20150916134159_update_delivery_method_permissions.rb diff --git a/db/migrate/20150916134159_update_delivery_method_permissions.rb b/db/migrate/20150916134159_update_delivery_method_permissions.rb new file mode 100644 index 000000000..2c3047965 --- /dev/null +++ b/db/migrate/20150916134159_update_delivery_method_permissions.rb @@ -0,0 +1,21 @@ +class UpdateDeliveryMethodPermissions < ActiveRecord::Migration + def up + Company.find_each do |company| + Current.company = company.yhtio + + Permission.where(nimi: 'yllapito.php', alanimi: 'toimitustapa').find_each do |permission| + permission.update(nimi: 'pupenext/delivery_methods', alanimi: '') + end + end + end + + def down + Company.find_each do |company| + Current.company = company.yhtio + + Permission.where(nimi: 'pupenext/delivery_methods', alanimi: '').find_each do |permission| + permission.update(nimi: 'yllapito.php', alanimi: 'toimitustapa') + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index a5d93de9c..3b60f5be6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150916082322) do +ActiveRecord::Schema.define(version: 20150916134159) do create_table "abc_aputaulu", primary_key: "tunnus", force: :cascade do |t| t.string "yhtio", limit: 5, default: "", null: false From 146abef5b54aa00ab8e24d32c166363fb9426f28 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Wed, 16 Sep 2015 16:46:35 +0300 Subject: [PATCH 067/189] blank belongs to view --- app/classes/postal_official_legend.rb | 1 - app/views/administration/delivery_methods/_form.html.erb | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/classes/postal_official_legend.rb b/app/classes/postal_official_legend.rb index e67b6a9bc..fd13e5e82 100644 --- a/app/classes/postal_official_legend.rb +++ b/app/classes/postal_official_legend.rb @@ -1,7 +1,6 @@ class PostalOfficialLegend def self.options [ - [ "Ei valintaa" , [ "Ei valintaa" ]], [ "Pupesoft / Itella", [ [ "Itella Express City 00", "Express City 00" ], [ "Itella Express Morning 9", "Express Morning 9" ], diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 185b01a77..8771ac844 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -13,7 +13,11 @@ <%= f.label :virallinen_selite %> - <%= f.select :virallinen_selite, grouped_options_for_select(PostalOfficialLegend.options, @delivery_method.virallinen_selite) %> + + <%= f.select :virallinen_selite, + grouped_options_for_select(PostalOfficialLegend.options, @delivery_method.virallinen_selite), + include_blank: true %> + <%= f.label :tulostustapa %> From 6efacce63012fb2275f17d8a8097a38e26d23878 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Wed, 16 Sep 2015 16:52:05 +0300 Subject: [PATCH 068/189] clean up index --- .../delivery_methods_controller.rb | 5 -- .../delivery_methods/index.html.erb | 62 +------------------ 2 files changed, 2 insertions(+), 65 deletions(-) diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index b273da023..85411f631 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -58,12 +58,7 @@ def delivery_method_params def searchable_columns [ :selite, - :tulostustapa, :sopimusnro, - :nouto, - :ei_pakkaamoa, - :extranet, - :rahtikirja, :jarjestys, ] end diff --git a/app/views/administration/delivery_methods/index.html.erb b/app/views/administration/delivery_methods/index.html.erb index f6ca03975..e50a5f64b 100644 --- a/app/views/administration/delivery_methods/index.html.erb +++ b/app/views/administration/delivery_methods/index.html.erb @@ -1,6 +1,6 @@ <%= render "administration/header", text: t('.header') %> -<%= button_to t('.button_new'), new_delivery_method_path, method: :get if update_access? %> +<%= button_to_new :delivery_method %>

@@ -14,42 +14,12 @@ <%= text_field_tag :selite, params[:selite] %> - - <%= sortable "tulostustapa", DeliveryMethod.human_attribute_name(:tulostustapa) %> -
- <%= text_field_tag :tulostustapa, params[:tulostustapa] %> - - <%= sortable "sopimusnro", DeliveryMethod.human_attribute_name(:sopimusnro) %>
<%= text_field_tag :sopimusnro, params[:sopimusnro] %> - - <%= sortable "nouto", DeliveryMethod.human_attribute_name(:nouto) %> -
- <%= text_field_tag :nouto, params[:nouto] %> - - - - <%= sortable "ei_pakkaamoa", DeliveryMethod.human_attribute_name(:ei_pakkaamoa) %> -
- <%= text_field_tag :ei_pakkaamoa, params[:ei_pakkaamoa] %> - - - - <%= sortable "extranet", DeliveryMethod.human_attribute_name(:extranet) %> -
- <%= text_field_tag :extranet, params[:extranet] %> - - - - <%= sortable "rahtikirja", DeliveryMethod.human_attribute_name(:rahtikirja) %> -
- <%= text_field_tag :rahtikirja, params[:rahtikirja] %> - - <%= sortable "jarjestys", DeliveryMethod.human_attribute_name(:jarjestys) %>
@@ -67,38 +37,10 @@ <%= link_to delivery_method.selite, edit_delivery_method_path(delivery_method.id) %> - - <%= t("administration.delivery_methods.print_method_options.batch") if delivery_method.batch? %> - <%= t("administration.delivery_methods.print_method_options.collective_batch") if delivery_method.collective_batch? %> - <%= t("administration.delivery_methods.print_method_options.collective_instant") if delivery_method.collective_instant? %> - <%= t("administration.delivery_methods.print_method_options.instant") if delivery_method.instant? %> - <%= t("administration.delivery_methods.print_method_options.skip_print") if delivery_method.skip_print? %> - - <%= delivery_method.sopimusnro %> - - <%= t("administration.delivery_methods.pickup_options.pickup") if delivery_method.pickup? %> - <%= t("administration.delivery_methods.pickup_options.shipment") if delivery_method.shipment? %> - - - - <%= t("administration.delivery_methods.packing_line_prohibition_options.not_reserving_packing_line") if delivery_method.not_reserving_packing_line? %> - <%= t("administration.delivery_methods.packing_line_prohibition_options.reserve_packing_line") if delivery_method.reserve_packing_line? %> - - - - <%= t("administration.delivery_methods.extranet_options.both_in_sales_and_extranet") if delivery_method.both_in_sales_and_extranet? %> - <%= t("administration.delivery_methods.extranet_options.only_in_extranet") if delivery_method.only_in_extranet? %> - <%= t("administration.delivery_methods.extranet_options.only_in_sales") if delivery_method.only_in_sales? %> - - - - <%= delivery_method.rahtikirja %> - - <%= delivery_method.jarjestys %> @@ -114,4 +56,4 @@
-<%= button_to t('.button_new'), new_delivery_method_path, method: :get if update_access? %> +<%= button_to_new :delivery_method %> From b3386d3c0c9bbd0adb4b449bce2719c1ef532e98 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Wed, 16 Sep 2015 16:52:26 +0300 Subject: [PATCH 069/189] normalize --- config/locales/fi.yml | 53 ++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/config/locales/fi.yml b/config/locales/fi.yml index cc1085a73..94ddf6050 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -300,6 +300,7 @@ fi: carrier: Rahdinkuljettaja cash_register: Kassalipas currency: Valuutta + delivery_method: Toimitustapa fiscal_year: Tilikausi head/purchase_invoice/approval: Ostolasku hyväksyttävänä head/purchase_invoice/approved: Ostolasku valmis maksatukseen @@ -424,6 +425,20 @@ fi: header: Valuutat update: update_success: Valuutta päivitettiin onnistuneesti + custom_attributes: + edit: + button_remove: Poista kenttä + confirm_remove: Oletko varma, että haluat poistaa kentän? + header: Ylläpitonäkymän kenttä + index: + button_search: Etsi + header: Ylläpitonäkymien kentät + required_options: + mandatory: Kentän arvo on pakollinen + optional: Kentän arvo ei ole pakollinen + visibility_options: + hidden: Kenttää ei näytetä näkymässä + visible: Kenttä näytetään näkymässä delivery_methods: adr_prohibition_options: adr_prohibition: Toimitustavalla ei saa toimittaa VAK-tuotteita @@ -440,6 +455,8 @@ fi: not_including_container: Ei create: create_success: Toimitustapa luotiin onnistuneesti + destroy: + destroy_success: Toimitustapa poistettiin onnistuneesti edit: button_remove: Poista toimitustapa confirm_remove: Oletko varma, että haluat poistaa toimitustavan? @@ -449,8 +466,6 @@ fi: both_in_sales_and_extranet: Toimitustapa näytetään molemmissa only_in_extranet: Toimitustapa näytetään vain extranetissä only_in_sales: Toimitustapa näytetään vain myynnissä - destroy: - destroy_success: Toimitustapa poistettiin onnistuneesti freight_contract_options: receiver_freight_contract: Käytetään vastaanottajan rahtisopimusta sender_freight_contract: Käytetään lähettäjän rahtisopimusta @@ -503,20 +518,6 @@ fi: no_waybill_specification: Toimitustavalle ei tulosteta rahtikirjaerittelyä print_waybill_specification: Toimitustavalle tulostetaan rahtikirjaerittely print_waybill_specification_per_customer: Toimitustavalle tulostetaan rahtikirjaerittely per asiakas - custom_attributes: - edit: - button_remove: Poista kenttä - confirm_remove: Oletko varma, että haluat poistaa kentän? - header: Ylläpitonäkymän kenttä - index: - button_search: Etsi - header: Ylläpitonäkymien kentät - required_options: - mandatory: Kentän arvo on pakollinen - optional: Kentän arvo ei ole pakollinen - visibility_options: - hidden: Kenttää ei näytetä näkymässä - visible: Kenttä näytetään näkymässä fiscal_years: create: create_success: Tilikausi perustettiin onnistuneesti @@ -668,7 +669,7 @@ fi: - pe - la abbr_month_names: - - + - - tammi - helmi - maalis @@ -694,7 +695,7 @@ fi: long: "%A %e. %Bta %Y" short: "%d %b" month_names: - - + - - tammikuu - helmikuu - maaliskuu @@ -762,6 +763,14 @@ fi: kateistilitys_missing: Käteistilitystili puuttuu tai sitä ei löydy luottokortti_missing: Luottokorttitili puuttuu tai sitä ei löydy pankkikortti_missing: Pankkikorttitili puuttuu tai sitä ei löydy + delivery_method: + in_use_customer_keywords: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaan avainsanassa' + in_use_customers: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaalla' + in_use_freight_contracts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtisopimuksella' + in_use_freights: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtimaksulla' + in_use_sales_order_drafts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} keskeneräisellä myyntitilauksella' + in_use_sales_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} toimittamattomalla myyntitilauksella' + mandatory_new_packaging_info_with_unifaun_waybill: 'HUOM: Koontierätulostus ei toimi Unifaun Online rahtikirjan kanssa ilman koontirahtikirjan pakkaustietoja' format: "%{attribute} %{message}" messages: accepted: täytyy olla hyväksytty @@ -812,14 +821,6 @@ fi: in_use_customers: 'HUOM: Maksuehtoa ei voi poistaa, koska se on käytössä %{count} asiakkaalla' in_use_sales_order_drafts: 'HUOM: Maksuehtoa ei voi poistaa, koska se on käytössä %{count} keskeneräisellä myyntitilauksella' in_use_sales_orders: 'HUOM: Maksuehtoa ei voi poistaa, koska se on käytössä %{count} toimittamattomalla myyntitilauksella' - delivery_method: - in_use_customers: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaalla' - in_use_sales_order_drafts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} keskeneräisellä myyntitilauksella' - in_use_sales_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} toimittamattomalla myyntitilauksella' - in_use_freight_contracts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtisopimuksella' - in_use_freights: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtimaksulla' - in_use_customer_keywords: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaan avainsanassa' - mandatory_new_packaging_info_with_unifaun_waybill: 'HUOM: Koontierätulostus ei toimi Unifaun Online rahtikirjan kanssa ilman koontirahtikirjan pakkaustietoja' fixed_assets: commodities: activate: From 2546d830459b61d6703a42b87afbbffdd10d6d6e Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Wed, 16 Sep 2015 16:55:39 +0300 Subject: [PATCH 070/189] allow all the fields! --- .../delivery_methods_controller.rb | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index 85411f631..cd421f99e 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -44,14 +44,19 @@ def destroy private def delivery_method_params params.require(:delivery_method).permit( - :selite, - :tulostustapa, - :sopimusnro, - :nouto, - :ei_pakkaamoa, - :extranet, - :rahtikirja, - :jarjestys, + :aktiivinen_kuljetus, :aktiivinen_kuljetus_kansallisuus, :ei_pakkaamoa, + :erikoispakkaus_kielto, :erilliskasiteltavakulu, :erittely, :extranet, + :jarjestys, :jvkielto, :jvkulu, :kauppatapahtuman_luonne, :kontti, + :kuljetusmuoto, :kuljetusvakuutus, :kuljetusvakuutus_tuotenumero, + :kuljetusvakuutus_tyyppi, :kuljyksikko, :kuluprosentti, :lahdon_selite, + :lajittelupiste, :lauantai, :lisakulu, :lisakulu_summa, :logy_rahtikirjanumerot, + :maa_maara, :merahti, :nouto, :osoitelappu, :poistumistoimipaikka_koodi, + :rahdinkuljettaja, :rahti_tuotenumero, :rahtikirja, :rahtikirjakopio_email, + :sallitut_alustat, :sallitut_maat, :selite, :sisamaan_kuljetus, + :sisamaan_kuljetus_kansallisuus, :sisamaan_kuljetusmuoto, :sopimusnro, + :toim_maa, :toim_nimi, :toim_nimitark, :toim_osoite, :toim_ovttunnus, + :toim_postino, :toim_postitp, :tulostustapa, :ulkomaanlisa, :uudet_pakkaustiedot, + :vaihtoehtoinen_vak_toimitustapa, :vak_kielto, :virallinen_selite, ) end From 08e58aa8596e0fae032e5120e19be71f2a561343 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Thu, 17 Sep 2015 09:53:49 +0300 Subject: [PATCH 071/189] form cleanup first pass --- .../delivery_methods/_form.html.erb | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 8771ac844..26c172e0a 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -2,229 +2,229 @@ <%= form_for @delivery_method do |f| %> - +
- + - + - + - + - + - + + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %> - + - + - + - + - + - + - + - + - + - + - + + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %> + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %> - + - + + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %> + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %> + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %> - + - + - + - + - + - + <%= render 'administration/resource_timestamps_and_users', resource: @delivery_method %> From a181ea6687f4faf36c8c1aecbc02a76f0196fbe0 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Thu, 17 Sep 2015 10:57:34 +0300 Subject: [PATCH 072/189] add translations --- config/locales/fi.yml | 58 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 94ddf6050..d088cae9f 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -179,6 +179,60 @@ fi: viivastyskorko: Viivästyskorkoprosentti www: WWW ytunnus: Y-tunnus + delivery_method: + aktiivinen_kuljetus: Oletus aktiivinen kuljetus + aktiivinen_kuljetus_kansallisuus: Oletus aktiivisen kuljetuksen kansallisuus + ei_pakkaamoa: Pakkaamokäsittely + erikoispakkaus_kielto: Erikoispakkauskäsittely + erilliskasiteltavakulu: + erittely: Rahtikirjaerittely + extranet: Extranet-toimitustapa + jarjestys: Järjestys + jvkielto: Jälkivaatimukset + jvkulu: Jälkivaatimuskulu + kauppatapahtuman_luonne: Oletus kauppatapahtuman luonne + kontti: Oletus kontti + kuljetusmuoto: Oletus kuljetusmuoto + kuljetusvakuutus: Kuljetusvakuutus + kuljetusvakuutus_tuotenumero: Kuljetusvakuutus tuote + kuljetusvakuutus_tyyppi: Kuljetusvakuutustyyppi + kuljyksikko: Itella kuljetusyksikkö + kuluprosentti: Kuluprosentti + lahdon_selite: Nimitys Lähtöjen hallinnassa + lajittelupiste: + lauantai: Lauantaijakelu + lisakulu: + lisakulu_summa: + logy_rahtikirjanumerot: + maa_maara: Oletus määrämaa + merahti: Rahtisopimus + nouto: Nouto + osoitelappu: Osoitelapputyyppi + poistumistoimipaikka_koodi: Oletus poistumistoimipaikan koodi + rahdinkuljettaja: Kuljetusyhtiä + rahti_tuotenumero: Rahtiveloitus tuotenumero + rahtikirja: Rahtikirjatyyppi + rahtikirjakopio_email: + sallitut_alustat: Sallitut keräilyalustat + sallitut_maat: Sallitut maat + selite: Nimitys + sisamaan_kuljetus: Oletus sisämaan kuljetus + sisamaan_kuljetus_kansallisuus: Oletus sisämaan kuljetuksen kansallisuus + sisamaan_kuljetusmuoto: Oletus sisämaan kuljetusmuoto + sopimusnro: Rahtisopimusnumero + toim_maa: Koontirahtikirjan maa + toim_nimi: Koontirahtikirjan nimi + toim_nimitark: Koontirahtikirjan nimitarkenne + toim_osoite: Koontirahtikirjan osoite + toim_ovttunnus: Koontirahtikirjan OVT-tunnus + toim_postino: Koontirahtikirjan postinumero + toim_postitp: Koontirahtikirjan postitoimipaikka + tulostustapa: Tulostustapa + ulkomaanlisa: Rahtikulujen ulkomaanlisä + uudet_pakkaustiedot: Koontirahtikirjan pakkaustiedot + vaihtoehtoinen_vak_toimitustapa: VAK-tuotteet omalle tilaukselle + vak_kielto: VAK-käsittely + virallinen_selite: Virallinen nimi keyword: jarjestys: Järjestys kieli: Kieli @@ -669,7 +723,7 @@ fi: - pe - la abbr_month_names: - - + - - tammi - helmi - maalis @@ -695,7 +749,7 @@ fi: long: "%A %e. %Bta %Y" short: "%d %b" month_names: - - + - - tammikuu - helmikuu - maaliskuu From 5069c5904112e78bf46cf0729e9bb05688bb79ff Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Thu, 17 Sep 2015 11:02:25 +0300 Subject: [PATCH 073/189] add missing translations --- config/locales/fi.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/locales/fi.yml b/config/locales/fi.yml index d088cae9f..f914fe92d 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -184,7 +184,7 @@ fi: aktiivinen_kuljetus_kansallisuus: Oletus aktiivisen kuljetuksen kansallisuus ei_pakkaamoa: Pakkaamokäsittely erikoispakkaus_kielto: Erikoispakkauskäsittely - erilliskasiteltavakulu: + erilliskasiteltavakulu: Erilliskäsiteltäväkulu erittely: Rahtikirjaerittely extranet: Extranet-toimitustapa jarjestys: Järjestys @@ -199,11 +199,11 @@ fi: kuljyksikko: Itella kuljetusyksikkö kuluprosentti: Kuluprosentti lahdon_selite: Nimitys Lähtöjen hallinnassa - lajittelupiste: + lajittelupiste: Lajittelupiste lauantai: Lauantaijakelu - lisakulu: - lisakulu_summa: - logy_rahtikirjanumerot: + lisakulu: Lisäkulu + lisakulu_summa: Lisäkulusumma + logy_rahtikirjanumerot: LOGY rahtikirjanumerot maa_maara: Oletus määrämaa merahti: Rahtisopimus nouto: Nouto From b3b4a964b8fbfe23c0ca8f420cab5a11b011a61a Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Thu, 17 Sep 2015 11:27:18 +0300 Subject: [PATCH 074/189] add translations --- config/locales/de.yml | 675 +++++++++++++++++++++----------------- config/locales/en.yml | 656 +++++++++++++++++++------------------ config/locales/et.yml | 561 ++++++++++++++++--------------- config/locales/sv.yml | 747 ++++++++++++++++++++++-------------------- 4 files changed, 1387 insertions(+), 1252 deletions(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index c143a4bb2..0819a5bb9 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -3,69 +3,69 @@ de: activerecord: attributes: account: - alv_taso: - kohde: - kustp: + alv_taso: + kohde: + kustp: laatija: Erstellt von luontiaika: Erstellt am muutospvm: "Änderungszeit" - muuttaja: + muuttaja: nimi: Name - projekti: - sisainen_taso: + projekti: + sisainen_taso: tilino: Kontonummer - tiliointi_tarkistus: - toimijaliitos: - ulkoinen_taso: + tiliointi_tarkistus: + toimijaliitos: + ulkoinen_taso: accounting/fixed_assets/commodity: - evl_poistotyyppi: + evl_poistotyyppi: kayttoonottopvm: Inbetriebnahmedatum bank_account: - asiakastunnus: + asiakastunnus: bic: SWIFT / BIC - factoring: - hyvak: - iban: + factoring: + hyvak: + iban: kaytossa: Status maksulimitti: Zahlungslimit nimi: Name - oletus_kohde: - oletus_kulutili: - oletus_kustp: - oletus_projekti: - oletus_rahatili: - oletus_selvittelytili: + oletus_kohde: + oletus_kulutili: + oletus_kustp: + oletus_projekti: + oletus_rahatili: + oletus_selvittelytili: tilino: Kontonummer - tilinylitys: + tilinylitys: valkoodi: Währung bank_detail: laatija: Erstellt von luontiaika: Erstellt am - muutospvm: - muuttaja: + muutospvm: + muuttaja: nimitys: Bezeichnung - pankkiiban1: - pankkiiban2: - pankkiiban3: - pankkinimi1: - pankkinimi2: - pankkinimi3: - pankkiswift1: - pankkiswift2: - pankkiswift3: + pankkiiban1: + pankkiiban2: + pankkiiban3: + pankkinimi1: + pankkinimi2: + pankkinimi3: + pankkiswift1: + pankkiswift2: + pankkiswift3: pankkitili1: Kontonummer pankkitili2: Kontonummer pankkitili3: Kontonummer - viite: + viite: carrier: - koodi: + koodi: luontiaika: Erstellt am - luottokortti: + luottokortti: muutospvm: "Änderungsdatum" - muuttaja: - neutraali: + muuttaja: + neutraali: nimi: Name - pakkauksen_sarman_minimimitta: + pakkauksen_sarman_minimimitta: cash_register: kassa: Kasse kassaerotus: Kassendifferenz @@ -85,10 +85,10 @@ de: email: E-Mailadresse factoringsaamiset: Factoringforderungen aus Lieferungen und Leistungen fax: Fax - int_koodi: - intrastat_sarjanro: + int_koodi: + intrastat_sarjanro: jarjestys: Sortierung - karhuerapvm: + karhuerapvm: kassa: Barverkauf kassaale: Rabatte der Einkäufe kassaerotus: "Übereinstimmungsdifferenzen der Barverkaufskasse" @@ -111,40 +111,40 @@ de: luottotappiot: Verkaufskreditverluste maa: Land matkalla_olevat: Umlaufvermögensrechnungen, die unterwegs sind - muutkulut: + muutkulut: myynninkassaale: Rabatte des Verkaufs myynninvaluuttaero: Währungskursdifferenzen des Verkaufs myynti: Verkauf myynti_ei_eu: Verkauf außerhalb der Gemeinschaft myynti_eu: Gemeinschaftsverkauf - myynti_kaanteinen: + myynti_kaanteinen: myynti_kohde: Standardziel des Verkaufs myynti_kustp: Standardkostenstelle des Verkaufs myynti_marginaali: Verkauf, Gebrauchtwaren myynti_projekti: Standardprojekt des Verkaufs - myyntireskontrakausi_alku: - myyntireskontrakausi_loppu: + myyntireskontrakausi_alku: + myyntireskontrakausi_loppu: myyntisaamiset: Forderungen aus Lieferungen und Leistungen nimi: Name osoite: Adresse osto_marginaali: Einkauf, Gebrauchtwaren (in Verbindung mit Verkauf) - ostoreskontrakausi_alku: - ostoreskontrakausi_loppu: + ostoreskontrakausi_alku: + ostoreskontrakausi_loppu: ostovelat: Verbindlichkeiten aus Lieferungen und Leistungen ovttunnus: EDI-Kennzeichen - pankkiiban1: - pankkiiban2: - pankkiiban3: + pankkiiban1: + pankkiiban2: + pankkiiban3: pankkikortti: Barverkauf Bankkartenzahlungen - pankkinimi1: - pankkinimi2: - pankkinimi3: - pankkiswift1: - pankkiswift2: - pankkiswift3: - pankkitili1: - pankkitili2: - pankkitili3: + pankkinimi1: + pankkinimi2: + pankkinimi3: + pankkiswift1: + pankkiswift2: + pankkiswift3: + pankkitili1: + pankkitili2: + pankkitili3: postino: Postleitzahl postitp: Poststelle puhelin: Telefon @@ -155,80 +155,99 @@ de: siirtosaamiset: ARAP-Konto für die Periodisierung der Einkaufsrechnung siirtovelka: PRAP-Konto für die Periodisierung der Verkaufsrechnung tilastotullikamari: statistikzollkammer - tilikauden_tulos: - tilikausi_alku: - tilikausi_loppu: - tilino_triang: - tulli_lisattava_era: - tulli_vahennettava_era: + tilikauden_tulos: + tilikausi_alku: + tilikausi_loppu: + tilino_triang: + tulli_lisattava_era: + tulli_vahennettava_era: tullikamari: zollkammer - tullin_asiaknro: - tullin_lupanro: + tullin_asiaknro: + tullin_lupanro: tullipaate: zollterminal valkoodi: Währung valuuttaero: Währungskursdifferenzen der Einkäufe varasto: Waren/Lager varastonmuutos: Lageränderung - varastonmuutos_epakurantti: - varastonmuutos_inventointi: - varastonmuutos_rahti: + varastonmuutos_epakurantti: + varastonmuutos_inventointi: + varastonmuutos_rahti: varastonmuutos_valmistuksesta: Lageränderung der Fertigung - viivastyskorko: + viivastyskorko: www: www ytunnus: Steuernummer + delivery_method: + aktiivinen_kuljetus: Standard aktiver Transport + aktiivinen_kuljetus_kansallisuus: Standard Nationalität des aktiven Transport + jarjestys: Sortierung + jvkulu: Nachnahmekosten + kauppatapahtuman_luonne: Standard Geschäftsart + kontti: Standard Container + kuljetusmuoto: Standard Transportart + kuluprosentti: Kostenprozent + lisakulu: Zusatzkosten + maa_maara: Standard Zielland + merahti: Frachtvertrag + poistumistoimipaikka_koodi: Standard Code des Abtrittgeschäftsstelle + rahtikirja: Frachtbrieftyp + selite: Bezeichnung + sisamaan_kuljetus: Standard Inlandtransport + sisamaan_kuljetus_kansallisuus: Standard Nationalität des Inlandtransport + sisamaan_kuljetusmuoto: Standard Inlandtransportart + tulostustapa: Ausdruckart keyword: jarjestys: Sortierung kieli: Sprache laji: Art selite: Erklärung - selitetark: - selitetark_2: - selitetark_3: + selitetark: + selitetark_2: + selitetark_3: keyword/custom_attribute: - database_field: - default_value: - help_text: - label: - required: - set_name: - visibility: + database_field: + default_value: + help_text: + label: + required: + set_name: + visibility: package: - erikoispakkaus: + erikoispakkaus: jarjestys: Sortierung - kayttoprosentti: + kayttoprosentti: kieli: Sprache korkeus: Höhe laji: Art leveys: Breite - minimi_paino: + minimi_paino: paino: Gewicht - pakkaus: + pakkaus: pakkauskuvaus: Verpackungsbeschreibung - pakkausveloitus_tuotenumero: - puukotus_kerroin: + pakkausveloitus_tuotenumero: + puukotus_kerroin: selite: Erklärung - selitetark: - selitetark_2: - selitetark_3: - syvyys: - yksin_eraan: + selitetark: + selitetark_2: + selitetark_3: + syvyys: + yksin_eraan: package_code: - koodi: - rahdinkuljettaja: + koodi: + rahdinkuljettaja: package_codes: - koodi: - rahdinkuljettaja: + koodi: + rahdinkuljettaja: packing_area: lokero: Fach nimi: Name - pakkaamon_prio: + pakkaamon_prio: printteri0: Auswahlliste printteri1: Versandpapier printteri2: Artikeletiketten printteri3: Adressetikett printteri4: Frachtbrief A5 printteri6: Frachtbrief A4 - printteri7: + printteri7: prio: Prio varasto: Lager printer: @@ -236,81 +255,82 @@ de: jarjestys: Sortierung kirjoitin: Drucker komento: befehl - mediatyyppi: + mediatyyppi: mediatyyppi_types: - A4: - A5: - LS149X104: - LS59X40: - LSN149X104: - LSN59X40: - kuittitulostin: + A4: + A5: + LS149X104: + LS59X40: + LSN149X104: + LSN59X40: + kuittitulostin: merkisto: zeichensatz merkisto_types: - '1': - '2': - '3': - '4': - '5': + '1': + '2': + '3': + '4': + '5': nimi: Name osoite: Adresse postino: Postleitzahl postitp: Poststelle puhelin: Telefon - unifaun_nimi: + unifaun_nimi: yhteyshenkilo: Kontaktperson qualifier: - isa_tarkenne: + isa_tarkenne: kaytossa: Wird benutzt - koodi: + koodi: nimi: Name tunnus: Kennzeichen tyyppi: Typ terms_of_payment: abs_pvm: Zahlungsdatum - erapvmkasin: - factoring: - itsetulostus: - jaksotettu: + erapvmkasin: + factoring: + itsetulostus: + jaksotettu: jarjestys: Sortierung jv: Nachnahme - kassa_abspvm: + kassa_abspvm: kassa_alepros: Kassenrabattsprozent - kassa_relpvm: + kassa_relpvm: kateinen: Barzahlung kaytossa: Wird benutzt laatija: Erstellt von luontiaika: Erstellt am - muutospvm: - muuttaja: + muutospvm: + muuttaja: pankkiyhteystiedot: Bankverbindungsdaten - rel_pvm: - sallitut_maat: - teksti: + rel_pvm: + sallitut_maat: + teksti: translations: - kieli: - selitetark: + kieli: + selitetark: models: account: Konto bank_account: Bankkonto - bank_detail: - carrier: - cash_register: + bank_detail: + carrier: + cash_register: currency: Währung + delivery_method: Versandart fiscal_year: Rechnungsjahr - head/purchase_invoice/approval: - head/purchase_invoice/approved: - head/purchase_invoice/paid: - head/purchase_invoice/transfer: - head/purchase_invoice/waiting: + head/purchase_invoice/approval: + head/purchase_invoice/approved: + head/purchase_invoice/paid: + head/purchase_invoice/transfer: + head/purchase_invoice/waiting: head/purchase_order: Kaufauftrag head/sales_invoice: Verkaufsrechnung head/sales_order: Auftrag head/sales_order_draft: Aufrag nicht abgeschlossen - head/voucher: - keyword/custom_attribute: + head/voucher: + keyword/custom_attribute: package: Verpackung - package_code: + package_code: packing_area: Packraum/Verpackungsabteilung printer: Drucker qualifier: Ergänzung @@ -318,239 +338,289 @@ de: qualifier/project: Projekt qualifier/target: Ziel sum_level: Ebene - sum_level/commodity: + sum_level/commodity: sum_level/external: Extern sum_level/internal: Intern - sum_level/profit: + sum_level/profit: sum_level/vat: Umsatzsteuer terms_of_payment: Zahlungsbedingung administration: accounts: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: button_remove: Konto löschen - confirm_remove: + confirm_remove: header: Konto no_cost_center: Keine Kostenstelle no_project: Kein Projekt - no_sum_level: + no_sum_level: no_target: Kein Ziel - no_vat: + no_vat: index: button_search: Suchen header: Kontotabelle manuaali_esto_options: - editing_disabled: - editing_enabled: + editing_disabled: + editing_enabled: tiliointi_tarkistus_options: - mandatory_cs: - mandatory_cs_project: - mandatory_cs_target: - mandatory_cs_target_project: - mandatory_project: - mandatory_target: - mandatory_target_project: - no_mandatory_fields: + mandatory_cs: + mandatory_cs_project: + mandatory_cs_target: + mandatory_cs_target_project: + mandatory_project: + mandatory_target: + mandatory_target_project: + no_mandatory_fields: toimijaliitos_options: - relation_not_required: - relation_required: + relation_not_required: + relation_required: update: - update_success: + update_success: actions: - button_saving: + button_saving: bank_accounts: create: - create_success: + create_success: edit: header: Bankkonto factoring_options: factoring_disabled: Wird nicht factoriert - factoring_enabled: + factoring_enabled: index: button_search: Suchen - header: - show_active: + header: + show_active: show_inactive: Gelöschte anzeigen kaytossa_options: active: Wird benutzt inactive: Gelöscht / Wird nicht benutzt tilinylitys_options: - limit_override_allowed: - limit_override_denied: + limit_override_allowed: + limit_override_denied: update: - update_success: + update_success: bank_details: edit: - header: + header: index: header: Bankverbindungsdaten bank_details_helper: - empty: + empty: finnish: Finnisch swedish: Schwedisch carriers: edit: - header: + header: index: button_search: Suchen - header: + header: neutraali_options: neutral: Ja not_neutral: Nein cash_registers: create: - create_success: + create_success: edit: - header: + header: no_select: Beliebig index: button_search: Suchen header: Kassen update: - update_success: + update_success: currencies: create: - create_success: + create_success: edit: header: Währung index: button_search: Suchen header: Währungen update: - update_success: + update_success: custom_attributes: edit: - button_remove: - confirm_remove: - header: + button_remove: + confirm_remove: + header: index: button_search: Suchen - header: + header: required_options: - mandatory: - optional: + mandatory: + optional: visibility_options: - hidden: - visible: + hidden: + visible: + delivery_methods: + adr_prohibition_options: + adr_prohibition: Liefern der ADR-Produkte nicht erlaubt bei der Lieferart + adr_shipment: ADR-Produkte werden geliefert mit der Lieferart + permit_adr: Liefern der ADR-Produkte erlaubt bei der Lieferart + cash_on_delivery_prohibition_options: + cash_on_delivery_permitted: Liefern der Nachnahmen erlaubt bei der Lieferart + cash_on_delivery_prohibition: Liefern der Nachnahmen nicht erlaubt bei der Lieferart + container_options: + includes_container: Ja + not_including_container: Nein + edit: + header: Versandart + no_select: Beliebig + extranet_options: + both_in_sales_and_extranet: Lieferart wird in beiden angezeigt + only_in_extranet: Lieferart wird nur im Extranet angezeigt + only_in_sales: Lieferart wird nur im Verkauf angezeigt + index: + button_new: Neue Lieferart + button_search: Suchen + header: Lieferarten + label_options: + compact_label: Komprimiert + intrade_label: Intrade + normal_label: Normal + packing_line_prohibition_options: + not_reserving_packing_line: Aufträge der Lieferart reservieren kein Packraum-/Verpackungsabteilungsfach + reserve_packing_line: Aufträge der Lieferart reservieren Packraum-/Verpackungsabteilungsfach + pickup_options: + pickup: Der Kunde holt die Aufträge ab + shipment: Aufträge werden an den Kunden geliefert + print_method_options: + batch: Losausdrucken + collective_batch: Sammel-Losausdrucken + collective_instant: Sammel-Sofortausdrucken + instant: Sofortausdrucken + skip_print: Frachbriefeingabe und -ausdrucken werden überholt + saturday_delivery_options: + not_saturday_delivery: Keine Samstagsdistribution + special_packaging_prohibition_options: + special_packaging_permitted: Liefern der Spezialverpackungen erlaubt bei der Lieferart + special_packaging_prohibition: Liefern der Spezialverpackungen nicht erlaubt bei der Lieferart + transport_unit_options: + not_transport_unit: Keinen Transporteinheittransport + transportation_insurance_type_options: + use_company_default: Standard der Firma + waybill_specification_options: + no_waybill_specification: Keine Frachtbriefspezifikation für die Lieferart ausdrucken + print_waybill_specification: Frachtbriefspezifikation für die Lieferart ausdrucken fiscal_years: create: - create_success: + create_success: edit: header: Rechnungsjahr index: button_search: Suchen - header: + header: update: - update_success: + update_success: packages: create: - create_success: + create_success: edit: header: Verpackung erikoispakkaus_options: - not_special: - special: + not_special: + special: index: button_search: Suchen - header: + header: package_codes: - link_new: + link_new: update: - update_success: + update_success: yksin_eraan_options: - combined_parcel: + combined_parcel: separate_parcel: Normalbehandlung packing_areas: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: - button_remove: - confirm_remove: + button_remove: + confirm_remove: header: Packraum/Verpackungsabteilung index: button_search: Suchen header: Packräume/Verpackungsabteilungen update: - update_success: + update_success: printers: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: - button_remove: - confirm_remove: + button_remove: + confirm_remove: header: Drucker index: button_search: Suchen header: Ausdrucker mediatyyppi_options: - media_a4: - media_a5: + media_a4: + media_a5: media_default: Beliebig - media_receipt: - media_thermal1: - media_thermal2: - media_thermal3: - media_thermal4: + media_receipt: + media_thermal1: + media_thermal2: + media_thermal3: + media_thermal4: merkisto_options: - charset_7bit: - charset_ansi: + charset_7bit: + charset_ansi: charset_default: Beliebig - charset_dos: - charset_scandic_off: - charset_utf8: + charset_dos: + charset_scandic_off: + charset_utf8: update: - update_success: + update_success: qualifiers: create: - create_success: + create_success: edit: - header: + header: index: button_search: Suchen - button_show_active: + button_show_active: button_show_removed: Gelöschte anzeigen - header: + header: kaytossa_options: in_use: Ja not_in_use: Nein update: - update_success: + update_success: sum_levels: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: button_remove: Ebene löschen - confirm_remove: - header: + confirm_remove: + header: index: button_search: Suchen - header: + header: kayttotarkoitus_options: normal: Beliebig - purchases: + purchases: turnover: Umsatz kumulatiivinen_options: - cumulative: + cumulative: not_cumulative: Nein update: - update_success: + update_success: terms_of_payments: cash_options: - cash: - credit_card: - debit_card: - not_cash: + cash: + credit_card: + debit_card: + not_cash: create: - create_success: + create_success: edit: header: Zahlungsbedingung no_factoring: Wird nicht factoriert @@ -560,22 +630,22 @@ de: inactive: Gelöscht / Wird nicht benutzt index: button_search: Suchen - button_show_active: - button_show_removed: - header: + button_show_active: + button_show_removed: + header: update: - update_success: + update_success: translations: language: Sprache link_new: Neue Übersetzung hinzufügen - text: + text: update_access: - forbidden: + forbidden: application: access_control: - forbidden: + forbidden: authorize: - unauthorized: + unauthorized: date: abbr_day_names: - So @@ -586,7 +656,7 @@ de: - Fr - Sa abbr_month_names: - - + - - Jan - Feb - Mär @@ -612,7 +682,7 @@ de: long: "%e. %B %Y" short: "%e. %b" month_names: - - + - - Januar - Februar - März @@ -674,19 +744,19 @@ de: year: Jahr //all are in singular now errors: cash_register: - kassa_missing: - kassaerotus_missing: - kateisotto_missing: - kateistilitys_missing: - luottokortti_missing: - pankkikortti_missing: + kassa_missing: + kassaerotus_missing: + kateisotto_missing: + kateistilitys_missing: + luottokortti_missing: + pankkikortti_missing: format: "%{attribute} %{message}" messages: accepted: muss akzeptiert werden - after: - after_or_equal_to: - before: - before_or_equal_to: + after: + after_or_equal_to: + before: + before_or_equal_to: blank: muss ausgefüllt werden confirmation: stimmt nicht mit %{attribute} überein empty: muss ausgefüllt werden @@ -699,7 +769,7 @@ de: invalid: ist nicht gültig less_than: muss kleiner als %{count} sein less_than_or_equal_to: muss kleiner oder gleich %{count} sein - not_a_date: + not_a_date: not_a_number: ist keine Zahl not_an_integer: muss ganzzahlig sein odd: muss ungerade sein @@ -720,89 +790,89 @@ de: one: hat die falsche Länge (muss genau 1 Zeichen haben) other: hat die falsche Länge (muss genau %{count} Zeichen haben) packing_area: - duplicate_cells: + duplicate_cells: qualifier: - accounts_found: + accounts_found: sum_level: - begin_with_error: - invalid_char: - not_same_type: + begin_with_error: + invalid_char: + not_same_type: template: body: 'Bitte überprüfen Sie die folgenden Felder:' header: one: 'Konnte %{model} nicht speichern: ein Fehler.' other: 'Konnte %{model} nicht speichern: %{count} Fehler.' terms_of_payment: - in_use_customers: - in_use_sales_order_drafts: - in_use_sales_orders: + in_use_customers: + in_use_sales_order_drafts: + in_use_sales_orders: fixed_assets: commodities: activate: - activation_failure: - activation_success: + activation_failure: + activation_success: commodity_rows: button_show_hide: Anzeigen / Verstecken - commodity_row_amount: - header: + commodity_row_amount: + header: confirm_sale: - sale_failure: - sale_success: + sale_failure: + sale_success: create: - create_success: + create_success: depreciations: button_show_hide: Anzeigen / Verstecken - depreciation_difference_amount: - depreciation_rows_amount: - header: + depreciation_difference_amount: + depreciation_rows_amount: + header: edit: - button_activate: - button_add_invoice_rows: - button_add_voucher_rows: - button_create: - button_sell: - header: + button_activate: + button_add_invoice_rows: + button_add_voucher_rows: + button_create: + button_sell: + header: form: - bookkeeping_value: - bookkeeping_value_now: + bookkeeping_value: + bookkeeping_value_now: index: - button_search: - header: + button_search: + header: link_order: - link_order_success: + link_order_success: link_voucher: - link_voucher_success: + link_voucher_success: link_voucher_row: - cannot_link_row: - row_already_linked: + cannot_link_row: + row_already_linked: new: - header: + header: procurement_rows: - button_remove: - header: + button_remove: + header: purchase_orders: - button_add: - button_search: - header: + button_add: + button_search: + header: sell: - confirm_sale: - header: + confirm_sale: + header: unlink: - unlink_success: + unlink_success: unlink_voucher_row: - cannot_unlink: + cannot_unlink: update: - update_success: + update_success: vouchers: - button_add: - button_search: - header: + button_add: + button_search: + header: helpers: select: prompt: Bitte wählen submit: create: "%{model} erstellen" - destroy: + destroy: new: Neu %{model} submit: "%{model} speichern" update: "%{model} aktualisieren" @@ -852,6 +922,9 @@ de: format: "%n %" shared: link_return_to: Zurück ins Programm + simple_form: + 'no': Nein + 'yes': Ja support: array: last_word_connector: " und " diff --git a/config/locales/en.yml b/config/locales/en.yml index 3cf781c23..0e058b4e5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3,73 +3,73 @@ en: activerecord: attributes: account: - alv_taso: - kohde: - kustp: + alv_taso: + kohde: + kustp: laatija: Created by luontiaika: Created muutospvm: Time of change muuttaja: Updated by nimi: Name - projekti: - sisainen_taso: + projekti: + sisainen_taso: tilino: 'Account #' - tiliointi_tarkistus: - toimijaliitos: - ulkoinen_taso: + tiliointi_tarkistus: + toimijaliitos: + ulkoinen_taso: accounting/fixed_assets/commodity: - evl_poistotyyppi: + evl_poistotyyppi: kayttoonottopvm: Deployment date bank_account: asiakastunnus: Customer nr bic: SWIFT/BIC - factoring: - hyvak: + factoring: + hyvak: iban: IBAN kaytossa: Status maksulimitti: Limit nimi: Name - oletus_kohde: - oletus_kulutili: - oletus_kustp: - oletus_projekti: - oletus_rahatili: - oletus_selvittelytili: + oletus_kohde: + oletus_kulutili: + oletus_kustp: + oletus_projekti: + oletus_rahatili: + oletus_selvittelytili: tilino: 'Account #' - tilinylitys: + tilinylitys: valkoodi: Currency bank_detail: laatija: Created by luontiaika: Date of creation - muutospvm: - muuttaja: + muutospvm: + muuttaja: nimitys: Product name - pankkiiban1: - pankkiiban2: - pankkiiban3: - pankkinimi1: - pankkinimi2: - pankkinimi3: - pankkiswift1: - pankkiswift2: - pankkiswift3: - pankkitili1: - pankkitili2: - pankkitili3: - viite: + pankkiiban1: + pankkiiban2: + pankkiiban3: + pankkinimi1: + pankkinimi2: + pankkinimi3: + pankkiswift1: + pankkiswift2: + pankkiswift3: + pankkitili1: + pankkitili2: + pankkitili3: + viite: carrier: - koodi: + koodi: luontiaika: Created - luottokortti: + luottokortti: muutospvm: Change date muuttaja: Updated by - neutraali: + neutraali: nimi: Name - pakkauksen_sarman_minimimitta: + pakkauksen_sarman_minimimitta: cash_register: kassa: Cash register kassaerotus: Cash difference - kateisotto: + kateisotto: kateistilitys: cash payment kustp: Cost center laatija: Created by @@ -85,14 +85,14 @@ en: email: Email factoringsaamiset: Factoring receivables fax: Fax - int_koodi: - intrastat_sarjanro: + int_koodi: + intrastat_sarjanro: jarjestys: Order - karhuerapvm: + karhuerapvm: kassa: Cash receipt kassaale: Purchase discounts - kassaerotus: - kateistilitys: + kassaerotus: + kateistilitys: kieli: Language konserni: Group konsernimyyntisaamiset: Receivables within the Group @@ -100,7 +100,7 @@ en: konsernisaamiset: Default account Corporate receivables konsernivelat: Default account Corporate payables kotipaikka: Domicile - kotitullauslupa: + kotitullauslupa: kuluprosentti: Expense % laskutus_maa: Invoicing country laskutus_nimi: Customer name invoicing address @@ -111,40 +111,40 @@ en: luottotappiot: Sales credit loss maa: Country matkalla_olevat: Inventories invoices in transit - muutkulut: + muutkulut: myynninkassaale: Sales discounts myynninvaluuttaero: Sales exchange rate premium myynti: Sales myynti_ei_eu: Sales outside EU myynti_eu: Community sales - myynti_kaanteinen: + myynti_kaanteinen: myynti_kohde: Sales default item myynti_kustp: Sales default cost senter myynti_marginaali: Sales, second hand myynti_projekti: Sales default project - myyntireskontrakausi_alku: - myyntireskontrakausi_loppu: + myyntireskontrakausi_alku: + myyntireskontrakausi_loppu: myyntisaamiset: Accounts receivable nimi: Name osoite: Address osto_marginaali: Purchase, second hand (sales related) - ostoreskontrakausi_alku: - ostoreskontrakausi_loppu: + ostoreskontrakausi_alku: + ostoreskontrakausi_loppu: ostovelat: Accounts payable ovttunnus: OVT-code - pankkiiban1: - pankkiiban2: - pankkiiban3: + pankkiiban1: + pankkiiban2: + pankkiiban3: pankkikortti: Cash receipts, bank cards - pankkinimi1: - pankkinimi2: - pankkinimi3: - pankkiswift1: - pankkiswift2: - pankkiswift3: - pankkitili1: - pankkitili2: - pankkitili3: + pankkinimi1: + pankkinimi2: + pankkinimi3: + pankkiswift1: + pankkiswift2: + pankkiswift3: + pankkitili1: + pankkitili2: + pankkitili3: postino: Postalc ode postitp: City puhelin: Telephone @@ -152,84 +152,87 @@ en: raaka_ainevarasto: Raw material stock raaka_ainevarastonmuutos: Raw material inventory change selvittelytili: Money accounts adjustment acc for unclear transactions - siirtosaamiset: - siirtovelka: - tilastotullikamari: - tilikauden_tulos: - tilikausi_alku: - tilikausi_loppu: - tilino_triang: - tulli_lisattava_era: - tulli_vahennettava_era: + siirtosaamiset: + siirtovelka: + tilastotullikamari: + tilikauden_tulos: + tilikausi_alku: + tilikausi_loppu: + tilino_triang: + tulli_lisattava_era: + tulli_vahennettava_era: tullikamari: customhouse - tullin_asiaknro: - tullin_lupanro: - tullipaate: + tullin_asiaknro: + tullin_lupanro: + tullipaate: valkoodi: Currency - valuuttaero: + valuuttaero: varasto: Goods/stock varastonmuutos: Inventory change - varastonmuutos_epakurantti: - varastonmuutos_inventointi: - varastonmuutos_rahti: + varastonmuutos_epakurantti: + varastonmuutos_inventointi: + varastonmuutos_rahti: varastonmuutos_valmistuksesta: Manufacture inventory change viivastyskorko: Penalty interest rate www: www ytunnus: VAT nr + delivery_method: + merahti: Freight contract + selite: Product name keyword: - jarjestys: - kieli: - laji: + jarjestys: + kieli: + laji: selite: Comment - selitetark: - selitetark_2: - selitetark_3: + selitetark: + selitetark_2: + selitetark_3: keyword/custom_attribute: - database_field: - default_value: - help_text: - label: - required: - set_name: - visibility: + database_field: + default_value: + help_text: + label: + required: + set_name: + visibility: package: - erikoispakkaus: - jarjestys: - kayttoprosentti: - kieli: - korkeus: - laji: - leveys: - minimi_paino: + erikoispakkaus: + jarjestys: + kayttoprosentti: + kieli: + korkeus: + laji: + leveys: + minimi_paino: paino: Weight - pakkaus: - pakkauskuvaus: - pakkausveloitus_tuotenumero: - puukotus_kerroin: + pakkaus: + pakkauskuvaus: + pakkausveloitus_tuotenumero: + puukotus_kerroin: selite: Comment - selitetark: - selitetark_2: - selitetark_3: - syvyys: - yksin_eraan: + selitetark: + selitetark_2: + selitetark_3: + syvyys: + yksin_eraan: package_code: - koodi: - rahdinkuljettaja: + koodi: + rahdinkuljettaja: package_codes: - koodi: - rahdinkuljettaja: + koodi: + rahdinkuljettaja: packing_area: - lokero: + lokero: nimi: Name - pakkaamon_prio: - printteri0: + pakkaamon_prio: + printteri0: printteri1: Dispatch note - printteri2: + printteri2: printteri3: Address label - printteri4: - printteri6: - printteri7: - prio: + printteri4: + printteri6: + printteri7: + prio: varasto: Storage printer: ip: Ip @@ -260,91 +263,92 @@ en: unifaun_nimi: Unifaun name yhteyshenkilo: Contact person qualifier: - isa_tarkenne: - kaytossa: - koodi: + isa_tarkenne: + kaytossa: + koodi: nimi: Name - tunnus: + tunnus: tyyppi: Type terms_of_payment: abs_pvm: Date of payment - erapvmkasin: - factoring: - itsetulostus: - jaksotettu: - jarjestys: - jv: - kassa_abspvm: - kassa_alepros: - kassa_relpvm: - kateinen: - kaytossa: + erapvmkasin: + factoring: + itsetulostus: + jaksotettu: + jarjestys: + jv: + kassa_abspvm: + kassa_alepros: + kassa_relpvm: + kateinen: + kaytossa: laatija: Created by luontiaika: Date of creation - muutospvm: - muuttaja: + muutospvm: + muuttaja: pankkiyhteystiedot: Bank accounts - rel_pvm: - sallitut_maat: - teksti: + rel_pvm: + sallitut_maat: + teksti: translations: - kieli: - selitetark: + kieli: + selitetark: models: account: Account - bank_account: - bank_detail: - carrier: + bank_account: + bank_detail: + carrier: cash_register: Kassa currency: Currency + delivery_method: Delivery fiscal_year: Fiscal year - head/purchase_invoice/approval: - head/purchase_invoice/approved: - head/purchase_invoice/paid: - head/purchase_invoice/transfer: - head/purchase_invoice/waiting: + head/purchase_invoice/approval: + head/purchase_invoice/approved: + head/purchase_invoice/paid: + head/purchase_invoice/transfer: + head/purchase_invoice/waiting: head/purchase_order: Purchase order head/sales_invoice: Invoice head/sales_order: Order head/sales_order_draft: Sales order has open issues - head/voucher: - keyword/custom_attribute: + head/voucher: + keyword/custom_attribute: package: package - package_code: - packing_area: + package_code: + packing_area: printer: Printer qualifier: Cost, profit center, projects - qualifier/cost_center: - qualifier/project: + qualifier/cost_center: + qualifier/project: qualifier/target: Target sum_level: Level - sum_level/commodity: - sum_level/external: - sum_level/internal: - sum_level/profit: + sum_level/commodity: + sum_level/external: + sum_level/internal: + sum_level/profit: sum_level/vat: VAT terms_of_payment: Terms of payment administration: accounts: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: button_remove: Delete account - confirm_remove: + confirm_remove: header: Account no_cost_center: No cost center no_project: No project - no_sum_level: + no_sum_level: no_target: No target - no_vat: + no_vat: index: button_search: Search header: Chart of accounts manuaali_esto_options: - editing_disabled: - editing_enabled: + editing_disabled: + editing_enabled: tiliointi_tarkistus_options: mandatory_cs: mandatory field in posting is cost center mandatory_cs_project: mandatory field in posting is cost center, project @@ -355,54 +359,54 @@ en: mandatory_target_project: target, project is compulsory field in posting no_mandatory_fields: No mandatory fields toimijaliitos_options: - relation_not_required: + relation_not_required: relation_required: Memo needs a customer or a supplier update: - update_success: + update_success: actions: - button_saving: + button_saving: bank_accounts: create: - create_success: + create_success: edit: - header: + header: factoring_options: - factoring_disabled: - factoring_enabled: + factoring_disabled: + factoring_enabled: index: button_search: Search - header: - show_active: + header: + show_active: show_inactive: Show removed kaytossa_options: - active: - inactive: + active: + inactive: tilinylitys_options: - limit_override_allowed: - limit_override_denied: + limit_override_allowed: + limit_override_denied: update: - update_success: + update_success: bank_details: edit: - header: + header: index: header: Bank accounts bank_details_helper: - empty: + empty: finnish: Finnish swedish: Swedish carriers: edit: - header: + header: index: button_search: Search - header: + header: neutraali_options: neutral: true not_neutral: false cash_registers: create: - create_success: + create_success: edit: header: Kassa no_select: No selection @@ -410,172 +414,181 @@ en: button_search: Search header: Cash accounts update: - update_success: + update_success: currencies: create: - create_success: + create_success: edit: header: Currency index: button_search: Search header: Currencies update: - update_success: + update_success: custom_attributes: edit: - button_remove: - confirm_remove: - header: + button_remove: + confirm_remove: + header: index: button_search: Search - header: + header: required_options: - mandatory: - optional: + mandatory: + optional: visibility_options: - hidden: - visible: + hidden: + visible: + delivery_methods: + container_options: + includes_container: 'Yes' + not_including_container: 'No' + edit: + header: Delivery + no_select: Any + index: + button_search: Search fiscal_years: create: - create_success: + create_success: edit: header: Fiscal year index: button_search: Search header: Fiscal periods update: - update_success: + update_success: packages: create: - create_success: + create_success: edit: header: package erikoispakkaus_options: - not_special: - special: + not_special: + special: index: button_search: Search - header: + header: package_codes: - link_new: + link_new: update: - update_success: + update_success: yksin_eraan_options: - combined_parcel: - separate_parcel: + combined_parcel: + separate_parcel: packing_areas: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: - button_remove: - confirm_remove: - header: + button_remove: + confirm_remove: + header: index: button_search: Search - header: + header: update: - update_success: + update_success: printers: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: - button_remove: - confirm_remove: + button_remove: + confirm_remove: header: Printer index: button_search: Search header: Printers mediatyyppi_options: - media_a4: - media_a5: + media_a4: + media_a5: media_default: No selection - media_receipt: - media_thermal1: - media_thermal2: - media_thermal3: - media_thermal4: + media_receipt: + media_thermal1: + media_thermal2: + media_thermal3: + media_thermal4: merkisto_options: - charset_7bit: - charset_ansi: + charset_7bit: + charset_ansi: charset_default: No selection - charset_dos: - charset_scandic_off: - charset_utf8: + charset_dos: + charset_scandic_off: + charset_utf8: update: - update_success: + update_success: qualifiers: create: - create_success: + create_success: edit: - header: + header: index: button_search: Search - button_show_active: + button_show_active: button_show_removed: Show removed - header: + header: kaytossa_options: in_use: 'Yes' not_in_use: 'No' update: - update_success: + update_success: sum_levels: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: button_remove: Delete level - confirm_remove: - header: + confirm_remove: + header: index: button_search: Search - header: + header: kayttotarkoitus_options: normal: No selection - purchases: + purchases: turnover: Revenue kumulatiivinen_options: - cumulative: + cumulative: not_cumulative: 'No' update: - update_success: + update_success: terms_of_payments: cash_options: - cash: - credit_card: - debit_card: - not_cash: + cash: + credit_card: + debit_card: + not_cash: create: - create_success: + create_success: edit: header: Terms of payment no_factoring: No factoring - use_company_defaults: + use_company_defaults: in_use_options: active: In use inactive: Deleted / Not in use index: button_search: Search - button_show_active: - button_show_removed: - header: + button_show_active: + button_show_removed: + header: update: - update_success: + update_success: translations: - language: - link_new: - text: + language: + link_new: + text: update_access: - forbidden: + forbidden: application: access_control: - forbidden: + forbidden: authorize: - unauthorized: + unauthorized: date: abbr_day_names: - Sun @@ -586,7 +599,7 @@ en: - Fri - Sat abbr_month_names: - - + - - Jan - Feb - Mar @@ -612,7 +625,7 @@ en: long: "%B %d, %Y" short: "%b %d" month_names: - - + - - January - February - March @@ -674,19 +687,19 @@ en: year: Year errors: cash_register: - kassa_missing: - kassaerotus_missing: - kateisotto_missing: - kateistilitys_missing: - luottokortti_missing: - pankkikortti_missing: + kassa_missing: + kassaerotus_missing: + kateisotto_missing: + kateistilitys_missing: + luottokortti_missing: + pankkikortti_missing: format: "%{attribute} %{message}" messages: accepted: must be accepted - after: - after_or_equal_to: - before: - before_or_equal_to: + after: + after_or_equal_to: + before: + before_or_equal_to: blank: can't be blank confirmation: doesn't match %{attribute} empty: can't be empty @@ -699,7 +712,7 @@ en: invalid: is invalid less_than: must be less than %{count} less_than_or_equal_to: must be less than or equal to %{count} - not_a_date: + not_a_date: not_a_number: is not a number not_an_integer: must be an integer odd: must be odd @@ -720,89 +733,89 @@ en: one: is the wrong length (should be 1 character) other: is the wrong length (should be %{count} characters) packing_area: - duplicate_cells: + duplicate_cells: qualifier: - accounts_found: + accounts_found: sum_level: - begin_with_error: - invalid_char: - not_same_type: + begin_with_error: + invalid_char: + not_same_type: template: body: 'There were problems with the following fields:' header: one: 1 error prohibited this %{model} from being saved other: "%{count} errors prohibited this %{model} from being saved" terms_of_payment: - in_use_customers: - in_use_sales_order_drafts: - in_use_sales_orders: + in_use_customers: + in_use_sales_order_drafts: + in_use_sales_orders: fixed_assets: commodities: activate: - activation_failure: - activation_success: + activation_failure: + activation_success: commodity_rows: button_show_hide: Display/Hide - commodity_row_amount: - header: + commodity_row_amount: + header: confirm_sale: - sale_failure: - sale_success: + sale_failure: + sale_success: create: - create_success: + create_success: depreciations: button_show_hide: Display/Hide - depreciation_difference_amount: - depreciation_rows_amount: - header: + depreciation_difference_amount: + depreciation_rows_amount: + header: edit: - button_activate: - button_add_invoice_rows: - button_add_voucher_rows: - button_create: - button_sell: - header: + button_activate: + button_add_invoice_rows: + button_add_voucher_rows: + button_create: + button_sell: + header: form: - bookkeeping_value: - bookkeeping_value_now: + bookkeeping_value: + bookkeeping_value_now: index: - button_search: - header: + button_search: + header: link_order: - link_order_success: + link_order_success: link_voucher: - link_voucher_success: + link_voucher_success: link_voucher_row: - cannot_link_row: - row_already_linked: + cannot_link_row: + row_already_linked: new: - header: + header: procurement_rows: - button_remove: - header: + button_remove: + header: purchase_orders: - button_add: - button_search: - header: + button_add: + button_search: + header: sell: - confirm_sale: - header: + confirm_sale: + header: unlink: - unlink_success: + unlink_success: unlink_voucher_row: - cannot_unlink: + cannot_unlink: update: - update_success: + update_success: vouchers: - button_add: - button_search: - header: + button_add: + button_search: + header: helpers: select: prompt: Please select submit: create: Create %{model} - destroy: + destroy: new: New %{model} submit: Save %{model} update: Update %{model} @@ -848,6 +861,9 @@ en: format: "%n%" shared: link_return_to: Go back to the program + simple_form: + 'no': 'No' + 'yes': 'Yes' support: array: last_word_connector: ", and " diff --git a/config/locales/et.yml b/config/locales/et.yml index 5e36e3ebe..7bf3b5ec2 100644 --- a/config/locales/et.yml +++ b/config/locales/et.yml @@ -15,57 +15,57 @@ et: sisainen_taso: Taseme kood (Sisene kasumiaruanne) tilino: Kontonumber tiliointi_tarkistus: Kohustuslikud väljad - toimijaliitos: + toimijaliitos: ulkoinen_taso: Taseme kood (Väline kasumiaruanne/Bilanss)) accounting/fixed_assets/commodity: - evl_poistotyyppi: + evl_poistotyyppi: kayttoonottopvm: Kasutuselevotu kuupäev bank_account: asiakastunnus: Klienditunnus bic: SWIFT / BIC - factoring: - hyvak: - iban: + factoring: + hyvak: + iban: kaytossa: Ruum maksulimitti: Makselimiit nimi: Nimi - oletus_kohde: - oletus_kulutili: - oletus_kustp: - oletus_projekti: - oletus_rahatili: - oletus_selvittelytili: + oletus_kohde: + oletus_kulutili: + oletus_kustp: + oletus_projekti: + oletus_rahatili: + oletus_selvittelytili: tilino: Kontonumber - tilinylitys: + tilinylitys: valkoodi: Valuuta bank_detail: laatija: Koostaja luontiaika: Koostamise aeg - muutospvm: - muuttaja: + muutospvm: + muuttaja: nimitys: Nimetus - pankkiiban1: - pankkiiban2: - pankkiiban3: - pankkinimi1: - pankkinimi2: - pankkinimi3: - pankkiswift1: - pankkiswift2: - pankkiswift3: + pankkiiban1: + pankkiiban2: + pankkiiban3: + pankkinimi1: + pankkinimi2: + pankkinimi3: + pankkiswift1: + pankkiswift2: + pankkiswift3: pankkitili1: Konto number pankkitili2: Konto number pankkitili3: Konto number - viite: + viite: carrier: koodi: Kood luontiaika: Koostamise aeg - luottokortti: + luottokortti: muutospvm: Muutmise kuupäev muuttaja: Muutja - neutraali: + neutraali: nimi: Nimi - pakkauksen_sarman_minimimitta: + pakkauksen_sarman_minimimitta: cash_register: kassa: Kassa kassaerotus: Kassa vahe @@ -91,7 +91,7 @@ et: karhuerapvm: Makse meeldetuletuste maksetähtaeg (pv) kassa: Sularaha müük kassaale: Ostude allahindlused - kassaerotus: + kassaerotus: kateistilitys: Kassa sularahamaksed kieli: Keel konserni: Kontsern @@ -115,7 +115,7 @@ et: myynninkassaale: Müügi allahindlused myynninvaluuttaero: Müügi valuutakursi vahed myynti: Müük - myynti_ei_eu: + myynti_ei_eu: myynti_eu: "Ühendatud müük" myynti_kaanteinen: Müük, pöördkäibemaks myynti_kohde: Müügi vaikimisi objekt @@ -152,13 +152,13 @@ et: raaka_ainevarasto: Tooraineladu raaka_ainevarastonmuutos: Toorainelao muutus selvittelytili: Rahakonto kliiringkonto ebamäärastele tehingutele - siirtosaamiset: - siirtovelka: + siirtosaamiset: + siirtovelka: tilastotullikamari: Statistikaameti tolliosakond tilikauden_tulos: Aruandeaasta kasum tilikausi_alku: Raamatupidamise perioodi alguskuupäev tilikausi_loppu: Raamatupidamise perioodi lõppkuupäev - tilino_triang: + tilino_triang: tulli_lisattava_era: SAD-ankeedi lisatav partii tulli_vahennettava_era: SAD-ankeedi vähendav partii tullikamari: Tolliosakond @@ -171,180 +171,188 @@ et: varastonmuutos: Lao muutus varastonmuutos_epakurantti: Mitteminevuse laoväärtus muutus varastonmuutos_inventointi: Inventuuride saldoparandus - varastonmuutos_rahti: + varastonmuutos_rahti: varastonmuutos_valmistuksesta: Tootmise varude muutus viivastyskorko: Viivise protsent www: WWW ytunnus: KMKR Nr. + delivery_method: + jarjestys: Järjekord + jvkulu: Lunamaksekulu + kuluprosentti: Kuluprotsent + merahti: Veoleping + selite: Nimetus + tulostustapa: Väljastamisviis keyword: jarjestys: Järjekord kieli: Keel - laji: + laji: selite: Selgitus - selitetark: - selitetark_2: - selitetark_3: + selitetark: + selitetark_2: + selitetark_3: keyword/custom_attribute: - database_field: - default_value: - help_text: - label: - required: - set_name: - visibility: + database_field: + default_value: + help_text: + label: + required: + set_name: + visibility: package: - erikoispakkaus: + erikoispakkaus: jarjestys: Järjekord - kayttoprosentti: + kayttoprosentti: kieli: Keel - korkeus: - laji: - leveys: - minimi_paino: + korkeus: + laji: + leveys: + minimi_paino: paino: Kaal - pakkaus: + pakkaus: pakkauskuvaus: Pakendi kirjeldus - pakkausveloitus_tuotenumero: - puukotus_kerroin: + pakkausveloitus_tuotenumero: + puukotus_kerroin: selite: Selgitus - selitetark: - selitetark_2: - selitetark_3: - syvyys: - yksin_eraan: + selitetark: + selitetark_2: + selitetark_3: + syvyys: + yksin_eraan: package_code: - koodi: - rahdinkuljettaja: + koodi: + rahdinkuljettaja: package_codes: - koodi: - rahdinkuljettaja: + koodi: + rahdinkuljettaja: packing_area: - lokero: + lokero: nimi: Nimi - pakkaamon_prio: + pakkaamon_prio: printteri0: Komplekteerimisleht printteri1: Saateleht printteri2: Tootekleebised printteri3: Aadressilipik printteri4: Veokiri A5 printteri6: Veokiri A4 - printteri7: - prio: + printteri7: + prio: varasto: Ladu printer: ip: ip jarjestys: Järjekord kirjoitin: Printer komento: käsklus - mediatyyppi: + mediatyyppi: mediatyyppi_types: - A4: - A5: - LS149X104: - LS59X40: - LSN149X104: - LSN59X40: - kuittitulostin: + A4: + A5: + LS149X104: + LS59X40: + LSN149X104: + LSN59X40: + kuittitulostin: merkisto: märgistik merkisto_types: - '1': - '2': - '3': - '4': - '5': + '1': + '2': + '3': + '4': + '5': nimi: Nimi osoite: Aadress postino: Postinr postitp: Postiaadress puhelin: Telefon - unifaun_nimi: + unifaun_nimi: yhteyshenkilo: Kontaktisik qualifier: - isa_tarkenne: + isa_tarkenne: kaytossa: Kasutusel - koodi: + koodi: nimi: Nimi - tunnus: + tunnus: tyyppi: Tyyp terms_of_payment: abs_pvm: Maksepäev - erapvmkasin: - factoring: - itsetulostus: - jaksotettu: + erapvmkasin: + factoring: + itsetulostus: + jaksotettu: jarjestys: Järjekord - jv: - kassa_abspvm: - kassa_alepros: - kassa_relpvm: - kateinen: + jv: + kassa_abspvm: + kassa_alepros: + kassa_relpvm: + kateinen: kaytossa: Kasutusel laatija: Koostaja luontiaika: Koostamise aeg - muutospvm: - muuttaja: + muutospvm: + muuttaja: pankkiyhteystiedot: Pangarekvisiidid - rel_pvm: - sallitut_maat: - teksti: + rel_pvm: + sallitut_maat: + teksti: translations: - kieli: - selitetark: + kieli: + selitetark: models: account: Arve bank_account: Pangakonto - bank_detail: - carrier: + bank_detail: + carrier: cash_register: Kassa currency: Valuuta + delivery_method: Kohaletoimetamise viis fiscal_year: Aruandeperiood - head/purchase_invoice/approval: - head/purchase_invoice/approved: - head/purchase_invoice/paid: - head/purchase_invoice/transfer: - head/purchase_invoice/waiting: + head/purchase_invoice/approval: + head/purchase_invoice/approved: + head/purchase_invoice/paid: + head/purchase_invoice/transfer: + head/purchase_invoice/waiting: head/purchase_order: Ostutellimus head/sales_invoice: Myygiarve head/sales_order: Myygitellimus head/sales_order_draft: Myygitellimus pooleli - head/voucher: - keyword/custom_attribute: + head/voucher: + keyword/custom_attribute: package: Pakend - package_code: - packing_area: + package_code: + packing_area: printer: Printer qualifier: Täpsustus qualifier/cost_center: Kulukoht qualifier/project: Projekt qualifier/target: Objekt sum_level: Tase - sum_level/commodity: - sum_level/external: + sum_level/commodity: + sum_level/external: sum_level/internal: Sisemine - sum_level/profit: + sum_level/profit: sum_level/vat: Km terms_of_payment: Maksutingimus administration: accounts: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: button_remove: Kustuta konto - confirm_remove: + confirm_remove: header: Arve no_cost_center: Kulukoht puudub no_project: Projekt puudub - no_sum_level: + no_sum_level: no_target: Objekt puudub - no_vat: + no_vat: index: button_search: Otsi header: Kontokaart manuaali_esto_options: editing_disabled: Konteeringu käsitsi lisamine/muutmine keelatud - editing_enabled: + editing_enabled: tiliointi_tarkistus_options: mandatory_cs: kohustuslikke välju konteerimisel on kulukoht mandatory_cs_project: kohustuslikke välju konteerimisel on kulukoht, projekt @@ -356,53 +364,53 @@ et: no_mandatory_fields: Kohustuslikud väljad puuduvad toimijaliitos_options: relation_not_required: Liitmine ei ole kohustuslik - relation_required: + relation_required: update: - update_success: + update_success: actions: - button_saving: + button_saving: bank_accounts: create: - create_success: + create_success: edit: header: Pangakonto factoring_options: factoring_disabled: Ei kasutata faktooringut - factoring_enabled: + factoring_enabled: index: button_search: Otsi - header: - show_active: + header: + show_active: show_inactive: Näita tyhistatuid kaytossa_options: active: Kasutusel inactive: Kustutatud/Ei ole kasutusel tilinylitys_options: - limit_override_allowed: - limit_override_denied: + limit_override_allowed: + limit_override_denied: update: - update_success: + update_success: bank_details: edit: - header: + header: index: header: Pangarekvisiidid bank_details_helper: - empty: + empty: finnish: Soome swedish: Rootsi carriers: edit: - header: + header: index: button_search: Otsi - header: + header: neutraali_options: neutral: Jah not_neutral: Ei cash_registers: create: - create_success: + create_success: edit: header: Kassa no_select: Pole valikut @@ -410,147 +418,159 @@ et: button_search: Otsi header: Kassarakised update: - update_success: + update_success: currencies: create: - create_success: + create_success: edit: header: Valuuta index: button_search: Otsi header: Valuutad update: - update_success: + update_success: custom_attributes: edit: - button_remove: - confirm_remove: - header: + button_remove: + confirm_remove: + header: index: button_search: Otsi - header: + header: required_options: - mandatory: - optional: + mandatory: + optional: visibility_options: - hidden: - visible: + hidden: + visible: + delivery_methods: + container_options: + includes_container: Jah + not_including_container: Ei + edit: + header: Kohaletoimetamise viis + no_select: Valikut ei ole + index: + button_search: Otsi + header: Tarnimisviisid + label_options: + normal_label: Normaalne fiscal_years: create: - create_success: + create_success: edit: header: Aruandeperiood index: button_search: Otsi header: Majandusaasta update: - update_success: + update_success: packages: create: - create_success: + create_success: edit: header: Pakend erikoispakkaus_options: - not_special: - special: + not_special: + special: index: button_search: Otsi - header: + header: package_codes: - link_new: + link_new: update: - update_success: + update_success: yksin_eraan_options: - combined_parcel: + combined_parcel: separate_parcel: Tavakäsitlus packing_areas: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: - button_remove: - confirm_remove: - header: + button_remove: + confirm_remove: + header: index: button_search: Otsi - header: + header: update: - update_success: + update_success: printers: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: - button_remove: - confirm_remove: + button_remove: + confirm_remove: header: Printer index: button_search: Otsi header: Printerid mediatyyppi_options: - media_a4: - media_a5: + media_a4: + media_a5: media_default: Pole valikut - media_receipt: - media_thermal1: - media_thermal2: - media_thermal3: - media_thermal4: + media_receipt: + media_thermal1: + media_thermal2: + media_thermal3: + media_thermal4: merkisto_options: - charset_7bit: - charset_ansi: + charset_7bit: + charset_ansi: charset_default: Pole valikut - charset_dos: - charset_scandic_off: - charset_utf8: + charset_dos: + charset_scandic_off: + charset_utf8: update: - update_success: + update_success: qualifiers: create: - create_success: + create_success: edit: - header: + header: index: button_search: Otsi - button_show_active: + button_show_active: button_show_removed: Näita tyhistatuid - header: + header: kaytossa_options: in_use: Jah not_in_use: Ei update: - update_success: + update_success: sum_levels: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: button_remove: Kustuta tase - confirm_remove: - header: + confirm_remove: + header: index: button_search: Otsi - header: + header: kayttotarkoitus_options: normal: Pole valikut - purchases: + purchases: turnover: Kaupluse vahetus kumulatiivinen_options: - cumulative: + cumulative: not_cumulative: Ei update: - update_success: + update_success: terms_of_payments: cash_options: - cash: - credit_card: - debit_card: - not_cash: + cash: + credit_card: + debit_card: + not_cash: create: - create_success: + create_success: edit: header: Maksutingimus no_factoring: Ei kasutata faktooringut @@ -560,22 +580,22 @@ et: inactive: Kustutatud/Ei ole kasutusel index: button_search: Otsi - button_show_active: - button_show_removed: - header: + button_show_active: + button_show_removed: + header: update: - update_success: + update_success: translations: language: Keel - link_new: - text: + link_new: + text: update_access: - forbidden: + forbidden: application: access_control: - forbidden: + forbidden: authorize: - unauthorized: + unauthorized: date: abbr_day_names: - P @@ -586,7 +606,7 @@ et: - R - L abbr_month_names: - - + - - jaan. - veebr. - märts @@ -612,7 +632,7 @@ et: long: "%d. %B %Y" short: "%d.%m.%y" month_names: - - + - - jaanuar - veebruar - märts @@ -674,19 +694,19 @@ et: year: Aasta errors: cash_register: - kassa_missing: - kassaerotus_missing: - kateisotto_missing: - kateistilitys_missing: - luottokortti_missing: - pankkikortti_missing: + kassa_missing: + kassaerotus_missing: + kateisotto_missing: + kateistilitys_missing: + luottokortti_missing: + pankkikortti_missing: format: "%{attribute} %{message}" messages: accepted: peab olema heaks kiidetud - after: - after_or_equal_to: - before: - before_or_equal_to: + after: + after_or_equal_to: + before: + before_or_equal_to: blank: on täitmata confirmation: ei vasta kinnitusele %{attribute} empty: on tühi @@ -699,102 +719,102 @@ et: invalid: ei ole korrektne less_than: peab olema vähem kui %{count} less_than_or_equal_to: peab olema vähem või võrdne arvuga %{count} - not_a_date: + not_a_date: not_a_number: ei ole number not_an_integer: peab olema täisarv odd: peab olema paaritu arv - other_than: - present: + other_than: + present: record_invalid: 'Valideerimine ebaõnnestus: %{errors}' - restrict_dependent_destroy: + restrict_dependent_destroy: taken: on juba võetud too_long: on liiga pikk (maksimum on %{count} tähemärki) too_short: on liiga lühike (miinimum on %{count} tähemärki) wrong_length: on vale pikkusega (peab olema %{count} tähemärki) packing_area: - duplicate_cells: + duplicate_cells: qualifier: - accounts_found: + accounts_found: sum_level: - begin_with_error: - invalid_char: - not_same_type: + begin_with_error: + invalid_char: + not_same_type: template: body: 'Probleeme ilmnes järgmiste väljadega:' header: one: "Üks viga takistas objekti %{model} salvestamist" other: "%{count} viga takistasid objekti %{model} salvestamist" terms_of_payment: - in_use_customers: - in_use_sales_order_drafts: - in_use_sales_orders: + in_use_customers: + in_use_sales_order_drafts: + in_use_sales_orders: fixed_assets: commodities: activate: - activation_failure: - activation_success: + activation_failure: + activation_success: commodity_rows: button_show_hide: Näita / Peida - commodity_row_amount: - header: + commodity_row_amount: + header: confirm_sale: - sale_failure: - sale_success: + sale_failure: + sale_success: create: - create_success: + create_success: depreciations: button_show_hide: Näita / Peida - depreciation_difference_amount: - depreciation_rows_amount: - header: + depreciation_difference_amount: + depreciation_rows_amount: + header: edit: - button_activate: - button_add_invoice_rows: - button_add_voucher_rows: - button_create: - button_sell: - header: + button_activate: + button_add_invoice_rows: + button_add_voucher_rows: + button_create: + button_sell: + header: form: - bookkeeping_value: - bookkeeping_value_now: + bookkeeping_value: + bookkeeping_value_now: index: - button_search: - header: + button_search: + header: link_order: - link_order_success: + link_order_success: link_voucher: - link_voucher_success: + link_voucher_success: link_voucher_row: - cannot_link_row: - row_already_linked: + cannot_link_row: + row_already_linked: new: - header: + header: procurement_rows: - button_remove: - header: + button_remove: + header: purchase_orders: - button_add: - button_search: - header: + button_add: + button_search: + header: sell: - confirm_sale: - header: + confirm_sale: + header: unlink: - unlink_success: + unlink_success: unlink_voucher_row: - cannot_unlink: + cannot_unlink: update: - update_success: + update_success: vouchers: - button_add: - button_search: - header: + button_add: + button_search: + header: helpers: select: prompt: Palun vali submit: create: Loo uus %{model} - destroy: + destroy: new: Uus %{model} submit: Salvesta %{model} update: Uuenda objekti %{model} @@ -837,9 +857,12 @@ et: tb: TB percentage: format: - format: + format: shared: link_return_to: Tagasi programmi + simple_form: + 'no': Ei + 'yes': Jah support: array: last_word_connector: " ja " diff --git a/config/locales/sv.yml b/config/locales/sv.yml index f800cf2d7..d6e1bfad9 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -3,232 +3,239 @@ sv: activerecord: attributes: account: - alv_taso: - kohde: - kustp: + alv_taso: + kohde: + kustp: laatija: Skapare luontiaika: Skapad - muutospvm: - muuttaja: + muutospvm: + muuttaja: nimi: Namn - projekti: - sisainen_taso: + projekti: + sisainen_taso: tilino: Kontonummer - tiliointi_tarkistus: - toimijaliitos: - ulkoinen_taso: + tiliointi_tarkistus: + toimijaliitos: + ulkoinen_taso: accounting/fixed_assets/commodity: - evl_poistotyyppi: + evl_poistotyyppi: kayttoonottopvm: Ibruktagningsdatum bank_account: asiakastunnus: Org.nummer - bic: - factoring: - hyvak: - iban: + bic: + factoring: + hyvak: + iban: kaytossa: Status - maksulimitti: + maksulimitti: nimi: Namn - oletus_kohde: - oletus_kulutili: - oletus_kustp: - oletus_projekti: - oletus_rahatili: - oletus_selvittelytili: + oletus_kohde: + oletus_kulutili: + oletus_kustp: + oletus_projekti: + oletus_rahatili: + oletus_selvittelytili: tilino: Kontonummer - tilinylitys: + tilinylitys: valkoodi: Valuta bank_detail: laatija: Skapare luontiaika: Skapad - muutospvm: - muuttaja: + muutospvm: + muuttaja: nimitys: Benämning - pankkiiban1: - pankkiiban2: - pankkiiban3: - pankkinimi1: - pankkinimi2: - pankkinimi3: - pankkiswift1: - pankkiswift2: - pankkiswift3: + pankkiiban1: + pankkiiban2: + pankkiiban3: + pankkinimi1: + pankkinimi2: + pankkinimi3: + pankkiswift1: + pankkiswift2: + pankkiswift3: pankkitili1: Kontonummer pankkitili2: Kontonummer pankkitili3: Kontonummer - viite: + viite: carrier: - koodi: + koodi: luontiaika: Skapad - luottokortti: + luottokortti: muutospvm: "ändringsdatum" - muuttaja: - neutraali: + muuttaja: + neutraali: nimi: Namn - pakkauksen_sarman_minimimitta: + pakkauksen_sarman_minimimitta: cash_register: kassa: Kassa - kassaerotus: - kateisotto: - kateistilitys: + kassaerotus: + kateisotto: + kateistilitys: kustp: Kostnadsställe laatija: Skapare luontiaika: Skapad - luottokortti: + luottokortti: muutospvm: "ändringsdatum" muuttaja: omvandlare nimi: Namn - pankkikortti: + pankkikortti: toimipaikka: Verksamhetsställe company: alv: Moms - email: - factoringsaamiset: + email: + factoringsaamiset: fax: Fax - int_koodi: - intrastat_sarjanro: + int_koodi: + intrastat_sarjanro: jarjestys: Ordning - karhuerapvm: - kassa: - kassaale: - kassaerotus: - kateistilitys: + karhuerapvm: + kassa: + kassaale: + kassaerotus: + kateistilitys: kieli: Språk konserni: Koncern konsernimyyntisaamiset: koncernförsäljningsfordringar konserniostovelat: koncernköpskulder - konsernisaamiset: - konsernivelat: + konsernisaamiset: + konsernivelat: kotipaikka: Hemplats kotitullauslupa: hemförtullningstillstånd kuluprosentti: Kostprocent - laskutus_maa: - laskutus_nimi: - laskutus_osoite: - laskutus_postino: - laskutus_postitp: - luottokortti: - luottotappiot: + laskutus_maa: + laskutus_nimi: + laskutus_osoite: + laskutus_postino: + laskutus_postitp: + luottokortti: + luottotappiot: maa: Land - matkalla_olevat: - muutkulut: - myynninkassaale: - myynninvaluuttaero: + matkalla_olevat: + muutkulut: + myynninkassaale: + myynninvaluuttaero: myynti: Försäljning - myynti_ei_eu: - myynti_eu: - myynti_kaanteinen: - myynti_kohde: - myynti_kustp: - myynti_marginaali: - myynti_projekti: - myyntireskontrakausi_alku: - myyntireskontrakausi_loppu: + myynti_ei_eu: + myynti_eu: + myynti_kaanteinen: + myynti_kohde: + myynti_kustp: + myynti_marginaali: + myynti_projekti: + myyntireskontrakausi_alku: + myyntireskontrakausi_loppu: myyntisaamiset: Försäljningsfordringar nimi: Namn osoite: Adress - osto_marginaali: - ostoreskontrakausi_alku: - ostoreskontrakausi_loppu: + osto_marginaali: + ostoreskontrakausi_alku: + ostoreskontrakausi_loppu: ostovelat: leverantörsskulder - ovttunnus: - pankkiiban1: - pankkiiban2: - pankkiiban3: - pankkikortti: - pankkinimi1: - pankkinimi2: - pankkinimi3: - pankkiswift1: - pankkiswift2: - pankkiswift3: - pankkitili1: - pankkitili2: - pankkitili3: + ovttunnus: + pankkiiban1: + pankkiiban2: + pankkiiban3: + pankkikortti: + pankkinimi1: + pankkinimi2: + pankkinimi3: + pankkiswift1: + pankkiswift2: + pankkiswift3: + pankkitili1: + pankkitili2: + pankkitili3: postino: Postnummer postitp: Postanstalt puhelin: Tel. - pyoristys: - raaka_ainevarasto: - raaka_ainevarastonmuutos: - selvittelytili: - siirtosaamiset: - siirtovelka: + pyoristys: + raaka_ainevarasto: + raaka_ainevarastonmuutos: + selvittelytili: + siirtosaamiset: + siirtovelka: tilastotullikamari: statistiktullkammare - tilikauden_tulos: - tilikausi_alku: - tilikausi_loppu: - tilino_triang: - tulli_lisattava_era: - tulli_vahennettava_era: + tilikauden_tulos: + tilikausi_alku: + tilikausi_loppu: + tilino_triang: + tulli_lisattava_era: + tulli_vahennettava_era: tullikamari: tullkammare - tullin_asiaknro: - tullin_lupanro: + tullin_asiaknro: + tullin_lupanro: tullipaate: tullterminal valkoodi: valuta - valuuttaero: - varasto: + valuuttaero: + varasto: varastonmuutos: Lagerförändring - varastonmuutos_epakurantti: - varastonmuutos_inventointi: - varastonmuutos_rahti: - varastonmuutos_valmistuksesta: - viivastyskorko: + varastonmuutos_epakurantti: + varastonmuutos_inventointi: + varastonmuutos_rahti: + varastonmuutos_valmistuksesta: + viivastyskorko: www: web ytunnus: Org.Nr + delivery_method: + jarjestys: Ordning + jvkulu: Postförskottsavgift + kuluprosentti: Kostprocent + merahti: Fraktkontrakt + selite: Benämning + tulostustapa: Utskriftsmetod keyword: jarjestys: Ordning kieli: Språk - laji: + laji: selite: Benämning - selitetark: - selitetark_2: - selitetark_3: + selitetark: + selitetark_2: + selitetark_3: keyword/custom_attribute: - database_field: - default_value: - help_text: - label: - required: - set_name: - visibility: + database_field: + default_value: + help_text: + label: + required: + set_name: + visibility: package: - erikoispakkaus: + erikoispakkaus: jarjestys: Ordning - kayttoprosentti: + kayttoprosentti: kieli: Språk - korkeus: - laji: - leveys: - minimi_paino: + korkeus: + laji: + leveys: + minimi_paino: paino: Vikt - pakkaus: + pakkaus: pakkauskuvaus: Paketbeskrivning - pakkausveloitus_tuotenumero: - puukotus_kerroin: + pakkausveloitus_tuotenumero: + puukotus_kerroin: selite: Benämning - selitetark: - selitetark_2: - selitetark_3: - syvyys: - yksin_eraan: + selitetark: + selitetark_2: + selitetark_3: + syvyys: + yksin_eraan: package_code: - koodi: - rahdinkuljettaja: + koodi: + rahdinkuljettaja: package_codes: - koodi: - rahdinkuljettaja: + koodi: + rahdinkuljettaja: packing_area: - lokero: + lokero: nimi: Namn - pakkaamon_prio: + pakkaamon_prio: printteri0: Plocklista printteri1: Följesedel printteri2: Artikeletiketter printteri3: adresslapp printteri4: Fraktsedel A5 printteri6: Fraktsedel A4 - printteri7: + printteri7: prio: Prio varasto: Lager printer: @@ -236,346 +243,359 @@ sv: jarjestys: Ordning kirjoitin: Skrivare komento: kommando - mediatyyppi: + mediatyyppi: mediatyyppi_types: - A4: - A5: - LS149X104: - LS59X40: - LSN149X104: - LSN59X40: - kuittitulostin: + A4: + A5: + LS149X104: + LS59X40: + LSN149X104: + LSN59X40: + kuittitulostin: merkisto: charset merkisto_types: - '1': - '2': - '3': - '4': - '5': + '1': + '2': + '3': + '4': + '5': nimi: Namn osoite: Adress postino: Post Nr postitp: Postadress puhelin: Tel. - unifaun_nimi: + unifaun_nimi: yhteyshenkilo: Kontaktperson qualifier: - isa_tarkenne: - kaytossa: - koodi: + isa_tarkenne: + kaytossa: + koodi: nimi: Namn - tunnus: + tunnus: tyyppi: Typ terms_of_payment: abs_pvm: Betalningsdag - erapvmkasin: - factoring: - itsetulostus: - jaksotettu: + erapvmkasin: + factoring: + itsetulostus: + jaksotettu: jarjestys: Ordning jv: Efterkrav - kassa_abspvm: - kassa_alepros: - kassa_relpvm: + kassa_abspvm: + kassa_alepros: + kassa_relpvm: kateinen: Kontant - kaytossa: + kaytossa: laatija: Skapare luontiaika: Skapad - muutospvm: - muuttaja: + muutospvm: + muuttaja: pankkiyhteystiedot: Bankuppgifter - rel_pvm: - sallitut_maat: - teksti: + rel_pvm: + sallitut_maat: + teksti: translations: - kieli: - selitetark: + kieli: + selitetark: models: account: Konto bank_account: Bankkonto - bank_detail: - carrier: - cash_register: + bank_detail: + carrier: + cash_register: currency: Valuta + delivery_method: Leveranssätt fiscal_year: Räkenskapsår - head/purchase_invoice/approval: - head/purchase_invoice/approved: - head/purchase_invoice/paid: - head/purchase_invoice/transfer: - head/purchase_invoice/waiting: + head/purchase_invoice/approval: + head/purchase_invoice/approved: + head/purchase_invoice/paid: + head/purchase_invoice/transfer: + head/purchase_invoice/waiting: head/purchase_order: Inköpsorder head/sales_invoice: Försäljningsfaktura head/sales_order: Försäljningsorder head/sales_order_draft: "Öppen försäljningsorder" - head/voucher: - keyword/custom_attribute: + head/voucher: + keyword/custom_attribute: package: Förpackning - package_code: - packing_area: + package_code: + packing_area: printer: Skrivare qualifier: Specifikation qualifier/cost_center: Kostnadsställe qualifier/project: Projekt qualifier/target: Objekt sum_level: Nivå - sum_level/commodity: - sum_level/external: + sum_level/commodity: + sum_level/external: sum_level/internal: Intern - sum_level/profit: + sum_level/profit: sum_level/vat: Moms terms_of_payment: Betalningsvillkor administration: accounts: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: button_remove: Radera konto - confirm_remove: + confirm_remove: header: Konto no_cost_center: Inget kostnadsställe no_project: Inget projekt - no_sum_level: + no_sum_level: no_target: Inget objekt - no_vat: + no_vat: index: button_search: Sök header: Kontotabell manuaali_esto_options: - editing_disabled: - editing_enabled: + editing_disabled: + editing_enabled: tiliointi_tarkistus_options: - mandatory_cs: - mandatory_cs_project: - mandatory_cs_target: - mandatory_cs_target_project: - mandatory_project: - mandatory_target: - mandatory_target_project: - no_mandatory_fields: + mandatory_cs: + mandatory_cs_project: + mandatory_cs_target: + mandatory_cs_target_project: + mandatory_project: + mandatory_target: + mandatory_target_project: + no_mandatory_fields: toimijaliitos_options: - relation_not_required: - relation_required: + relation_not_required: + relation_required: update: - update_success: + update_success: actions: - button_saving: + button_saving: bank_accounts: create: - create_success: + create_success: edit: header: Bankkonto factoring_options: factoring_disabled: Ej factoring - factoring_enabled: + factoring_enabled: index: button_search: Sök - header: - show_active: + header: + show_active: show_inactive: Visa raderade kaytossa_options: - active: + active: inactive: Borttagit / Inte i bruk tilinylitys_options: - limit_override_allowed: - limit_override_denied: + limit_override_allowed: + limit_override_denied: update: - update_success: + update_success: bank_details: edit: - header: + header: index: header: Bankuppgifter bank_details_helper: - empty: + empty: finnish: Finska swedish: Svenska carriers: edit: - header: + header: index: button_search: Sök - header: + header: neutraali_options: neutral: Ja not_neutral: Nej cash_registers: create: - create_success: + create_success: edit: - header: + header: no_select: Inget val index: button_search: Sök - header: + header: update: - update_success: + update_success: currencies: create: - create_success: + create_success: edit: header: Valuta index: button_search: Sök header: Valutor update: - update_success: + update_success: custom_attributes: edit: - button_remove: - confirm_remove: - header: + button_remove: + confirm_remove: + header: index: button_search: Sök - header: + header: required_options: - mandatory: - optional: + mandatory: + optional: visibility_options: - hidden: - visible: + hidden: + visible: + delivery_methods: + container_options: + includes_container: Ja + not_including_container: Nej + edit: + header: Leveranssätt + no_select: Inget val + index: + button_search: Sök + header: Leveranssätt + label_options: + normal_label: Normal fiscal_years: create: - create_success: + create_success: edit: header: Räkenskapsår index: button_search: Sök header: Räkenskapsåren update: - update_success: + update_success: packages: create: - create_success: + create_success: edit: header: Förpackning erikoispakkaus_options: - not_special: - special: + not_special: + special: index: button_search: Sök - header: + header: package_codes: - link_new: + link_new: update: - update_success: + update_success: yksin_eraan_options: - combined_parcel: + combined_parcel: separate_parcel: Normal behandling packing_areas: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: - button_remove: - confirm_remove: - header: + button_remove: + confirm_remove: + header: index: button_search: Sök - header: + header: update: - update_success: + update_success: printers: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: - button_remove: - confirm_remove: + button_remove: + confirm_remove: header: Skrivare index: button_search: Sök header: Skrivare mediatyyppi_options: - media_a4: - media_a5: + media_a4: + media_a5: media_default: Inget val - media_receipt: - media_thermal1: - media_thermal2: - media_thermal3: - media_thermal4: + media_receipt: + media_thermal1: + media_thermal2: + media_thermal3: + media_thermal4: merkisto_options: - charset_7bit: - charset_ansi: + charset_7bit: + charset_ansi: charset_default: Inget val - charset_dos: - charset_scandic_off: - charset_utf8: + charset_dos: + charset_scandic_off: + charset_utf8: update: - update_success: + update_success: qualifiers: create: - create_success: + create_success: edit: - header: + header: index: button_search: Sök - button_show_active: + button_show_active: button_show_removed: Visa raderade - header: + header: kaytossa_options: in_use: Ja not_in_use: Nej update: - update_success: + update_success: sum_levels: create: - create_success: + create_success: destroy: - destroy_success: + destroy_success: edit: button_remove: Radera nivå - confirm_remove: - header: + confirm_remove: + header: index: button_search: Sök - header: + header: kayttotarkoitus_options: normal: Inget val - purchases: + purchases: turnover: Omsättning kumulatiivinen_options: - cumulative: + cumulative: not_cumulative: Nej update: - update_success: + update_success: terms_of_payments: cash_options: - cash: - credit_card: - debit_card: - not_cash: + cash: + credit_card: + debit_card: + not_cash: create: - create_success: + create_success: edit: header: Betalningsvillkor no_factoring: Ej factoring - use_company_defaults: + use_company_defaults: in_use_options: active: i bruk inactive: Borttagit / Inte i bruk index: button_search: Sök - button_show_active: - button_show_removed: - header: + button_show_active: + button_show_removed: + header: update: - update_success: + update_success: translations: language: Språk - link_new: - text: + link_new: + text: update_access: - forbidden: + forbidden: application: access_control: - forbidden: + forbidden: authorize: - unauthorized: + unauthorized: date: abbr_day_names: - sön @@ -586,7 +606,7 @@ sv: - fre - lör abbr_month_names: - - + - - jan - feb - mar @@ -612,7 +632,7 @@ sv: long: "%e %B %Y" short: "%e %b" month_names: - - + - - januari - februari - mars @@ -674,19 +694,19 @@ sv: year: "År" errors: cash_register: - kassa_missing: - kassaerotus_missing: - kateisotto_missing: - kateistilitys_missing: - luottokortti_missing: - pankkikortti_missing: + kassa_missing: + kassaerotus_missing: + kateisotto_missing: + kateistilitys_missing: + luottokortti_missing: + pankkikortti_missing: format: "%{attribute} %{message}" messages: accepted: måste vara accepterad - after: - after_or_equal_to: - before: - before_or_equal_to: + after: + after_or_equal_to: + before: + before_or_equal_to: blank: måste anges confirmation: stämmer inte överens %{attribute} empty: får ej vara tom @@ -699,7 +719,7 @@ sv: invalid: har fel format less_than: måste vara mindre än %{count} less_than_or_equal_to: måste vara mindre än eller lika med %{count} - not_a_date: + not_a_date: not_a_number: "är inte ett nummer" not_an_integer: måste vara ett heltal odd: måste vara udda @@ -714,89 +734,89 @@ sv: too_short: "är för kort (minimum är %{count} tecken)" wrong_length: har fel längd (ska vara %{count} tecken) packing_area: - duplicate_cells: + duplicate_cells: qualifier: - accounts_found: + accounts_found: sum_level: - begin_with_error: - invalid_char: - not_same_type: + begin_with_error: + invalid_char: + not_same_type: template: body: 'Det var problem med följande fält:' header: one: Ett fel förhindrade denna %{model} från att sparas other: "%{count} fel förhindrade denna %{model} från att sparas" terms_of_payment: - in_use_customers: - in_use_sales_order_drafts: - in_use_sales_orders: + in_use_customers: + in_use_sales_order_drafts: + in_use_sales_orders: fixed_assets: commodities: activate: - activation_failure: - activation_success: + activation_failure: + activation_success: commodity_rows: button_show_hide: Visa / Dölj - commodity_row_amount: - header: + commodity_row_amount: + header: confirm_sale: - sale_failure: - sale_success: + sale_failure: + sale_success: create: - create_success: + create_success: depreciations: button_show_hide: Visa / Dölj - depreciation_difference_amount: - depreciation_rows_amount: - header: + depreciation_difference_amount: + depreciation_rows_amount: + header: edit: - button_activate: - button_add_invoice_rows: - button_add_voucher_rows: - button_create: - button_sell: - header: + button_activate: + button_add_invoice_rows: + button_add_voucher_rows: + button_create: + button_sell: + header: form: - bookkeeping_value: - bookkeeping_value_now: + bookkeeping_value: + bookkeeping_value_now: index: - button_search: - header: + button_search: + header: link_order: - link_order_success: + link_order_success: link_voucher: - link_voucher_success: + link_voucher_success: link_voucher_row: - cannot_link_row: - row_already_linked: + cannot_link_row: + row_already_linked: new: - header: + header: procurement_rows: - button_remove: - header: + button_remove: + header: purchase_orders: - button_add: - button_search: - header: + button_add: + button_search: + header: sell: - confirm_sale: - header: + confirm_sale: + header: unlink: - unlink_success: + unlink_success: unlink_voucher_row: - cannot_unlink: + cannot_unlink: update: - update_success: + update_success: vouchers: - button_add: - button_search: - header: + button_add: + button_search: + header: helpers: select: prompt: Välj submit: create: Skapa %{model} - destroy: + destroy: new: Ny %{model} submit: Spara %{model} update: "Ändra %{model}" @@ -842,15 +862,18 @@ sv: format: "%n%" shared: link_return_to: "Återgå till" + simple_form: + 'no': Nej + 'yes': Ja support: array: last_word_connector: " och " two_words_connector: " och " words_connector: ", " time: - am: + am: formats: default: "%a, %e %b %Y %H:%M:%S %z" long: "%e %B %Y %H:%M" short: "%e %b %H:%M" - pm: + pm: From 6c0ad4e78917c27e0cdfc9ad0d46501291d4130b Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Thu, 17 Sep 2015 11:53:04 +0300 Subject: [PATCH 075/189] draw checkboxes --- app/views/administration/delivery_methods/_form.html.erb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 26c172e0a..2dd3bd40c 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -212,7 +212,14 @@ - + From f9ceba4a7b3803d2a10960440b08dde666a3df10 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Thu, 17 Sep 2015 14:28:54 +0300 Subject: [PATCH 076/189] cleanup --- app/models/delivery_method.rb | 42 ++++++++++++++++------------------- config/locales/fi.yml | 2 +- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 507873075..868e1511f 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -130,71 +130,67 @@ def permitted_packaging_options private - def permit_adr_shipments - DeliveryMethod.permit_adr.shipment.pluck(:selite) - end - def mandatory_new_packaging_information - root = 'errors.delivery_method' - errors.add(:base, I18n.t("#{root}.mandatory_new_packaging_info_with_unifaun_waybill")) if rahtikirja.include? 'rahtikirja_unifaun' + if rahtikirja.include? 'rahtikirja_unifaun' + errors.add :base, I18n.t("errors.delivery_method.unifaun_info_missing") + end end def vak_kielto_validation allowed = DeliveryMethod.permit_adr.shipment.pluck(:selite) + [ '', 'K' ] - errors.add :vak_kielto, I18n.t('errors.messages.inclusion') unless allowed.include? vak_kielto + + unless allowed.include? vak_kielto + errors.add :vak_kielto, I18n.t('errors.messages.inclusion') + end end def vaihtoehtoinen_vak_toimitustapa_validation - allowed = permit_adr_shipments + [ '' ] - errors.add :vaihtoehtoinen_vak_toimitustapa, I18n.t('errors.messages.inclusion') unless allowed.include? vaihtoehtoinen_vak_toimitustapa + allowed = DeliveryMethod.permit_adr.shipment.pluck(:selite) + [ '' ] + + unless allowed.include? vaihtoehtoinen_vak_toimitustapa + errors.add :vaihtoehtoinen_vak_toimitustapa, I18n.t('errors.messages.inclusion') + end end def check_relations - root = 'errors.delivery_method' allow_delete = true count = company.customers.where(toimitustapa: selite).count - if count.nonzero? - errors.add(:base, I18n.t("#{root}.in_use_customers", count: count)) + errors.add :base, I18n.t("errors.delivery_method.in_use_customers", count: count) allow_delete = false end count = company.sales_orders.not_delivered.where(toimitustapa: selite).count - if count.nonzero? - errors.add(:base, I18n.t("#{root}.in_use_sales_orders", count: count)) + errors.add :base, I18n.t("errors.delivery_method.in_use_sales_orders", count: count) allow_delete = false end count = company.sales_order_drafts.where(toimitustapa: selite).count - if count.nonzero? - errors.add(:base, I18n.t("#{root}.in_use_sales_order_drafts", count: count)) + errors.add :base, I18n.t("errors.delivery_method.in_use_sales_order_drafts", count: count) allow_delete = false end count = company.freights.where(toimitustapa: selite).count - if count.nonzero? - errors.add(:base, I18n.t("#{root}.in_use_freights", count: count)) + errors.add :base, I18n.t("errors.delivery_method.in_use_freights", count: count) allow_delete = false end count = company.freight_contracts.where(toimitustapa: selite).count - if count.nonzero? - errors.add(:base, I18n.t("#{root}.in_use_freight_contracts", count: count)) + errors.add :base, I18n.t("errors.delivery_method.in_use_freight_contracts", count: count) allow_delete = false end count = company.customer_keywords.where(avainsana: selite).count - if count.nonzero? - errors.add(:base, I18n.t("#{root}.in_use_customer_keywords", count: count)) + errors.add :base, I18n.t("errors.delivery_method.in_use_customer_keywords", count: count) allow_delete = false end - return allow_delete + allow_delete end end diff --git a/config/locales/fi.yml b/config/locales/fi.yml index f914fe92d..5fbca5198 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -824,7 +824,7 @@ fi: in_use_freights: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtimaksulla' in_use_sales_order_drafts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} keskeneräisellä myyntitilauksella' in_use_sales_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} toimittamattomalla myyntitilauksella' - mandatory_new_packaging_info_with_unifaun_waybill: 'HUOM: Koontierätulostus ei toimi Unifaun Online rahtikirjan kanssa ilman koontirahtikirjan pakkaustietoja' + unifaun_info_missing: 'HUOM: Koontierätulostus ei toimi Unifaun Online rahtikirjan kanssa ilman koontirahtikirjan pakkaustietoja' format: "%{attribute} %{message}" messages: accepted: täytyy olla hyväksytty From 0b0599d3f1c2d907fbd2c580779e9740429fb9a2 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Thu, 17 Sep 2015 15:44:11 +0300 Subject: [PATCH 077/189] fix defaults --- app/models/delivery_method.rb | 11 +++++++++-- .../administration/delivery_methods/_form.html.erb | 3 +-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 868e1511f..97c3aece0 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -28,6 +28,7 @@ class DeliveryMethod < BaseModel validate :vak_kielto_validation validate :mandatory_new_packaging_information if :package_info_entry_denied && :collective_batch + before_save :defaults before_destroy :check_relations float_columns :jvkulu, :erilliskasiteltavakulu, :kuljetusvakuutus, :kuluprosentti, :ulkomaanlisa, @@ -62,8 +63,8 @@ class DeliveryMethod < BaseModel } enum merahti: { + receiver_freight_contract: '', sender_freight_contract: 'K', - receiver_freight_contract: '' } enum logy_rahtikirjanumerot: { @@ -78,8 +79,8 @@ class DeliveryMethod < BaseModel } enum kontti: { + not_including_container: '0', includes_container: '1', - not_including_container: '0' } enum jvkielto: { @@ -193,4 +194,10 @@ def check_relations allow_delete end + + def defaults + self.kauppatapahtuman_luonne ||= 0 + self.kuljetusmuoto ||= 0 + self.sisamaan_kuljetusmuoto ||= 0 + end end diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 2dd3bd40c..13c899fb3 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -176,8 +176,7 @@ - + From 76cec137639880b1935f246745d270ecb7c9082f Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Thu, 17 Sep 2015 16:02:09 +0300 Subject: [PATCH 078/189] save sallitut_alustat as string --- .../administration/delivery_methods_controller.rb | 3 +++ .../delivery_method_controller_test.rb | 15 ++++++++++++++- test/fixtures/packages.yml | 13 +++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index cd421f99e..75d3a266b 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -43,6 +43,9 @@ def destroy private def delivery_method_params + alustat = params[:delivery_method][:sallitut_alustat] + params[:delivery_method][:sallitut_alustat] = alustat.reject(&:empty?).join(',') if alustat + params.require(:delivery_method).permit( :aktiivinen_kuljetus, :aktiivinen_kuljetus_kansallisuus, :ei_pakkaamoa, :erikoispakkaus_kielto, :erilliskasiteltavakulu, :erittely, :extranet, diff --git a/test/controllers/administration/delivery_method_controller_test.rb b/test/controllers/administration/delivery_method_controller_test.rb index 1a3b9158f..807181baf 100644 --- a/test/controllers/administration/delivery_method_controller_test.rb +++ b/test/controllers/administration/delivery_method_controller_test.rb @@ -1,7 +1,7 @@ require 'test_helper' class Administration::DeliveryMethodsControllerTest < ActionController::TestCase - fixtures %w(delivery_methods) + fixtures %w(delivery_methods packages) def setup login users(:joe) @@ -91,4 +91,17 @@ def setup assert_redirected_to delivery_methods_path end + + test 'should save sallitut_alustat array as string' do + login users(:bob) + package_one = packages(:steel_barrel).id + package_two = packages(:oak_barrel).id + + params = { sallitut_alustat: [ package_one, package_two, '' ] } + + patch :update, id: @delivery_method.id, delivery_method: params + assert_redirected_to delivery_methods_path + + assert_equal "#{package_one},#{package_two}", @delivery_method.reload.sallitut_alustat + end end diff --git a/test/fixtures/packages.yml b/test/fixtures/packages.yml index 49a69f90c..3ee89ea48 100644 --- a/test/fixtures/packages.yml +++ b/test/fixtures/packages.yml @@ -10,3 +10,16 @@ steel_barrel: muutospvm: <%= Time.now %> laatija: joe muuttaja: joe + +oak_barrel: + yhtio: acme + pakkaus: 2A + pakkauskuvaus: Tammitynnyri + leveys: 10 + korkeus: 10 + syvyys: 10 + paino: 10 + luontiaika: <%= Time.now %> + muutospvm: <%= Time.now %> + laatija: joe + muuttaja: joe From 12ec88e00fde9f1b41609e3f86daed8ebe60fb75 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Thu, 17 Sep 2015 16:09:49 +0300 Subject: [PATCH 079/189] check the correct boxes --- app/views/administration/delivery_methods/_form.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 13c899fb3..b36a3fd4d 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -212,7 +212,8 @@ From 3254dd5d6842c19bb296dde35e87f59c0b8a8ec4 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 18 Sep 2015 10:42:18 +0300 Subject: [PATCH 083/189] add missing fixture --- test/models/supplier_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/models/supplier_test.rb b/test/models/supplier_test.rb index e15bd7f54..8df1bb7c3 100644 --- a/test/models/supplier_test.rb +++ b/test/models/supplier_test.rb @@ -1,7 +1,7 @@ require 'test_helper' class SupplierTest < ActiveSupport::TestCase - fixtures %w(suppliers product/suppliers) + fixtures %w(suppliers product/suppliers products) setup do @supplier = suppliers :domestic_supplier From 8d9fff71dfa828b352f426f399dcc9f85c9bb190 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 18 Sep 2015 10:43:12 +0300 Subject: [PATCH 084/189] remove waybills from database, use enum instead --- app/helpers/delivery_method_helper.rb | 15 +++++++++++++++ app/helpers/keyword_helper.rb | 4 ---- app/models/delivery_method.rb | 16 ++++++++++++++-- app/models/keyword.rb | 1 - app/models/keyword/waybill.rb | 8 -------- config/locales/fi.yml | 11 +++++++++++ .../delivery_method_controller_test.rb | 2 +- test/fixtures/keywords.yml | 10 ---------- test/helpers/keyword_helper_test.rb | 5 ----- 9 files changed, 41 insertions(+), 31 deletions(-) delete mode 100644 app/models/keyword/waybill.rb diff --git a/app/helpers/delivery_method_helper.rb b/app/helpers/delivery_method_helper.rb index a48762e46..d3b410a59 100644 --- a/app/helpers/delivery_method_helper.rb +++ b/app/helpers/delivery_method_helper.rb @@ -121,4 +121,19 @@ def transportation_insurance_type_options [ t("#{ROOT}.transportation_insurance_type_options.#{key}"), key ] end end + + def waybill_options + [ + [ t('administration.delivery_methods.waybill_options.generic_a4'), :generic_a4 ], + [ t('administration.delivery_methods.waybill_options.itella_a5'), :itella_a5 ], + [ t('administration.delivery_methods.waybill_options.itella_thermal'), :itella_thermal ], + [ t('administration.delivery_methods.waybill_options.itella_priority_foreign'), :itella_priority_foreign ], + [ t('administration.delivery_methods.waybill_options.unifaun_online'), :unifaun_online ], + [ t('administration.delivery_methods.waybill_options.unifaun_print_server'), :unifaun_print_server ], + [ t('administration.delivery_methods.waybill_options.dpd_waybill'), :dpd_waybill ], + [ t('administration.delivery_methods.waybill_options.dpd_ftp'), :dpd_ftp ], + [ t('administration.delivery_methods.waybill_options.ups_ftp'), :ups_ftp ], + [ t('administration.delivery_methods.waybill_options.no_waybill'), :no_waybill ], + ] + end end diff --git a/app/helpers/keyword_helper.rb b/app/helpers/keyword_helper.rb index 93bbefc6a..f252c0ae7 100644 --- a/app/helpers/keyword_helper.rb +++ b/app/helpers/keyword_helper.rb @@ -29,10 +29,6 @@ def translatable_locales_options ] end - def waybill_options - Keyword::Waybill.pluck(:selitetark, :selite) - end - def mode_of_transport_options Keyword::ModeOfTransport.pluck(:selitetark, :selite) end diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 97c3aece0..e23005150 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -3,7 +3,6 @@ class DeliveryMethod < BaseModel include Searchable with_options foreign_key: :selite do |o| - o.has_many :waybills, primary_key: :rahtikirja, class_name: 'Keyword::Waybill' o.has_many :mode_of_transports, primary_key: :kuljetusmuoto, class_name: 'Keyword::ModeOfTransport' o.has_many :nature_of_transactions, primary_key: :kauppatapahtuman_luonne, class_name: 'Keyword::NatureOfTransaction' o.has_many :customs, primary_key: :poistumistoimipaikka_koodi, class_name: 'Keyword::Customs' @@ -67,6 +66,19 @@ class DeliveryMethod < BaseModel sender_freight_contract: 'K', } + enum rahtikirja: { + generic_a4: 'rahtikirja_pdf.inc', + itella_a5: 'rahtikirja_postitarra_pdf.inc', + itella_priority_foreign: 'rahtikirja_postitarra_ulkomaa_pdf.inc', + itella_thermal: 'rahtikirja_postitarra.inc', + unifaun_online: 'rahtikirja_unifaun_uo_siirto.inc', + unifaun_print_server: 'rahtikirja_unifaun_ps_siirto.inc', + dpd_waybill: 'rahtikirja_dpd.inc', + dpd_ftp: 'rahtikirja_dpd_siirto.inc', + ups_ftp: 'rahtikirja_ups_siirto.inc', + no_waybill: 'rahtikirja_tyhja.inc', + } + enum logy_rahtikirjanumerot: { not_using_logy_waybill_numbers: '', use_logy_waybill_numbers: 'K' @@ -132,7 +144,7 @@ def permitted_packaging_options private def mandatory_new_packaging_information - if rahtikirja.include? 'rahtikirja_unifaun' + if unifaun_online? || unifaun_print_server? errors.add :base, I18n.t("errors.delivery_method.unifaun_info_missing") end end diff --git a/app/models/keyword.rb b/app/models/keyword.rb index f4400b94b..a92c38259 100644 --- a/app/models/keyword.rb +++ b/app/models/keyword.rb @@ -21,7 +21,6 @@ def self.child_class_names 'MYSQLALIAS' => Keyword::CustomAttribute, 'OSASTO' => Product::Category, 'PAKKAUSKV' => Keyword::PackageTranslation, - 'RAHTIKIRJA' => Keyword::Waybill, 'S' => Product::Status, 'TOIMTAPALP' => Keyword::SortingPoint, 'TRY' => Product::Subcategory, diff --git a/app/models/keyword/waybill.rb b/app/models/keyword/waybill.rb deleted file mode 100644 index ee45bd93e..000000000 --- a/app/models/keyword/waybill.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Keyword::Waybill < Keyword - validates :selitetark, presence: true - - # Rails requires sti_name method to return type column (laji) value - def self.sti_name - 'RAHTIKIRJA' - end -end diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 3eeb629c0..893289f43 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -568,6 +568,17 @@ fi: use_company_default: Yhtiön oletus update: update_success: Toimitustapa päivitettiin onnistuneesti + waybill_options: + dpd_ftp: DPD ftp-siirto + dpd_waybill: DPD A5 PDF-rahtikirja + generic_a4: Yleisrahtikirja A4 PDF + itella_a5: Postin A5 PDF-rahtikirja + itella_priority_foreign: Itella Priority Ulkomaa + itella_thermal: Postin lämpösiirto-rahtikirja + no_waybill: Rahtikirjaa ei tulosteta + unifaun_online: Unifaun Online + unifaun_print_server: Unifaun Print Server + ups_ftp: UPS ftp-siirto waybill_specification_options: no_waybill_specification: Toimitustavalle ei tulosteta rahtikirjaerittelyä print_waybill_specification: Toimitustavalle tulostetaan rahtikirjaerittely diff --git a/test/controllers/administration/delivery_method_controller_test.rb b/test/controllers/administration/delivery_method_controller_test.rb index 807181baf..b9b9544e7 100644 --- a/test/controllers/administration/delivery_method_controller_test.rb +++ b/test/controllers/administration/delivery_method_controller_test.rb @@ -37,7 +37,7 @@ def setup nouto: :shipment, ei_pakkaamoa: '1', extranet: :only_in_sales, - rahtikirja: 'rahtikirja.inc', + rahtikirja: 'generic_a4', jarjestys: 1 } diff --git a/test/fixtures/keywords.yml b/test/fixtures/keywords.yml index d2ed3311e..db5e40544 100644 --- a/test/fixtures/keywords.yml +++ b/test/fixtures/keywords.yml @@ -37,16 +37,6 @@ brand_tools: laji: TUOTEMERKKI <<: *DEFAULTS -waybill: - yhtio: acme - selite: rahtikirja.inc - selitetark: Yleisrahtikirja A4 teksti - laji: RAHTIKIRJA - muuttaja: joe - laatija: joe - luontiaika: <%= Time.now %> - muutospvm: <%= Time.now %> - mode_of_transport: yhtio: acme selite: 1 diff --git a/test/helpers/keyword_helper_test.rb b/test/helpers/keyword_helper_test.rb index 64e7bc1a6..4fe66bd0b 100644 --- a/test/helpers/keyword_helper_test.rb +++ b/test/helpers/keyword_helper_test.rb @@ -1,11 +1,6 @@ require 'test_helper' class KeywordHelperTest < ActionView::TestCase - test "should get waybill options" do - assert_kind_of Array, waybill_options - assert_equal 'rahtikirja.inc', waybill_options.first.second - end - test "should get mode of transport options" do assert_kind_of Array, mode_of_transport_options assert_equal '1 - Merikuljetus (ml. auto- ja junalauttakuljetus)', mode_of_transport_options.first.first From cecce51496343b20d6d6092788c53edff749d336 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 18 Sep 2015 10:52:05 +0300 Subject: [PATCH 085/189] remove unused key --- config/locales/de.yml | 1 - config/locales/fi.yml | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index 0819a5bb9..8bf57e15d 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -474,7 +474,6 @@ de: only_in_extranet: Lieferart wird nur im Extranet angezeigt only_in_sales: Lieferart wird nur im Verkauf angezeigt index: - button_new: Neue Lieferart button_search: Suchen header: Lieferarten label_options: diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 893289f43..b45b7dc83 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -212,7 +212,7 @@ fi: rahdinkuljettaja: Kuljetusyhtiö rahti_tuotenumero: Rahtiveloitus tuotenumero rahtikirja: Rahtikirjatyyppi - rahtikirjakopio_email: + rahtikirjakopio_email: sallitut_alustat: Sallitut keräilyalustat sallitut_maat: Sallitut maat selite: Nimitys @@ -524,7 +524,6 @@ fi: receiver_freight_contract: Käytetään vastaanottajan rahtisopimusta sender_freight_contract: Käytetään lähettäjän rahtisopimusta index: - button_new: Uusi toimitustapa button_search: Etsi header: Toimitustavat label_options: @@ -734,7 +733,7 @@ fi: - pe - la abbr_month_names: - - + - - tammi - helmi - maalis @@ -760,7 +759,7 @@ fi: long: "%A %e. %Bta %Y" short: "%d %b" month_names: - - + - - tammikuu - helmikuu - maaliskuu From 54a739bd7157829d232fff65e1eca487b971158a Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 18 Sep 2015 11:06:10 +0300 Subject: [PATCH 086/189] clean up validations --- app/models/delivery_method.rb | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index e23005150..357210805 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -9,19 +9,17 @@ class DeliveryMethod < BaseModel o.has_many :sorting_point, primary_key: :lajittelupiste, class_name: 'Keyword::SortingPoint' end - validates :selite, uniqueness: true, length: { within: 1..50 } - validates :lahdon_selite, :sallitut_alustat, length: { within: 1..150 }, allow_blank: true - validates :rahti_tuotenumero, :rahtikirjakopio_email, :kuljetusvakuutus_tuotenumero, :toim_nimi, - :toim_nimitark, length: { within: 1..60 }, allow_blank: true - validates :sopimusnro, :sallitut_maat, length: { within: 1..50 }, allow_blank: true + validates :aktiivinen_kuljetus_kansallisuus, :maa_maara, :sisamaan_kuljetus_kansallisuus, inclusion: { in: Country.pluck(:koodi) }, allow_blank: true validates :jarjestys, numericality: { only_integer: true }, allow_blank: true - validates :toim_ovttunnus, length: { within: 1..25 }, allow_blank: true - validates :toim_osoite, length: { within: 1..55 }, allow_blank: true - validates :toim_postino, length: { within: 1..15 }, allow_blank: true - validates :toim_postitp, :toim_maa, length: { within: 1..35 }, allow_blank: true - validates :maa_maara, :sisamaan_kuljetus_kansallisuus, :aktiivinen_kuljetus_kansallisuus, - length: { within: 1..2 }, allow_blank: true - validates :sisamaan_kuljetus, :aktiivinen_kuljetus, length: { within: 1..30 }, allow_blank: true + validates :lahdon_selite, :sallitut_alustat, length: { maximum: 150 } + validates :rahti_tuotenumero, :rahtikirjakopio_email, :kuljetusvakuutus_tuotenumero, :toim_nimi, :toim_nimitark, length: { maximum: 60 } + validates :selite, uniqueness: true, presence: true, length: { maximum: 150 } + validates :sisamaan_kuljetus, :aktiivinen_kuljetus, length: { maximum: 30 } + validates :sopimusnro, :sallitut_maat, length: { maximum: 50 } + validates :toim_osoite, length: { maximum: 55 } + validates :toim_ovttunnus, length: { maximum: 25 } + validates :toim_postino, length: { maximum: 15 } + validates :toim_postitp, :toim_maa, length: { maximum: 35 } validate :vaihtoehtoinen_vak_toimitustapa_validation validate :vak_kielto_validation From d2801b64d8f56a731bcf2fd74aff600faa1d4814 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Tue, 20 Oct 2015 18:09:21 +0300 Subject: [PATCH 087/189] we have only one draft in fixtures --- test/models/terms_of_payment_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/models/terms_of_payment_test.rb b/test/models/terms_of_payment_test.rb index ab8b0eccc..f76466941 100644 --- a/test/models/terms_of_payment_test.rb +++ b/test/models/terms_of_payment_test.rb @@ -58,7 +58,7 @@ class TermsOfPaymentTest < ActiveSupport::TestCase top_fourth.kaytossa = 'E' refute top_fourth.valid?, "This terms of payment is used by a undelivered sales order" - message = I18n.t 'errors.terms_of_payment.in_use_sales_orders', count: 2 + message = I18n.t 'errors.terms_of_payment.in_use_sales_orders', count: 1 assert_equal message, top_fourth.errors.full_messages.first end From d5c4e90e23e3ad917a0f7ddafebd262fb4eb7977 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 21 Oct 2015 11:34:50 +0300 Subject: [PATCH 088/189] add defaults to fixture --- test/fixtures/delivery_methods.yml | 31 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/test/fixtures/delivery_methods.yml b/test/fixtures/delivery_methods.yml index 3591dddef..f0831ac9b 100644 --- a/test/fixtures/delivery_methods.yml +++ b/test/fixtures/delivery_methods.yml @@ -1,23 +1,22 @@ -kaukokiito: +DEFAULTS: &DEFAULTS yhtio: acme - selite: Kaukokiito - tulostustapa: H - rahtikirja: rahtikirja.inc - rahdinkuljettaja: Kaukokiito + muuttaja: joe + laatija: joe + luontiaika: <%= Time.now %> + muutospvm: <%= Time.now %> + +kaukokiito: kuljetusmuoto: 1 osoitelappu: tiivistetty - laatija: 'joe' - luontiaika: <%= Date.today %> - muutospvm: <%= Date.today %> - muuttaja: 'joe' + rahdinkuljettaja: Kaukokiito + rahtikirja: rahtikirja.inc + selite: Kaukokiito + tulostustapa: H + <<: *DEFAULTS kiitolinja: - yhtio: acme + rahdinkuljettaja: Kiitolinja + rahtikirja: rahtikirja_pdf.inc selite: Kiitolinja tulostustapa: H - rahtikirja: rahtikirja_pdf.inc - rahdinkuljettaja: Kiitolinja - laatija: 'joe' - luontiaika: <%= Date.today %> - muutospvm: <%= Date.today %> - muuttaja: 'joe' + <<: *DEFAULTS From e29fa9663c3c890e1d76d545906dc47b3e7dbb1a Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 22 Oct 2015 17:10:41 +0300 Subject: [PATCH 089/189] update relations after save method --- app/models/delivery_method.rb | 14 ++++++++++++-- test/models/delivery_method_test.rb | 30 ++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 357210805..d35b555e8 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -26,6 +26,7 @@ class DeliveryMethod < BaseModel validate :mandatory_new_packaging_information if :package_info_entry_denied && :collective_batch before_save :defaults + after_save :update_relations before_destroy :check_relations float_columns :jvkulu, :erilliskasiteltavakulu, :kuljetusvakuutus, :kuluprosentti, :ulkomaanlisa, @@ -141,6 +142,15 @@ def permitted_packaging_options private + def update_relations + if selite_was.present? + company.delivery_methods.where(vak_kielto: selite_was).update_all(vak_kielto: selite) + company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite_was).update_all(vaihtoehtoinen_vak_toimitustapa: selite) + company.customers.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + end + true + end + def mandatory_new_packaging_information if unifaun_online? || unifaun_print_server? errors.add :base, I18n.t("errors.delivery_method.unifaun_info_missing") @@ -148,7 +158,7 @@ def mandatory_new_packaging_information end def vak_kielto_validation - allowed = DeliveryMethod.permit_adr.shipment.pluck(:selite) + [ '', 'K' ] + allowed = company.delivery_methods.permit_adr.shipment.pluck(:selite) + [ '', 'K' ] unless allowed.include? vak_kielto errors.add :vak_kielto, I18n.t('errors.messages.inclusion') @@ -156,7 +166,7 @@ def vak_kielto_validation end def vaihtoehtoinen_vak_toimitustapa_validation - allowed = DeliveryMethod.permit_adr.shipment.pluck(:selite) + [ '' ] + allowed = company.delivery_methods.permit_adr.shipment.pluck(:selite) + [ '' ] unless allowed.include? vaihtoehtoinen_vak_toimitustapa errors.add :vaihtoehtoinen_vak_toimitustapa, I18n.t('errors.messages.inclusion') diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index d7d908d4f..af5e196b3 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -1,7 +1,11 @@ require 'test_helper' class DeliveryMethodTest < ActiveSupport::TestCase - fixtures %w(delivery_methods heads customers) + fixtures %w( + delivery_methods + heads + customers + ) def setup @delivery_method = delivery_methods(:kaukokiito) @@ -48,4 +52,28 @@ def setup @delivery_method.destroy end end + + test 'should update relations when updating selite' do + deli2 = @delivery_method.dup + deli2.selite = 'Kaukokiito2' + deli2.rahdinkuljettaja = 'Kaukokiito2' + deli2.vak_kielto = @delivery_method.selite + deli2.vaihtoehtoinen_vak_toimitustapa = @delivery_method.selite + deli2.save! + + assert_equal 'Kaukokiito', deli2.vak_kielto + + @delivery_method.selite = 'Kaukokiito3' + @delivery_method.save! + @delivery_method.reload + assert @delivery_method.valid?, @delivery_method.errors.full_messages + + # delivery_method + assert_equal 'Kaukokiito3', deli2.reload.vak_kielto + assert_equal 'Kaukokiito3', deli2.vaihtoehtoinen_vak_toimitustapa + + # customers + cust = customers :stubborn_customer + assert_equal 'Kaukokiito3', cust.reload.toimitustapa + end end From cb52bc0d85cf798f20d333882794afaf3c89ea77 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 22 Oct 2015 17:42:40 +0300 Subject: [PATCH 090/189] company to default values --- test/fixtures/sales_order/drafts.yml | 2 +- test/fixtures/sales_order/orders.yml | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/test/fixtures/sales_order/drafts.yml b/test/fixtures/sales_order/drafts.yml index e97349b57..988e73a12 100644 --- a/test/fixtures/sales_order/drafts.yml +++ b/test/fixtures/sales_order/drafts.yml @@ -1,4 +1,5 @@ DEFAULTS: &DEFAULTS + yhtio: acme luontiaika: <%= Time.now %> laatija: joe muutospvm: <%= Time.now %> @@ -22,7 +23,6 @@ DEFAULTS: &DEFAULTS popvm: <%= Time.now %> not_finished_order: - yhtio: acme tila: N alatila: '' terms_of_payment: hundred_days_net diff --git a/test/fixtures/sales_order/orders.yml b/test/fixtures/sales_order/orders.yml index e94effb5e..5b8bf2e95 100644 --- a/test/fixtures/sales_order/orders.yml +++ b/test/fixtures/sales_order/orders.yml @@ -1,4 +1,5 @@ DEFAULTS: &DEFAULTS + yhtio: acme luontiaika: <%= Time.now %> laatija: joe muutospvm: <%= Time.now %> @@ -23,20 +24,16 @@ DEFAULTS: &DEFAULTS # Myyntitilaus so_one: - yhtio: acme tila: L <<: *DEFAULTS - not_delivered_order_1: - yhtio: acme tila: L alatila: A terms_of_payment: eighty_days_net <<: *DEFAULTS not_delivered_order_2: - yhtio: acme tila: L alatila: C terms_of_payment: ninety_days_net From 353062d376612e66479e2d100ab32377747e7dde Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 22 Oct 2015 17:43:22 +0300 Subject: [PATCH 091/189] sales orders relations update --- app/models/delivery_method.rb | 2 ++ test/models/delivery_method_test.rb | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index d35b555e8..aadb79390 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -147,6 +147,8 @@ def update_relations company.delivery_methods.where(vak_kielto: selite_was).update_all(vak_kielto: selite) company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite_was).update_all(vaihtoehtoinen_vak_toimitustapa: selite) company.customers.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + company.sales_orders.not_delivered.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + company.sales_order_drafts.where(toimitustapa: selite_was).update_all(toimitustapa: selite) end true end diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index af5e196b3..037b7f340 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -2,9 +2,11 @@ class DeliveryMethodTest < ActiveSupport::TestCase fixtures %w( + customers delivery_methods heads - customers + sales_order/orders + sales_order/drafts ) def setup @@ -61,6 +63,14 @@ def setup deli2.vaihtoehtoinen_vak_toimitustapa = @delivery_method.selite deli2.save! + order = sales_order_orders :not_delivered_order_1 + order.toimitustapa = @delivery_method.selite + order.save! + + draft = sales_order_drafts :not_finished_order + draft.toimitustapa = @delivery_method.selite + draft.save! + assert_equal 'Kaukokiito', deli2.vak_kielto @delivery_method.selite = 'Kaukokiito3' @@ -75,5 +85,9 @@ def setup # customers cust = customers :stubborn_customer assert_equal 'Kaukokiito3', cust.reload.toimitustapa + + # sales orders + assert_equal 'Kaukokiito3', order.reload.toimitustapa + assert_equal 'Kaukokiito3', draft.reload.toimitustapa end end From b210aab9b34e31fbd3224ef246f77bbaec8dd490 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Fri, 23 Oct 2015 16:17:52 +0300 Subject: [PATCH 092/189] relation updates --- .../delivery_methods_controller.rb | 8 ++++- app/models/customer.rb | 1 + app/models/customer_keyword.rb | 3 +- app/models/delivery_method.rb | 34 ++++++++++++++----- .../delivery_methods/index.html.erb | 1 + test/fixtures/customer_keywords.yml | 10 ++++++ test/models/delivery_method_test.rb | 20 +++++++---- 7 files changed, 61 insertions(+), 16 deletions(-) create mode 100644 test/fixtures/customer_keywords.yml diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index 75d3a266b..631829238 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -27,7 +27,13 @@ def create def update if @delivery_method.update delivery_method_params - redirect_to delivery_methods_path, notice: t('.update_success') + if @delivery_method.previous_changes.include?('selite') + relation_update_notices = @delivery_method.relation_update + else + relation_update_notices = '' + end + + redirect_to delivery_methods_path, notice: relation_update_notices else render :edit end diff --git a/app/models/customer.rb b/app/models/customer.rb index 64b0bac91..434d949a1 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -3,6 +3,7 @@ class Customer < BaseModel belongs_to :delivery_method, foreign_key: :toimitustapa, primary_key: :selite has_many :transports + has_many :customer_keywords, foreign_key: :liitostunnus default_scope { where.not(laji: %w(P R)) } diff --git a/app/models/customer_keyword.rb b/app/models/customer_keyword.rb index 6a21e903b..a9dbf4b75 100644 --- a/app/models/customer_keyword.rb +++ b/app/models/customer_keyword.rb @@ -1,5 +1,6 @@ class CustomerKeyword < BaseModel - belongs_to :delivery_method, foreign_key: :toimitustapa, primary_key: :avainsana + belongs_to :delivery_method, foreign_key: :avainsana, primary_key: :selite + belongs_to :customer, foreign_key: :liitostunnus self.table_name = :asiakkaan_avainsanat self.primary_key = :tunnus diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index aadb79390..d821713dc 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -7,6 +7,7 @@ class DeliveryMethod < BaseModel o.has_many :nature_of_transactions, primary_key: :kauppatapahtuman_luonne, class_name: 'Keyword::NatureOfTransaction' o.has_many :customs, primary_key: :poistumistoimipaikka_koodi, class_name: 'Keyword::Customs' o.has_many :sorting_point, primary_key: :lajittelupiste, class_name: 'Keyword::SortingPoint' + o.has_many :customer_keywords, primary_key: :avainsana end validates :aktiivinen_kuljetus_kansallisuus, :maa_maara, :sisamaan_kuljetus_kansallisuus, inclusion: { in: Country.pluck(:koodi) }, allow_blank: true @@ -26,7 +27,6 @@ class DeliveryMethod < BaseModel validate :mandatory_new_packaging_information if :package_info_entry_denied && :collective_batch before_save :defaults - after_save :update_relations before_destroy :check_relations float_columns :jvkulu, :erilliskasiteltavakulu, :kuljetusvakuutus, :kuluprosentti, :ulkomaanlisa, @@ -140,17 +140,35 @@ def permitted_packaging_options [] end + def relation_update + update_relations + end + private def update_relations - if selite_was.present? - company.delivery_methods.where(vak_kielto: selite_was).update_all(vak_kielto: selite) - company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite_was).update_all(vaihtoehtoinen_vak_toimitustapa: selite) - company.customers.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - company.sales_orders.not_delivered.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - company.sales_order_drafts.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + msg = [] + + if previous_changes.include?('selite') + cnt = company.delivery_methods.where(vak_kielto: previous_changes['selite'].first).update_all(vak_kielto: selite) + msg << "päivitettiin #{cnt} toimitustapaa" if cnt.nonzero? + + cnt = company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: previous_changes['selite'].first).update_all(vaihtoehtoinen_vak_toimitustapa: selite) + msg << "päivitettiin #{cnt} vaihtoehtoista vak toimitustapaa" if cnt.nonzero? + + cnt = company.customers.where(toimitustapa: previous_changes['selite'].first).update_all(toimitustapa: selite) + msg << "päivitettiin #{cnt} asiakasta" if cnt.nonzero? + + cnt = company.sales_orders.not_delivered.where(toimitustapa: previous_changes['selite'].first).update_all(toimitustapa: selite) + msg << "päivitettiin #{cnt} myyntitilaus otsikkoa" if cnt.nonzero? + + cnt = company.sales_order_drafts.where(toimitustapa: previous_changes['selite'].first).update_all(toimitustapa: selite) + msg << "päivitettiin #{cnt} myyntitilaus kesken otsikkoa" if cnt.nonzero? + + cnt = company.customer_keywords.where(avainsana: previous_changes['selite'].first).update_all(avainsana: selite) + msg << "päivitettiin #{cnt} asiakkaan avainsanaa" if cnt.nonzero? end - true + msg.join(', ') end def mandatory_new_packaging_information diff --git a/app/views/administration/delivery_methods/index.html.erb b/app/views/administration/delivery_methods/index.html.erb index e50a5f64b..724874252 100644 --- a/app/views/administration/delivery_methods/index.html.erb +++ b/app/views/administration/delivery_methods/index.html.erb @@ -1,4 +1,5 @@ <%= render "administration/header", text: t('.header') %> +<%= render "administration/notice" %> <%= button_to_new :delivery_method %> diff --git a/test/fixtures/customer_keywords.yml b/test/fixtures/customer_keywords.yml new file mode 100644 index 000000000..859ff6d84 --- /dev/null +++ b/test/fixtures/customer_keywords.yml @@ -0,0 +1,10 @@ +DEFAULTS: &DEFAULTS + yhtio: acme + luontiaika: <%= Time.now %> + laatija: joe + muutospvm: <%= Time.now %> + muuttaja: joe + +keyword_1: + avainsana: Kaukokiito + <<: *DEFAULTS diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 037b7f340..412460a54 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -2,6 +2,7 @@ class DeliveryMethodTest < ActiveSupport::TestCase fixtures %w( + customer_keywords customers delivery_methods heads @@ -78,16 +79,23 @@ def setup @delivery_method.reload assert @delivery_method.valid?, @delivery_method.errors.full_messages + @delivery_method.relation_update + # delivery_method assert_equal 'Kaukokiito3', deli2.reload.vak_kielto assert_equal 'Kaukokiito3', deli2.vaihtoehtoinen_vak_toimitustapa - # customers - cust = customers :stubborn_customer - assert_equal 'Kaukokiito3', cust.reload.toimitustapa + # # customers + # cust = customers :stubborn_customer + # assert_equal 'Kaukokiito3', cust.reload.toimitustapa + + # # customer keywords + # cust_key = customer_keywords :keyword_1 + # puts "foo: #{cust_key.inspect}" + # assert_equal 'Kaukokiito3', cust_key.reload.avainsana - # sales orders - assert_equal 'Kaukokiito3', order.reload.toimitustapa - assert_equal 'Kaukokiito3', draft.reload.toimitustapa + # # sales orders + # assert_equal 'Kaukokiito3', order.reload.toimitustapa + # assert_equal 'Kaukokiito3', draft.reload.toimitustapa end end From 8e4101b4b662f6163700cdb182314ecec0b9df01 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 10:17:49 +0200 Subject: [PATCH 093/189] fix syntax error --- app/models/keyword.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/keyword.rb b/app/models/keyword.rb index 9a1f6403c..2a8da8f8d 100644 --- a/app/models/keyword.rb +++ b/app/models/keyword.rb @@ -15,7 +15,7 @@ def self.child_class_names { ALV: Keyword::Vat, ALVULK: Keyword::ForeignVat, - ASIAKASRYHMA: Keyword::CustomerSubcategory + ASIAKASRYHMA: Keyword::CustomerSubcategory, KM: Keyword::ModeOfTransport, KT: Keyword::NatureOfTransaction, LISATIETO: Keyword::ProductInformationType, From e2165ba9e607221dbca5f9ccfbbda184384db3db Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 10:18:10 +0200 Subject: [PATCH 094/189] comment broken test --- test/models/delivery_method_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 412460a54..491fc3d7c 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -82,8 +82,8 @@ def setup @delivery_method.relation_update # delivery_method - assert_equal 'Kaukokiito3', deli2.reload.vak_kielto - assert_equal 'Kaukokiito3', deli2.vaihtoehtoinen_vak_toimitustapa + # assert_equal 'Kaukokiito3', deli2.reload.vak_kielto + # assert_equal 'Kaukokiito3', deli2.vaihtoehtoinen_vak_toimitustapa # # customers # cust = customers :stubborn_customer From 94cff87cda4e1595eaef74bb2863d644a39812ca Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 11:31:15 +0200 Subject: [PATCH 095/189] add stock transfer & preorder validations --- app/models/company.rb | 1 + app/models/delivery_method.rb | 42 +++++++++++++++++------- app/models/head.rb | 1 + app/models/preorder/order.rb | 10 ++++++ app/models/preorder/row.rb | 10 ++++++ app/models/row.rb | 1 + app/models/stock_transfer/order.rb | 2 ++ test/fixtures/preorder/orders.yml | 28 ++++++++++++++++ test/fixtures/stock_transfer/orders.yml | 1 + test/models/delivery_method_test.rb | 43 ++++++++++++++++--------- 10 files changed, 112 insertions(+), 27 deletions(-) create mode 100644 app/models/preorder/order.rb create mode 100644 app/models/preorder/row.rb create mode 100644 test/fixtures/preorder/orders.yml diff --git a/app/models/company.rb b/app/models/company.rb index 8825533df..b88da1dca 100644 --- a/app/models/company.rb +++ b/app/models/company.rb @@ -43,6 +43,7 @@ class Company < ActiveRecord::Base o.has_many :heads o.has_many :manufacture_orders, class_name: 'ManufactureOrder::Order' + o.has_many :preorders, class_name: 'Preorder::Order' o.has_many :purchase_invoices_approval, class_name: 'Head::PurchaseInvoice::Approval' o.has_many :purchase_invoices_approved, class_name: 'Head::PurchaseInvoice::Approved' o.has_many :purchase_invoices_paid, class_name: 'Head::PurchaseInvoice::Paid' diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index d821713dc..2942202a6 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -29,11 +29,15 @@ class DeliveryMethod < BaseModel before_save :defaults before_destroy :check_relations + after_save :update_relations + float_columns :jvkulu, :erilliskasiteltavakulu, :kuljetusvakuutus, :kuluprosentti, :ulkomaanlisa, :lisakulu, :lisakulu_summa scope :permit_adr, -> { where(vak_kielto: '') } + attr_accessor :flash_notice + self.table_name = :toimitustapa self.primary_key = :tunnus @@ -140,35 +144,37 @@ def permitted_packaging_options [] end - def relation_update - update_relations - end - private def update_relations msg = [] - if previous_changes.include?('selite') - cnt = company.delivery_methods.where(vak_kielto: previous_changes['selite'].first).update_all(vak_kielto: selite) + if selite_was.present? + cnt = company.delivery_methods.where(vak_kielto: selite_was).update_all(vak_kielto: selite) msg << "päivitettiin #{cnt} toimitustapaa" if cnt.nonzero? - cnt = company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: previous_changes['selite'].first).update_all(vaihtoehtoinen_vak_toimitustapa: selite) + cnt = company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite_was).update_all(vaihtoehtoinen_vak_toimitustapa: selite) msg << "päivitettiin #{cnt} vaihtoehtoista vak toimitustapaa" if cnt.nonzero? - cnt = company.customers.where(toimitustapa: previous_changes['selite'].first).update_all(toimitustapa: selite) + cnt = company.customers.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << "päivitettiin #{cnt} asiakasta" if cnt.nonzero? - cnt = company.sales_orders.not_delivered.where(toimitustapa: previous_changes['selite'].first).update_all(toimitustapa: selite) + cnt = company.sales_orders.not_delivered.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << "päivitettiin #{cnt} myyntitilaus otsikkoa" if cnt.nonzero? - cnt = company.sales_order_drafts.where(toimitustapa: previous_changes['selite'].first).update_all(toimitustapa: selite) + cnt = company.sales_order_drafts.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << "päivitettiin #{cnt} myyntitilaus kesken otsikkoa" if cnt.nonzero? - cnt = company.customer_keywords.where(avainsana: previous_changes['selite'].first).update_all(avainsana: selite) + cnt = company.customer_keywords.where(avainsana: selite_was).update_all(avainsana: selite) msg << "päivitettiin #{cnt} asiakkaan avainsanaa" if cnt.nonzero? + + cnt = company.stock_transfers.not_delivered.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + msg << "päivitettiin #{cnt} siirtolistan otsikkoa" if cnt.nonzero? + + cnt = company.preorders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + msg << "päivitettiin #{cnt} ennakkotilauksen otsikkoa" if cnt.nonzero? end - msg.join(', ') + flash_notice = msg.join(', ') end def mandatory_new_packaging_information @@ -232,6 +238,18 @@ def check_relations allow_delete = false end + count = company.stock_transfers.not_delivered.where(toimitustapa: selite).count + if count.nonzero? + errors.add :base, I18n.t("errors.delivery_method.in_use_stock_transfers", count: count) + allow_delete = false + end + + count = company.preorders.where(toimitustapa: selite).count + if count.nonzero? + errors.add :base, I18n.t("errors.delivery_method.in_use_preorders", count: count) + allow_delete = false + end + allow_delete end diff --git a/app/models/head.rb b/app/models/head.rb index 9ee56fdfa..6484cd237 100644 --- a/app/models/head.rb +++ b/app/models/head.rb @@ -20,6 +20,7 @@ def self.default_child_instance def self.child_class_names { + 'E' => Preorder::Order, 'G' => StockTransfer::Order, 'H' => Head::PurchaseInvoice::Approval, 'L' => SalesOrder::Order, diff --git a/app/models/preorder/order.rb b/app/models/preorder/order.rb new file mode 100644 index 000000000..1b115e314 --- /dev/null +++ b/app/models/preorder/order.rb @@ -0,0 +1,10 @@ +class Preorder::Order < Head + has_many :rows, foreign_key: :otunnus, class_name: 'Preorder::Row' + + validates :tila, inclusion: { in: ['E'] } + + # Rails requires sti_name method to return type column (tyyppi) value + def self.sti_name + "E" + end +end diff --git a/app/models/preorder/row.rb b/app/models/preorder/row.rb new file mode 100644 index 000000000..f5c49a186 --- /dev/null +++ b/app/models/preorder/row.rb @@ -0,0 +1,10 @@ +class Preorder::Row < Row + belongs_to :order, foreign_key: :otunnus, class_name: 'Preorder::Order' + + validates :tyyppi, inclusion: { in: ['L'] } + + # Rails requires sti_name method to return type column (tyyppi) value + def self.sti_name + "E" + end +end diff --git a/app/models/row.rb b/app/models/row.rb index b35cb8542..a445042cb 100644 --- a/app/models/row.rb +++ b/app/models/row.rb @@ -11,6 +11,7 @@ def self.default_child_instance def self.child_class_names { + 'E' => Preorder::Row, 'G' => StockTransfer::Row, 'O' => PurchaseOrder::Row, 'V' => ManufactureOrder::Row, diff --git a/app/models/stock_transfer/order.rb b/app/models/stock_transfer/order.rb index 6b336d014..9cc5b5e77 100644 --- a/app/models/stock_transfer/order.rb +++ b/app/models/stock_transfer/order.rb @@ -3,6 +3,8 @@ class StockTransfer::Order < Head validates :tila, inclusion: { in: ['G'] } + scope :not_delivered, -> { where(alatila: %W(#{} J KJ A C T P)) } + # Rails requires sti_name method to return type column (tyyppi) value def self.sti_name "G" diff --git a/test/fixtures/preorder/orders.yml b/test/fixtures/preorder/orders.yml new file mode 100644 index 000000000..c3bf03513 --- /dev/null +++ b/test/fixtures/preorder/orders.yml @@ -0,0 +1,28 @@ +DEFAULTS: &DEFAULTS + luontiaika: <%= Time.now %> + laatija: joe + muutospvm: <%= Time.now %> + muuttaja: joe + tapvm: <%= Time.now %> + lapvm: <%= Time.now %> + kapvm: <%= Time.now %> + erpcm: <%= Time.now %> + olmapvm: <%= Time.now %> + kerayspvm: <%= Time.now %> + toimaika: <%= Time.now %> + maksuaika: <%= Time.now %> + lahetepvm: <%= Time.now %> + laskutettu: <%= Time.now %> + h1time: <%= Time.now %> + h2time: <%= Time.now %> + h3time: <%= Time.now %> + h4time: <%= Time.now %> + h5time: <%= Time.now %> + mapvm: <%= Time.now %> + popvm: <%= Time.now %> + +# Ostotilaus +pre_one: + yhtio: acme + tila: E + <<: *DEFAULTS diff --git a/test/fixtures/stock_transfer/orders.yml b/test/fixtures/stock_transfer/orders.yml index fb4f9271d..00d0a755a 100644 --- a/test/fixtures/stock_transfer/orders.yml +++ b/test/fixtures/stock_transfer/orders.yml @@ -24,4 +24,5 @@ DEFAULTS: &DEFAULTS st_one: yhtio: acme tila: G + toimitustapa: Kaukokiito <<: *DEFAULTS diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 491fc3d7c..8a7f6b92a 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -6,8 +6,10 @@ class DeliveryMethodTest < ActiveSupport::TestCase customers delivery_methods heads - sales_order/orders + preorder/orders sales_order/drafts + sales_order/orders + stock_transfer/orders ) def setup @@ -72,6 +74,14 @@ def setup draft.toimitustapa = @delivery_method.selite draft.save! + stock = stock_transfer_orders :st_one + stock.toimitustapa = @delivery_method.selite + stock.save! + + preorder = preorder_orders :pre_one + preorder.toimitustapa = @delivery_method.selite + preorder.save! + assert_equal 'Kaukokiito', deli2.vak_kielto @delivery_method.selite = 'Kaukokiito3' @@ -79,23 +89,26 @@ def setup @delivery_method.reload assert @delivery_method.valid?, @delivery_method.errors.full_messages - @delivery_method.relation_update - # delivery_method - # assert_equal 'Kaukokiito3', deli2.reload.vak_kielto - # assert_equal 'Kaukokiito3', deli2.vaihtoehtoinen_vak_toimitustapa + assert_equal 'Kaukokiito3', deli2.reload.vak_kielto + assert_equal 'Kaukokiito3', deli2.vaihtoehtoinen_vak_toimitustapa + + # customers + cust = customers :stubborn_customer + assert_equal 'Kaukokiito3', cust.reload.toimitustapa + + # customer keywords + cust_key = customer_keywords :keyword_1 + assert_equal 'Kaukokiito3', cust_key.reload.avainsana - # # customers - # cust = customers :stubborn_customer - # assert_equal 'Kaukokiito3', cust.reload.toimitustapa + # sales orders + assert_equal 'Kaukokiito3', order.reload.toimitustapa + assert_equal 'Kaukokiito3', draft.reload.toimitustapa - # # customer keywords - # cust_key = customer_keywords :keyword_1 - # puts "foo: #{cust_key.inspect}" - # assert_equal 'Kaukokiito3', cust_key.reload.avainsana + # stock transfer orders + assert_equal 'Kaukokiito3', stock.reload.toimitustapa - # # sales orders - # assert_equal 'Kaukokiito3', order.reload.toimitustapa - # assert_equal 'Kaukokiito3', draft.reload.toimitustapa + # stock transfer orders + assert_equal 'Kaukokiito3', preorder.reload.toimitustapa end end From c5eef8226a40e1a6273f18207e8a157e95078547 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 11:49:33 +0200 Subject: [PATCH 096/189] add offer orders --- app/models/company.rb | 3 ++- app/models/delivery_method.rb | 9 +++++++++ app/models/head.rb | 1 + app/models/offer_order/order.rb | 12 ++++++++++++ app/models/offer_order/row.rb | 10 ++++++++++ app/models/row.rb | 3 ++- test/fixtures/offer_order/orders.yml | 28 ++++++++++++++++++++++++++++ test/fixtures/preorder/orders.yml | 4 ++-- test/models/delivery_method_test.rb | 8 ++++++++ 9 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 app/models/offer_order/order.rb create mode 100644 app/models/offer_order/row.rb create mode 100644 test/fixtures/offer_order/orders.yml diff --git a/app/models/company.rb b/app/models/company.rb index b88da1dca..41af1066b 100644 --- a/app/models/company.rb +++ b/app/models/company.rb @@ -43,6 +43,7 @@ class Company < ActiveRecord::Base o.has_many :heads o.has_many :manufacture_orders, class_name: 'ManufactureOrder::Order' + o.has_many :offer_orders, class_name: 'OfferOrder::Order' o.has_many :preorders, class_name: 'Preorder::Order' o.has_many :purchase_invoices_approval, class_name: 'Head::PurchaseInvoice::Approval' o.has_many :purchase_invoices_approved, class_name: 'Head::PurchaseInvoice::Approved' @@ -53,9 +54,9 @@ class Company < ActiveRecord::Base o.has_many :sales_invoices, class_name: 'Head::SalesInvoice' o.has_many :sales_order_drafts, class_name: 'SalesOrder::Draft' o.has_many :sales_orders, class_name: 'SalesOrder::Order' + o.has_many :stock_transfers, class_name: 'StockTransfer::Order' o.has_many :voucher_rows, class_name: 'Head::VoucherRow' o.has_many :vouchers, class_name: 'Head::Voucher' - o.has_many :stock_transfers, class_name: 'StockTransfer::Order' o.has_many :qualifiers o.has_many :cost_centers, class_name: 'Qualifier::CostCenter' diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 2942202a6..6164a2334 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -173,6 +173,9 @@ def update_relations cnt = company.preorders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << "päivitettiin #{cnt} ennakkotilauksen otsikkoa" if cnt.nonzero? + + cnt = company.offer_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + msg << "päivitettiin #{cnt} ennakkotilauksen otsikkoa" if cnt.nonzero? end flash_notice = msg.join(', ') end @@ -250,6 +253,12 @@ def check_relations allow_delete = false end + count = company.offer_orders.where(toimitustapa: selite).count + if count.nonzero? + errors.add :base, I18n.t("errors.delivery_method.in_use_offer_orders", count: count) + allow_delete = false + end + allow_delete end diff --git a/app/models/head.rb b/app/models/head.rb index 6484cd237..499345548 100644 --- a/app/models/head.rb +++ b/app/models/head.rb @@ -29,6 +29,7 @@ def self.child_class_names 'O' => PurchaseOrder::Order, 'P' => Head::PurchaseInvoice::Transfer, 'Q' => Head::PurchaseInvoice::Waiting, + 'T' => OfferOrder::Order, 'U' => Head::SalesInvoice, 'V' => ManufactureOrder::Order, 'X' => Head::Voucher, diff --git a/app/models/offer_order/order.rb b/app/models/offer_order/order.rb new file mode 100644 index 000000000..0165a9d6a --- /dev/null +++ b/app/models/offer_order/order.rb @@ -0,0 +1,12 @@ +class OfferOrder::Order < Head + has_many :rows, foreign_key: :otunnus, class_name: 'OfferOrder::Row' + + validates :tila, inclusion: { in: ['T'] } + + scope :printed_and_accepted, -> { where(alatila: %W(#{} A B)) } + + # Rails requires sti_name method to return type column (tyyppi) value + def self.sti_name + "T" + end +end diff --git a/app/models/offer_order/row.rb b/app/models/offer_order/row.rb new file mode 100644 index 000000000..da1bb110a --- /dev/null +++ b/app/models/offer_order/row.rb @@ -0,0 +1,10 @@ +class OfferOrder::Row < Row + belongs_to :order, foreign_key: :otunnus, class_name: 'OfferOrder::Order' + + validates :tyyppi, inclusion: { in: ['L'] } + + # Rails requires sti_name method to return type column (tyyppi) value + def self.sti_name + "T" + end +end diff --git a/app/models/row.rb b/app/models/row.rb index a445042cb..69f83fc38 100644 --- a/app/models/row.rb +++ b/app/models/row.rb @@ -13,9 +13,10 @@ def self.child_class_names { 'E' => Preorder::Row, 'G' => StockTransfer::Row, + 'L' => SalesOrder::Row, 'O' => PurchaseOrder::Row, + 'T' => OfferOrder::Row, 'V' => ManufactureOrder::Row, - 'L' => SalesOrder::Row, } end diff --git a/test/fixtures/offer_order/orders.yml b/test/fixtures/offer_order/orders.yml new file mode 100644 index 000000000..5a4473f74 --- /dev/null +++ b/test/fixtures/offer_order/orders.yml @@ -0,0 +1,28 @@ +DEFAULTS: &DEFAULTS + yhtio: acme + luontiaika: <%= Time.now %> + laatija: joe + muutospvm: <%= Time.now %> + muuttaja: joe + tapvm: <%= Time.now %> + lapvm: <%= Time.now %> + kapvm: <%= Time.now %> + erpcm: <%= Time.now %> + olmapvm: <%= Time.now %> + kerayspvm: <%= Time.now %> + toimaika: <%= Time.now %> + maksuaika: <%= Time.now %> + lahetepvm: <%= Time.now %> + laskutettu: <%= Time.now %> + h1time: <%= Time.now %> + h2time: <%= Time.now %> + h3time: <%= Time.now %> + h4time: <%= Time.now %> + h5time: <%= Time.now %> + mapvm: <%= Time.now %> + popvm: <%= Time.now %> + +# Tarjoustilaus +offer_one: + tila: T + <<: *DEFAULTS diff --git a/test/fixtures/preorder/orders.yml b/test/fixtures/preorder/orders.yml index c3bf03513..2f9297193 100644 --- a/test/fixtures/preorder/orders.yml +++ b/test/fixtures/preorder/orders.yml @@ -1,4 +1,5 @@ DEFAULTS: &DEFAULTS + yhtio: acme luontiaika: <%= Time.now %> laatija: joe muutospvm: <%= Time.now %> @@ -21,8 +22,7 @@ DEFAULTS: &DEFAULTS mapvm: <%= Time.now %> popvm: <%= Time.now %> -# Ostotilaus +# Ennakkotilaus pre_one: - yhtio: acme tila: E <<: *DEFAULTS diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 8a7f6b92a..4ec542fe9 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -6,6 +6,7 @@ class DeliveryMethodTest < ActiveSupport::TestCase customers delivery_methods heads + offer_order/orders preorder/orders sales_order/drafts sales_order/orders @@ -82,6 +83,10 @@ def setup preorder.toimitustapa = @delivery_method.selite preorder.save! + offer = offer_order_orders :offer_one + offer.toimitustapa = @delivery_method.selite + offer.save! + assert_equal 'Kaukokiito', deli2.vak_kielto @delivery_method.selite = 'Kaukokiito3' @@ -110,5 +115,8 @@ def setup # stock transfer orders assert_equal 'Kaukokiito3', preorder.reload.toimitustapa + + # offer order orders + assert_equal 'Kaukokiito3', offer.reload.toimitustapa end end From 1d3f663a3c17caa47b20b3e618a0e784783a8070 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 11:50:26 +0200 Subject: [PATCH 097/189] correct offer order update message --- app/models/delivery_method.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 6164a2334..42fb0aa09 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -175,7 +175,7 @@ def update_relations msg << "päivitettiin #{cnt} ennakkotilauksen otsikkoa" if cnt.nonzero? cnt = company.offer_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} ennakkotilauksen otsikkoa" if cnt.nonzero? + msg << "päivitettiin #{cnt} tarjouksen otsikkoa" if cnt.nonzero? end flash_notice = msg.join(', ') end From 5c04d3c2ddb9c85b773653059dd6ad0d21c159e7 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 11:56:33 +0200 Subject: [PATCH 098/189] add manufacture order validation --- app/models/delivery_method.rb | 9 +++++++++ app/models/manufacture_order/order.rb | 2 ++ test/fixtures/manufacture_order/orders.yml | 2 +- test/models/delivery_method_test.rb | 8 ++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 42fb0aa09..c7246cec1 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -176,6 +176,9 @@ def update_relations cnt = company.offer_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << "päivitettiin #{cnt} tarjouksen otsikkoa" if cnt.nonzero? + + cnt = company.manufacture_orders.not_manufactured.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + msg << "päivitettiin #{cnt} valmistuksen otsikkoa" if cnt.nonzero? end flash_notice = msg.join(', ') end @@ -259,6 +262,12 @@ def check_relations allow_delete = false end + count = company.manufacture_orders.where(toimitustapa: selite).count + if count.nonzero? + errors.add :base, I18n.t("errors.delivery_method.in_use_manufacture_orders", count: count) + allow_delete = false + end + allow_delete end diff --git a/app/models/manufacture_order/order.rb b/app/models/manufacture_order/order.rb index 5b6cb371d..d36e1ac55 100644 --- a/app/models/manufacture_order/order.rb +++ b/app/models/manufacture_order/order.rb @@ -3,6 +3,8 @@ class ManufactureOrder::Order < Head validates :tila, inclusion: { in: ['V'] } + scope :not_manufactured, -> { where(alatila: %W(#{} K J A C)) } + # Rails requires sti_name method to return type column (tyyppi) value def self.sti_name "V" diff --git a/test/fixtures/manufacture_order/orders.yml b/test/fixtures/manufacture_order/orders.yml index 43942e617..d3660460e 100644 --- a/test/fixtures/manufacture_order/orders.yml +++ b/test/fixtures/manufacture_order/orders.yml @@ -1,4 +1,5 @@ DEFAULTS: &DEFAULTS + yhtio: acme luontiaika: <%= Time.now %> laatija: joe muutospvm: <%= Time.now %> @@ -22,6 +23,5 @@ DEFAULTS: &DEFAULTS popvm: <%= Time.now %> mo_one: - yhtio: acme tila: V <<: *DEFAULTS diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 4ec542fe9..3052e8e67 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -6,6 +6,7 @@ class DeliveryMethodTest < ActiveSupport::TestCase customers delivery_methods heads + manufacture_order/orders offer_order/orders preorder/orders sales_order/drafts @@ -87,6 +88,10 @@ def setup offer.toimitustapa = @delivery_method.selite offer.save! + manufacture = manufacture_order_orders :mo_one + manufacture.toimitustapa = @delivery_method.selite + manufacture.save! + assert_equal 'Kaukokiito', deli2.vak_kielto @delivery_method.selite = 'Kaukokiito3' @@ -118,5 +123,8 @@ def setup # offer order orders assert_equal 'Kaukokiito3', offer.reload.toimitustapa + + # manufacture order orders + assert_equal 'Kaukokiito3', manufacture.reload.toimitustapa end end From 69a41172d0c5a91ffa4613a9000e6233bb266fd3 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 12:09:43 +0200 Subject: [PATCH 099/189] add work orders --- app/models/company.rb | 1 + app/models/delivery_method.rb | 9 +++++++++ app/models/head.rb | 1 + app/models/row.rb | 1 + app/models/work_order/order.rb | 10 ++++++++++ app/models/work_order/row.rb | 10 ++++++++++ test/fixtures/work_order/orders.yml | 28 ++++++++++++++++++++++++++++ test/models/delivery_method_test.rb | 9 +++++++-- 8 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 app/models/work_order/order.rb create mode 100644 app/models/work_order/row.rb create mode 100644 test/fixtures/work_order/orders.yml diff --git a/app/models/company.rb b/app/models/company.rb index 41af1066b..b672def86 100644 --- a/app/models/company.rb +++ b/app/models/company.rb @@ -57,6 +57,7 @@ class Company < ActiveRecord::Base o.has_many :stock_transfers, class_name: 'StockTransfer::Order' o.has_many :voucher_rows, class_name: 'Head::VoucherRow' o.has_many :vouchers, class_name: 'Head::Voucher' + o.has_many :work_orders, class_name: 'WorkOrder::Order' o.has_many :qualifiers o.has_many :cost_centers, class_name: 'Qualifier::CostCenter' diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index c7246cec1..73466c5ca 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -179,6 +179,9 @@ def update_relations cnt = company.manufacture_orders.not_manufactured.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << "päivitettiin #{cnt} valmistuksen otsikkoa" if cnt.nonzero? + + cnt = company.work_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + msg << "päivitettiin #{cnt} työmääräyksen otsikkoa" if cnt.nonzero? end flash_notice = msg.join(', ') end @@ -268,6 +271,12 @@ def check_relations allow_delete = false end + count = company.work_orders.where(toimitustapa: selite).count + if count.nonzero? + errors.add :base, I18n.t("errors.delivery_method.in_use_work_orders", count: count) + allow_delete = false + end + allow_delete end diff --git a/app/models/head.rb b/app/models/head.rb index 499345548..38663b5c2 100644 --- a/app/models/head.rb +++ b/app/models/head.rb @@ -20,6 +20,7 @@ def self.default_child_instance def self.child_class_names { + 'A' => WorkOrder::Order, 'E' => Preorder::Order, 'G' => StockTransfer::Order, 'H' => Head::PurchaseInvoice::Approval, diff --git a/app/models/row.rb b/app/models/row.rb index 69f83fc38..42f216cb4 100644 --- a/app/models/row.rb +++ b/app/models/row.rb @@ -11,6 +11,7 @@ def self.default_child_instance def self.child_class_names { + 'A' => WorkOrder::Row, 'E' => Preorder::Row, 'G' => StockTransfer::Row, 'L' => SalesOrder::Row, diff --git a/app/models/work_order/order.rb b/app/models/work_order/order.rb new file mode 100644 index 000000000..c7c5dcaf0 --- /dev/null +++ b/app/models/work_order/order.rb @@ -0,0 +1,10 @@ +class WorkOrder::Order < Head + has_many :rows, foreign_key: :otunnus, class_name: 'WorkOrder::Row' + + validates :tila, inclusion: { in: ['A'] } + + # Rails requires sti_name method to return type column (tyyppi) value + def self.sti_name + "A" + end +end diff --git a/app/models/work_order/row.rb b/app/models/work_order/row.rb new file mode 100644 index 000000000..7f708b2bd --- /dev/null +++ b/app/models/work_order/row.rb @@ -0,0 +1,10 @@ +class WorkOrder::Row < Row + belongs_to :order, foreign_key: :otunnus, class_name: 'WorkOrder::Order' + + validates :tyyppi, inclusion: { in: ['L'] } + + # Rails requires sti_name method to return type column (tyyppi) value + def self.sti_name + "A" + end +end diff --git a/test/fixtures/work_order/orders.yml b/test/fixtures/work_order/orders.yml new file mode 100644 index 000000000..7087c8244 --- /dev/null +++ b/test/fixtures/work_order/orders.yml @@ -0,0 +1,28 @@ +DEFAULTS: &DEFAULTS + yhtio: acme + luontiaika: <%= Time.now %> + laatija: joe + muutospvm: <%= Time.now %> + muuttaja: joe + tapvm: <%= Time.now %> + lapvm: <%= Time.now %> + kapvm: <%= Time.now %> + erpcm: <%= Time.now %> + olmapvm: <%= Time.now %> + kerayspvm: <%= Time.now %> + toimaika: <%= Time.now %> + maksuaika: <%= Time.now %> + lahetepvm: <%= Time.now %> + laskutettu: <%= Time.now %> + h1time: <%= Time.now %> + h2time: <%= Time.now %> + h3time: <%= Time.now %> + h4time: <%= Time.now %> + h5time: <%= Time.now %> + mapvm: <%= Time.now %> + popvm: <%= Time.now %> + +# Työmääräystilaus +work_one: + tila: A + <<: *DEFAULTS diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 3052e8e67..1d73acede 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -12,6 +12,7 @@ class DeliveryMethodTest < ActiveSupport::TestCase sales_order/drafts sales_order/orders stock_transfer/orders + work_order/orders ) def setup @@ -92,6 +93,10 @@ def setup manufacture.toimitustapa = @delivery_method.selite manufacture.save! + work = work_order_orders :work_one + work.toimitustapa = @delivery_method.selite + work.save! + assert_equal 'Kaukokiito', deli2.vak_kielto @delivery_method.selite = 'Kaukokiito3' @@ -124,7 +129,7 @@ def setup # offer order orders assert_equal 'Kaukokiito3', offer.reload.toimitustapa - # manufacture order orders - assert_equal 'Kaukokiito3', manufacture.reload.toimitustapa + # work order orders + assert_equal 'Kaukokiito3', work.reload.toimitustapa end end From ec1b892d833069710e99661fb37fc829e93e1714 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 12:10:41 +0200 Subject: [PATCH 100/189] add manufacture order test back --- test/models/delivery_method_test.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 1d73acede..cd502a504 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -129,6 +129,9 @@ def setup # offer order orders assert_equal 'Kaukokiito3', offer.reload.toimitustapa + # manufacture order orders + assert_equal 'Kaukokiito3', manufacture.reload.toimitustapa + # work order orders assert_equal 'Kaukokiito3', work.reload.toimitustapa end From 695159056ceaee67bb7037f5799c15e39aaa5258 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 12:19:11 +0200 Subject: [PATCH 101/189] add project orders --- app/models/company.rb | 1 + app/models/delivery_method.rb | 9 +++++++++ app/models/head.rb | 1 + app/models/project_order/order.rb | 12 +++++++++++ app/models/project_order/row.rb | 10 +++++++++ app/models/row.rb | 1 + test/fixtures/project_order/orders.yml | 28 ++++++++++++++++++++++++++ test/models/delivery_method_test.rb | 8 ++++++++ 8 files changed, 70 insertions(+) create mode 100644 app/models/project_order/order.rb create mode 100644 app/models/project_order/row.rb create mode 100644 test/fixtures/project_order/orders.yml diff --git a/app/models/company.rb b/app/models/company.rb index b672def86..57ee6e5a1 100644 --- a/app/models/company.rb +++ b/app/models/company.rb @@ -45,6 +45,7 @@ class Company < ActiveRecord::Base o.has_many :manufacture_orders, class_name: 'ManufactureOrder::Order' o.has_many :offer_orders, class_name: 'OfferOrder::Order' o.has_many :preorders, class_name: 'Preorder::Order' + o.has_many :project_orders, class_name: 'ProjectOrder::Order' o.has_many :purchase_invoices_approval, class_name: 'Head::PurchaseInvoice::Approval' o.has_many :purchase_invoices_approved, class_name: 'Head::PurchaseInvoice::Approved' o.has_many :purchase_invoices_paid, class_name: 'Head::PurchaseInvoice::Paid' diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 73466c5ca..9a0daef1f 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -182,6 +182,9 @@ def update_relations cnt = company.work_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << "päivitettiin #{cnt} työmääräyksen otsikkoa" if cnt.nonzero? + + cnt = company.project_orders.active.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + msg << "päivitettiin #{cnt} projektin otsikkoa" if cnt.nonzero? end flash_notice = msg.join(', ') end @@ -277,6 +280,12 @@ def check_relations allow_delete = false end + count = company.project_orders.active.where(toimitustapa: selite).count + if count.nonzero? + errors.add :base, I18n.t("errors.delivery_method.in_use_project_orders", count: count) + allow_delete = false + end + allow_delete end diff --git a/app/models/head.rb b/app/models/head.rb index 38663b5c2..1b479b188 100644 --- a/app/models/head.rb +++ b/app/models/head.rb @@ -30,6 +30,7 @@ def self.child_class_names 'O' => PurchaseOrder::Order, 'P' => Head::PurchaseInvoice::Transfer, 'Q' => Head::PurchaseInvoice::Waiting, + 'R' => ProjectOrder::Order, 'T' => OfferOrder::Order, 'U' => Head::SalesInvoice, 'V' => ManufactureOrder::Order, diff --git a/app/models/project_order/order.rb b/app/models/project_order/order.rb new file mode 100644 index 000000000..eca6aa4a4 --- /dev/null +++ b/app/models/project_order/order.rb @@ -0,0 +1,12 @@ +class ProjectOrder::Order < Head + has_many :rows, foreign_key: :otunnus, class_name: 'ProjectOrder::Row' + + validates :tila, inclusion: { in: ['R'] } + + scope :active, -> { where(alatila: %W(#{} A)) } + + # Rails requires sti_name method to return type column (tyyppi) value + def self.sti_name + "R" + end +end diff --git a/app/models/project_order/row.rb b/app/models/project_order/row.rb new file mode 100644 index 000000000..828706d17 --- /dev/null +++ b/app/models/project_order/row.rb @@ -0,0 +1,10 @@ +class ProjectOrder::Row < Row + belongs_to :order, foreign_key: :otunnus, class_name: 'ProjectOrder::Order' + + validates :tyyppi, inclusion: { in: ['L'] } + + # Rails requires sti_name method to return type column (tyyppi) value + def self.sti_name + "R" + end +end diff --git a/app/models/row.rb b/app/models/row.rb index 42f216cb4..fbd5d7ac1 100644 --- a/app/models/row.rb +++ b/app/models/row.rb @@ -16,6 +16,7 @@ def self.child_class_names 'G' => StockTransfer::Row, 'L' => SalesOrder::Row, 'O' => PurchaseOrder::Row, + 'R' => ProjectOrder::Row, 'T' => OfferOrder::Row, 'V' => ManufactureOrder::Row, } diff --git a/test/fixtures/project_order/orders.yml b/test/fixtures/project_order/orders.yml new file mode 100644 index 000000000..769ec1263 --- /dev/null +++ b/test/fixtures/project_order/orders.yml @@ -0,0 +1,28 @@ +DEFAULTS: &DEFAULTS + yhtio: acme + luontiaika: <%= Time.now %> + laatija: joe + muutospvm: <%= Time.now %> + muuttaja: joe + tapvm: <%= Time.now %> + lapvm: <%= Time.now %> + kapvm: <%= Time.now %> + erpcm: <%= Time.now %> + olmapvm: <%= Time.now %> + kerayspvm: <%= Time.now %> + toimaika: <%= Time.now %> + maksuaika: <%= Time.now %> + lahetepvm: <%= Time.now %> + laskutettu: <%= Time.now %> + h1time: <%= Time.now %> + h2time: <%= Time.now %> + h3time: <%= Time.now %> + h4time: <%= Time.now %> + h5time: <%= Time.now %> + mapvm: <%= Time.now %> + popvm: <%= Time.now %> + +# Projektitilaus +project_one: + tila: R + <<: *DEFAULTS diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index cd502a504..4c1099e06 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -9,6 +9,7 @@ class DeliveryMethodTest < ActiveSupport::TestCase manufacture_order/orders offer_order/orders preorder/orders + project_order/orders sales_order/drafts sales_order/orders stock_transfer/orders @@ -97,6 +98,10 @@ def setup work.toimitustapa = @delivery_method.selite work.save! + project = project_order_orders :project_one + project.toimitustapa = @delivery_method.selite + project.save! + assert_equal 'Kaukokiito', deli2.vak_kielto @delivery_method.selite = 'Kaukokiito3' @@ -134,5 +139,8 @@ def setup # work order orders assert_equal 'Kaukokiito3', work.reload.toimitustapa + + # project order orders + assert_equal 'Kaukokiito3', project.reload.toimitustapa end end From e8273760fc02a7b0646a32c3fd03cc5b6bf97eca Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 12:26:37 +0200 Subject: [PATCH 102/189] add reclamation order --- app/models/company.rb | 1 + app/models/delivery_method.rb | 9 +++++++ app/models/head.rb | 1 + app/models/reclamation_order/order.rb | 10 ++++++++ app/models/reclamation_order/row.rb | 10 ++++++++ app/models/row.rb | 1 + test/fixtures/reclamation_order/orders.yml | 28 ++++++++++++++++++++++ test/models/delivery_method_test.rb | 8 +++++++ 8 files changed, 68 insertions(+) create mode 100644 app/models/reclamation_order/order.rb create mode 100644 app/models/reclamation_order/row.rb create mode 100644 test/fixtures/reclamation_order/orders.yml diff --git a/app/models/company.rb b/app/models/company.rb index 57ee6e5a1..a27859b56 100644 --- a/app/models/company.rb +++ b/app/models/company.rb @@ -52,6 +52,7 @@ class Company < ActiveRecord::Base o.has_many :purchase_invoices_ready_for_transfer, class_name: 'Head::PurchaseInvoice::Transfer' o.has_many :purchase_invoices_waiting_for_payment, class_name: 'Head::PurchaseInvoice::Waiting' o.has_many :purchase_orders, class_name: 'PurchaseOrder::Order' + o.has_many :reclamation_orders, class_name: 'ReclamationOrder::Order' o.has_many :sales_invoices, class_name: 'Head::SalesInvoice' o.has_many :sales_order_drafts, class_name: 'SalesOrder::Draft' o.has_many :sales_orders, class_name: 'SalesOrder::Order' diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 9a0daef1f..280ba6478 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -185,6 +185,9 @@ def update_relations cnt = company.project_orders.active.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << "päivitettiin #{cnt} projektin otsikkoa" if cnt.nonzero? + + cnt = company.reclamation_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + msg << "päivitettiin #{cnt} reklamaation otsikkoa" if cnt.nonzero? end flash_notice = msg.join(', ') end @@ -286,6 +289,12 @@ def check_relations allow_delete = false end + count = company.reclamation_orders.active.where(toimitustapa: selite).count + if count.nonzero? + errors.add :base, I18n.t("errors.delivery_method.in_use_reclamation_orders", count: count) + allow_delete = false + end + allow_delete end diff --git a/app/models/head.rb b/app/models/head.rb index 1b479b188..9b110a46b 100644 --- a/app/models/head.rb +++ b/app/models/head.rb @@ -21,6 +21,7 @@ def self.default_child_instance def self.child_class_names { 'A' => WorkOrder::Order, + 'C' => ReclamationOrder::Order, 'E' => Preorder::Order, 'G' => StockTransfer::Order, 'H' => Head::PurchaseInvoice::Approval, diff --git a/app/models/reclamation_order/order.rb b/app/models/reclamation_order/order.rb new file mode 100644 index 000000000..bd14eed51 --- /dev/null +++ b/app/models/reclamation_order/order.rb @@ -0,0 +1,10 @@ +class ReclamationOrder::Order < Head + has_many :rows, foreign_key: :otunnus, class_name: 'ReclamationOrder::Row' + + validates :tila, inclusion: { in: ['C'] } + + # Rails requires sti_name method to return type column (tyyppi) value + def self.sti_name + "C" + end +end diff --git a/app/models/reclamation_order/row.rb b/app/models/reclamation_order/row.rb new file mode 100644 index 000000000..5449c113e --- /dev/null +++ b/app/models/reclamation_order/row.rb @@ -0,0 +1,10 @@ +class ReclamationOrder::Row < Row + belongs_to :order, foreign_key: :otunnus, class_name: 'ReclamationOrder::Order' + + validates :tyyppi, inclusion: { in: ['L'] } + + # Rails requires sti_name method to return type column (tyyppi) value + def self.sti_name + "C" + end +end diff --git a/app/models/row.rb b/app/models/row.rb index fbd5d7ac1..4e44d03e6 100644 --- a/app/models/row.rb +++ b/app/models/row.rb @@ -12,6 +12,7 @@ def self.default_child_instance def self.child_class_names { 'A' => WorkOrder::Row, + 'C' => ReclamationOrder::Row, 'E' => Preorder::Row, 'G' => StockTransfer::Row, 'L' => SalesOrder::Row, diff --git a/test/fixtures/reclamation_order/orders.yml b/test/fixtures/reclamation_order/orders.yml new file mode 100644 index 000000000..6f67bb5a3 --- /dev/null +++ b/test/fixtures/reclamation_order/orders.yml @@ -0,0 +1,28 @@ +DEFAULTS: &DEFAULTS + yhtio: acme + luontiaika: <%= Time.now %> + laatija: joe + muutospvm: <%= Time.now %> + muuttaja: joe + tapvm: <%= Time.now %> + lapvm: <%= Time.now %> + kapvm: <%= Time.now %> + erpcm: <%= Time.now %> + olmapvm: <%= Time.now %> + kerayspvm: <%= Time.now %> + toimaika: <%= Time.now %> + maksuaika: <%= Time.now %> + lahetepvm: <%= Time.now %> + laskutettu: <%= Time.now %> + h1time: <%= Time.now %> + h2time: <%= Time.now %> + h3time: <%= Time.now %> + h4time: <%= Time.now %> + h5time: <%= Time.now %> + mapvm: <%= Time.now %> + popvm: <%= Time.now %> + +# Reklamaatiotilaus +reclamation_one: + tila: C + <<: *DEFAULTS diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 4c1099e06..8ca4fd169 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -10,6 +10,7 @@ class DeliveryMethodTest < ActiveSupport::TestCase offer_order/orders preorder/orders project_order/orders + reclamation_order/orders sales_order/drafts sales_order/orders stock_transfer/orders @@ -102,6 +103,10 @@ def setup project.toimitustapa = @delivery_method.selite project.save! + reclamation = reclamation_order_orders :reclamation_one + reclamation.toimitustapa = @delivery_method.selite + reclamation.save! + assert_equal 'Kaukokiito', deli2.vak_kielto @delivery_method.selite = 'Kaukokiito3' @@ -142,5 +147,8 @@ def setup # project order orders assert_equal 'Kaukokiito3', project.reload.toimitustapa + + # reclamation order orders + assert_equal 'Kaukokiito3', reclamation.reload.toimitustapa end end From deb23a7559eb6d67439647c421ec8e96830f4e6f Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 12:48:58 +0200 Subject: [PATCH 103/189] add freight relation update --- app/models/delivery_method.rb | 3 +++ test/models/delivery_method_test.rb | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 280ba6478..da893df6b 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -188,6 +188,9 @@ def update_relations cnt = company.reclamation_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << "päivitettiin #{cnt} reklamaation otsikkoa" if cnt.nonzero? + + cnt = company.freights.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + msg << "päivitettiin #{cnt} rahtimaksua" if cnt.nonzero? end flash_notice = msg.join(', ') end diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 8ca4fd169..7e97b788d 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -5,6 +5,7 @@ class DeliveryMethodTest < ActiveSupport::TestCase customer_keywords customers delivery_methods + freights heads manufacture_order/orders offer_order/orders @@ -107,6 +108,10 @@ def setup reclamation.toimitustapa = @delivery_method.selite reclamation.save! + freight = freights :kaukokiito_freight + freight.toimitustapa = @delivery_method.selite + freight.save! + assert_equal 'Kaukokiito', deli2.vak_kielto @delivery_method.selite = 'Kaukokiito3' @@ -150,5 +155,8 @@ def setup # reclamation order orders assert_equal 'Kaukokiito3', reclamation.reload.toimitustapa + + # freights + assert_equal 'Kaukokiito3', freight.reload.toimitustapa end end From d9a18ad91c6c3dab1f2a098cf61ae227878813d9 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 12:52:53 +0200 Subject: [PATCH 104/189] add freight contracts relation update --- app/models/delivery_method.rb | 3 +++ test/fixtures/freight_contracts.yml | 7 +++++++ test/models/delivery_method_test.rb | 8 ++++++++ 3 files changed, 18 insertions(+) create mode 100644 test/fixtures/freight_contracts.yml diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index da893df6b..b3422ae0a 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -191,6 +191,9 @@ def update_relations cnt = company.freights.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << "päivitettiin #{cnt} rahtimaksua" if cnt.nonzero? + + cnt = company.freight_contracts.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + msg << "päivitettiin #{cnt} rahtisopimusta" if cnt.nonzero? end flash_notice = msg.join(', ') end diff --git a/test/fixtures/freight_contracts.yml b/test/fixtures/freight_contracts.yml new file mode 100644 index 000000000..909c5e096 --- /dev/null +++ b/test/fixtures/freight_contracts.yml @@ -0,0 +1,7 @@ +kaukokiito_freight_contract: + yhtio: acme + toimitustapa: Kaukokiito + laatija: joe + luontiaika: <%= Date.today %> + muutospvm: <%= Date.today %> + muuttaja: joe diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 7e97b788d..c2caf13fa 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -5,6 +5,7 @@ class DeliveryMethodTest < ActiveSupport::TestCase customer_keywords customers delivery_methods + freight_contracts freights heads manufacture_order/orders @@ -112,6 +113,10 @@ def setup freight.toimitustapa = @delivery_method.selite freight.save! + freight_contract = freight_contracts :kaukokiito_freight_contract + freight_contract.toimitustapa = @delivery_method.selite + freight_contract.save! + assert_equal 'Kaukokiito', deli2.vak_kielto @delivery_method.selite = 'Kaukokiito3' @@ -158,5 +163,8 @@ def setup # freights assert_equal 'Kaukokiito3', freight.reload.toimitustapa + + # freight_contract + assert_equal 'Kaukokiito3', freight_contract.reload.toimitustapa end end From df947cec3c5901f4cb6c5161ab9817d48e99a695 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 13:02:09 +0200 Subject: [PATCH 105/189] add waybills --- app/models/company.rb | 1 + app/models/delivery_method.rb | 10 ++++++++++ app/models/waybill.rb | 8 ++++++++ test/fixtures/waybills.yml | 7 +++++++ test/models/delivery_method_test.rb | 8 ++++++++ 5 files changed, 34 insertions(+) create mode 100644 app/models/waybill.rb create mode 100644 test/fixtures/waybills.yml diff --git a/app/models/company.rb b/app/models/company.rb index a27859b56..031963c22 100644 --- a/app/models/company.rb +++ b/app/models/company.rb @@ -26,6 +26,7 @@ class Company < ActiveRecord::Base o.has_many :terms_of_payments o.has_many :users o.has_many :warehouses + o.has_many :waybills o.has_many :products o.has_many :brands, class_name: 'Product::Brand' diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index b3422ae0a..ffa4da5cf 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -8,6 +8,7 @@ class DeliveryMethod < BaseModel o.has_many :customs, primary_key: :poistumistoimipaikka_koodi, class_name: 'Keyword::Customs' o.has_many :sorting_point, primary_key: :lajittelupiste, class_name: 'Keyword::SortingPoint' o.has_many :customer_keywords, primary_key: :avainsana + o.has_many :waybills, primary_key: :toimitustapa end validates :aktiivinen_kuljetus_kansallisuus, :maa_maara, :sisamaan_kuljetus_kansallisuus, inclusion: { in: Country.pluck(:koodi) }, allow_blank: true @@ -194,6 +195,9 @@ def update_relations cnt = company.freight_contracts.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << "päivitettiin #{cnt} rahtisopimusta" if cnt.nonzero? + + cnt = company.waybills.not_printed.where(toimitustapa: selite_was).update_all(toimitustapa: selite) + msg << "päivitettiin #{cnt} tulostamatonta rahtikirjaa" if cnt.nonzero? end flash_notice = msg.join(', ') end @@ -301,6 +305,12 @@ def check_relations allow_delete = false end + count = company.waybills.not_printed.active.where(toimitustapa: selite).count + if count.nonzero? + errors.add :base, I18n.t("errors.delivery_method.in_use_waybills", count: count) + allow_delete = false + end + allow_delete end diff --git a/app/models/waybill.rb b/app/models/waybill.rb new file mode 100644 index 000000000..5f2debfd9 --- /dev/null +++ b/app/models/waybill.rb @@ -0,0 +1,8 @@ +class Waybill < BaseModel + belongs_to :delivery_method, foreign_key: :toimitustapa, primary_key: :selite + + scope :not_printed, -> { where(tulostettu: 0) } + + self.table_name = :rahtikirjat + self.primary_key = :tunnus +end diff --git a/test/fixtures/waybills.yml b/test/fixtures/waybills.yml new file mode 100644 index 000000000..56ba245af --- /dev/null +++ b/test/fixtures/waybills.yml @@ -0,0 +1,7 @@ +DEFAULTS: &DEFAULTS + yhtio: acme + +waybill_one: + toimitustapa: Kaukokiito + tulostettu: 0 + <<: *DEFAULTS diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index c2caf13fa..fb4304354 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -16,6 +16,7 @@ class DeliveryMethodTest < ActiveSupport::TestCase sales_order/drafts sales_order/orders stock_transfer/orders + waybills work_order/orders ) @@ -117,6 +118,10 @@ def setup freight_contract.toimitustapa = @delivery_method.selite freight_contract.save! + waybill = waybills :waybill_one + waybill.toimitustapa = @delivery_method.selite + waybill.save! + assert_equal 'Kaukokiito', deli2.vak_kielto @delivery_method.selite = 'Kaukokiito3' @@ -166,5 +171,8 @@ def setup # freight_contract assert_equal 'Kaukokiito3', freight_contract.reload.toimitustapa + + # waybill + assert_equal 'Kaukokiito3', waybill.reload.toimitustapa end end From b4636fc1d85ba07ff5dc9f9a2d5f82a69ac0e8ac Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 13:40:10 +0200 Subject: [PATCH 106/189] add translations --- config/locales/fi.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 34950de00..5e9f1faee 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -212,7 +212,7 @@ fi: rahdinkuljettaja: Kuljetusyhtiö rahti_tuotenumero: Rahtiveloitus tuotenumero rahtikirja: Rahtikirjatyyppi - rahtikirjakopio_email: + rahtikirjakopio_email: sallitut_alustat: Sallitut keräilyalustat sallitut_maat: Sallitut maat selite: Nimitys @@ -884,8 +884,16 @@ fi: in_use_customers: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaalla' in_use_freight_contracts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtisopimuksella' in_use_freights: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtimaksulla' + in_use_manufacture_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} valmistuksella' + in_use_offer_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} tarjouksella' + in_use_preorders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} ennakkotilauksella' + in_use_project_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} projektilla' + in_use_reclamation_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} reklamaatiolla' in_use_sales_order_drafts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} keskeneräisellä myyntitilauksella' in_use_sales_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} toimittamattomalla myyntitilauksella' + in_use_stock_transfers: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} siirtolistalla' + in_use_waybills: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtikirjalla' + in_use_work_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} työmääräyksellä' unifaun_info_missing: 'HUOM: Koontierätulostus ei toimi Unifaun Online rahtikirjan kanssa ilman koontirahtikirjan pakkaustietoja' format: "%{attribute} %{message}" import: From f47a2811f338245b656b8fbf11c1a7bf90cfbdb1 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 13:40:55 +0200 Subject: [PATCH 107/189] remove nonexistent scopes --- app/models/delivery_method.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index ffa4da5cf..7199b8ef8 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -299,13 +299,13 @@ def check_relations allow_delete = false end - count = company.reclamation_orders.active.where(toimitustapa: selite).count + count = company.reclamation_orders.where(toimitustapa: selite).count if count.nonzero? errors.add :base, I18n.t("errors.delivery_method.in_use_reclamation_orders", count: count) allow_delete = false end - count = company.waybills.not_printed.active.where(toimitustapa: selite).count + count = company.waybills.not_printed.where(toimitustapa: selite).count if count.nonzero? errors.add :base, I18n.t("errors.delivery_method.in_use_waybills", count: count) allow_delete = false From 3ddcaeb3aa9ab430ee8f3e86afbfd55d42522096 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 13:41:46 +0200 Subject: [PATCH 108/189] fix update message --- .../administration/delivery_methods_controller.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index 631829238..788804c41 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -27,13 +27,15 @@ def create def update if @delivery_method.update delivery_method_params - if @delivery_method.previous_changes.include?('selite') - relation_update_notices = @delivery_method.relation_update - else - relation_update_notices = '' + + msg = [] + msg << t('.update_success') + + if @delivery_method.flash_notice.present? + msg << @delivery_method.flash_notice end - redirect_to delivery_methods_path, notice: relation_update_notices + redirect_to delivery_methods_path, notice: msg.join(', ') else render :edit end From 61e6a45baf5261e431aebce251f131a0fd98eb51 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 14:13:11 +0200 Subject: [PATCH 109/189] fix test --- .../administration/delivery_method_controller_test.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/controllers/administration/delivery_method_controller_test.rb b/test/controllers/administration/delivery_method_controller_test.rb index b9b9544e7..639db935f 100644 --- a/test/controllers/administration/delivery_method_controller_test.rb +++ b/test/controllers/administration/delivery_method_controller_test.rb @@ -82,11 +82,10 @@ def setup test "should delete delivery method" do login users(:bob) - @delivery_method.selite = 'Random delivery method' - @delivery_method.save + deli2 = delivery_methods :kiitolinja assert_difference("DeliveryMethod.count", -1) do - delete :destroy, id: @delivery_method.id + delete :destroy, id: deli2.id end assert_redirected_to delivery_methods_path From 951db983ebfb5b35d5f7832bf5c54018d915bee2 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 15:21:29 +0200 Subject: [PATCH 110/189] use chosen-select --- .../delivery_methods/_form.html.erb | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 04ff72983..595938cc0 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -16,29 +16,29 @@ - + - + - + - + + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %> @@ -58,31 +58,31 @@ - + - + - + - + - + - + - + @@ -90,7 +90,7 @@ - + @@ -102,28 +102,28 @@ - + - + - + - + - + + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %> @@ -172,11 +172,11 @@ + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %> - + @@ -189,17 +189,17 @@ + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %> + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %> + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %> From d8848c9a7bd7ce28846c8e37cc4b9165ad5f5a9e Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 15:33:12 +0200 Subject: [PATCH 111/189] alternative adr delivery method validation --- app/models/delivery_method.rb | 6 ++++++ config/locales/fi.yml | 1 + test/models/delivery_method_test.rb | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 7199b8ef8..d3f4ca390 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -214,6 +214,12 @@ def vak_kielto_validation unless allowed.include? vak_kielto errors.add :vak_kielto, I18n.t('errors.messages.inclusion') end + + count = company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite).count + + if count > 0 + errors.add :vak_kielto, I18n.t('errors.delivery_method.in_use_adr') + end end def vaihtoehtoinen_vak_toimitustapa_validation diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 5e9f1faee..c1e452139 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -880,6 +880,7 @@ fi: luottokortti_missing: Luottokorttitili puuttuu tai sitä ei löydy pankkikortti_missing: Pankkikorttitili puuttuu tai sitä ei löydy delivery_method: + in_use_adr: 'HUOM: Et voi asettaa toimitustavalle VAK-kieltoa, sillä muut toimitustavat käyttävät tätä toimitustapaa vaihtoehtoisena VAK-toimitustapana' in_use_customer_keywords: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaan avainsanassa' in_use_customers: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaalla' in_use_freight_contracts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtisopimuksella' diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index fb4304354..edf73223b 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -42,6 +42,12 @@ def setup @delivery_method.vak_kielto = 'neko' refute @delivery_method.valid?, "Invalid vak_kielto value" + + deli2 = delivery_methods :kiitolinja + deli2.vaihtoehtoinen_vak_toimitustapa = 'Kaukokiito' + deli2.save + @delivery_method.vak_kielto = 'K' + refute @delivery_method.valid?, @delivery_method.errors.full_messages end test 'should validate alternative adr prohibition' do From 2db34f50392c6fa6a86493062cf81524b26fc692 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 15:58:58 +0200 Subject: [PATCH 112/189] fix test --- app/models/delivery_method.rb | 8 +++++--- test/models/delivery_method_test.rb | 7 ++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index d3f4ca390..7e630b4bd 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -215,10 +215,12 @@ def vak_kielto_validation errors.add :vak_kielto, I18n.t('errors.messages.inclusion') end - count = company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite).count + if vak_kielto.present? + count = company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: vak_kielto).count - if count > 0 - errors.add :vak_kielto, I18n.t('errors.delivery_method.in_use_adr') + if count > 0 + errors.add :vak_kielto, I18n.t('errors.delivery_method.in_use_adr') + end end end diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index edf73223b..ef1e72492 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -76,7 +76,7 @@ def setup deli2 = @delivery_method.dup deli2.selite = 'Kaukokiito2' deli2.rahdinkuljettaja = 'Kaukokiito2' - deli2.vak_kielto = @delivery_method.selite + deli2.vak_kielto = '' deli2.vaihtoehtoinen_vak_toimitustapa = @delivery_method.selite deli2.save! @@ -128,15 +128,12 @@ def setup waybill.toimitustapa = @delivery_method.selite waybill.save! - assert_equal 'Kaukokiito', deli2.vak_kielto - @delivery_method.selite = 'Kaukokiito3' @delivery_method.save! - @delivery_method.reload assert @delivery_method.valid?, @delivery_method.errors.full_messages # delivery_method - assert_equal 'Kaukokiito3', deli2.reload.vak_kielto + deli2.reload assert_equal 'Kaukokiito3', deli2.vaihtoehtoinen_vak_toimitustapa # customers From 8feac556074a0d0e5b81e1243bf4fb1c2b52c685 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 16:11:23 +0200 Subject: [PATCH 113/189] fix adr prohibition test --- app/models/delivery_method.rb | 4 ++-- test/models/delivery_method_test.rb | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 7e630b4bd..57dcf8f70 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -215,8 +215,8 @@ def vak_kielto_validation errors.add :vak_kielto, I18n.t('errors.messages.inclusion') end - if vak_kielto.present? - count = company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: vak_kielto).count + if vak_kielto_was.present? && vak_kielto.empty? + count = company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite).count if count > 0 errors.add :vak_kielto, I18n.t('errors.delivery_method.in_use_adr') diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index ef1e72492..f08cec980 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -45,8 +45,10 @@ def setup deli2 = delivery_methods :kiitolinja deli2.vaihtoehtoinen_vak_toimitustapa = 'Kaukokiito' - deli2.save + deli2.save! @delivery_method.vak_kielto = 'K' + @delivery_method.save + @delivery_method.vak_kielto = '' refute @delivery_method.valid?, @delivery_method.errors.full_messages end From 57d2af7a8f9f8d79a87c02d4e6ce5ae9be94557c Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 29 Oct 2015 16:47:02 +0200 Subject: [PATCH 114/189] freight & cargo insurance sku tests --- app/models/delivery_method.rb | 20 +++++++++++++++++++ config/locales/fi.yml | 1 + .../data_export_controller_test.rb | 2 +- test/fixtures/products.yml | 7 +++++++ test/models/delivery_method_test.rb | 17 ++++++++++++++++ 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 57dcf8f70..08bcd36d2 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -26,6 +26,8 @@ class DeliveryMethod < BaseModel validate :vaihtoehtoinen_vak_toimitustapa_validation validate :vak_kielto_validation validate :mandatory_new_packaging_information if :package_info_entry_denied && :collective_batch + validate :freight_sku, if: :has_freight_sku? + validate :cargo_insurance_sku, if: :has_cargo_insurance_sku? before_save :defaults before_destroy :check_relations @@ -147,6 +149,24 @@ def permitted_packaging_options private + def has_freight_sku? + rahti_tuotenumero.present? + end + + def freight_sku + cnt = company.products.no_inventory_management.where(tuoteno: rahti_tuotenumero).count + errors.add :rahti_tuotenumero, I18n.t('errors.delivery_method.product_not_in_inventory_management') if cnt.zero? + end + + def has_cargo_insurance_sku? + kuljetusvakuutus_tuotenumero.present? + end + + def cargo_insurance_sku + cnt = company.products.no_inventory_management.where(tuoteno: kuljetusvakuutus_tuotenumero).count + errors.add :kuljetusvakuutus_tuotenumero, I18n.t('errors.delivery_method.product_not_in_inventory_management') if cnt.zero? + end + def update_relations msg = [] diff --git a/config/locales/fi.yml b/config/locales/fi.yml index c1e452139..46a9913fd 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -880,6 +880,7 @@ fi: luottokortti_missing: Luottokorttitili puuttuu tai sitä ei löydy pankkikortti_missing: Pankkikorttitili puuttuu tai sitä ei löydy delivery_method: + product_not_in_inventory_management: 'Tuotetta ei löydy / tuote pitää olla saldoton' in_use_adr: 'HUOM: Et voi asettaa toimitustavalle VAK-kieltoa, sillä muut toimitustavat käyttävät tätä toimitustapaa vaihtoehtoisena VAK-toimitustapana' in_use_customer_keywords: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaan avainsanassa' in_use_customers: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaalla' diff --git a/test/controllers/data_export_controller_test.rb b/test/controllers/data_export_controller_test.rb index a719d4c32..283457aae 100644 --- a/test/controllers/data_export_controller_test.rb +++ b/test/controllers/data_export_controller_test.rb @@ -44,7 +44,7 @@ class DataExportControllerTest < ActionController::TestCase header = ["Tuoteno", "Malliston nimi", "Tuotteen väri"] assert_equal header, excel.row(1) - row = ["hammer123", "Aluminium", " "] + row = ["non_inventory_manageable_product", " ", " "] assert_equal row, excel.row(2) end end diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index 736bdd716..d5b4f55f9 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -46,3 +46,10 @@ pr1: nimitys: Päiväraha tuotetyyppi: A <<: *DEFAULTS + +non_manageable: + yhtio: acme + tuoteno: non_inventory_manageable_product + nimitys: Jarrusatula + ei_saldoa: o + <<: *DEFAULTS diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index f08cec980..508be933c 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -11,6 +11,7 @@ class DeliveryMethodTest < ActiveSupport::TestCase manufacture_order/orders offer_order/orders preorder/orders + products project_order/orders reclamation_order/orders sales_order/drafts @@ -52,6 +53,22 @@ def setup refute @delivery_method.valid?, @delivery_method.errors.full_messages end + test 'should validate freight sku' do + @delivery_method.rahti_tuotenumero = 'non_inventory_manageable_product' + assert @delivery_method.valid?, @delivery_method.errors.full_messages + + @delivery_method.rahti_tuotenumero = 'hammer123' + refute @delivery_method.valid?, @delivery_method.errors.full_messages + end + + test 'should validate cargo insurance sku' do + @delivery_method.kuljetusvakuutus_tuotenumero = 'non_inventory_manageable_product' + assert @delivery_method.valid?, @delivery_method.errors.full_messages + + @delivery_method.kuljetusvakuutus_tuotenumero = 'hammer123' + refute @delivery_method.valid?, @delivery_method.errors.full_messages + end + test 'should validate alternative adr prohibition' do @delivery_method.vaihtoehtoinen_vak_toimitustapa = '' assert @delivery_method.valid? From cd27a8a458e63bf88c4a94f3a4300cc62935eeba Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Fri, 30 Oct 2015 13:42:24 +0200 Subject: [PATCH 115/189] add translations --- app/models/delivery_method.rb | 33 ++++++++++++------------ config/locales/fi.yml | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 16 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 08bcd36d2..8977b0ccc 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -172,53 +172,54 @@ def update_relations if selite_was.present? cnt = company.delivery_methods.where(vak_kielto: selite_was).update_all(vak_kielto: selite) - msg << "päivitettiin #{cnt} toimitustapaa" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.delivery_methods', count: cnt) if cnt.nonzero? cnt = company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite_was).update_all(vaihtoehtoinen_vak_toimitustapa: selite) - msg << "päivitettiin #{cnt} vaihtoehtoista vak toimitustapaa" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.alternative_adr_delivery_methods', count: cnt) if cnt.nonzero? cnt = company.customers.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} asiakasta" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.customers', count: cnt) if cnt.nonzero? cnt = company.sales_orders.not_delivered.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} myyntitilaus otsikkoa" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.not_delivered_sales_orders', count: cnt) if cnt.nonzero? cnt = company.sales_order_drafts.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} myyntitilaus kesken otsikkoa" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.sales_order_drafts', count: cnt) if cnt.nonzero? cnt = company.customer_keywords.where(avainsana: selite_was).update_all(avainsana: selite) - msg << "päivitettiin #{cnt} asiakkaan avainsanaa" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.customer_keywords', count: cnt) if cnt.nonzero? cnt = company.stock_transfers.not_delivered.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} siirtolistan otsikkoa" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.not_delivered_stock_transfers', count: cnt) if cnt.nonzero? cnt = company.preorders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} ennakkotilauksen otsikkoa" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.preorders', count: cnt) if cnt.nonzero? cnt = company.offer_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} tarjouksen otsikkoa" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.offer_orders', count: cnt) if cnt.nonzero? cnt = company.manufacture_orders.not_manufactured.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} valmistuksen otsikkoa" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.not_manufactured_manufacture_orders', count: cnt) if cnt.nonzero? cnt = company.work_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} työmääräyksen otsikkoa" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.work_orders', count: cnt) if cnt.nonzero? cnt = company.project_orders.active.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} projektin otsikkoa" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.project_orders', count: cnt) if cnt.nonzero? cnt = company.reclamation_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} reklamaation otsikkoa" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.reclamation_orders', count: cnt) if cnt.nonzero? cnt = company.freights.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} rahtimaksua" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.freights', count: cnt) if cnt.nonzero? cnt = company.freight_contracts.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} rahtisopimusta" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.freight_contracts', count: cnt) if cnt.nonzero? cnt = company.waybills.not_printed.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << "päivitettiin #{cnt} tulostamatonta rahtikirjaa" if cnt.nonzero? + msg << I18n.t('administration.delivery_methods.update.not_printed_waybills', count: cnt) if cnt.nonzero? end + flash_notice = msg.join(', ') end diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 46a9913fd..5a6cd75d2 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -585,6 +585,54 @@ fi: use_company_default: Yhtiön oletus update: update_success: Toimitustapa päivitettiin onnistuneesti + delivery_methods: + one: Päivitettiin %{count} toimitustapa + other: Päivitettiin %{count} toimitustapaa + alternative_adr_delivery_methods: + one: Päivitettiin %{count} vaihtoehtoista vak toimitustapa + other: Päivitettiin %{count} vaihtoehtoista vak toimitustapaa + customers: + one: Päivitettiin %{count} asiakas + other: Päivitettiin %{count} asiakasta + not_delivered_sales_orders: + one: Päivitettiin %{count} myyntitilauksen otsikko + other: Päivitettiin %{count} myyntitilauksen otsikkoa + sales_order_drafts: + one: Päivitettiin %{count} kesken oleva myyntitilauksen otsikko + other: Päivitettiin %{count} kesken olevaa myyntitilauksen otsikkoa + customer_keywords: + one: Päivitettiin %{count} asiakkaan avainsana + other: Päivitettiin %{count} asiakkaan avainsanaa + not_delivered_stock_transfers: + one: Päivitettiin %{count} siirtolistan otsikko + other: Päivitettiin %{count} siirtolistan otsikkoa + preorders: + one: Päivitettiin %{count} ennakkotilauksen otsikko + other: Päivitettiin %{count} ennakkotilauksen otsikkoa + offer_orders: + one: Päivitettiin %{count} tarjouksen otsikko + other: Päivitettiin %{count} tarjouksen otsikkoa + not_manufactured_manufacture_orders: + one: Päivitettiin %{count} valmistuksen otsikko + other: Päivitettiin %{count} valmistuksen otsikkoa + work_orders: + one: Päivitettiin %{count} työmääräyksen otsikko + other: Päivitettiin %{count} työmääräyksen otsikkoa + project_orders: + one: Päivitettiin %{count} projektin otsikko + other: Päivitettiin %{count} projektin otsikkoa + reclamation_orders: + one: Päivitettiin %{count} reklamaation otsikko + other: Päivitettiin %{count} reklamaation otsikkoa + freights: + one: Päivitettiin %{count} rahtimaksu + other: Päivitettiin %{count} rahtimaksua + freight_contracts: + one: Päivitettiin %{count} rahtisopimus + other: Päivitettiin %{count} rahtisopimusta + not_printed_waybills: + one: Päivitettiin %{count} tulostamaton rahtikirja + other: Päivitettiin %{count} tulostamatonta rahtikirjaa waybill_options: dpd_ftp: DPD ftp-siirto dpd_waybill: DPD A5 PDF-rahtikirja From b73d76082dfebd256c4b539630d63e9f943a29ee Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Fri, 30 Oct 2015 13:52:23 +0200 Subject: [PATCH 116/189] normalize translations --- config/locales/fi.yml | 134 +++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 07d9f5969..6a6721369 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -212,7 +212,7 @@ fi: rahdinkuljettaja: Kuljetusyhtiö rahti_tuotenumero: Rahtiveloitus tuotenumero rahtikirja: Rahtikirjatyyppi - rahtikirjakopio_email: + rahtikirjakopio_email: sallitut_alustat: Sallitut keräilyalustat sallitut_maat: Sallitut maat selite: Nimitys @@ -584,55 +584,55 @@ fi: percentage_based_insurance_with_discount: Prosentuaalinen kuljetusvakuutus lisätään. Käytetään kuljetusvakuutustuotteen asiakasalennusta use_company_default: Yhtiön oletus update: - update_success: Toimitustapa päivitettiin onnistuneesti - delivery_methods: - one: Päivitettiin %{count} toimitustapa - other: Päivitettiin %{count} toimitustapaa alternative_adr_delivery_methods: - one: Päivitettiin %{count} vaihtoehtoista vak toimitustapa - other: Päivitettiin %{count} vaihtoehtoista vak toimitustapaa + one: Päivitettiin %{count} vaihtoehtoista vak toimitustapa + other: Päivitettiin %{count} vaihtoehtoista vak toimitustapaa + customer_keywords: + one: Päivitettiin %{count} asiakkaan avainsana + other: Päivitettiin %{count} asiakkaan avainsanaa customers: - one: Päivitettiin %{count} asiakas - other: Päivitettiin %{count} asiakasta + one: Päivitettiin %{count} asiakas + other: Päivitettiin %{count} asiakasta + delivery_methods: + one: Päivitettiin %{count} toimitustapa + other: Päivitettiin %{count} toimitustapaa + freight_contracts: + one: Päivitettiin %{count} rahtisopimus + other: Päivitettiin %{count} rahtisopimusta + freights: + one: Päivitettiin %{count} rahtimaksu + other: Päivitettiin %{count} rahtimaksua not_delivered_sales_orders: - one: Päivitettiin %{count} myyntitilauksen otsikko - other: Päivitettiin %{count} myyntitilauksen otsikkoa - sales_order_drafts: - one: Päivitettiin %{count} kesken oleva myyntitilauksen otsikko - other: Päivitettiin %{count} kesken olevaa myyntitilauksen otsikkoa - customer_keywords: - one: Päivitettiin %{count} asiakkaan avainsana - other: Päivitettiin %{count} asiakkaan avainsanaa + one: Päivitettiin %{count} myyntitilauksen otsikko + other: Päivitettiin %{count} myyntitilauksen otsikkoa not_delivered_stock_transfers: - one: Päivitettiin %{count} siirtolistan otsikko - other: Päivitettiin %{count} siirtolistan otsikkoa - preorders: - one: Päivitettiin %{count} ennakkotilauksen otsikko - other: Päivitettiin %{count} ennakkotilauksen otsikkoa - offer_orders: - one: Päivitettiin %{count} tarjouksen otsikko - other: Päivitettiin %{count} tarjouksen otsikkoa + one: Päivitettiin %{count} siirtolistan otsikko + other: Päivitettiin %{count} siirtolistan otsikkoa not_manufactured_manufacture_orders: - one: Päivitettiin %{count} valmistuksen otsikko - other: Päivitettiin %{count} valmistuksen otsikkoa - work_orders: - one: Päivitettiin %{count} työmääräyksen otsikko - other: Päivitettiin %{count} työmääräyksen otsikkoa + one: Päivitettiin %{count} valmistuksen otsikko + other: Päivitettiin %{count} valmistuksen otsikkoa + not_printed_waybills: + one: Päivitettiin %{count} tulostamaton rahtikirja + other: Päivitettiin %{count} tulostamatonta rahtikirjaa + offer_orders: + one: Päivitettiin %{count} tarjouksen otsikko + other: Päivitettiin %{count} tarjouksen otsikkoa + preorders: + one: Päivitettiin %{count} ennakkotilauksen otsikko + other: Päivitettiin %{count} ennakkotilauksen otsikkoa project_orders: - one: Päivitettiin %{count} projektin otsikko - other: Päivitettiin %{count} projektin otsikkoa + one: Päivitettiin %{count} projektin otsikko + other: Päivitettiin %{count} projektin otsikkoa reclamation_orders: - one: Päivitettiin %{count} reklamaation otsikko - other: Päivitettiin %{count} reklamaation otsikkoa - freights: - one: Päivitettiin %{count} rahtimaksu - other: Päivitettiin %{count} rahtimaksua - freight_contracts: - one: Päivitettiin %{count} rahtisopimus - other: Päivitettiin %{count} rahtisopimusta - not_printed_waybills: - one: Päivitettiin %{count} tulostamaton rahtikirja - other: Päivitettiin %{count} tulostamatonta rahtikirjaa + one: Päivitettiin %{count} reklamaation otsikko + other: Päivitettiin %{count} reklamaation otsikkoa + sales_order_drafts: + one: Päivitettiin %{count} kesken oleva myyntitilauksen otsikko + other: Päivitettiin %{count} kesken olevaa myyntitilauksen otsikkoa + update_success: Toimitustapa päivitettiin onnistuneesti + work_orders: + one: Päivitettiin %{count} työmääräyksen otsikko + other: Päivitettiin %{count} työmääräyksen otsikkoa waybill_options: dpd_ftp: DPD ftp-siirto dpd_waybill: DPD A5 PDF-rahtikirja @@ -825,7 +825,7 @@ fi: - pe - la abbr_month_names: - - + - - tammi - helmi - maalis @@ -851,7 +851,7 @@ fi: long: "%A %e. %Bta %Y" short: "%d %b" month_names: - - + - - tammikuu - helmikuu - maaliskuu @@ -928,7 +928,6 @@ fi: luottokortti_missing: Luottokorttitili puuttuu tai sitä ei löydy pankkikortti_missing: Pankkikorttitili puuttuu tai sitä ei löydy delivery_method: - product_not_in_inventory_management: 'Tuotetta ei löydy / tuote pitää olla saldoton' in_use_adr: 'HUOM: Et voi asettaa toimitustavalle VAK-kieltoa, sillä muut toimitustavat käyttävät tätä toimitustapaa vaihtoehtoisena VAK-toimitustapana' in_use_customer_keywords: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaan avainsanassa' in_use_customers: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaalla' @@ -944,6 +943,7 @@ fi: in_use_stock_transfers: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} siirtolistalla' in_use_waybills: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtikirjalla' in_use_work_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} työmääräyksellä' + product_not_in_inventory_management: Tuotetta ei löydy / tuote pitää olla saldoton unifaun_info_missing: 'HUOM: Koontierätulostus ei toimi Unifaun Online rahtikirjan kanssa ilman koontirahtikirjan pakkaustietoja' format: "%{attribute} %{message}" import: @@ -1182,44 +1182,44 @@ fi: revenue_expenditure_month: one: "%{count} kuukausi" other: "%{count} kuukautta" - stock_listing_csv: - index: - header: Varastosaldot CSV - run: Aja raportti - running: Raporttia ajetaan! Valmis raportti löytyy omalta download arealtasi! stock_availability: - index: - header: Varastotilanne form: button_make: Ruudulle button_run: Pdf + constraints: Rajaus period: Tarkasteluaika weeks: Viikon ajalta - constraints: Rajaus - show_data: + index: header: Varastotilanne + show_data: available: Saatavilla - past: Myöhässä future: Tulevat + header: Varastotilanne + past: Myöhässä product: Tuote purchases: Tulossa - sales: Menossa - stock: Varastosaldo - week: Viikko - total: Yhteensä - report_category: Valitut osastot %{selected} - report_subcategory: Valitut tuoteryhmät %{selected} report_brand: Valitut tuotemerkit %{selected} + report_category: Valitut osastot %{selected} report_period: Tarkasteluaika %{period} viikkoa + report_subcategory: Valitut tuoteryhmät %{selected} + sales: Menossa + stock: Varastosaldo + total: Yhteensä + week: Viikko view_connected_sales_orders: - order_number: Tilausnumero - shipping_address: Toimitusosoite - information: Tilausviite delivery_date: Toimituspäivä - product_info: Tuotenumero - unit: Kappaletta + information: Tilausviite + order_number: Tilausnumero ordered_amount: Tilattu + product_info: Tuotenumero + shipping_address: Toimitusosoite total_amount: Laskun summa + unit: Kappaletta + stock_listing_csv: + index: + header: Varastosaldot CSV + run: Aja raportti + running: Raporttia ajetaan! Valmis raportti löytyy omalta download arealtasi! shared: excel: company: Yritystiedot From 1b7a97dbd31edec2b834469c9bb01f4c3c94d899 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Fri, 30 Oct 2015 14:19:47 +0200 Subject: [PATCH 117/189] use carrier fixture --- test/helpers/carrier_helper_test.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/helpers/carrier_helper_test.rb b/test/helpers/carrier_helper_test.rb index 17df23ef3..cbfb2c97f 100644 --- a/test/helpers/carrier_helper_test.rb +++ b/test/helpers/carrier_helper_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class CarrierHelperTest < ActionView::TestCase + fixtures %w(carriers) + test "returns translated neutraali options valid for collection" do assert neutraali_options.is_a? Array From 4eecb182360b83f56b2f3625058ac4d6295fbffb Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Fri, 30 Oct 2015 14:20:00 +0200 Subject: [PATCH 118/189] add delivery method to fixtures --- test/fixtures/manufacture_order/orders.yml | 1 + test/fixtures/offer_order/orders.yml | 1 + test/fixtures/preorder/orders.yml | 1 + test/fixtures/project_order/orders.yml | 1 + test/fixtures/reclamation_order/orders.yml | 1 + test/fixtures/sales_order/drafts.yml | 1 + test/fixtures/sales_order/orders.yml | 1 + test/fixtures/work_order/orders.yml | 1 + 8 files changed, 8 insertions(+) diff --git a/test/fixtures/manufacture_order/orders.yml b/test/fixtures/manufacture_order/orders.yml index d3660460e..bd306153c 100644 --- a/test/fixtures/manufacture_order/orders.yml +++ b/test/fixtures/manufacture_order/orders.yml @@ -24,4 +24,5 @@ DEFAULTS: &DEFAULTS mo_one: tila: V + toimitustapa: Kaukokiito <<: *DEFAULTS diff --git a/test/fixtures/offer_order/orders.yml b/test/fixtures/offer_order/orders.yml index 5a4473f74..01c232e24 100644 --- a/test/fixtures/offer_order/orders.yml +++ b/test/fixtures/offer_order/orders.yml @@ -25,4 +25,5 @@ DEFAULTS: &DEFAULTS # Tarjoustilaus offer_one: tila: T + toimitustapa: Kaukokiito <<: *DEFAULTS diff --git a/test/fixtures/preorder/orders.yml b/test/fixtures/preorder/orders.yml index 2f9297193..1d691541a 100644 --- a/test/fixtures/preorder/orders.yml +++ b/test/fixtures/preorder/orders.yml @@ -25,4 +25,5 @@ DEFAULTS: &DEFAULTS # Ennakkotilaus pre_one: tila: E + toimitustapa: Kaukokiito <<: *DEFAULTS diff --git a/test/fixtures/project_order/orders.yml b/test/fixtures/project_order/orders.yml index 769ec1263..7420fa1e1 100644 --- a/test/fixtures/project_order/orders.yml +++ b/test/fixtures/project_order/orders.yml @@ -25,4 +25,5 @@ DEFAULTS: &DEFAULTS # Projektitilaus project_one: tila: R + toimitustapa: Kaukokiito <<: *DEFAULTS diff --git a/test/fixtures/reclamation_order/orders.yml b/test/fixtures/reclamation_order/orders.yml index 6f67bb5a3..9ad7906e6 100644 --- a/test/fixtures/reclamation_order/orders.yml +++ b/test/fixtures/reclamation_order/orders.yml @@ -25,4 +25,5 @@ DEFAULTS: &DEFAULTS # Reklamaatiotilaus reclamation_one: tila: C + toimitustapa: Kaukokiito <<: *DEFAULTS diff --git a/test/fixtures/sales_order/drafts.yml b/test/fixtures/sales_order/drafts.yml index 988e73a12..5776295a4 100644 --- a/test/fixtures/sales_order/drafts.yml +++ b/test/fixtures/sales_order/drafts.yml @@ -26,4 +26,5 @@ not_finished_order: tila: N alatila: '' terms_of_payment: hundred_days_net + toimitustapa: Kaukokiito <<: *DEFAULTS diff --git a/test/fixtures/sales_order/orders.yml b/test/fixtures/sales_order/orders.yml index 5b8bf2e95..e4f74225b 100644 --- a/test/fixtures/sales_order/orders.yml +++ b/test/fixtures/sales_order/orders.yml @@ -31,6 +31,7 @@ not_delivered_order_1: tila: L alatila: A terms_of_payment: eighty_days_net + toimitustapa: Kaukokiito <<: *DEFAULTS not_delivered_order_2: diff --git a/test/fixtures/work_order/orders.yml b/test/fixtures/work_order/orders.yml index 7087c8244..c4bc30d34 100644 --- a/test/fixtures/work_order/orders.yml +++ b/test/fixtures/work_order/orders.yml @@ -25,4 +25,5 @@ DEFAULTS: &DEFAULTS # Työmääräystilaus work_one: tila: A + toimitustapa: Kaukokiito <<: *DEFAULTS From ecfdd2123bdab43ecc1039e55558198045074373 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Fri, 30 Oct 2015 15:22:36 +0200 Subject: [PATCH 119/189] use translated package description --- app/controllers/application_controller.rb | 5 +++++ app/models/package.rb | 4 ++++ app/views/administration/delivery_methods/_form.html.erb | 2 +- test/models/package_test.rb | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f35ea6cfe..53d42d733 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base helper_method :current_user helper_method :current_company helper_method :update_access? + helper_method :get_locale def current_user @current_user ||= User.unscoped.find_by_session(cookies[:pupesoft_session]) @@ -34,6 +35,10 @@ def update_access? @update_access ||= current_user.can_update?(request_path, alias_set: alias_set) end + def get_locale + users_locale + end + protected def authorize diff --git a/app/models/package.rb b/app/models/package.rb index 643422b44..6ae8f7d1d 100644 --- a/app/models/package.rb +++ b/app/models/package.rb @@ -37,6 +37,10 @@ def dimensions_are_mandatory? company.parameter.varastopaikkojen_maarittely == "M" end + def translated_description(locale) + translations.find_by(kieli: locale).try(:selitetark) || pakkauskuvaus + end + private def initial_values diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 595938cc0..d39f3f4b8 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -216,7 +216,7 @@ checked: @delivery_method.sallitut_alustat.split(',') do |b| %>
<%= b.check_box %> - <%= b.label %> + <%= b.label { b.object.pakkaus + " " + b.object.translated_description(get_locale) } %>
<% end %> diff --git a/test/models/package_test.rb b/test/models/package_test.rb index e2cae39e0..84f1d5679 100644 --- a/test/models/package_test.rb +++ b/test/models/package_test.rb @@ -60,4 +60,9 @@ class PackageTest < ActiveSupport::TestCase assert_equal 100, Package.new.kayttoprosentti end + + test "translated description" do + assert_equal "Terästynnyri", @package.translated_description(:fi) + assert_equal "Steel Barrel", @package.translated_description(:en) + end end From b182a602139ee9abe16b94e0c51ada180ecac129 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Fri, 30 Oct 2015 15:42:30 +0200 Subject: [PATCH 120/189] remove unnecessary method --- app/models/delivery_method.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 8977b0ccc..1389d6486 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -143,10 +143,6 @@ class DeliveryMethod < BaseModel simple_label: 'oslap_mg' } - def permitted_packaging_options - [] - end - private def has_freight_sku? From f26fd21ddbdfc0256b65c40b428b099280d9c53b Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Mon, 2 Nov 2015 12:05:05 +0200 Subject: [PATCH 121/189] add delivery method translation model --- app/models/delivery_method.rb | 12 +++++++++++ app/models/keyword.rb | 1 + .../keyword/delivery_method_translation.rb | 12 +++++++++++ test/fixtures/keywords.yml | 8 +++++++ test/models/keyword_test.rb | 21 +++++++++++++++++-- 5 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 app/models/keyword/delivery_method_translation.rb diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 1389d6486..eba87f36b 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -11,6 +11,8 @@ class DeliveryMethod < BaseModel o.has_many :waybills, primary_key: :toimitustapa end + has_many :translations, foreign_key: :selite, class_name: 'Keyword::DeliveryMethodTranslation' + validates :aktiivinen_kuljetus_kansallisuus, :maa_maara, :sisamaan_kuljetus_kansallisuus, inclusion: { in: Country.pluck(:koodi) }, allow_blank: true validates :jarjestys, numericality: { only_integer: true }, allow_blank: true validates :lahdon_selite, :sallitut_alustat, length: { maximum: 150 } @@ -37,6 +39,8 @@ class DeliveryMethod < BaseModel float_columns :jvkulu, :erilliskasiteltavakulu, :kuljetusvakuutus, :kuluprosentti, :ulkomaanlisa, :lisakulu, :lisakulu_summa + accepts_nested_attributes_for :translations, allow_destroy: true + scope :permit_adr, -> { where(vak_kielto: '') } attr_accessor :flash_notice @@ -143,6 +147,14 @@ class DeliveryMethod < BaseModel simple_label: 'oslap_mg' } + def translated_locales + translations.map(&:kieli) + end + + def name_translated(locale) + translations.find_by(kieli: locale).try(:selitetark) || selite + end + private def has_freight_sku? diff --git a/app/models/keyword.rb b/app/models/keyword.rb index 2a8da8f8d..fdd46df31 100644 --- a/app/models/keyword.rb +++ b/app/models/keyword.rb @@ -26,6 +26,7 @@ def self.child_class_names PARAMETRI: Keyword::ProductParameterType, REVENUEREP: Keyword::RevenueExpenditure, S: Product::Status, + TOIMTAPAKV: Keyword::DeliveryMethodTranslation, TOIMTAPALP: Keyword::SortingPoint, TRY: Product::Subcategory, TULLI: Keyword::Customs, diff --git a/app/models/keyword/delivery_method_translation.rb b/app/models/keyword/delivery_method_translation.rb new file mode 100644 index 000000000..478073445 --- /dev/null +++ b/app/models/keyword/delivery_method_translation.rb @@ -0,0 +1,12 @@ +class Keyword::DeliveryMethodTranslation < Keyword + belongs_to :delivery_method, foreign_key: :selite + + validates :selitetark, presence: true + validates :kieli, inclusion: { in: Dictionary.locales } + validates :kieli, uniqueness: { scope: [:yhtio, :selite] } + + # Rails requires sti_name method to return type column (laji) value + def self.sti_name + 'TOIMTAPAKV' + end +end diff --git a/test/fixtures/keywords.yml b/test/fixtures/keywords.yml index afb39742e..6c5bb79a7 100644 --- a/test/fixtures/keywords.yml +++ b/test/fixtures/keywords.yml @@ -127,6 +127,14 @@ top_locale_en: laji: MAKSUEHTOKV <<: *DEFAULTS +deliverymethod_locale_en: + yhtio: acme + selite: <%= ActiveRecord::FixtureSet.identify(:kaukokiito) %> + selitetark: Kaukokiito Logistics + kieli: en + laji: TOIMTAPAKV + <<: *DEFAULTS + mysql_alias_1: yhtio: acme laji: MYSQLALIAS diff --git a/test/models/keyword_test.rb b/test/models/keyword_test.rb index 6d402fd5b..1b0b29617 100644 --- a/test/models/keyword_test.rb +++ b/test/models/keyword_test.rb @@ -7,39 +7,56 @@ class KeywordTest < ActiveSupport::TestCase @vat = keywords(:vat) @foreign_vat = keywords(:foreign_vat) @top_translation = keywords(:top_locale_se) + @dm_translation = keywords(:deliverymethod_locale_en) end test "fixtures are valid" do assert @vat.valid?, @vat.errors.full_messages assert @foreign_vat.valid?, @foreign_vat.errors.full_messages assert @top_translation.valid?, @top_translation.errors.full_messages + assert @dm_translation.valid?, @dm_translation.errors.full_messages assert keywords(:top_locale_en).valid? + assert keywords(:deliverymethod_locale_en).valid? end - test 'top translation relation' do + test 'translation relation' do assert TermsOfPayment, @top_translation.terms_of_payment.class + assert DeliveryMethod, @dm_translation.delivery_method.class end - test 'top translation scope' do + test 'translation scope' do # translations :kieli is scoped [:yhtio, :selite] new_translation = @top_translation.dup + dm_new_translation = @dm_translation.dup refute new_translation.valid? + refute dm_new_translation.valid? error_message = [:kieli, I18n.t('errors.messages.taken')] assert_equal error_message, new_translation.errors.first + assert_equal error_message, dm_new_translation.errors.first # changing yhtio should make it valid new_translation.yhtio = 'esto' + dm_new_translation.yhtio = 'esto' assert new_translation.valid? + assert dm_new_translation.valid? # changing selite should make it valid new_translation = @top_translation.dup new_translation.selite = 324 assert new_translation.valid? + dm_new_translation = @dm_translation.dup + dm_new_translation.selite = 324 + assert dm_new_translation.valid? + # or changing kieli should make it valid new_translation = @top_translation.dup new_translation.kieli = 'no' assert new_translation.valid? + + dm_new_translation = @dm_translation.dup + dm_new_translation.kieli = 'no' + assert dm_new_translation.valid? end end From 14648d73cf4c89cd3a021b4d4616c8c83aca00f1 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Mon, 2 Nov 2015 13:54:27 +0200 Subject: [PATCH 122/189] add translations to controller & add tests --- .../delivery_methods_controller.rb | 1 + .../delivery_method_controller_test.rb | 55 ++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index 788804c41..20e5a3110 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -68,6 +68,7 @@ def delivery_method_params :toim_maa, :toim_nimi, :toim_nimitark, :toim_osoite, :toim_ovttunnus, :toim_postino, :toim_postitp, :tulostustapa, :ulkomaanlisa, :uudet_pakkaustiedot, :vaihtoehtoinen_vak_toimitustapa, :vak_kielto, :virallinen_selite, + translations_attributes: [ :id, :kieli, :selitetark, :_destroy ], ) end diff --git a/test/controllers/administration/delivery_method_controller_test.rb b/test/controllers/administration/delivery_method_controller_test.rb index 639db935f..89f45cfa1 100644 --- a/test/controllers/administration/delivery_method_controller_test.rb +++ b/test/controllers/administration/delivery_method_controller_test.rb @@ -1,7 +1,10 @@ require 'test_helper' class Administration::DeliveryMethodsControllerTest < ActionController::TestCase - fixtures %w(delivery_methods packages) + fixtures %w( + delivery_methods + packages + ) def setup login users(:joe) @@ -103,4 +106,54 @@ def setup assert_equal "#{package_one},#{package_two}", @delivery_method.reload.sallitut_alustat end + + test "should add translations" do + login users(:bob) + + params = { + translations_attributes: { + "0" => { + kieli: 'no', + selitetark: 'Kaukokiito Transports', + } + } + } + + assert_difference 'Keyword::DeliveryMethodTranslation.count' do + patch :update, id: @delivery_method.id, delivery_method: params + end + end + + test "should update and destroy translations" do + login users(:bob) + translated = keywords :deliverymethod_locale_en + + params = { + translations_attributes: { + "0" => { + id: translated.id, + selitetark: 'a translation', + } + } + } + + assert_no_difference('Keyword::DeliveryMethodTranslation.count') do + patch :update, id: translated.delivery_method.id, delivery_method: params + end + + assert_equal 'a translation', translated.reload.selitetark + + params = { + translations_attributes: { + "0" => { + id: translated.id, + _destroy: 'true', + } + } + } + + assert_difference('Keyword::DeliveryMethodTranslation.count', -1) do + patch :update, id: translated.delivery_method.id, delivery_method: params + end + end end From 43773fcfb6d40235db3a8ada5e3e46bbccfe85bf Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Mon, 2 Nov 2015 13:55:01 +0200 Subject: [PATCH 123/189] add view partials --- .../delivery_methods/_addresses.html.erb | 30 ++ .../delivery_methods/_adr.html.erb | 10 + .../delivery_methods/_advanced.html.erb | 79 ++++++ .../delivery_methods/_basic.html.erb | 102 +++++++ .../_cargo_insurance.html.erb | 14 + .../_cash_on_delivery.html.erb | 10 + .../delivery_methods/_form.html.erb | 262 ++---------------- 7 files changed, 273 insertions(+), 234 deletions(-) create mode 100644 app/views/administration/delivery_methods/_addresses.html.erb create mode 100644 app/views/administration/delivery_methods/_adr.html.erb create mode 100644 app/views/administration/delivery_methods/_advanced.html.erb create mode 100644 app/views/administration/delivery_methods/_basic.html.erb create mode 100644 app/views/administration/delivery_methods/_cargo_insurance.html.erb create mode 100644 app/views/administration/delivery_methods/_cash_on_delivery.html.erb diff --git a/app/views/administration/delivery_methods/_addresses.html.erb b/app/views/administration/delivery_methods/_addresses.html.erb new file mode 100644 index 000000000..ff97c59ed --- /dev/null +++ b/app/views/administration/delivery_methods/_addresses.html.erb @@ -0,0 +1,30 @@ +
<%= f.label :selite %><%= f.text_field :selite %><%= f.text_field :selite, class: :large %>
<%= f.label :lahdon_selite %><%= f.text_field :lahdon_selite %><%= f.text_field :lahdon_selite, class: :large %>
<%= f.label :virallinen_selite %> <%= f.select :virallinen_selite, grouped_options_for_select(PostalOfficialLegend.options, @delivery_method.virallinen_selite), - include_blank: true %> + { include_blank: true }, class: :large %>
<%= f.label :tulostustapa %><%= f.select :tulostustapa, print_method_options %><%= f.select :tulostustapa, print_method_options, {}, class: :large %>
<%= f.label :rahtikirja %><%= f.select :rahtikirja, waybill_options %><%= f.select :rahtikirja, waybill_options, {}, class: :large %>
<%= f.label :logy_rahtikirjanumerot %><%= f.select :logy_rahtikirjanumerot, logy_waybill_number_options %><%= f.select :logy_rahtikirjanumerot, logy_waybill_number_options, {}, class: :large %>
<%= f.label :osoitelappu %><%= f.select :osoitelappu, label_options %><%= f.select :osoitelappu, label_options, {}, class: :large %>
<%= f.label :rahdinkuljettaja %> <%= f.select :rahdinkuljettaja, carrier_options, - { include_blank: t('administration.delivery_methods.edit.no_select') } %>
<%= f.label :rahti_tuotenumero %><%= f.text_field :rahti_tuotenumero %><%= f.text_field :rahti_tuotenumero, class: :large %>
<%= f.label :sopimusnro %><%= f.text_field :sopimusnro %><%= f.text_field :sopimusnro, class: :large %>
<%= f.label :rahtikirjakopio_email %><%= f.text_field :rahtikirjakopio_email %><%= f.text_field :rahtikirjakopio_email, class: :large %>
<%= f.label :jvkulu %><%= f.text_field :jvkulu %><%= f.text_field :jvkulu, class: :large %>
<%= f.label :jvkielto %><%= f.select :jvkielto, cash_on_delivery_prohibition_options %><%= f.select :jvkielto, cash_on_delivery_prohibition_options, {}, class: :large %>
<%= f.label :vak_kielto %><%= f.select :vak_kielto, adr_prohibition_options %><%= f.select :vak_kielto, adr_prohibition_options, {}, class: :large %>
<%= f.label :vaihtoehtoinen_vak_toimitustapa %><%= f.select :vaihtoehtoinen_vak_toimitustapa, alternative_adr_delivery_method_options %><%= f.select :vaihtoehtoinen_vak_toimitustapa, alternative_adr_delivery_method_options, {}, class: :large %>
<%= f.label :erikoispakkaus_kielto %><%= f.select :erikoispakkaus_kielto, special_packaging_prohibition_options %><%= f.select :erikoispakkaus_kielto, special_packaging_prohibition_options, {}, class: :large %>
<%= f.label :nouto %><%= f.select :nouto, pickup_options %><%= f.select :nouto, pickup_options, {}, class: :large %>
<%= f.label :lauantai %><%= f.select :lauantai, saturday_delivery_options %><%= f.select :lauantai, saturday_delivery_options, {}, class: :large %>
<%= f.label :kuljyksikko %><%= f.select :kuljyksikko, transport_unit_options %><%= f.select :kuljyksikko, transport_unit_options, {}, class: :large %>
<%= f.label :erilliskasiteltavakulu %><%= f.text_field :erilliskasiteltavakulu %><%= f.text_field :erilliskasiteltavakulu, class: :large %>
<%= f.label :merahti %><%= f.select :merahti, freight_contract_options %><%= f.select :merahti, freight_contract_options, {}, class: :large %>
<%= f.label :kuljetusvakuutus_tuotenumero %><%= f.text_field :kuljetusvakuutus_tuotenumero %><%= f.text_field :kuljetusvakuutus_tuotenumero, class: :large %>
<%= f.label :kuljetusvakuutus %><%= f.text_field :kuljetusvakuutus %><%= f.text_field :kuljetusvakuutus, class: :large %>
<%= f.label :kuljetusvakuutus_tyyppi %><%= f.select :kuljetusvakuutus_tyyppi, transportation_insurance_type_options %><%= f.select :kuljetusvakuutus_tyyppi, transportation_insurance_type_options, {}, class: :large %>
<%= f.label :extranet %><%= f.select :extranet, extranet_options %><%= f.select :extranet, extranet_options, {}, class: :large %>
<%= f.label :ei_pakkaamoa %><%= f.select :ei_pakkaamoa, packing_line_prohibition_options %><%= f.select :ei_pakkaamoa, packing_line_prohibition_options, {}, class: :large %>
<%= f.label :erittely %><%= f.select :erittely, waybill_specification_options %><%= f.select :erittely, waybill_specification_options, {}, class: :large %>
<%= f.label :uudet_pakkaustiedot %><%= f.select :uudet_pakkaustiedot, new_packaging_information_options %><%= f.select :uudet_pakkaustiedot, new_packaging_information_options, {}, class: :large %>
<%= f.label :lajittelupiste %> <%= f.select :lajittelupiste, sorting_point_options, - { include_blank: t('administration.delivery_methods.edit.no_select') } %>
<%= f.label :kuluprosentti %><%= f.text_field :kuluprosentti %><%= f.text_field :kuluprosentti, class: :large %>
<%= f.label :toim_ovttunnus %><%= f.text_field :toim_ovttunnus %><%= f.text_field :toim_ovttunnus, class: :large %>
<%= f.label :toim_nimi %><%= f.text_field :toim_nimi %><%= f.text_field :toim_nimi, class: :large %>
<%= f.label :toim_nimitark %><%= f.text_field :toim_nimitark %><%= f.text_field :toim_nimitark, class: :large %>
<%= f.label :toim_osoite %><%= f.text_field :toim_osoite %><%= f.text_field :toim_osoite, class: :large %>
<%= f.label :toim_postino %><%= f.text_field :toim_postino %><%= f.text_field :toim_postino, class: :large %>
<%= f.label :toim_postitp %><%= f.text_field :toim_postitp %><%= f.text_field :toim_postitp, class: :large %>
<%= f.label :toim_maa %><%= f.text_field :toim_maa %><%= f.text_field :toim_maa, class: :large %>
<%= f.label :maa_maara %><%= f.text_field :maa_maara %><%= f.text_field :maa_maara, class: :large %>
<%= f.label :sisamaan_kuljetus %><%= f.text_field :sisamaan_kuljetus %><%= f.text_field :sisamaan_kuljetus, class: :large %>
<%= f.label :sisamaan_kuljetus_kansallisuus %><%= f.text_field :sisamaan_kuljetus_kansallisuus %><%= f.text_field :sisamaan_kuljetus_kansallisuus, class: :large %>
<%= f.label :sisamaan_kuljetusmuoto %> <%= f.select :sisamaan_kuljetusmuoto, mode_of_transport_options, - { include_blank: t('administration.delivery_methods.edit.no_select') } %>
<%= f.label :kontti %> <%= f.select :kontti, container_options, - { include_blank: t('administration.delivery_methods.edit.no_select') } %>
<%= f.label :aktiivinen_kuljetus %><%= f.text_field :aktiivinen_kuljetus %><%= f.text_field :aktiivinen_kuljetus, class: :large %>
<%= f.label :aktiivinen_kuljetus_kansallisuus %><%= f.text_field :aktiivinen_kuljetus_kansallisuus %><%= f.text_field :aktiivinen_kuljetus_kansallisuus, class: :large %>
<%= f.label :kauppatapahtuman_luonne %> <%= f.select :kauppatapahtuman_luonne, nature_of_transaction_options, - { include_blank: t('administration.delivery_methods.edit.no_select') } %>
<%= f.label :kuljetusmuoto %> <%= f.select :kuljetusmuoto, mode_of_transport_options, - { include_blank: t('administration.delivery_methods.edit.no_select') } %>
<%= f.label :poistumistoimipaikka_koodi %> <%= f.select :poistumistoimipaikka_koodi, customs_options, - { include_blank: t('administration.delivery_methods.edit.no_select') } %>
<%= f.label :ulkomaanlisa %><%= f.text_field :ulkomaanlisa %><%= f.text_field :ulkomaanlisa, class: :large %>
<%= f.label :sallitut_maat %><%= f.text_field :sallitut_maat %><%= f.text_field :sallitut_maat, class: :large %>
<%= f.label :sallitut_alustat %><%= f.text_field :sallitut_alustat %><%= f.text_field :sallitut_alustat, class: :large %>
<%= f.label :lisakulu %><%= f.text_field :lisakulu %><%= f.text_field :lisakulu, class: :large %>
<%= f.label :lisakulu_summa %><%= f.text_field :lisakulu_summa %><%= f.text_field :lisakulu_summa, class: :large %>
<%= f.label :jarjestys %><%= f.text_field :jarjestys %><%= f.text_field :jarjestys, class: :large %>
<%= f.label :sallitut_alustat %><%= f.text_field :sallitut_alustat, class: :large %> + <%= f.collection_check_boxes :sallitut_alustat, Package.all, :tunnus, :pakkauskuvaus do |b| %> +
+ <%= b.check_box %> + <%= b.label %> +
+ <% end %> +
<%= f.label :lisakulu %>
<%= f.label :kontti %><%= f.select :kontti, container_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %><%= f.select :kontti, container_options, {}, class: :large %>
<%= f.label :aktiivinen_kuljetus %>
<%= f.label :sallitut_alustat %> - <%= f.collection_check_boxes :sallitut_alustat, Package.all, :tunnus, :pakkauskuvaus do |b| %> + <%= f.collection_check_boxes :sallitut_alustat, Package.all, :tunnus, :pakkauskuvaus, + checked: @delivery_method.sallitut_alustat.split(',') do |b| %>
<%= b.check_box %> <%= b.label %> From 6da3a690d07d62a5bf716f32841f1fed4680c62a Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Thu, 17 Sep 2015 16:16:38 +0300 Subject: [PATCH 080/189] fix typo --- config/locales/fi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 5fbca5198..3eeb629c0 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -209,7 +209,7 @@ fi: nouto: Nouto osoitelappu: Osoitelapputyyppi poistumistoimipaikka_koodi: Oletus poistumistoimipaikan koodi - rahdinkuljettaja: Kuljetusyhtiä + rahdinkuljettaja: Kuljetusyhtiö rahti_tuotenumero: Rahtiveloitus tuotenumero rahtikirja: Rahtikirjatyyppi rahtikirjakopio_email: From aca96ba985c43f2ce471e0e7fae27b07f8a0b5c8 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 18 Sep 2015 09:47:40 +0300 Subject: [PATCH 081/189] fix default option --- test/classes/postal_official_legend_test.rb | 2 +- test/helpers/delivery_method_helper_test.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/classes/postal_official_legend_test.rb b/test/classes/postal_official_legend_test.rb index f09cc5b05..8a17997cf 100644 --- a/test/classes/postal_official_legend_test.rb +++ b/test/classes/postal_official_legend_test.rb @@ -3,6 +3,6 @@ class PostalOfficialLegendTest < ActiveSupport::TestCase test 'should get proper legend' do legends = PostalOfficialLegend.options - assert_equal 'Itella Express City 00', legends.second.second.first.first + assert_equal Array, legends.class end end diff --git a/test/helpers/delivery_method_helper_test.rb b/test/helpers/delivery_method_helper_test.rb index 4805a7360..0a2bd5d7a 100644 --- a/test/helpers/delivery_method_helper_test.rb +++ b/test/helpers/delivery_method_helper_test.rb @@ -38,9 +38,9 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated freight contract options valid for collection" do assert freight_contract_options.is_a? Array - text = I18n.t 'administration.delivery_methods.freight_contract_options.sender_freight_contract' + text = I18n.t 'administration.delivery_methods.freight_contract_options.receiver_freight_contract' assert_equal text, freight_contract_options.first.first - assert_equal 'sender_freight_contract', freight_contract_options.first.second + assert_equal 'receiver_freight_contract', freight_contract_options.first.second end test "returns translated logy waybill number options valid for collection" do @@ -62,9 +62,9 @@ class DeliveryMethodHelperTest < ActionView::TestCase test "returns translated container options valid for collection" do assert container_options.is_a? Array - text = I18n.t 'administration.delivery_methods.container_options.includes_container' + text = I18n.t 'administration.delivery_methods.container_options.not_including_container' assert_equal text, container_options.first.first - assert_equal 'includes_container', container_options.first.second + assert_equal 'not_including_container', container_options.first.second end test "returns translated cash on delivery prohibition options valid for collection" do From be1c3827e8a44749e429e4f2cb01a5964751ebe9 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 18 Sep 2015 09:52:30 +0300 Subject: [PATCH 082/189] add blank label --- app/views/administration/delivery_methods/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index b36a3fd4d..04ff72983 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -16,7 +16,7 @@
<%= f.select :virallinen_selite, grouped_options_for_select(PostalOfficialLegend.options, @delivery_method.virallinen_selite), - { include_blank: true }, class: :large %> + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %>
<%= f.select :virallinen_selite, grouped_options_for_select(PostalOfficialLegend.options, @delivery_method.virallinen_selite), - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %> + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :tulostustapa %><%= f.select :tulostustapa, print_method_options, {}, class: :large %><%= f.select :tulostustapa, print_method_options, {}, class: 'chosen-select' %>
<%= f.label :rahtikirja %><%= f.select :rahtikirja, waybill_options, {}, class: :large %><%= f.select :rahtikirja, waybill_options, {}, class: 'chosen-select' %>
<%= f.label :logy_rahtikirjanumerot %><%= f.select :logy_rahtikirjanumerot, logy_waybill_number_options, {}, class: :large %><%= f.select :logy_rahtikirjanumerot, logy_waybill_number_options, {}, class: 'chosen-select' %>
<%= f.label :osoitelappu %><%= f.select :osoitelappu, label_options, {}, class: :large %><%= f.select :osoitelappu, label_options, {}, class: 'chosen-select' %>
<%= f.label :rahdinkuljettaja %> <%= f.select :rahdinkuljettaja, carrier_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %>
<%= f.label :rahti_tuotenumero %>
<%= f.label :jvkielto %><%= f.select :jvkielto, cash_on_delivery_prohibition_options, {}, class: :large %><%= f.select :jvkielto, cash_on_delivery_prohibition_options, {}, class: 'chosen-select' %>
<%= f.label :vak_kielto %><%= f.select :vak_kielto, adr_prohibition_options, {}, class: :large %><%= f.select :vak_kielto, adr_prohibition_options, {}, class: 'chosen-select' %>
<%= f.label :vaihtoehtoinen_vak_toimitustapa %><%= f.select :vaihtoehtoinen_vak_toimitustapa, alternative_adr_delivery_method_options, {}, class: :large %><%= f.select :vaihtoehtoinen_vak_toimitustapa, alternative_adr_delivery_method_options, {}, class: 'chosen-select' %>
<%= f.label :erikoispakkaus_kielto %><%= f.select :erikoispakkaus_kielto, special_packaging_prohibition_options, {}, class: :large %><%= f.select :erikoispakkaus_kielto, special_packaging_prohibition_options, {}, class: 'chosen-select' %>
<%= f.label :nouto %><%= f.select :nouto, pickup_options, {}, class: :large %><%= f.select :nouto, pickup_options, {}, class: 'chosen-select' %>
<%= f.label :lauantai %><%= f.select :lauantai, saturday_delivery_options, {}, class: :large %><%= f.select :lauantai, saturday_delivery_options, {}, class: 'chosen-select' %>
<%= f.label :kuljyksikko %><%= f.select :kuljyksikko, transport_unit_options, {}, class: :large %><%= f.select :kuljyksikko, transport_unit_options, {}, class: 'chosen-select' %>
<%= f.label :erilliskasiteltavakulu %>
<%= f.label :merahti %><%= f.select :merahti, freight_contract_options, {}, class: :large %><%= f.select :merahti, freight_contract_options, {}, class: 'chosen-select' %>
<%= f.label :kuljetusvakuutus_tuotenumero %>
<%= f.label :kuljetusvakuutus_tyyppi %><%= f.select :kuljetusvakuutus_tyyppi, transportation_insurance_type_options, {}, class: :large %><%= f.select :kuljetusvakuutus_tyyppi, transportation_insurance_type_options, {}, class: 'chosen-select' %>
<%= f.label :extranet %><%= f.select :extranet, extranet_options, {}, class: :large %><%= f.select :extranet, extranet_options, {}, class: 'chosen-select' %>
<%= f.label :ei_pakkaamoa %><%= f.select :ei_pakkaamoa, packing_line_prohibition_options, {}, class: :large %><%= f.select :ei_pakkaamoa, packing_line_prohibition_options, {}, class: 'chosen-select' %>
<%= f.label :erittely %><%= f.select :erittely, waybill_specification_options, {}, class: :large %><%= f.select :erittely, waybill_specification_options, {}, class: 'chosen-select' %>
<%= f.label :uudet_pakkaustiedot %><%= f.select :uudet_pakkaustiedot, new_packaging_information_options, {}, class: :large %><%= f.select :uudet_pakkaustiedot, new_packaging_information_options, {}, class: 'chosen-select' %>
<%= f.label :lajittelupiste %> <%= f.select :lajittelupiste, sorting_point_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %>
<%= f.label :kuluprosentti %>
<%= f.label :sisamaan_kuljetusmuoto %> <%= f.select :sisamaan_kuljetusmuoto, mode_of_transport_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %>
<%= f.label :kontti %><%= f.select :kontti, container_options, {}, class: :large %><%= f.select :kontti, container_options, {}, class: 'chosen-select' %>
<%= f.label :aktiivinen_kuljetus %>
<%= f.label :kauppatapahtuman_luonne %> <%= f.select :kauppatapahtuman_luonne, nature_of_transaction_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %>
<%= f.label :kuljetusmuoto %> <%= f.select :kuljetusmuoto, mode_of_transport_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %>
<%= f.label :poistumistoimipaikka_koodi %> <%= f.select :poistumistoimipaikka_koodi, customs_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: :large %>
<%= f.label :ulkomaanlisa %>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%= f.label :toim_ovttunnus %><%= f.text_field :toim_ovttunnus, class: :large %>
<%= f.label :toim_nimi %><%= f.text_field :toim_nimi, class: :large %>
<%= f.label :toim_nimitark %><%= f.text_field :toim_nimitark, class: :large %>
<%= f.label :toim_osoite %><%= f.text_field :toim_osoite, class: :large %>
<%= f.label :toim_postino %><%= f.text_field :toim_postino, class: :large %>
<%= f.label :toim_postitp %><%= f.text_field :toim_postitp, class: :large %>
<%= f.label :toim_maa %><%= f.text_field :toim_maa, class: :large %>
diff --git a/app/views/administration/delivery_methods/_adr.html.erb b/app/views/administration/delivery_methods/_adr.html.erb new file mode 100644 index 000000000..688e333ae --- /dev/null +++ b/app/views/administration/delivery_methods/_adr.html.erb @@ -0,0 +1,10 @@ + + + + + + + + + +
<%= f.label :vak_kielto %><%= f.select :vak_kielto, adr_prohibition_options, {}, class: 'chosen-select' %>
<%= f.label :vaihtoehtoinen_vak_toimitustapa %><%= f.select :vaihtoehtoinen_vak_toimitustapa, alternative_adr_delivery_method_options, {}, class: 'chosen-select' %>
diff --git a/app/views/administration/delivery_methods/_advanced.html.erb b/app/views/administration/delivery_methods/_advanced.html.erb new file mode 100644 index 000000000..8c2dc3565 --- /dev/null +++ b/app/views/administration/delivery_methods/_advanced.html.erb @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%= f.label :uudet_pakkaustiedot %><%= f.select :uudet_pakkaustiedot, new_packaging_information_options, {}, class: 'chosen-select' %>
<%= f.label :lajittelupiste %><%= f.select :lajittelupiste, sorting_point_options, + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :maa_maara %><%= f.text_field :maa_maara, class: :large %>
<%= f.label :sisamaan_kuljetus %><%= f.text_field :sisamaan_kuljetus, class: :large %>
<%= f.label :sisamaan_kuljetus_kansallisuus %><%= f.text_field :sisamaan_kuljetus_kansallisuus, class: :large %>
<%= f.label :sisamaan_kuljetusmuoto %><%= f.select :sisamaan_kuljetusmuoto, mode_of_transport_options, + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :kontti %><%= f.select :kontti, container_options, {}, class: 'chosen-select' %>
<%= f.label :aktiivinen_kuljetus %><%= f.text_field :aktiivinen_kuljetus, class: :large %>
<%= f.label :aktiivinen_kuljetus_kansallisuus %><%= f.text_field :aktiivinen_kuljetus_kansallisuus, class: :large %>
<%= f.label :kauppatapahtuman_luonne %><%= f.select :kauppatapahtuman_luonne, nature_of_transaction_options, + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :kuljetusmuoto %><%= f.select :kuljetusmuoto, mode_of_transport_options, + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :poistumistoimipaikka_koodi %><%= f.select :poistumistoimipaikka_koodi, customs_options, + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :ulkomaanlisa %><%= f.text_field :ulkomaanlisa, class: :large %>
<%= f.label :sallitut_alustat %> + <%= f.collection_check_boxes :sallitut_alustat, Package.all, :tunnus, :pakkauskuvaus, + checked: @delivery_method.sallitut_alustat.split(',') do |b| %> +
+ <%= b.check_box %> + <%= b.label { b.object.pakkaus + " " + b.object.translated_description(get_locale) } %> +
+ <% end %> +
<%= f.label :lisakulu %><%= f.text_field :lisakulu, class: :large %>
<%= f.label :lisakulu_summa %><%= f.text_field :lisakulu_summa, class: :large %>
diff --git a/app/views/administration/delivery_methods/_basic.html.erb b/app/views/administration/delivery_methods/_basic.html.erb new file mode 100644 index 000000000..e3d2546b6 --- /dev/null +++ b/app/views/administration/delivery_methods/_basic.html.erb @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%= render 'administration/resource_timestamps_and_users', resource: @delivery_method %> + +
<%= f.label :selite %><%= f.text_field :selite, class: :large %>
<%= f.label :lahdon_selite %><%= f.text_field :lahdon_selite, class: :large %>
<%= f.label :virallinen_selite %> + <%= f.select :virallinen_selite, + grouped_options_for_select(PostalOfficialLegend.options, @delivery_method.virallinen_selite), + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %> +
<%= f.label :tulostustapa %><%= f.select :tulostustapa, print_method_options, {}, class: 'chosen-select' %>
<%= f.label :rahtikirja %><%= f.select :rahtikirja, waybill_options, {}, class: 'chosen-select' %>
<%= f.label :logy_rahtikirjanumerot %><%= f.select :logy_rahtikirjanumerot, logy_waybill_number_options, {}, class: 'chosen-select' %>
<%= f.label :osoitelappu %><%= f.select :osoitelappu, label_options, {}, class: 'chosen-select' %>
<%= f.label :rahdinkuljettaja %><%= f.select :rahdinkuljettaja, carrier_options, + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :rahti_tuotenumero %><%= f.text_field :rahti_tuotenumero, class: :large %>
<%= f.label :sopimusnro %><%= f.text_field :sopimusnro, class: :large %>
<%= f.label :rahtikirjakopio_email %><%= f.text_field :rahtikirjakopio_email, class: :large %>
<%= f.label :erikoispakkaus_kielto %><%= f.select :erikoispakkaus_kielto, special_packaging_prohibition_options, {}, class: 'chosen-select' %>
<%= f.label :nouto %><%= f.select :nouto, pickup_options, {}, class: 'chosen-select' %>
<%= f.label :lauantai %><%= f.select :lauantai, saturday_delivery_options, {}, class: 'chosen-select' %>
<%= f.label :kuljyksikko %><%= f.select :kuljyksikko, transport_unit_options, {}, class: 'chosen-select' %>
<%= f.label :erilliskasiteltavakulu %><%= f.text_field :erilliskasiteltavakulu, class: :large %>
<%= f.label :merahti %><%= f.select :merahti, freight_contract_options, {}, class: 'chosen-select' %>
<%= f.label :extranet %><%= f.select :extranet, extranet_options, {}, class: 'chosen-select' %>
<%= f.label :ei_pakkaamoa %><%= f.select :ei_pakkaamoa, packing_line_prohibition_options, {}, class: 'chosen-select' %>
<%= f.label :erittely %><%= f.select :erittely, waybill_specification_options, {}, class: 'chosen-select' %>
<%= f.label :kuluprosentti %><%= f.text_field :kuluprosentti, class: :large %>
<%= f.label :sallitut_maat %><%= f.text_field :sallitut_maat, class: :large %>
<%= f.label :jarjestys %><%= f.text_field :jarjestys, class: :large %>
diff --git a/app/views/administration/delivery_methods/_cargo_insurance.html.erb b/app/views/administration/delivery_methods/_cargo_insurance.html.erb new file mode 100644 index 000000000..1104d5811 --- /dev/null +++ b/app/views/administration/delivery_methods/_cargo_insurance.html.erb @@ -0,0 +1,14 @@ + + + + + + + + + + + + + +
<%= f.label :kuljetusvakuutus_tuotenumero %><%= f.text_field :kuljetusvakuutus_tuotenumero, class: :large %>
<%= f.label :kuljetusvakuutus %><%= f.text_field :kuljetusvakuutus, class: :large %>
<%= f.label :kuljetusvakuutus_tyyppi %><%= f.select :kuljetusvakuutus_tyyppi, transportation_insurance_type_options, {}, class: 'chosen-select' %>
diff --git a/app/views/administration/delivery_methods/_cash_on_delivery.html.erb b/app/views/administration/delivery_methods/_cash_on_delivery.html.erb new file mode 100644 index 000000000..05a4b72bc --- /dev/null +++ b/app/views/administration/delivery_methods/_cash_on_delivery.html.erb @@ -0,0 +1,10 @@ + + + + + + + + + +
<%= f.label :jvkulu %><%= f.text_field :jvkulu, class: :large %>
<%= f.label :jvkielto %><%= f.select :jvkielto, cash_on_delivery_prohibition_options, {}, class: 'chosen-select' %>
diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index d39f3f4b8..3be55376a 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -2,242 +2,36 @@ <%= form_for @delivery_method do |f| %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+ <%= render 'basic', f: f %> +
- <%= render 'administration/resource_timestamps_and_users', resource: @delivery_method %> +
+ <%= render 'administration/translations', f: f %> +
-
<%= f.label :selite %><%= f.text_field :selite, class: :large %>
<%= f.label :lahdon_selite %><%= f.text_field :lahdon_selite, class: :large %>
<%= f.label :virallinen_selite %> - <%= f.select :virallinen_selite, - grouped_options_for_select(PostalOfficialLegend.options, @delivery_method.virallinen_selite), - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %> -
<%= f.label :tulostustapa %><%= f.select :tulostustapa, print_method_options, {}, class: 'chosen-select' %>
<%= f.label :rahtikirja %><%= f.select :rahtikirja, waybill_options, {}, class: 'chosen-select' %>
<%= f.label :logy_rahtikirjanumerot %><%= f.select :logy_rahtikirjanumerot, logy_waybill_number_options, {}, class: 'chosen-select' %>
<%= f.label :osoitelappu %><%= f.select :osoitelappu, label_options, {}, class: 'chosen-select' %>
<%= f.label :rahdinkuljettaja %><%= f.select :rahdinkuljettaja, carrier_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :rahti_tuotenumero %><%= f.text_field :rahti_tuotenumero, class: :large %>
<%= f.label :sopimusnro %><%= f.text_field :sopimusnro, class: :large %>
<%= f.label :rahtikirjakopio_email %><%= f.text_field :rahtikirjakopio_email, class: :large %>
<%= f.label :jvkulu %><%= f.text_field :jvkulu, class: :large %>
<%= f.label :jvkielto %><%= f.select :jvkielto, cash_on_delivery_prohibition_options, {}, class: 'chosen-select' %>
<%= f.label :vak_kielto %><%= f.select :vak_kielto, adr_prohibition_options, {}, class: 'chosen-select' %>
<%= f.label :vaihtoehtoinen_vak_toimitustapa %><%= f.select :vaihtoehtoinen_vak_toimitustapa, alternative_adr_delivery_method_options, {}, class: 'chosen-select' %>
<%= f.label :erikoispakkaus_kielto %><%= f.select :erikoispakkaus_kielto, special_packaging_prohibition_options, {}, class: 'chosen-select' %>
<%= f.label :nouto %><%= f.select :nouto, pickup_options, {}, class: 'chosen-select' %>
<%= f.label :lauantai %><%= f.select :lauantai, saturday_delivery_options, {}, class: 'chosen-select' %>
<%= f.label :kuljyksikko %><%= f.select :kuljyksikko, transport_unit_options, {}, class: 'chosen-select' %>
<%= f.label :erilliskasiteltavakulu %><%= f.text_field :erilliskasiteltavakulu, class: :large %>
<%= f.label :merahti %><%= f.select :merahti, freight_contract_options, {}, class: 'chosen-select' %>
<%= f.label :kuljetusvakuutus_tuotenumero %><%= f.text_field :kuljetusvakuutus_tuotenumero, class: :large %>
<%= f.label :kuljetusvakuutus %><%= f.text_field :kuljetusvakuutus, class: :large %>
<%= f.label :kuljetusvakuutus_tyyppi %><%= f.select :kuljetusvakuutus_tyyppi, transportation_insurance_type_options, {}, class: 'chosen-select' %>
<%= f.label :extranet %><%= f.select :extranet, extranet_options, {}, class: 'chosen-select' %>
<%= f.label :ei_pakkaamoa %><%= f.select :ei_pakkaamoa, packing_line_prohibition_options, {}, class: 'chosen-select' %>
<%= f.label :erittely %><%= f.select :erittely, waybill_specification_options, {}, class: 'chosen-select' %>
<%= f.label :uudet_pakkaustiedot %><%= f.select :uudet_pakkaustiedot, new_packaging_information_options, {}, class: 'chosen-select' %>
<%= f.label :lajittelupiste %><%= f.select :lajittelupiste, sorting_point_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :kuluprosentti %><%= f.text_field :kuluprosentti, class: :large %>
<%= f.label :toim_ovttunnus %><%= f.text_field :toim_ovttunnus, class: :large %>
<%= f.label :toim_nimi %><%= f.text_field :toim_nimi, class: :large %>
<%= f.label :toim_nimitark %><%= f.text_field :toim_nimitark, class: :large %>
<%= f.label :toim_osoite %><%= f.text_field :toim_osoite, class: :large %>
<%= f.label :toim_postino %><%= f.text_field :toim_postino, class: :large %>
<%= f.label :toim_postitp %><%= f.text_field :toim_postitp, class: :large %>
<%= f.label :toim_maa %><%= f.text_field :toim_maa, class: :large %>
<%= f.label :maa_maara %><%= f.text_field :maa_maara, class: :large %>
<%= f.label :sisamaan_kuljetus %><%= f.text_field :sisamaan_kuljetus, class: :large %>
<%= f.label :sisamaan_kuljetus_kansallisuus %><%= f.text_field :sisamaan_kuljetus_kansallisuus, class: :large %>
<%= f.label :sisamaan_kuljetusmuoto %><%= f.select :sisamaan_kuljetusmuoto, mode_of_transport_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :kontti %><%= f.select :kontti, container_options, {}, class: 'chosen-select' %>
<%= f.label :aktiivinen_kuljetus %><%= f.text_field :aktiivinen_kuljetus, class: :large %>
<%= f.label :aktiivinen_kuljetus_kansallisuus %><%= f.text_field :aktiivinen_kuljetus_kansallisuus, class: :large %>
<%= f.label :kauppatapahtuman_luonne %><%= f.select :kauppatapahtuman_luonne, nature_of_transaction_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :kuljetusmuoto %><%= f.select :kuljetusmuoto, mode_of_transport_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :poistumistoimipaikka_koodi %><%= f.select :poistumistoimipaikka_koodi, customs_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :ulkomaanlisa %><%= f.text_field :ulkomaanlisa, class: :large %>
<%= f.label :sallitut_maat %><%= f.text_field :sallitut_maat, class: :large %>
<%= f.label :sallitut_alustat %> - <%= f.collection_check_boxes :sallitut_alustat, Package.all, :tunnus, :pakkauskuvaus, - checked: @delivery_method.sallitut_alustat.split(',') do |b| %> -
- <%= b.check_box %> - <%= b.label { b.object.pakkaus + " " + b.object.translated_description(get_locale) } %> -
- <% end %> -
<%= f.label :lisakulu %><%= f.text_field :lisakulu, class: :large %>
<%= f.label :lisakulu_summa %><%= f.text_field :lisakulu_summa, class: :large %>
<%= f.label :jarjestys %><%= f.text_field :jarjestys, class: :large %>
+
+ <%= render 'addresses', f: f %> +
- <%= render 'administration/actions', f: f %> +
+ <%= render 'cash_on_delivery', f: f %> +
+ +
+ <%= render 'adr', f: f %> +
+ +
+ <%= render 'cargo_insurance', f: f %> +
+ +
+ <%= render 'advanced', f: f %> +
+ +
+ <%= render 'administration/actions', f: f %> +
<% end %> From f6eafd26c22e20173e6dc99412fca08a9a220dc5 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Mon, 2 Nov 2015 14:09:33 +0200 Subject: [PATCH 124/189] fix view partials --- .../delivery_methods/_addresses.html.erb | 2 +- .../delivery_methods/_advanced.html.erb | 2 +- .../delivery_methods/_cargo_insurance.html.erb | 2 +- .../administration/delivery_methods/_form.html.erb | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/views/administration/delivery_methods/_addresses.html.erb b/app/views/administration/delivery_methods/_addresses.html.erb index ff97c59ed..842f1c64e 100644 --- a/app/views/administration/delivery_methods/_addresses.html.erb +++ b/app/views/administration/delivery_methods/_addresses.html.erb @@ -1,4 +1,4 @@ - +
diff --git a/app/views/administration/delivery_methods/_advanced.html.erb b/app/views/administration/delivery_methods/_advanced.html.erb index 8c2dc3565..75911a418 100644 --- a/app/views/administration/delivery_methods/_advanced.html.erb +++ b/app/views/administration/delivery_methods/_advanced.html.erb @@ -1,4 +1,4 @@ -
<%= f.label :toim_ovttunnus %> <%= f.text_field :toim_ovttunnus, class: :large %>
+
diff --git a/app/views/administration/delivery_methods/_cargo_insurance.html.erb b/app/views/administration/delivery_methods/_cargo_insurance.html.erb index 1104d5811..1763d90bc 100644 --- a/app/views/administration/delivery_methods/_cargo_insurance.html.erb +++ b/app/views/administration/delivery_methods/_cargo_insurance.html.erb @@ -1,4 +1,4 @@ -
<%= f.label :uudet_pakkaustiedot %> <%= f.select :uudet_pakkaustiedot, new_packaging_information_options, {}, class: 'chosen-select' %>
+
diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 3be55376a..6cbf19b8a 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -6,11 +6,7 @@ <%= render 'basic', f: f %> -
- <%= render 'administration/translations', f: f %> -
- -
+
<%= render 'addresses', f: f %>
@@ -22,14 +18,18 @@ <%= render 'adr', f: f %>
-
+
<%= render 'cargo_insurance', f: f %>
-
+
<%= render 'advanced', f: f %>
+
+ <%= render 'administration/translations', f: f %> +
+
<%= render 'administration/actions', f: f %>
From 79546954496df289625777dab1513ebf1b96db63 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 3 Nov 2015 12:47:44 +0200 Subject: [PATCH 125/189] add departures --- app/models/delivery_method.rb | 3 ++- app/models/delivery_method/departure.rb | 8 ++++++++ test/fixtures/delivery_method/departures.yml | 13 +++++++++++++ test/models/delivery_method_test.rb | 9 ++++++++- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 app/models/delivery_method/departure.rb create mode 100644 test/fixtures/delivery_method/departures.yml diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index eba87f36b..13e6e2650 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -9,9 +9,10 @@ class DeliveryMethod < BaseModel o.has_many :sorting_point, primary_key: :lajittelupiste, class_name: 'Keyword::SortingPoint' o.has_many :customer_keywords, primary_key: :avainsana o.has_many :waybills, primary_key: :toimitustapa + o.has_many :translations, class_name: 'Keyword::DeliveryMethodTranslation' end - has_many :translations, foreign_key: :selite, class_name: 'Keyword::DeliveryMethodTranslation' + has_many :departures, foreign_key: :liitostunnus, class_name: 'DeliveryMethod::Departure' validates :aktiivinen_kuljetus_kansallisuus, :maa_maara, :sisamaan_kuljetus_kansallisuus, inclusion: { in: Country.pluck(:koodi) }, allow_blank: true validates :jarjestys, numericality: { only_integer: true }, allow_blank: true diff --git a/app/models/delivery_method/departure.rb b/app/models/delivery_method/departure.rb new file mode 100644 index 000000000..1c3e5018d --- /dev/null +++ b/app/models/delivery_method/departure.rb @@ -0,0 +1,8 @@ +class DeliveryMethod::Departure < BaseModel + belongs_to :delivery_method, foreign_key: :liitostunnus + + validates :kerailyn_aloitusaika, format: { with: /\d{2}:\d{2}:\d{2}/i } + + self.table_name = :toimitustavan_lahdot + self.primary_key = :tunnus +end diff --git a/test/fixtures/delivery_method/departures.yml b/test/fixtures/delivery_method/departures.yml new file mode 100644 index 000000000..8e64089e1 --- /dev/null +++ b/test/fixtures/delivery_method/departures.yml @@ -0,0 +1,13 @@ +DEFAULTS: &DEFAULTS + yhtio: acme + luontiaika: <%= Time.now %> + laatija: joe + muutospvm: <%= Time.now %> + muuttaja: joe + +# Ostotilaus +departure_one: + liitostunnus: <%= ActiveRecord::FixtureSet.identify(:kaukokiito) %> + kerailyn_aloitusaika: '12:00:00' + alkupvm: 0 + <<: *DEFAULTS diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 508be933c..1ec8bc97b 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -4,6 +4,7 @@ class DeliveryMethodTest < ActiveSupport::TestCase fixtures %w( customer_keywords customers + delivery_method/departures delivery_methods freight_contracts freights @@ -22,11 +23,13 @@ class DeliveryMethodTest < ActiveSupport::TestCase ) def setup - @delivery_method = delivery_methods(:kaukokiito) + @delivery_method = delivery_methods :kaukokiito + @departure = delivery_method_departures :departure_one end test "fixtures should be valid" do assert @delivery_method.valid?, @delivery_method.errors.messages + assert @departure.valid?, @departure.errors.full_messages end test "selite should be unique" do @@ -197,4 +200,8 @@ def setup # waybill assert_equal 'Kaukokiito3', waybill.reload.toimitustapa end + + test 'should have departure' do + assert_equal 1, @delivery_method.departures.count + end end From 3a891d9a241db9abc66f93a6c953898a9a2b2968 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 3 Nov 2015 13:08:15 +0200 Subject: [PATCH 126/189] remove partials --- .../delivery_methods/_addresses.html.erb | 30 ---- .../delivery_methods/_adr.html.erb | 10 -- .../delivery_methods/_advanced.html.erb | 79 ----------- .../delivery_methods/_basic.html.erb | 133 ++++++++++++++++++ .../_cargo_insurance.html.erb | 14 -- .../_cash_on_delivery.html.erb | 10 -- .../delivery_methods/_form.html.erb | 20 --- 7 files changed, 133 insertions(+), 163 deletions(-) delete mode 100644 app/views/administration/delivery_methods/_addresses.html.erb delete mode 100644 app/views/administration/delivery_methods/_adr.html.erb delete mode 100644 app/views/administration/delivery_methods/_advanced.html.erb delete mode 100644 app/views/administration/delivery_methods/_cargo_insurance.html.erb delete mode 100644 app/views/administration/delivery_methods/_cash_on_delivery.html.erb diff --git a/app/views/administration/delivery_methods/_addresses.html.erb b/app/views/administration/delivery_methods/_addresses.html.erb deleted file mode 100644 index 842f1c64e..000000000 --- a/app/views/administration/delivery_methods/_addresses.html.erb +++ /dev/null @@ -1,30 +0,0 @@ -
<%= f.label :kuljetusvakuutus_tuotenumero %> <%= f.text_field :kuljetusvakuutus_tuotenumero, class: :large %>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<%= f.label :toim_ovttunnus %><%= f.text_field :toim_ovttunnus, class: :large %>
<%= f.label :toim_nimi %><%= f.text_field :toim_nimi, class: :large %>
<%= f.label :toim_nimitark %><%= f.text_field :toim_nimitark, class: :large %>
<%= f.label :toim_osoite %><%= f.text_field :toim_osoite, class: :large %>
<%= f.label :toim_postino %><%= f.text_field :toim_postino, class: :large %>
<%= f.label :toim_postitp %><%= f.text_field :toim_postitp, class: :large %>
<%= f.label :toim_maa %><%= f.text_field :toim_maa, class: :large %>
diff --git a/app/views/administration/delivery_methods/_adr.html.erb b/app/views/administration/delivery_methods/_adr.html.erb deleted file mode 100644 index 688e333ae..000000000 --- a/app/views/administration/delivery_methods/_adr.html.erb +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - -
<%= f.label :vak_kielto %><%= f.select :vak_kielto, adr_prohibition_options, {}, class: 'chosen-select' %>
<%= f.label :vaihtoehtoinen_vak_toimitustapa %><%= f.select :vaihtoehtoinen_vak_toimitustapa, alternative_adr_delivery_method_options, {}, class: 'chosen-select' %>
diff --git a/app/views/administration/delivery_methods/_advanced.html.erb b/app/views/administration/delivery_methods/_advanced.html.erb deleted file mode 100644 index 75911a418..000000000 --- a/app/views/administration/delivery_methods/_advanced.html.erb +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<%= f.label :uudet_pakkaustiedot %><%= f.select :uudet_pakkaustiedot, new_packaging_information_options, {}, class: 'chosen-select' %>
<%= f.label :lajittelupiste %><%= f.select :lajittelupiste, sorting_point_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :maa_maara %><%= f.text_field :maa_maara, class: :large %>
<%= f.label :sisamaan_kuljetus %><%= f.text_field :sisamaan_kuljetus, class: :large %>
<%= f.label :sisamaan_kuljetus_kansallisuus %><%= f.text_field :sisamaan_kuljetus_kansallisuus, class: :large %>
<%= f.label :sisamaan_kuljetusmuoto %><%= f.select :sisamaan_kuljetusmuoto, mode_of_transport_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :kontti %><%= f.select :kontti, container_options, {}, class: 'chosen-select' %>
<%= f.label :aktiivinen_kuljetus %><%= f.text_field :aktiivinen_kuljetus, class: :large %>
<%= f.label :aktiivinen_kuljetus_kansallisuus %><%= f.text_field :aktiivinen_kuljetus_kansallisuus, class: :large %>
<%= f.label :kauppatapahtuman_luonne %><%= f.select :kauppatapahtuman_luonne, nature_of_transaction_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :kuljetusmuoto %><%= f.select :kuljetusmuoto, mode_of_transport_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :poistumistoimipaikka_koodi %><%= f.select :poistumistoimipaikka_koodi, customs_options, - { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %>
<%= f.label :ulkomaanlisa %><%= f.text_field :ulkomaanlisa, class: :large %>
<%= f.label :sallitut_alustat %> - <%= f.collection_check_boxes :sallitut_alustat, Package.all, :tunnus, :pakkauskuvaus, - checked: @delivery_method.sallitut_alustat.split(',') do |b| %> -
- <%= b.check_box %> - <%= b.label { b.object.pakkaus + " " + b.object.translated_description(get_locale) } %> -
- <% end %> -
<%= f.label :lisakulu %><%= f.text_field :lisakulu, class: :large %>
<%= f.label :lisakulu_summa %><%= f.text_field :lisakulu_summa, class: :large %>
diff --git a/app/views/administration/delivery_methods/_basic.html.erb b/app/views/administration/delivery_methods/_basic.html.erb index e3d2546b6..d64458b8d 100644 --- a/app/views/administration/delivery_methods/_basic.html.erb +++ b/app/views/administration/delivery_methods/_basic.html.erb @@ -48,6 +48,62 @@ <%= f.label :rahtikirjakopio_email %> <%= f.text_field :rahtikirjakopio_email, class: :large %> + + <%= f.label :toim_ovttunnus %> + <%= f.text_field :toim_ovttunnus, class: :large %> + + + <%= f.label :toim_nimi %> + <%= f.text_field :toim_nimi, class: :large %> + + + <%= f.label :toim_nimitark %> + <%= f.text_field :toim_nimitark, class: :large %> + + + <%= f.label :toim_osoite %> + <%= f.text_field :toim_osoite, class: :large %> + + + <%= f.label :toim_postino %> + <%= f.text_field :toim_postino, class: :large %> + + + <%= f.label :toim_postitp %> + <%= f.text_field :toim_postitp, class: :large %> + + + <%= f.label :toim_maa %> + <%= f.text_field :toim_maa, class: :large %> + + + <%= f.label :jvkulu %> + <%= f.text_field :jvkulu, class: :large %> + + + <%= f.label :jvkielto %> + <%= f.select :jvkielto, cash_on_delivery_prohibition_options, {}, class: 'chosen-select' %> + + + <%= f.label :kuljetusvakuutus_tuotenumero %> + <%= f.text_field :kuljetusvakuutus_tuotenumero, class: :large %> + + + <%= f.label :kuljetusvakuutus %> + <%= f.text_field :kuljetusvakuutus, class: :large %> + + + <%= f.label :kuljetusvakuutus_tyyppi %> + <%= f.select :kuljetusvakuutus_tyyppi, transportation_insurance_type_options, {}, class: 'chosen-select' %> + + + <%= f.label :vak_kielto %> + <%= f.select :vak_kielto, adr_prohibition_options, {}, class: 'chosen-select' %> + + + <%= f.label :vaihtoehtoinen_vak_toimitustapa %> + <%= f.select :vaihtoehtoinen_vak_toimitustapa, alternative_adr_delivery_method_options, {}, class: 'chosen-select' %> + <%= f.label :erikoispakkaus_kielto %> <%= f.select :erikoispakkaus_kielto, special_packaging_prohibition_options, {}, class: 'chosen-select' %> @@ -92,6 +148,83 @@ <%= f.label :sallitut_maat %> <%= f.text_field :sallitut_maat, class: :large %> + + <%= f.label :uudet_pakkaustiedot %> + <%= f.select :uudet_pakkaustiedot, new_packaging_information_options, {}, class: 'chosen-select' %> + + + <%= f.label :lajittelupiste %> + <%= f.select :lajittelupiste, sorting_point_options, + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %> + + + <%= f.label :maa_maara %> + <%= f.text_field :maa_maara, class: :large %> + + + <%= f.label :sisamaan_kuljetus %> + <%= f.text_field :sisamaan_kuljetus, class: :large %> + + + <%= f.label :sisamaan_kuljetus_kansallisuus %> + <%= f.text_field :sisamaan_kuljetus_kansallisuus, class: :large %> + + + <%= f.label :sisamaan_kuljetusmuoto %> + <%= f.select :sisamaan_kuljetusmuoto, mode_of_transport_options, + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %> + + + <%= f.label :kontti %> + <%= f.select :kontti, container_options, {}, class: 'chosen-select' %> + + + <%= f.label :aktiivinen_kuljetus %> + <%= f.text_field :aktiivinen_kuljetus, class: :large %> + + + <%= f.label :aktiivinen_kuljetus_kansallisuus %> + <%= f.text_field :aktiivinen_kuljetus_kansallisuus, class: :large %> + + + <%= f.label :kauppatapahtuman_luonne %> + <%= f.select :kauppatapahtuman_luonne, nature_of_transaction_options, + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %> + + + <%= f.label :kuljetusmuoto %> + <%= f.select :kuljetusmuoto, mode_of_transport_options, + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %> + + + <%= f.label :poistumistoimipaikka_koodi %> + <%= f.select :poistumistoimipaikka_koodi, customs_options, + { include_blank: t('administration.delivery_methods.edit.no_select') }, class: 'chosen-select' %> + + + <%= f.label :ulkomaanlisa %> + <%= f.text_field :ulkomaanlisa, class: :large %> + + + <%= f.label :sallitut_alustat %> + + <%= f.collection_check_boxes :sallitut_alustat, Package.all, :tunnus, :pakkauskuvaus, + checked: @delivery_method.sallitut_alustat.split(',') do |b| %> +
+ <%= b.check_box %> + <%= b.label { b.object.pakkaus + " " + b.object.translated_description(get_locale) } %> +
+ <% end %> + + + + <%= f.label :lisakulu %> + <%= f.text_field :lisakulu, class: :large %> + + + <%= f.label :lisakulu_summa %> + <%= f.text_field :lisakulu_summa, class: :large %> + <%= f.label :jarjestys %> <%= f.text_field :jarjestys, class: :large %> diff --git a/app/views/administration/delivery_methods/_cargo_insurance.html.erb b/app/views/administration/delivery_methods/_cargo_insurance.html.erb deleted file mode 100644 index 1763d90bc..000000000 --- a/app/views/administration/delivery_methods/_cargo_insurance.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - -
<%= f.label :kuljetusvakuutus_tuotenumero %><%= f.text_field :kuljetusvakuutus_tuotenumero, class: :large %>
<%= f.label :kuljetusvakuutus %><%= f.text_field :kuljetusvakuutus, class: :large %>
<%= f.label :kuljetusvakuutus_tyyppi %><%= f.select :kuljetusvakuutus_tyyppi, transportation_insurance_type_options, {}, class: 'chosen-select' %>
diff --git a/app/views/administration/delivery_methods/_cash_on_delivery.html.erb b/app/views/administration/delivery_methods/_cash_on_delivery.html.erb deleted file mode 100644 index 05a4b72bc..000000000 --- a/app/views/administration/delivery_methods/_cash_on_delivery.html.erb +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - -
<%= f.label :jvkulu %><%= f.text_field :jvkulu, class: :large %>
<%= f.label :jvkielto %><%= f.select :jvkielto, cash_on_delivery_prohibition_options, {}, class: 'chosen-select' %>
diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 6cbf19b8a..238f20763 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -6,26 +6,6 @@ <%= render 'basic', f: f %> -
- <%= render 'addresses', f: f %> -
- -
- <%= render 'cash_on_delivery', f: f %> -
- -
- <%= render 'adr', f: f %> -
- -
- <%= render 'cargo_insurance', f: f %> -
- -
- <%= render 'advanced', f: f %> -
-
<%= render 'administration/translations', f: f %>
From ee39f6b70c09d8bc95bbc929adc4e0358140259e Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 3 Nov 2015 14:36:54 +0200 Subject: [PATCH 127/189] add TimeOfDay object --- app/classes/time_of_day.rb | 31 +++++++++++++++++++++++++ app/models/delivery_method/departure.rb | 4 ++++ test/classes/time_of_day_test.rb | 19 +++++++++++++++ test/models/delivery_method_test.rb | 4 ++++ 4 files changed, 58 insertions(+) create mode 100644 app/classes/time_of_day.rb create mode 100644 test/classes/time_of_day_test.rb diff --git a/app/classes/time_of_day.rb b/app/classes/time_of_day.rb new file mode 100644 index 000000000..18162dc4a --- /dev/null +++ b/app/classes/time_of_day.rb @@ -0,0 +1,31 @@ +class TimeOfDay + + attr_accessor :hour, :min, :sec + + def initialize(time: '00:00:00') + parse_time time + end + + def to_s + "#{hour}:#{min}:#{sec}" + end + + def ==(obj) + self.to_s == obj.to_s + end + + private + + def parse_time(time) + # Assume the time format for string is hh:mm:ss + if time.is_a? String + @hour, @min, @sec = time.split ":" + elsif time.respond_to? :strftime + @hour = time.strftime '%H' + @min = time.strftime '%M' + @sec = time.strftime '%S' + else + raise ArgumentError, "pass time as string or datetime or time" + end + end +end diff --git a/app/models/delivery_method/departure.rb b/app/models/delivery_method/departure.rb index 1c3e5018d..66acc5984 100644 --- a/app/models/delivery_method/departure.rb +++ b/app/models/delivery_method/departure.rb @@ -3,6 +3,10 @@ class DeliveryMethod::Departure < BaseModel validates :kerailyn_aloitusaika, format: { with: /\d{2}:\d{2}:\d{2}/i } + def kerailyn_aloitusaika + TimeOfDay.new(time: read_attribute(:kerailyn_aloitusaika)) + end + self.table_name = :toimitustavan_lahdot self.primary_key = :tunnus end diff --git a/test/classes/time_of_day_test.rb b/test/classes/time_of_day_test.rb new file mode 100644 index 000000000..d7c711499 --- /dev/null +++ b/test/classes/time_of_day_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +class TimeOfDayTest < ActiveSupport::TestCase + test 'initialization with wrong values' do + assert_raise ArgumentError do + TimeOfDay.new(nil) + end + + assert_raise ArgumentError do + TimeOfDay.new('') + end + end + + test 'should return valid time' do + assert_equal '12:00:00', TimeOfDay.new(time: '12:00:00').to_s + assert_equal '12:00:00', TimeOfDay.new(time: DateTime.new(2007,11,19,12,00,00,"-06:00")).to_s + assert_equal '12:00:00', TimeOfDay.new(time: Time.parse("12:00")).to_s + end +end diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 1ec8bc97b..d1cab87f9 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -32,6 +32,10 @@ def setup assert @departure.valid?, @departure.errors.full_messages end + test 'departure should have valid time' do + assert_equal '12:00:00', @departure.kerailyn_aloitusaika.to_s, @departure.errors.full_messages + end + test "selite should be unique" do @delivery_method.selite = "Kiitolinja" refute @delivery_method.valid?, "Delivery method already exists" From 02f8e9b63b743c869bd2f13e74de2ae08011a709 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 3 Nov 2015 14:59:44 +0200 Subject: [PATCH 128/189] remove get_locale method & use current user's locale --- app/controllers/application_controller.rb | 5 ----- app/views/administration/delivery_methods/_basic.html.erb | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 53d42d733..f35ea6cfe 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,7 +9,6 @@ class ApplicationController < ActionController::Base helper_method :current_user helper_method :current_company helper_method :update_access? - helper_method :get_locale def current_user @current_user ||= User.unscoped.find_by_session(cookies[:pupesoft_session]) @@ -35,10 +34,6 @@ def update_access? @update_access ||= current_user.can_update?(request_path, alias_set: alias_set) end - def get_locale - users_locale - end - protected def authorize diff --git a/app/views/administration/delivery_methods/_basic.html.erb b/app/views/administration/delivery_methods/_basic.html.erb index d64458b8d..761a8550c 100644 --- a/app/views/administration/delivery_methods/_basic.html.erb +++ b/app/views/administration/delivery_methods/_basic.html.erb @@ -212,7 +212,7 @@ checked: @delivery_method.sallitut_alustat.split(',') do |b| %>
<%= b.check_box %> - <%= b.label { b.object.pakkaus + " " + b.object.translated_description(get_locale) } %> + <%= b.label { b.object.pakkaus + " " + b.object.translated_description(current_user.locale) } %>
<% end %> From bf37c5a3c2ce06acfbf7074e881b56a18a87ec7e Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 3 Nov 2015 15:22:26 +0200 Subject: [PATCH 129/189] departures partial --- .../delivery_methods_controller.rb | 1 + .../delivery_methods/_departure_fields.html.erb | 10 ++++++++++ .../delivery_methods/_departures.html.erb | 16 ++++++++++++++++ .../delivery_methods/_form.html.erb | 4 ++++ 4 files changed, 31 insertions(+) create mode 100644 app/views/administration/delivery_methods/_departure_fields.html.erb create mode 100644 app/views/administration/delivery_methods/_departures.html.erb diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index 20e5a3110..748a90579 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -69,6 +69,7 @@ def delivery_method_params :toim_postino, :toim_postitp, :tulostustapa, :ulkomaanlisa, :uudet_pakkaustiedot, :vaihtoehtoinen_vak_toimitustapa, :vak_kielto, :virallinen_selite, translations_attributes: [ :id, :kieli, :selitetark, :_destroy ], + departures_attributes: [ :id, :kerailyn_aloitusaika, :_destroy ], ) end diff --git a/app/views/administration/delivery_methods/_departure_fields.html.erb b/app/views/administration/delivery_methods/_departure_fields.html.erb new file mode 100644 index 000000000..394814eff --- /dev/null +++ b/app/views/administration/delivery_methods/_departure_fields.html.erb @@ -0,0 +1,10 @@ + + + <%= f.text_field :kerailyn_aloitusaika, class: :large %> + + + + <%= f.check_box :_destroy %> + + + diff --git a/app/views/administration/delivery_methods/_departures.html.erb b/app/views/administration/delivery_methods/_departures.html.erb new file mode 100644 index 000000000..38508b503 --- /dev/null +++ b/app/views/administration/delivery_methods/_departures.html.erb @@ -0,0 +1,16 @@ + + + + + + + <%= f.fields_for :departures do |departure| %> + <%= render 'departure_fields', f: departure %> + <% end %> +
<%= label_tag t('administration.delivery_methods.departures.kerailyn_aloitusaika') %><%= label_tag t('helpers.submit.destroy', model: '') %>
+ +
+ +<%= link_to_add_association t('administration.delivery_methods.departures.link_new'), f, :departures, + data: { association_insertion_method: :append, association_insertion_node: '#departures'}, + partial: 'departure_fields' %> diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 238f20763..7da4208f5 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -10,6 +10,10 @@ <%= render 'administration/translations', f: f %> +
+ <%= render 'departures', f: f %> +
+
<%= render 'administration/actions', f: f %>
From d089491cb7daef0237cf5d1b95492867ebce2564 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 3 Nov 2015 17:03:56 +0200 Subject: [PATCH 130/189] terminal area & customer category keywords --- .../delivery_methods_controller.rb | 11 ++++- app/models/customer.rb | 4 ++ app/models/delivery_method/departure.rb | 7 ++- app/models/keyword.rb | 40 ++++++++-------- app/models/keyword/customer_category.rb | 7 +++ app/models/keyword/terminal_area.rb | 8 ++++ .../_departure_fields.html.erb | 20 ++++++++ .../delivery_methods/_departures.html.erb | 5 ++ .../delivery_methods/_form.html.erb | 2 +- config/locales/fi.yml | 14 ++++-- test/fixtures/customers.yml | 1 + test/fixtures/keyword/customer_categories.yml | 15 ++++++ test/fixtures/keywords.yml | 48 +++++-------------- test/models/keyword/customer_category_test.rb | 23 +++++++++ test/models/keyword_test.rb | 10 ++-- 15 files changed, 149 insertions(+), 66 deletions(-) create mode 100644 app/models/keyword/customer_category.rb create mode 100644 app/models/keyword/terminal_area.rb create mode 100644 test/fixtures/keyword/customer_categories.yml create mode 100644 test/models/keyword/customer_category_test.rb diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index 748a90579..206170d8b 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -69,7 +69,16 @@ def delivery_method_params :toim_postino, :toim_postitp, :tulostustapa, :ulkomaanlisa, :uudet_pakkaustiedot, :vaihtoehtoinen_vak_toimitustapa, :vak_kielto, :virallinen_selite, translations_attributes: [ :id, :kieli, :selitetark, :_destroy ], - departures_attributes: [ :id, :kerailyn_aloitusaika, :_destroy ], + departures_attributes: [ + :id, + :kerailyn_aloitusaika, + :lahdon_viikonpvm, + :lahdon_kellonaika, + :viimeinen_tilausaika, + :terminaalialue, + :asiakasluokka, + :_destroy + ], ) end diff --git a/app/models/customer.rb b/app/models/customer.rb index 643567fd8..0b275b8a7 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,5 +1,9 @@ class Customer < BaseModel belongs_to :delivery_method, foreign_key: :toimitustapa, primary_key: :selite + belongs_to :category, + class_name: 'Keyword::CustomerCategory', + foreign_key: :luokka, + primary_key: :selite belongs_to :subcategory, class_name: 'Keyword::CustomerSubcategory', foreign_key: :ryhma, diff --git a/app/models/delivery_method/departure.rb b/app/models/delivery_method/departure.rb index 66acc5984..1375589c0 100644 --- a/app/models/delivery_method/departure.rb +++ b/app/models/delivery_method/departure.rb @@ -1,7 +1,12 @@ class DeliveryMethod::Departure < BaseModel belongs_to :delivery_method, foreign_key: :liitostunnus + has_many :terminal_area, primary_key: :terminaalialue, foreign_key: :selite, class_name: 'Keyword::TerminalArea' - validates :kerailyn_aloitusaika, format: { with: /\d{2}:\d{2}:\d{2}/i } + validates :kerailyn_aloitusaika, :lahdon_kellonaika, :viimeinen_tilausaika, + format: { with: /\d{2}:\d{2}:\d{2}/i } + validates :lahdon_viikonpvm, numericality: { only_integer: true } + validates :terminaalialue, length: { within: 1..150 }, allow_blank: true + validates :asiakasluokka, length: { within: 1..50 }, allow_blank: true def kerailyn_aloitusaika TimeOfDay.new(time: read_attribute(:kerailyn_aloitusaika)) diff --git a/app/models/keyword.rb b/app/models/keyword.rb index fdd46df31..99f0ecfae 100644 --- a/app/models/keyword.rb +++ b/app/models/keyword.rb @@ -13,25 +13,27 @@ def self.default_child_instance def self.child_class_names { - ALV: Keyword::Vat, - ALVULK: Keyword::ForeignVat, - ASIAKASRYHMA: Keyword::CustomerSubcategory, - KM: Keyword::ModeOfTransport, - KT: Keyword::NatureOfTransaction, - LISATIETO: Keyword::ProductInformationType, - MAKSUEHTOKV: Keyword::TermsOfPaymentTranslation, - MYSQLALIAS: Keyword::CustomAttribute, - OSASTO: Product::Category, - PAKKAUSKV: Keyword::PackageTranslation, - PARAMETRI: Keyword::ProductParameterType, - REVENUEREP: Keyword::RevenueExpenditure, - S: Product::Status, - TOIMTAPAKV: Keyword::DeliveryMethodTranslation, - TOIMTAPALP: Keyword::SortingPoint, - TRY: Product::Subcategory, - TULLI: Keyword::Customs, - TUOTEMERKKI: Product::Brand, - TUOTEULK: Keyword::ProductKeywordType, + ALV: Keyword::Vat, + ALVULK: Keyword::ForeignVat, + ASIAKASLUOKKA: Keyword::CustomerCategory, + ASIAKASRYHMA: Keyword::CustomerSubcategory, + KM: Keyword::ModeOfTransport, + KT: Keyword::NatureOfTransaction, + LISATIETO: Keyword::ProductInformationType, + MAKSUEHTOKV: Keyword::TermsOfPaymentTranslation, + MYSQLALIAS: Keyword::CustomAttribute, + OSASTO: Product::Category, + PAKKAUSKV: Keyword::PackageTranslation, + PARAMETRI: Keyword::ProductParameterType, + REVENUEREP: Keyword::RevenueExpenditure, + S: Product::Status, + TERMINAALIALUE: Keyword::TerminalArea, + TOIMTAPAKV: Keyword::DeliveryMethodTranslation, + TOIMTAPALP: Keyword::SortingPoint, + TRY: Product::Subcategory, + TULLI: Keyword::Customs, + TUOTEMERKKI: Product::Brand, + TUOTEULK: Keyword::ProductKeywordType, }.stringify_keys end end diff --git a/app/models/keyword/customer_category.rb b/app/models/keyword/customer_category.rb new file mode 100644 index 000000000..56de6453a --- /dev/null +++ b/app/models/keyword/customer_category.rb @@ -0,0 +1,7 @@ +class Keyword::CustomerCategory < Keyword + has_many :customers, foreign_key: :luokka, primary_key: :selite + + def self.sti_name + :ASIAKASLUOKKA + end +end diff --git a/app/models/keyword/terminal_area.rb b/app/models/keyword/terminal_area.rb new file mode 100644 index 000000000..fe2dc1219 --- /dev/null +++ b/app/models/keyword/terminal_area.rb @@ -0,0 +1,8 @@ +class Keyword::TerminalArea < Keyword + validates :selitetark, presence: true + + # Rails requires sti_name method to return type column (laji) value + def self.sti_name + 'TERMINAALIALUE' + end +end diff --git a/app/views/administration/delivery_methods/_departure_fields.html.erb b/app/views/administration/delivery_methods/_departure_fields.html.erb index 394814eff..db27b9c7f 100644 --- a/app/views/administration/delivery_methods/_departure_fields.html.erb +++ b/app/views/administration/delivery_methods/_departure_fields.html.erb @@ -1,8 +1,28 @@ + + <%= f.text_field :lahdon_viikonpvm, class: :large %> + + + + <%= f.text_field :lahdon_kellonaika, class: :large %> + + + + <%= f.text_field :viimeinen_tilausaika, class: :large %> + + <%= f.text_field :kerailyn_aloitusaika, class: :large %> + + <%= f.text_field :terminaalialue, class: :large %> + + + + <%= f.text_field :asiakasluokka, class: :large %> + + <%= f.check_box :_destroy %> diff --git a/app/views/administration/delivery_methods/_departures.html.erb b/app/views/administration/delivery_methods/_departures.html.erb index 38508b503..bbb677d3b 100644 --- a/app/views/administration/delivery_methods/_departures.html.erb +++ b/app/views/administration/delivery_methods/_departures.html.erb @@ -1,6 +1,11 @@ + + + + + diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 7da4208f5..8f927a07e 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -10,7 +10,7 @@ <%= render 'administration/translations', f: f %> -
+
<%= render 'departures', f: f %>
diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 6a6721369..1487573d9 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -212,7 +212,7 @@ fi: rahdinkuljettaja: Kuljetusyhtiö rahti_tuotenumero: Rahtiveloitus tuotenumero rahtikirja: Rahtikirjatyyppi - rahtikirjakopio_email: + rahtikirjakopio_email: sallitut_alustat: Sallitut keräilyalustat sallitut_maat: Sallitut maat selite: Nimitys @@ -512,6 +512,14 @@ fi: hidden: Kenttää ei näytetä näkymässä visible: Kenttä näytetään näkymässä delivery_methods: + departures: + kerailyn_aloitusaika: Keräilyn aloitusaika + lahdon_viikonpvm: Lähdön viikonpäivä + lahdon_kellonaika: Lähdön kellonaika + viimeinen_tilausaika: Viimeinen tilausaika + terminaalialue: Terminaalialue + asiakasluokka: Asiakasluokka + link_new: Lisää uusi lähtö adr_prohibition_options: adr_prohibition: Toimitustavalla ei saa toimittaa VAK-tuotteita adr_shipment: VAK-tuotteet toimitetaan toimitustavalla @@ -825,7 +833,7 @@ fi: - pe - la abbr_month_names: - - + - - tammi - helmi - maalis @@ -851,7 +859,7 @@ fi: long: "%A %e. %Bta %Y" short: "%d %b" month_names: - - + - - tammikuu - helmikuu - maaliskuu diff --git a/test/fixtures/customers.yml b/test/fixtures/customers.yml index b6411193b..719b8eb35 100644 --- a/test/fixtures/customers.yml +++ b/test/fixtures/customers.yml @@ -20,4 +20,5 @@ stubborn_customer: terms_of_payment: sixty_days_net toimitustapa: Kaukokiito ryhma: 10 + luokka: 100 <<: *DEFAULTS diff --git a/test/fixtures/keyword/customer_categories.yml b/test/fixtures/keyword/customer_categories.yml new file mode 100644 index 000000000..ebfe2604e --- /dev/null +++ b/test/fixtures/keyword/customer_categories.yml @@ -0,0 +1,15 @@ +DEFAULTS: &DEFAULTS + yhtio: acme + luontiaika: <%= Time.now %> + muutospvm: <%= Time.now %> + laji: ASIAKASLUOKKA + +customer_category_1: + selite: 100 + selitetark: Reipas + <<: *DEFAULTS + +customer_category_2: + selite: 200 + selitetark: Laiska + <<: *DEFAULTS diff --git a/test/fixtures/keywords.yml b/test/fixtures/keywords.yml index 6c5bb79a7..9f3fdf10d 100644 --- a/test/fixtures/keywords.yml +++ b/test/fixtures/keywords.yml @@ -1,24 +1,22 @@ DEFAULTS: &DEFAULTS + yhtio: acme muuttaja: joe laatija: joe luontiaika: <%= Time.now %> muutospvm: <%= Time.now %> vat: - yhtio: acme selite: 24 laji: ALV <<: *DEFAULTS foreign_vat: - yhtio: acme selite: 5.5 selitetark_2: SE laji: ALV <<: *DEFAULTS category_tools: - yhtio: acme selite: 1000 selitetark: Tools kieli: fi @@ -26,7 +24,6 @@ category_tools: <<: *DEFAULTS category_gears: - yhtio: acme selite: 1001 selitetark: Gears kieli: fi @@ -34,7 +31,6 @@ category_gears: <<: *DEFAULTS category_winter: - yhtio: acme selite: 1005 selitetark: Winter kieli: fi @@ -42,7 +38,6 @@ category_winter: <<: *DEFAULTS subcategory_tools: - yhtio: acme selite: 2000 selitetark: Power tools kieli: fi @@ -50,7 +45,6 @@ subcategory_tools: <<: *DEFAULTS subcategory_gears: - yhtio: acme selite: 2001 selitetark: Full-face helmet kieli: fi @@ -58,61 +52,48 @@ subcategory_gears: <<: *DEFAULTS brand_tools: - yhtio: acme selite: Bosch kieli: fi laji: TUOTEMERKKI <<: *DEFAULTS brand_gears: - yhtio: acme selite: Alpinestars kieli: fi laji: TUOTEMERKKI <<: *DEFAULTS mode_of_transport: - yhtio: acme selite: 1 selitetark: 1 - Merikuljetus (ml. auto- ja junalauttakuljetus) laji: KM - muuttaja: joe - laatija: joe - luontiaika: <%= Time.now %> - muutospvm: <%= Time.now %> + <<: *DEFAULTS nature_of_transaction: - yhtio: acme selite: 11 selitetark: 11 - Suora osto/myynti laji: KT - muuttaja: joe - laatija: joe - luontiaika: <%= Time.now %> - muutospvm: <%= Time.now %> + <<: *DEFAULTS + +terminal_area: + selite: LASTAUS + selitetark: Lastauslaituri + laji: TERMINAALIALUE + <<: *DEFAULTS customs: - yhtio: acme selite: FI001000 selitetark: Helsinki Postitulli laji: TULLI - muuttaja: joe - laatija: joe - luontiaika: <%= Time.now %> - muutospvm: <%= Time.now %> + <<: *DEFAULTS sorting_point: - yhtio: acme selite: FIVAT selitetark: FIVAT laji: TOIMTAPALP - muuttaja: joe - laatija: joe - luontiaika: <%= Time.now %> - muutospvm: <%= Time.now %> + <<: *DEFAULTS top_locale_se: - yhtio: acme selite: <%= ActiveRecord::FixtureSet.identify(:sixty_days_net) %> selitetark: 60 dagar netto kieli: se @@ -120,7 +101,6 @@ top_locale_se: <<: *DEFAULTS top_locale_en: - yhtio: acme selite: <%= ActiveRecord::FixtureSet.identify(:sixty_days_net) %> selitetark: 60 days net kieli: en @@ -128,7 +108,6 @@ top_locale_en: <<: *DEFAULTS deliverymethod_locale_en: - yhtio: acme selite: <%= ActiveRecord::FixtureSet.identify(:kaukokiito) %> selitetark: Kaukokiito Logistics kieli: en @@ -136,7 +115,6 @@ deliverymethod_locale_en: <<: *DEFAULTS mysql_alias_1: - yhtio: acme laji: MYSQLALIAS selite: asiakas.nimi selitetark: Nimiskuukkeli @@ -148,7 +126,6 @@ mysql_alias_1: <<: *DEFAULTS mysql_alias_2: - yhtio: acme laji: MYSQLALIAS selite: asiakas.nimi selitetark: Kumisniikkeli @@ -160,7 +137,6 @@ mysql_alias_2: <<: *DEFAULTS package_locale_en: - yhtio: acme selite: <%= ActiveRecord::FixtureSet.identify(:steel_barrel) %> selitetark: Steel Barrel kieli: en @@ -168,7 +144,6 @@ package_locale_en: <<: *DEFAULTS weekly_alternative_expenditure_one: - yhtio: acme laji: REVENUEREP selite: 38 / 2015 selitetark: Palkat @@ -176,7 +151,6 @@ weekly_alternative_expenditure_one: <<: *DEFAULTS status_active: - yhtio: acme selite: A selitetark: Aktiivi laji: S diff --git a/test/models/keyword/customer_category_test.rb b/test/models/keyword/customer_category_test.rb new file mode 100644 index 000000000..99c8a02f4 --- /dev/null +++ b/test/models/keyword/customer_category_test.rb @@ -0,0 +1,23 @@ +require 'test_helper' + +class Keyword::CustomerCategoryTest < ActiveSupport::TestCase + fixtures %w( + customers + keyword/customer_categories + ) + + setup do + @one = keyword_customer_categories :customer_category_1 + @two = keyword_customer_categories :customer_category_2 + end + + test 'fixtures are valid' do + assert @one.valid?, @one.errors.full_messages + assert @two.valid?, @two.errors.full_messages + end + + test 'associations work' do + assert_equal 1, @one.customers.count + assert_equal 0, @two.customers.count + end +end diff --git a/test/models/keyword_test.rb b/test/models/keyword_test.rb index 1b0b29617..9515fd49b 100644 --- a/test/models/keyword_test.rb +++ b/test/models/keyword_test.rb @@ -4,15 +4,17 @@ class KeywordTest < ActiveSupport::TestCase fixtures %w(keywords) setup do - @vat = keywords(:vat) - @foreign_vat = keywords(:foreign_vat) - @top_translation = keywords(:top_locale_se) - @dm_translation = keywords(:deliverymethod_locale_en) + @vat = keywords :vat + @foreign_vat = keywords :foreign_vat + @terminal_area = keywords :terminal_area + @top_translation = keywords :top_locale_se + @dm_translation = keywords :deliverymethod_locale_en end test "fixtures are valid" do assert @vat.valid?, @vat.errors.full_messages assert @foreign_vat.valid?, @foreign_vat.errors.full_messages + assert @terminal_area.valid?, @terminal_area.errors.full_messages assert @top_translation.valid?, @top_translation.errors.full_messages assert @dm_translation.valid?, @dm_translation.errors.full_messages assert keywords(:top_locale_en).valid? From 974e2ac8b85cd728a991b4e2d5fd977b3660b9d9 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Tue, 3 Nov 2015 17:38:18 +0200 Subject: [PATCH 131/189] warehouse relation to departures --- .../delivery_methods_controller.rb | 1 + app/models/delivery_method/departure.rb | 3 ++- app/models/warehouse.rb | 1 + .../_departure_fields.html.erb | 4 ++++ .../delivery_methods/_departures.html.erb | 1 + config/locales/fi.yml | 23 ++++++++++--------- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index 206170d8b..c5f83fe5e 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -77,6 +77,7 @@ def delivery_method_params :viimeinen_tilausaika, :terminaalialue, :asiakasluokka, + :varasto, :_destroy ], ) diff --git a/app/models/delivery_method/departure.rb b/app/models/delivery_method/departure.rb index 1375589c0..b39e9b437 100644 --- a/app/models/delivery_method/departure.rb +++ b/app/models/delivery_method/departure.rb @@ -1,10 +1,11 @@ class DeliveryMethod::Departure < BaseModel belongs_to :delivery_method, foreign_key: :liitostunnus + belongs_to :warehouse, foreign_key: :varasto has_many :terminal_area, primary_key: :terminaalialue, foreign_key: :selite, class_name: 'Keyword::TerminalArea' validates :kerailyn_aloitusaika, :lahdon_kellonaika, :viimeinen_tilausaika, format: { with: /\d{2}:\d{2}:\d{2}/i } - validates :lahdon_viikonpvm, numericality: { only_integer: true } + validates :lahdon_viikonpvm, :varasto, numericality: { only_integer: true } validates :terminaalialue, length: { within: 1..150 }, allow_blank: true validates :asiakasluokka, length: { within: 1..50 }, allow_blank: true diff --git a/app/models/warehouse.rb b/app/models/warehouse.rb index b6cc7c768..6a1aa105c 100644 --- a/app/models/warehouse.rb +++ b/app/models/warehouse.rb @@ -1,6 +1,7 @@ class Warehouse < BaseModel has_many :packing_areas, foreign_key: :varasto has_many :shelf_locations, foreign_key: :varasto + has_many :departures, foreign_key: :varasto, class_name: 'DeliveryMethod::Departure' scope :active, -> { where.not(tyyppi: 'P') } diff --git a/app/views/administration/delivery_methods/_departure_fields.html.erb b/app/views/administration/delivery_methods/_departure_fields.html.erb index db27b9c7f..016203ca3 100644 --- a/app/views/administration/delivery_methods/_departure_fields.html.erb +++ b/app/views/administration/delivery_methods/_departure_fields.html.erb @@ -23,6 +23,10 @@ <%= f.text_field :asiakasluokka, class: :large %> +
+ diff --git a/app/views/administration/delivery_methods/_departures.html.erb b/app/views/administration/delivery_methods/_departures.html.erb index bbb677d3b..1092342a8 100644 --- a/app/views/administration/delivery_methods/_departures.html.erb +++ b/app/views/administration/delivery_methods/_departures.html.erb @@ -6,6 +6,7 @@ + diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 1487573d9..bfa1f8a9c 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -212,7 +212,7 @@ fi: rahdinkuljettaja: Kuljetusyhtiö rahti_tuotenumero: Rahtiveloitus tuotenumero rahtikirja: Rahtikirjatyyppi - rahtikirjakopio_email: + rahtikirjakopio_email: sallitut_alustat: Sallitut keräilyalustat sallitut_maat: Sallitut maat selite: Nimitys @@ -512,14 +512,6 @@ fi: hidden: Kenttää ei näytetä näkymässä visible: Kenttä näytetään näkymässä delivery_methods: - departures: - kerailyn_aloitusaika: Keräilyn aloitusaika - lahdon_viikonpvm: Lähdön viikonpäivä - lahdon_kellonaika: Lähdön kellonaika - viimeinen_tilausaika: Viimeinen tilausaika - terminaalialue: Terminaalialue - asiakasluokka: Asiakasluokka - link_new: Lisää uusi lähtö adr_prohibition_options: adr_prohibition: Toimitustavalla ei saa toimittaa VAK-tuotteita adr_shipment: VAK-tuotteet toimitetaan toimitustavalla @@ -535,6 +527,15 @@ fi: not_including_container: Ei create: create_success: Toimitustapa luotiin onnistuneesti + departures: + asiakasluokka: Asiakasluokka + kerailyn_aloitusaika: Keräilyn aloitusaika + lahdon_kellonaika: Lähdön kellonaika + lahdon_viikonpvm: Lähdön viikonpäivä + link_new: Lisää uusi lähtö + terminaalialue: Terminaalialue + varasto: Varasto + viimeinen_tilausaika: Viimeinen tilausaika destroy: destroy_success: Toimitustapa poistettiin onnistuneesti edit: @@ -833,7 +834,7 @@ fi: - pe - la abbr_month_names: - - + - - tammi - helmi - maalis @@ -859,7 +860,7 @@ fi: long: "%A %e. %Bta %Y" short: "%d %b" month_names: - - + - - tammikuu - helmikuu - maaliskuu From 5f29210db3462dcc5826b48115f3b1d0b54a23d5 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 4 Nov 2015 11:48:54 +0200 Subject: [PATCH 132/189] add fields to departures & use of pupenext_date_field --- .../delivery_methods_controller.rb | 5 ++++- app/models/delivery_method/departure.rb | 18 ++++++++++++++++++ .../_departure_fields.html.erb | 12 ++++++++++++ .../delivery_methods/_departures.html.erb | 17 ++++++++++------- config/locales/fi.yml | 17 ++++++++++------- 5 files changed, 54 insertions(+), 15 deletions(-) diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index c5f83fe5e..124773763 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -68,7 +68,7 @@ def delivery_method_params :toim_maa, :toim_nimi, :toim_nimitark, :toim_osoite, :toim_ovttunnus, :toim_postino, :toim_postitp, :tulostustapa, :ulkomaanlisa, :uudet_pakkaustiedot, :vaihtoehtoinen_vak_toimitustapa, :vak_kielto, :virallinen_selite, - translations_attributes: [ :id, :kieli, :selitetark, :_destroy ], + translations_attributes: [:id, :kieli, :selitetark, :_destroy], departures_attributes: [ :id, :kerailyn_aloitusaika, @@ -78,6 +78,9 @@ def delivery_method_params :terminaalialue, :asiakasluokka, :varasto, + :aktiivi, + :ohjausmerkki, + {alkupvm: [:day, :month, :year]}, :_destroy ], ) diff --git a/app/models/delivery_method/departure.rb b/app/models/delivery_method/departure.rb index b39e9b437..615d35f83 100644 --- a/app/models/delivery_method/departure.rb +++ b/app/models/delivery_method/departure.rb @@ -1,4 +1,6 @@ class DeliveryMethod::Departure < BaseModel + include SplittableDates + belongs_to :delivery_method, foreign_key: :liitostunnus belongs_to :warehouse, foreign_key: :varasto has_many :terminal_area, primary_key: :terminaalialue, foreign_key: :selite, class_name: 'Keyword::TerminalArea' @@ -8,11 +10,27 @@ class DeliveryMethod::Departure < BaseModel validates :lahdon_viikonpvm, :varasto, numericality: { only_integer: true } validates :terminaalialue, length: { within: 1..150 }, allow_blank: true validates :asiakasluokka, length: { within: 1..50 }, allow_blank: true + validates :ohjausmerkki, length: { within: 1..70 }, allow_blank: true + + splittable_dates :alkupvm def kerailyn_aloitusaika TimeOfDay.new(time: read_attribute(:kerailyn_aloitusaika)) end + def lahdon_kellonaika + TimeOfDay.new(time: read_attribute(:lahdon_kellonaika)) + end + + def viimeinen_tilausaika + TimeOfDay.new(time: read_attribute(:viimeinen_tilausaika)) + end + self.table_name = :toimitustavan_lahdot self.primary_key = :tunnus + + enum aktiivi: { + in_use: '', + not_in_use: 'E' + } end diff --git a/app/views/administration/delivery_methods/_departure_fields.html.erb b/app/views/administration/delivery_methods/_departure_fields.html.erb index 016203ca3..ec9042ee0 100644 --- a/app/views/administration/delivery_methods/_departure_fields.html.erb +++ b/app/views/administration/delivery_methods/_departure_fields.html.erb @@ -27,6 +27,18 @@ <%= f.text_field :varasto, class: :large %> + + + + + + diff --git a/app/views/administration/delivery_methods/_departures.html.erb b/app/views/administration/delivery_methods/_departures.html.erb index 1092342a8..1c5615db7 100644 --- a/app/views/administration/delivery_methods/_departures.html.erb +++ b/app/views/administration/delivery_methods/_departures.html.erb @@ -1,12 +1,15 @@
<%= label_tag t('administration.delivery_methods.departures.lahdon_viikonpvm') %><%= label_tag t('administration.delivery_methods.departures.lahdon_kellonaika') %><%= label_tag t('administration.delivery_methods.departures.viimeinen_tilausaika') %> <%= label_tag t('administration.delivery_methods.departures.kerailyn_aloitusaika') %><%= label_tag t('administration.delivery_methods.departures.terminaalialue') %><%= label_tag t('administration.delivery_methods.departures.asiakasluokka') %> <%= label_tag t('helpers.submit.destroy', model: '') %>
+ <%= f.text_field :varasto, class: :large %> + <%= f.check_box :_destroy %> <%= label_tag t('administration.delivery_methods.departures.kerailyn_aloitusaika') %> <%= label_tag t('administration.delivery_methods.departures.terminaalialue') %> <%= label_tag t('administration.delivery_methods.departures.asiakasluokka') %><%= label_tag t('administration.delivery_methods.departures.varasto') %> <%= label_tag t('helpers.submit.destroy', model: '') %>
+ <%= f.text_field :aktiivi, class: :large %> + + <%= f.text_field :ohjausmerkki, class: :large %> + + <%= f.pupenext_date_field :alkupvm, class: :large %> + <%= f.check_box :_destroy %>
- - - - - - - + + + + + + + + + + diff --git a/config/locales/fi.yml b/config/locales/fi.yml index bfa1f8a9c..98b3c9b7c 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -528,14 +528,17 @@ fi: create: create_success: Toimitustapa luotiin onnistuneesti departures: - asiakasluokka: Asiakasluokka - kerailyn_aloitusaika: Keräilyn aloitusaika - lahdon_kellonaika: Lähdön kellonaika - lahdon_viikonpvm: Lähdön viikonpäivä + collecting_start_time: Keräilyn aloitusaika + control_character: Ohjausmerkki + customer_category: Asiakasluokka + day_of_the_week: Lähdön viikonpäivä + last_ordering_time: Viimeinen tilausaika link_new: Lisää uusi lähtö - terminaalialue: Terminaalialue - varasto: Varasto - viimeinen_tilausaika: Viimeinen tilausaika + start_date: Alkamispäivämäärä + status: Tila + terminal_area: Terminaalialue + time: Lähdön kellonaika + warehouse: Varasto destroy: destroy_success: Toimitustapa poistettiin onnistuneesti edit: From 004ff11d84abe72d9324cdccc3f561b8fc1bd53e Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 4 Nov 2015 13:53:41 +0200 Subject: [PATCH 133/189] departure helper --- .../administration/delivery_methods_controller.rb | 2 +- app/helpers/administration/departure_helper.rb | 10 ++++++++++ .../delivery_methods/_departure_fields.html.erb | 2 +- config/locales/fi.yml | 9 +++++++++ test/helpers/departure_helper_test.rb | 11 +++++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 app/helpers/administration/departure_helper.rb create mode 100644 test/helpers/departure_helper_test.rb diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index 124773763..724010cce 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -80,7 +80,7 @@ def delivery_method_params :varasto, :aktiivi, :ohjausmerkki, - {alkupvm: [:day, :month, :year]}, + { alkupvm: [:day, :month, :year] }, :_destroy ], ) diff --git a/app/helpers/administration/departure_helper.rb b/app/helpers/administration/departure_helper.rb new file mode 100644 index 000000000..293c12bee --- /dev/null +++ b/app/helpers/administration/departure_helper.rb @@ -0,0 +1,10 @@ +module Administration::DepartureHelper + ROOT = 'administration.delivery_methods.departures' + + def day_of_the_week_options + Date::DAYS_INTO_WEEK.inject([]) do |result, day| + index = day.first == :sunday ? 0 : day.second + 1 + result << [t("#{ROOT}.day_of_the_week_options.#{day.first}"), index] + end + end +end diff --git a/app/views/administration/delivery_methods/_departure_fields.html.erb b/app/views/administration/delivery_methods/_departure_fields.html.erb index ec9042ee0..41db9c5e5 100644 --- a/app/views/administration/delivery_methods/_departure_fields.html.erb +++ b/app/views/administration/delivery_methods/_departure_fields.html.erb @@ -1,6 +1,6 @@ - - - -
<%= label_tag t('administration.delivery_methods.departures.lahdon_viikonpvm') %><%= label_tag t('administration.delivery_methods.departures.lahdon_kellonaika') %><%= label_tag t('administration.delivery_methods.departures.viimeinen_tilausaika') %><%= label_tag t('administration.delivery_methods.departures.kerailyn_aloitusaika') %><%= label_tag t('administration.delivery_methods.departures.terminaalialue') %><%= label_tag t('administration.delivery_methods.departures.asiakasluokka') %><%= label_tag t('administration.delivery_methods.departures.varasto') %><%= label_tag t('administration.delivery_methods.departures.day_of_the_week') %><%= label_tag t('administration.delivery_methods.departures.time') %><%= label_tag t('administration.delivery_methods.departures.last_ordering_time') %><%= label_tag t('administration.delivery_methods.departures.collecting_start_time') %><%= label_tag t('administration.delivery_methods.departures.terminal_area') %><%= label_tag t('administration.delivery_methods.departures.customer_category') %><%= label_tag t('administration.delivery_methods.departures.warehouse') %><%= label_tag t('administration.delivery_methods.departures.status') %><%= label_tag t('administration.delivery_methods.departures.control_character') %><%= label_tag t('administration.delivery_methods.departures.start_date') %> <%= label_tag t('helpers.submit.destroy', model: '') %>
- <%= f.text_field :lahdon_viikonpvm, class: :large %> + <%= f.select :lahdon_viikonpvm, day_of_the_week_options, { include_blank: t('administration.delivery_methods.departures.no_selected_day') }, class: 'chosen-select' %> diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 98b3c9b7c..795b39ae2 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -532,8 +532,17 @@ fi: control_character: Ohjausmerkki customer_category: Asiakasluokka day_of_the_week: Lähdön viikonpäivä + day_of_the_week_options: + friday: Perjantai + monday: Maanantai + saturday: Lauantai + sunday: Sunnuntai + thursday: Torstai + tuesday: Tiistai + wednesday: Keskiviikko last_ordering_time: Viimeinen tilausaika link_new: Lisää uusi lähtö + no_selected_day: Ei valittua päivää start_date: Alkamispäivämäärä status: Tila terminal_area: Terminaalialue diff --git a/test/helpers/departure_helper_test.rb b/test/helpers/departure_helper_test.rb new file mode 100644 index 000000000..bea0e68e9 --- /dev/null +++ b/test/helpers/departure_helper_test.rb @@ -0,0 +1,11 @@ +require 'test_helper' + +class Administration::DepartureHelperTest < ActionView::TestCase + test "returns translated departure options valid for collection" do + assert day_of_the_week_options.is_a? Array + + text = I18n.t 'administration.delivery_methods.departures.day_of_the_week_options.monday', :fi + assert_equal text, day_of_the_week_options.first.first + assert_equal 1, day_of_the_week_options.first.second + end +end From cfe5ad5f95c40b27c21745add424bc802d94b27f Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 4 Nov 2015 14:06:43 +0200 Subject: [PATCH 134/189] terminal area helper --- app/helpers/administration/departure_helper.rb | 6 ++++++ app/models/keyword/terminal_area.rb | 3 +++ .../delivery_methods/_departure_fields.html.erb | 2 +- config/locales/fi.yml | 7 ++++--- test/helpers/departure_helper_test.rb | 7 +++++++ 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/helpers/administration/departure_helper.rb b/app/helpers/administration/departure_helper.rb index 293c12bee..4c8a9e54f 100644 --- a/app/helpers/administration/departure_helper.rb +++ b/app/helpers/administration/departure_helper.rb @@ -7,4 +7,10 @@ def day_of_the_week_options result << [t("#{ROOT}.day_of_the_week_options.#{day.first}"), index] end end + + def terminal_area_options + Keyword::TerminalArea.order(:label, :code).pluck(:label, :code) do |c| + [ c.label, c.code ] + end + end end diff --git a/app/models/keyword/terminal_area.rb b/app/models/keyword/terminal_area.rb index fe2dc1219..54ca9de64 100644 --- a/app/models/keyword/terminal_area.rb +++ b/app/models/keyword/terminal_area.rb @@ -1,6 +1,9 @@ class Keyword::TerminalArea < Keyword validates :selitetark, presence: true + alias_attribute :code, :selite + alias_attribute :label, :selitetark + # Rails requires sti_name method to return type column (laji) value def self.sti_name 'TERMINAALIALUE' diff --git a/app/views/administration/delivery_methods/_departure_fields.html.erb b/app/views/administration/delivery_methods/_departure_fields.html.erb index 41db9c5e5..fd3df3193 100644 --- a/app/views/administration/delivery_methods/_departure_fields.html.erb +++ b/app/views/administration/delivery_methods/_departure_fields.html.erb @@ -16,7 +16,7 @@ - <%= f.text_field :terminaalialue, class: :large %> + <%= f.select :terminaalialue, terminal_area_options, { include_blank: t('administration.delivery_methods.departures.no_selected_terminal_area') }, class: 'chosen-select' %> diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 795b39ae2..e80efd3bb 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -212,7 +212,7 @@ fi: rahdinkuljettaja: Kuljetusyhtiö rahti_tuotenumero: Rahtiveloitus tuotenumero rahtikirja: Rahtikirjatyyppi - rahtikirjakopio_email: + rahtikirjakopio_email: sallitut_alustat: Sallitut keräilyalustat sallitut_maat: Sallitut maat selite: Nimitys @@ -543,6 +543,7 @@ fi: last_ordering_time: Viimeinen tilausaika link_new: Lisää uusi lähtö no_selected_day: Ei valittua päivää + no_selected_terminal_area: Ei terminaalialuetta start_date: Alkamispäivämäärä status: Tila terminal_area: Terminaalialue @@ -846,7 +847,7 @@ fi: - pe - la abbr_month_names: - - + - - tammi - helmi - maalis @@ -872,7 +873,7 @@ fi: long: "%A %e. %Bta %Y" short: "%d %b" month_names: - - + - - tammikuu - helmikuu - maaliskuu diff --git a/test/helpers/departure_helper_test.rb b/test/helpers/departure_helper_test.rb index bea0e68e9..fda8e05a7 100644 --- a/test/helpers/departure_helper_test.rb +++ b/test/helpers/departure_helper_test.rb @@ -8,4 +8,11 @@ class Administration::DepartureHelperTest < ActionView::TestCase assert_equal text, day_of_the_week_options.first.first assert_equal 1, day_of_the_week_options.first.second end + + test "returns translated terminal area options valid for collection" do + assert terminal_area_options.is_a? Array + + assert_equal 'Lastauslaituri', terminal_area_options.first.first + assert_equal 'LASTAUS', terminal_area_options.first.second + end end From d4f0684c514d9d8f4a7241929985d560cbbbe215 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 4 Nov 2015 15:56:29 +0200 Subject: [PATCH 135/189] customer category helper --- app/helpers/administration/departure_helper.rb | 6 ++++++ app/models/keyword/customer_category.rb | 5 +++++ .../delivery_methods/_departure_fields.html.erb | 6 +++--- config/locales/fi.yml | 6 ++++-- test/fixtures/keywords.yml | 6 ++++++ test/helpers/departure_helper_test.rb | 7 +++++++ 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/app/helpers/administration/departure_helper.rb b/app/helpers/administration/departure_helper.rb index 4c8a9e54f..533a69d20 100644 --- a/app/helpers/administration/departure_helper.rb +++ b/app/helpers/administration/departure_helper.rb @@ -13,4 +13,10 @@ def terminal_area_options [ c.label, c.code ] end end + + def customer_category_options + Keyword::CustomerCategory.order(:label, :code).pluck(:label, :code) do |c| + [ c.label, c.code ] + end + end end diff --git a/app/models/keyword/customer_category.rb b/app/models/keyword/customer_category.rb index 56de6453a..4b8b61e22 100644 --- a/app/models/keyword/customer_category.rb +++ b/app/models/keyword/customer_category.rb @@ -1,6 +1,11 @@ class Keyword::CustomerCategory < Keyword has_many :customers, foreign_key: :luokka, primary_key: :selite + validates :selitetark, presence: true + + alias_attribute :code, :selite + alias_attribute :label, :selitetark + def self.sti_name :ASIAKASLUOKKA end diff --git a/app/views/administration/delivery_methods/_departure_fields.html.erb b/app/views/administration/delivery_methods/_departure_fields.html.erb index fd3df3193..2c47fb963 100644 --- a/app/views/administration/delivery_methods/_departure_fields.html.erb +++ b/app/views/administration/delivery_methods/_departure_fields.html.erb @@ -1,6 +1,6 @@
- <%= f.select :lahdon_viikonpvm, day_of_the_week_options, { include_blank: t('administration.delivery_methods.departures.no_selected_day') }, class: 'chosen-select' %> + <%= f.select :lahdon_viikonpvm, day_of_the_week_options, { include_blank: t('administration.delivery_methods.departures.no_selected.day') }, class: 'chosen-select' %> @@ -16,11 +16,11 @@ - <%= f.select :terminaalialue, terminal_area_options, { include_blank: t('administration.delivery_methods.departures.no_selected_terminal_area') }, class: 'chosen-select' %> + <%= f.select :terminaalialue, terminal_area_options, { include_blank: t('administration.delivery_methods.departures.no_selected.terminal_area') }, class: 'chosen-select' %> - <%= f.text_field :asiakasluokka, class: :large %> + <%= f.select :asiakasluokka, customer_category_options, { include_blank: t('administration.delivery_methods.departures.no_selected.customer_category') }, class: 'chosen-select' %> diff --git a/config/locales/fi.yml b/config/locales/fi.yml index e80efd3bb..9aa08a034 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -542,8 +542,10 @@ fi: wednesday: Keskiviikko last_ordering_time: Viimeinen tilausaika link_new: Lisää uusi lähtö - no_selected_day: Ei valittua päivää - no_selected_terminal_area: Ei terminaalialuetta + no_selected: + day: Ei valittua päivää + terminal_area: Ei terminaalialuetta + customer_category: Ei asiakasluokkaa start_date: Alkamispäivämäärä status: Tila terminal_area: Terminaalialue diff --git a/test/fixtures/keywords.yml b/test/fixtures/keywords.yml index 9f3fdf10d..d75159dde 100644 --- a/test/fixtures/keywords.yml +++ b/test/fixtures/keywords.yml @@ -81,6 +81,12 @@ terminal_area: laji: TERMINAALIALUE <<: *DEFAULTS +customer_category: + selite: 18 + selitetark: Täysi-ikäinen + laji: ASIAKASLUOKKA + <<: *DEFAULTS + customs: selite: FI001000 selitetark: Helsinki Postitulli diff --git a/test/helpers/departure_helper_test.rb b/test/helpers/departure_helper_test.rb index fda8e05a7..c62e22a18 100644 --- a/test/helpers/departure_helper_test.rb +++ b/test/helpers/departure_helper_test.rb @@ -15,4 +15,11 @@ class Administration::DepartureHelperTest < ActionView::TestCase assert_equal 'Lastauslaituri', terminal_area_options.first.first assert_equal 'LASTAUS', terminal_area_options.first.second end + + test "returns translated customer category options valid for collection" do + assert customer_category_options.is_a? Array + + assert_equal 'Täysi-ikäinen', customer_category_options.first.first + assert_equal '18', customer_category_options.first.second + end end From a73cccbfee223baf30a5a658f34c196815053e51 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 4 Nov 2015 16:09:14 +0200 Subject: [PATCH 136/189] warehouse helper --- app/helpers/administration/departure_helper.rb | 6 ++++++ .../delivery_methods/_departure_fields.html.erb | 4 ++-- config/locales/fi.yml | 9 +++++---- test/helpers/departure_helper_test.rb | 10 ++++++++-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/helpers/administration/departure_helper.rb b/app/helpers/administration/departure_helper.rb index 533a69d20..e42fc83d8 100644 --- a/app/helpers/administration/departure_helper.rb +++ b/app/helpers/administration/departure_helper.rb @@ -19,4 +19,10 @@ def customer_category_options [ c.label, c.code ] end end + + def warehouse_options + Warehouse.order(:nimitys).pluck(:nimitys, :tunnus) do |c| + [ c.nimitys, c.tunnus ] + end + end end diff --git a/app/views/administration/delivery_methods/_departure_fields.html.erb b/app/views/administration/delivery_methods/_departure_fields.html.erb index 2c47fb963..b632d785a 100644 --- a/app/views/administration/delivery_methods/_departure_fields.html.erb +++ b/app/views/administration/delivery_methods/_departure_fields.html.erb @@ -24,7 +24,7 @@ - <%= f.text_field :varasto, class: :large %> + <%= f.select :varasto, warehouse_options, { include_blank: t('administration.delivery_methods.departures.no_selected.warehouse') }, class: 'chosen-select' %> @@ -36,7 +36,7 @@ - <%= f.pupenext_date_field :alkupvm, class: :large %> + <%= f.text_field :alkupvm, class: :large %> diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 9aa08a034..bd7d93684 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -212,7 +212,7 @@ fi: rahdinkuljettaja: Kuljetusyhtiö rahti_tuotenumero: Rahtiveloitus tuotenumero rahtikirja: Rahtikirjatyyppi - rahtikirjakopio_email: + rahtikirjakopio_email: sallitut_alustat: Sallitut keräilyalustat sallitut_maat: Sallitut maat selite: Nimitys @@ -543,9 +543,10 @@ fi: last_ordering_time: Viimeinen tilausaika link_new: Lisää uusi lähtö no_selected: + customer_category: Ei asiakasluokkaa day: Ei valittua päivää terminal_area: Ei terminaalialuetta - customer_category: Ei asiakasluokkaa + warehouse: Ei varastoa start_date: Alkamispäivämäärä status: Tila terminal_area: Terminaalialue @@ -849,7 +850,7 @@ fi: - pe - la abbr_month_names: - - + - - tammi - helmi - maalis @@ -875,7 +876,7 @@ fi: long: "%A %e. %Bta %Y" short: "%d %b" month_names: - - + - - tammikuu - helmikuu - maaliskuu diff --git a/test/helpers/departure_helper_test.rb b/test/helpers/departure_helper_test.rb index c62e22a18..53615d868 100644 --- a/test/helpers/departure_helper_test.rb +++ b/test/helpers/departure_helper_test.rb @@ -9,17 +9,23 @@ class Administration::DepartureHelperTest < ActionView::TestCase assert_equal 1, day_of_the_week_options.first.second end - test "returns translated terminal area options valid for collection" do + test "returns terminal area options valid for collection" do assert terminal_area_options.is_a? Array assert_equal 'Lastauslaituri', terminal_area_options.first.first assert_equal 'LASTAUS', terminal_area_options.first.second end - test "returns translated customer category options valid for collection" do + test "returns customer category options valid for collection" do assert customer_category_options.is_a? Array assert_equal 'Täysi-ikäinen', customer_category_options.first.first assert_equal '18', customer_category_options.first.second end + + test "returns warehouse options valid for collection" do + assert warehouse_options.is_a? Array + + assert_equal 'Veikkolan varasto', warehouse_options.first.first + end end From feabbe77d64e6fa00fc9584eadd3408846ab24e0 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Wed, 4 Nov 2015 16:19:05 +0200 Subject: [PATCH 137/189] status options --- app/helpers/administration/departure_helper.rb | 7 +++++++ .../delivery_methods/_departure_fields.html.erb | 2 +- config/locales/fi.yml | 3 +++ test/helpers/departure_helper_test.rb | 7 +++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/helpers/administration/departure_helper.rb b/app/helpers/administration/departure_helper.rb index e42fc83d8..52dd58cdf 100644 --- a/app/helpers/administration/departure_helper.rb +++ b/app/helpers/administration/departure_helper.rb @@ -25,4 +25,11 @@ def warehouse_options [ c.nimitys, c.tunnus ] end end + + def status_options + [ + [ t("#{ROOT}.status_options.in_use"), :in_use ], + [ t("#{ROOT}.status_options.not_in_use"), :not_in_use ], + ] + end end diff --git a/app/views/administration/delivery_methods/_departure_fields.html.erb b/app/views/administration/delivery_methods/_departure_fields.html.erb index b632d785a..8387a1c59 100644 --- a/app/views/administration/delivery_methods/_departure_fields.html.erb +++ b/app/views/administration/delivery_methods/_departure_fields.html.erb @@ -28,7 +28,7 @@ - <%= f.text_field :aktiivi, class: :large %> + <%= f.select :aktiivi, status_options, {}, class: 'chosen-select' %> diff --git a/config/locales/fi.yml b/config/locales/fi.yml index bd7d93684..99b5c87f2 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -549,6 +549,9 @@ fi: warehouse: Ei varastoa start_date: Alkamispäivämäärä status: Tila + status_options: + in_use: Käytössä + not_in_use: Ei käytössä terminal_area: Terminaalialue time: Lähdön kellonaika warehouse: Varasto diff --git a/test/helpers/departure_helper_test.rb b/test/helpers/departure_helper_test.rb index 53615d868..0d2a64360 100644 --- a/test/helpers/departure_helper_test.rb +++ b/test/helpers/departure_helper_test.rb @@ -28,4 +28,11 @@ class Administration::DepartureHelperTest < ActionView::TestCase assert_equal 'Veikkolan varasto', warehouse_options.first.first end + + test "returns status options valid for collection" do + assert status_options.is_a? Array + + assert_equal 'Ei käytössä', status_options.second.first + assert_equal :not_in_use, status_options.second.second + end end From 0e2ef13884f6e3f1e85a835fb8799f3946f4cfa6 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 10:42:18 +0200 Subject: [PATCH 138/189] fix status options test --- test/helpers/departure_helper_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/helpers/departure_helper_test.rb b/test/helpers/departure_helper_test.rb index 0d2a64360..3539dd402 100644 --- a/test/helpers/departure_helper_test.rb +++ b/test/helpers/departure_helper_test.rb @@ -32,7 +32,8 @@ class Administration::DepartureHelperTest < ActionView::TestCase test "returns status options valid for collection" do assert status_options.is_a? Array - assert_equal 'Ei käytössä', status_options.second.first + text = I18n.t 'administration.delivery_methods.departures.status_options.not_in_use', :fi + assert_equal text, status_options.second.first assert_equal :not_in_use, status_options.second.second end end From 894e4d6378214e481e5fe2751f37ba1af4b36db5 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 11:37:50 +0200 Subject: [PATCH 139/189] fix fixtures --- test/fixtures/delivery_methods.yml | 2 ++ test/fixtures/keywords.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/fixtures/delivery_methods.yml b/test/fixtures/delivery_methods.yml index f0831ac9b..2472aa5f5 100644 --- a/test/fixtures/delivery_methods.yml +++ b/test/fixtures/delivery_methods.yml @@ -6,6 +6,8 @@ DEFAULTS: &DEFAULTS muutospvm: <%= Time.now %> kaukokiito: + kauppatapahtuman_luonne: 11 + poistumistoimipaikka_koodi: FI0 kuljetusmuoto: 1 osoitelappu: tiivistetty rahdinkuljettaja: Kaukokiito diff --git a/test/fixtures/keywords.yml b/test/fixtures/keywords.yml index d75159dde..33fee4e3b 100644 --- a/test/fixtures/keywords.yml +++ b/test/fixtures/keywords.yml @@ -88,7 +88,7 @@ customer_category: <<: *DEFAULTS customs: - selite: FI001000 + selite: FI0 selitetark: Helsinki Postitulli laji: TULLI <<: *DEFAULTS From e0f23772493d7b5ad9faef3e7a63ef9ea0829219 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 11:39:02 +0200 Subject: [PATCH 140/189] fix departure nested attributes --- app/controllers/administration/delivery_methods_controller.rb | 4 ++-- app/models/delivery_method.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index 724010cce..fe3266950 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -80,8 +80,8 @@ def delivery_method_params :varasto, :aktiivi, :ohjausmerkki, - { alkupvm: [:day, :month, :year] }, - :_destroy + :_destroy, + alkupvm: [:day, :month, :year], ], ) end diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 13e6e2650..06e709287 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -41,6 +41,7 @@ class DeliveryMethod < BaseModel :lisakulu, :lisakulu_summa accepts_nested_attributes_for :translations, allow_destroy: true + accepts_nested_attributes_for :departures, allow_destroy: true scope :permit_adr, -> { where(vak_kielto: '') } From a7176ecccc07ed7d794c3abd900510e3422da161 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 11:39:42 +0200 Subject: [PATCH 141/189] add length validation for custom's selite field --- app/models/keyword/customs.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/keyword/customs.rb b/app/models/keyword/customs.rb index 2502c4147..0a523242b 100644 --- a/app/models/keyword/customs.rb +++ b/app/models/keyword/customs.rb @@ -1,4 +1,5 @@ class Keyword::Customs < Keyword + validates :selite, length: 1..3 validates :selitetark, presence: true # Rails requires sti_name method to return type column (laji) value From 48b140bb8313f2b5a22fd73382bacf8dc72b048f Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 11:41:05 +0200 Subject: [PATCH 142/189] add tests for departure nested attribute --- .../delivery_method_controller_test.rb | 86 ++++++++++++------- 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/test/controllers/administration/delivery_method_controller_test.rb b/test/controllers/administration/delivery_method_controller_test.rb index 89f45cfa1..82380e33c 100644 --- a/test/controllers/administration/delivery_method_controller_test.rb +++ b/test/controllers/administration/delivery_method_controller_test.rb @@ -7,7 +7,7 @@ class Administration::DeliveryMethodsControllerTest < ActionController::TestCase ) def setup - login users(:joe) + login users(:bob) @delivery_method = delivery_methods(:kaukokiito) end @@ -29,8 +29,6 @@ def setup end test 'should create delivery method' do - login users(:bob) - assert_difference('DeliveryMethod.count', 1, response.body) do params = { @@ -50,8 +48,6 @@ def setup end test 'should not create delivery method' do - login users(:bob) - assert_no_difference('DeliveryMethod.count') do params = { @@ -65,8 +61,6 @@ def setup end test 'should update delivery method' do - login users(:bob) - params = { tulostustapa: :collective_batch } patch :update, id: @delivery_method.id, delivery_method: params @@ -74,8 +68,6 @@ def setup end test 'should not update delivery method' do - login users(:bob) - params = { selite: 'Kiitolinja' } patch :update, id: @delivery_method.id, delivery_method: params @@ -83,8 +75,6 @@ def setup end test "should delete delivery method" do - login users(:bob) - deli2 = delivery_methods :kiitolinja assert_difference("DeliveryMethod.count", -1) do @@ -95,7 +85,6 @@ def setup end test 'should save sallitut_alustat array as string' do - login users(:bob) package_one = packages(:steel_barrel).id package_two = packages(:oak_barrel).id @@ -108,15 +97,10 @@ def setup end test "should add translations" do - login users(:bob) - params = { - translations_attributes: { - "0" => { - kieli: 'no', - selitetark: 'Kaukokiito Transports', - } - } + translations_attributes: [ + { kieli: 'no', selitetark: 'Kaukokiito Transports' } + ] } assert_difference 'Keyword::DeliveryMethodTranslation.count' do @@ -125,16 +109,12 @@ def setup end test "should update and destroy translations" do - login users(:bob) translated = keywords :deliverymethod_locale_en params = { - translations_attributes: { - "0" => { - id: translated.id, - selitetark: 'a translation', - } - } + translations_attributes: [ + { id: translated.id, selitetark: 'a translation' } + ] } assert_no_difference('Keyword::DeliveryMethodTranslation.count') do @@ -144,16 +124,56 @@ def setup assert_equal 'a translation', translated.reload.selitetark params = { - translations_attributes: { - "0" => { - id: translated.id, - _destroy: 'true', - } - } + translations_attributes: [ + { id: translated.id, _destroy: 'true' } + ] } assert_difference('Keyword::DeliveryMethodTranslation.count', -1) do patch :update, id: translated.delivery_method.id, delivery_method: params end end + + test "should update departure date" do + params = { + departures_attributes: [ + { id: @delivery_method.departures.first.id, alkupvm: { day: '12', month: '10', year: '2015' } } + ] + } + + patch :update, id: @delivery_method.id, delivery_method: params + + assert_equal '2015-10-12', @delivery_method.departures.first.reload.alkupvm.to_s + end + + test "should create departure" do + params = { + departures_attributes: [ + { + alkupvm: { day: '12', month: '10', year: '2015' }, + kerailyn_aloitusaika: '12:00:00', + lahdon_kellonaika: '13:20:56', + viimeinen_tilausaika: '23:59:59', + lahdon_viikonpvm: 1, + varasto: 10 + } + ] + } + + assert_difference('DeliveryMethod::Departure.count', 1) do + patch :update, id: @delivery_method.id, delivery_method: params + end + end + + test 'should destroy departure' do + params = { + departures_attributes: [ + { id: @delivery_method.departures.first.id, _destroy: 'true' } + ] + } + + assert_difference('DeliveryMethod::Departure.count', -1) do + patch :update, id: @delivery_method.id, delivery_method: params + end + end end From e4c937897e116a51ed99a9ad53786c26f6629dcf Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 11:55:24 +0200 Subject: [PATCH 143/189] fix customs options test --- test/helpers/keyword_helper_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helpers/keyword_helper_test.rb b/test/helpers/keyword_helper_test.rb index 4fe66bd0b..3a3483f1f 100644 --- a/test/helpers/keyword_helper_test.rb +++ b/test/helpers/keyword_helper_test.rb @@ -13,7 +13,7 @@ class KeywordHelperTest < ActionView::TestCase test "should get customs options" do assert_kind_of Array, customs_options - assert_equal 'FI001000', customs_options.first.second + assert_equal 'FI0', customs_options.first.second end test "should get sorting point options" do From 42ba125d49082e3c7ef65b006cfc5002d0f96f76 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 14:37:47 +0200 Subject: [PATCH 144/189] remove time of day class --- app/classes/time_of_day.rb | 31 ------------------------- app/models/delivery_method/departure.rb | 12 ---------- test/classes/time_of_day_test.rb | 19 --------------- 3 files changed, 62 deletions(-) delete mode 100644 app/classes/time_of_day.rb delete mode 100644 test/classes/time_of_day_test.rb diff --git a/app/classes/time_of_day.rb b/app/classes/time_of_day.rb deleted file mode 100644 index 18162dc4a..000000000 --- a/app/classes/time_of_day.rb +++ /dev/null @@ -1,31 +0,0 @@ -class TimeOfDay - - attr_accessor :hour, :min, :sec - - def initialize(time: '00:00:00') - parse_time time - end - - def to_s - "#{hour}:#{min}:#{sec}" - end - - def ==(obj) - self.to_s == obj.to_s - end - - private - - def parse_time(time) - # Assume the time format for string is hh:mm:ss - if time.is_a? String - @hour, @min, @sec = time.split ":" - elsif time.respond_to? :strftime - @hour = time.strftime '%H' - @min = time.strftime '%M' - @sec = time.strftime '%S' - else - raise ArgumentError, "pass time as string or datetime or time" - end - end -end diff --git a/app/models/delivery_method/departure.rb b/app/models/delivery_method/departure.rb index 615d35f83..2c737f78b 100644 --- a/app/models/delivery_method/departure.rb +++ b/app/models/delivery_method/departure.rb @@ -14,18 +14,6 @@ class DeliveryMethod::Departure < BaseModel splittable_dates :alkupvm - def kerailyn_aloitusaika - TimeOfDay.new(time: read_attribute(:kerailyn_aloitusaika)) - end - - def lahdon_kellonaika - TimeOfDay.new(time: read_attribute(:lahdon_kellonaika)) - end - - def viimeinen_tilausaika - TimeOfDay.new(time: read_attribute(:viimeinen_tilausaika)) - end - self.table_name = :toimitustavan_lahdot self.primary_key = :tunnus diff --git a/test/classes/time_of_day_test.rb b/test/classes/time_of_day_test.rb deleted file mode 100644 index d7c711499..000000000 --- a/test/classes/time_of_day_test.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'test_helper' - -class TimeOfDayTest < ActiveSupport::TestCase - test 'initialization with wrong values' do - assert_raise ArgumentError do - TimeOfDay.new(nil) - end - - assert_raise ArgumentError do - TimeOfDay.new('') - end - end - - test 'should return valid time' do - assert_equal '12:00:00', TimeOfDay.new(time: '12:00:00').to_s - assert_equal '12:00:00', TimeOfDay.new(time: DateTime.new(2007,11,19,12,00,00,"-06:00")).to_s - assert_equal '12:00:00', TimeOfDay.new(time: Time.parse("12:00")).to_s - end -end From 985aec088a7acf670cd4af5ad69b770cd6c7e752 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 14:38:24 +0200 Subject: [PATCH 145/189] use time select --- .../delivery_methods/_departure_fields.html.erb | 14 +++++++------- test/fixtures/delivery_method/departures.yml | 1 + test/models/delivery_method_test.rb | 9 ++++++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/views/administration/delivery_methods/_departure_fields.html.erb b/app/views/administration/delivery_methods/_departure_fields.html.erb index 8387a1c59..fe5d1c6b4 100644 --- a/app/views/administration/delivery_methods/_departure_fields.html.erb +++ b/app/views/administration/delivery_methods/_departure_fields.html.erb @@ -3,16 +3,16 @@ <%= f.select :lahdon_viikonpvm, day_of_the_week_options, { include_blank: t('administration.delivery_methods.departures.no_selected.day') }, class: 'chosen-select' %> - <%= f.text_field :lahdon_kellonaika, class: :large %> + + <%= f.time_select :lahdon_kellonaika, ignore_date: true, class: :large %> - <%= f.text_field :viimeinen_tilausaika, class: :large %> + + <%= f.time_select :viimeinen_tilausaika, ignore_date: true, class: :large %> - <%= f.text_field :kerailyn_aloitusaika, class: :large %> + + <%= f.time_select :kerailyn_aloitusaika, ignore_date: true, class: :large %> @@ -36,7 +36,7 @@ - <%= f.text_field :alkupvm, class: :large %> + <%= f.pupenext_date_field :alkupvm, class: :large %> diff --git a/test/fixtures/delivery_method/departures.yml b/test/fixtures/delivery_method/departures.yml index 8e64089e1..a8408f751 100644 --- a/test/fixtures/delivery_method/departures.yml +++ b/test/fixtures/delivery_method/departures.yml @@ -9,5 +9,6 @@ DEFAULTS: &DEFAULTS departure_one: liitostunnus: <%= ActiveRecord::FixtureSet.identify(:kaukokiito) %> kerailyn_aloitusaika: '12:00:00' + lahdon_kellonaika: '13:24:59' alkupvm: 0 <<: *DEFAULTS diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index d1cab87f9..fbfb790a9 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -27,13 +27,20 @@ def setup @departure = delivery_method_departures :departure_one end + test 'relations' do + assert_not_equal 0, @delivery_method.mode_of_transports.count + assert_not_equal 0, @delivery_method.nature_of_transactions.count + assert_not_equal 0, @delivery_method.customs.count + end + test "fixtures should be valid" do assert @delivery_method.valid?, @delivery_method.errors.messages assert @departure.valid?, @departure.errors.full_messages end test 'departure should have valid time' do - assert_equal '12:00:00', @departure.kerailyn_aloitusaika.to_s, @departure.errors.full_messages + assert_equal '12:00:00', @departure.kerailyn_aloitusaika.strftime('%H:%M:%S'), @departure.errors.full_messages + assert_equal '13:24:59', @departure.lahdon_kellonaika.strftime('%H:%M:%S'), @departure.errors.full_messages end test "selite should be unique" do From 959acf1a8b011f7fabad7f9b55a658c5ef1e00a7 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 15:08:01 +0200 Subject: [PATCH 146/189] test relations --- app/models/delivery_method.rb | 18 ++++++++++++++++-- test/fixtures/delivery_methods.yml | 1 + test/models/delivery_method_test.rb | 18 +++++++++++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 06e709287..9c1f1b02d 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -7,11 +7,25 @@ class DeliveryMethod < BaseModel o.has_many :nature_of_transactions, primary_key: :kauppatapahtuman_luonne, class_name: 'Keyword::NatureOfTransaction' o.has_many :customs, primary_key: :poistumistoimipaikka_koodi, class_name: 'Keyword::Customs' o.has_many :sorting_point, primary_key: :lajittelupiste, class_name: 'Keyword::SortingPoint' - o.has_many :customer_keywords, primary_key: :avainsana - o.has_many :waybills, primary_key: :toimitustapa o.has_many :translations, class_name: 'Keyword::DeliveryMethodTranslation' end + with_options foreign_key: :toimitustapa, primary_key: :selite do |o| + o.has_many :freights + o.has_many :manufacture_orders, class_name: 'ManufactureOrder::Order' + o.has_many :offer_orders, class_name: 'OfferOrder::Order' + o.has_many :preorders, class_name: 'Preorder::Order' + o.has_many :project_orders, class_name: 'ProjectOrder::Order' + o.has_many :reclamation_orders, class_name: 'ReclamationOrder::Order' + o.has_many :sales_order_drafts, class_name: 'SalesOrder::Draft' + o.has_many :sales_orders, class_name: 'SalesOrder::Order' + o.has_many :stock_transfers, class_name: 'StockTransfer::Order' + o.has_many :waybills + o.has_many :work_orders, class_name: 'WorkOrder::Order' + o.has_many :freight_contracts + end + + has_many :customer_keywords, foreign_key: :avainsana, primary_key: :selite has_many :departures, foreign_key: :liitostunnus, class_name: 'DeliveryMethod::Departure' validates :aktiivinen_kuljetus_kansallisuus, :maa_maara, :sisamaan_kuljetus_kansallisuus, inclusion: { in: Country.pluck(:koodi) }, allow_blank: true diff --git a/test/fixtures/delivery_methods.yml b/test/fixtures/delivery_methods.yml index 2472aa5f5..120568421 100644 --- a/test/fixtures/delivery_methods.yml +++ b/test/fixtures/delivery_methods.yml @@ -8,6 +8,7 @@ DEFAULTS: &DEFAULTS kaukokiito: kauppatapahtuman_luonne: 11 poistumistoimipaikka_koodi: FI0 + lajittelupiste: FIVAT kuljetusmuoto: 1 osoitelappu: tiivistetty rahdinkuljettaja: Kaukokiito diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index fbfb790a9..fa2b4b9a6 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -28,9 +28,25 @@ def setup end test 'relations' do + assert_not_equal 0, @delivery_method.customer_keywords.count + assert_not_equal 0, @delivery_method.customs.count + assert_not_equal 0, @delivery_method.departures.count + assert_not_equal 0, @delivery_method.freights.count + assert_not_equal 0, @delivery_method.manufacture_orders.count assert_not_equal 0, @delivery_method.mode_of_transports.count assert_not_equal 0, @delivery_method.nature_of_transactions.count - assert_not_equal 0, @delivery_method.customs.count + assert_not_equal 0, @delivery_method.offer_orders.count + assert_not_equal 0, @delivery_method.preorders.count + assert_not_equal 0, @delivery_method.project_orders.count + assert_not_equal 0, @delivery_method.reclamation_orders.count + assert_not_equal 0, @delivery_method.sales_order_drafts.count + assert_not_equal 0, @delivery_method.sales_orders.not_delivered.count + assert_not_equal 0, @delivery_method.sorting_point.count + assert_not_equal 0, @delivery_method.stock_transfers.not_delivered.count + assert_not_equal 0, @delivery_method.translations.count + assert_not_equal 0, @delivery_method.waybills.count + assert_not_equal 0, @delivery_method.work_orders.count + assert_not_equal 0, @delivery_method.freight_contracts.count end test "fixtures should be valid" do From ef9f8d0bd2e51f1f637e34e7f55f90ed70c98037 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 15:14:19 +0200 Subject: [PATCH 147/189] add fixture --- .../administration/delivery_method_controller_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/controllers/administration/delivery_method_controller_test.rb b/test/controllers/administration/delivery_method_controller_test.rb index 82380e33c..3dc4927ab 100644 --- a/test/controllers/administration/delivery_method_controller_test.rb +++ b/test/controllers/administration/delivery_method_controller_test.rb @@ -3,6 +3,7 @@ class Administration::DeliveryMethodsControllerTest < ActionController::TestCase fixtures %w( delivery_methods + delivery_method/departures packages ) From cf51aae5823d588e4989d51021918640c8a98615 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 15:30:14 +0200 Subject: [PATCH 148/189] set datefield to nowrap --- .../delivery_methods/_departure_fields.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/administration/delivery_methods/_departure_fields.html.erb b/app/views/administration/delivery_methods/_departure_fields.html.erb index fe5d1c6b4..2c8ac5010 100644 --- a/app/views/administration/delivery_methods/_departure_fields.html.erb +++ b/app/views/administration/delivery_methods/_departure_fields.html.erb @@ -35,8 +35,8 @@ <%= f.text_field :ohjausmerkki, class: :large %> - <%= f.pupenext_date_field :alkupvm, class: :large %> + + <%= f.pupenext_date_field :alkupvm %> From 3fed43e5a2b2bfc00862de2ac7cdeb4eb5d4088e Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 15:37:29 +0200 Subject: [PATCH 149/189] add header texts to partials --- app/views/administration/delivery_methods/_basic.html.erb | 2 +- app/views/administration/delivery_methods/_form.html.erb | 6 ++++-- config/locales/fi.yml | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/views/administration/delivery_methods/_basic.html.erb b/app/views/administration/delivery_methods/_basic.html.erb index 761a8550c..430e83c42 100644 --- a/app/views/administration/delivery_methods/_basic.html.erb +++ b/app/views/administration/delivery_methods/_basic.html.erb @@ -1,4 +1,4 @@ - +
diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 8f927a07e..0e82f3f5a 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -2,15 +2,17 @@ <%= form_for @delivery_method do |f| %> -
+
<%= render 'basic', f: f %>
+ <%= render "administration/header", text: t('administration.delivery_methods.edit.translations.header') %> <%= render 'administration/translations', f: f %>
-
+
+ <%= render "administration/header", text: t('administration.delivery_methods.edit.departures.header') %> <%= render 'departures', f: f %>
diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 99b5c87f2..d908a8167 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -560,8 +560,12 @@ fi: edit: button_remove: Poista toimitustapa confirm_remove: Oletko varma, että haluat poistaa toimitustavan? + departures: + header: Toimitustavan lähdöt header: Toimitustapa no_select: Ei valintaa + translations: + header: Toimitustavan käännökset extranet_options: both_in_sales_and_extranet: Toimitustapa näytetään molemmissa only_in_extranet: Toimitustapa näytetään vain extranetissä From 6dfe3042789753d27cbfcc4eb22ddf76898492ef Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 15:48:32 +0200 Subject: [PATCH 150/189] add fixture --- test/helpers/departure_helper_test.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/helpers/departure_helper_test.rb b/test/helpers/departure_helper_test.rb index 3539dd402..43411d37c 100644 --- a/test/helpers/departure_helper_test.rb +++ b/test/helpers/departure_helper_test.rb @@ -1,6 +1,10 @@ require 'test_helper' class Administration::DepartureHelperTest < ActionView::TestCase + fixtures %w( + warehouses + ) + test "returns translated departure options valid for collection" do assert day_of_the_week_options.is_a? Array From f3322841a48cc3498535a58c905e5ffc8a3b1b52 Mon Sep 17 00:00:00 2001 From: Sami Luukkonen Date: Thu, 5 Nov 2015 17:00:08 +0200 Subject: [PATCH 151/189] make kerayserat-column to enum --- app/helpers/delivery_method_helper.rb | 2 +- app/models/parameter.rb | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/helpers/delivery_method_helper.rb b/app/helpers/delivery_method_helper.rb index d3b410a59..89e9a0931 100644 --- a/app/helpers/delivery_method_helper.rb +++ b/app/helpers/delivery_method_helper.rb @@ -35,7 +35,7 @@ def label_options [ t("#{ROOT}.label_options.#{key}"), key ] end - options.reject { |_,key| !Current.company.parameter.use_kerayserat? && key == 'simple_label' } + options.reject { |_,key| !Current.company.parameter.collection_batch_based_on_dimensions? && key == 'simple_label' } end def pickup_options diff --git a/app/models/parameter.rb b/app/models/parameter.rb index ea5eb614b..606224ce2 100644 --- a/app/models/parameter.rb +++ b/app/models/parameter.rb @@ -2,7 +2,10 @@ class Parameter < BaseModel self.table_name = :yhtion_parametrit self.primary_key = :tunnus - def use_kerayserat? - kerayserat == 'K' - end + enum kerayserat: { + collection_batch_not_in_use: '', + collection_batch_based_on_dimensions: 'K', + collection_batch_based_on_weight: 'P', + collection_batch_based_on_weight_if_customer_permit: 'A' + } end From c344dd1a0299108c2acd80f2559a4255ed820ab1 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Thu, 5 Nov 2015 17:00:27 +0200 Subject: [PATCH 152/189] translate keys --- config/locales/de.yml | 148 ++++++++++++++++++++++++++++++++++++++++++ config/locales/en.yml | 72 ++++++++++++++++++++ config/locales/et.yml | 90 +++++++++++++++++++++++++ config/locales/sv.yml | 97 +++++++++++++++++++++++++++ 4 files changed, 407 insertions(+) diff --git a/config/locales/de.yml b/config/locales/de.yml index 78be91bdc..a28fb1519 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -176,6 +176,25 @@ de: viivastyskorko: www: www ytunnus: Steuernummer + delivery_method: + aktiivinen_kuljetus: Standard aktiver Transport + aktiivinen_kuljetus_kansallisuus: Standard Nationalität des aktiven Transport + jarjestys: Sortierung + jvkulu: Nachnahmekosten + kauppatapahtuman_luonne: Standard Geschäftsart + kontti: Standard Container + kuljetusmuoto: Standard Transportart + kuluprosentti: Kostenprozent + lisakulu: Zusatzkosten + maa_maara: Standard Zielland + merahti: Frachtvertrag + poistumistoimipaikka_koodi: Standard Code des Abtrittgeschäftsstelle + rahtikirja: Frachtbrieftyp + selite: Bezeichnung + sisamaan_kuljetus: Standard Inlandtransport + sisamaan_kuljetus_kansallisuus: Standard Nationalität des Inlandtransport + sisamaan_kuljetusmuoto: Standard Inlandtransportart + tulostustapa: Ausdruckart keyword: jarjestys: Sortierung kieli: Sprache @@ -233,6 +252,8 @@ de: printteri7: prio: Prio varasto: Lager + pending_updates: + value: Wert printer: ip: ip jarjestys: Sortierung @@ -292,6 +313,10 @@ de: translations: kieli: selitetark: + transport: + customer: Kunde + password: Passwort + username: Benutzername models: account: Konto bank_account: Bankkonto @@ -299,6 +324,7 @@ de: carrier: cash_register: currency: Währung + delivery_method: Versandart fiscal_year: Rechnungsjahr head/purchase_invoice/approval: head/purchase_invoice/approved: @@ -315,6 +341,7 @@ de: package_code: packing_area: Packraum/Verpackungsabteilung printer: Drucker + product/keyword: Schlüsselwörter des Artikels qualifier: Ergänzung qualifier/cost_center: Kostenstelle qualifier/project: Projekt @@ -437,6 +464,72 @@ de: visibility_options: hidden: visible: + delivery_methods: + adr_prohibition_options: + adr_prohibition: Liefern der ADR-Produkte nicht erlaubt bei der Lieferart + adr_shipment: ADR-Produkte werden geliefert mit der Lieferart + permit_adr: Liefern der ADR-Produkte erlaubt bei der Lieferart + cash_on_delivery_prohibition_options: + cash_on_delivery_permitted: Liefern der Nachnahmen erlaubt bei der Lieferart + cash_on_delivery_prohibition: Liefern der Nachnahmen nicht erlaubt bei der Lieferart + container_options: + includes_container: Ja + not_including_container: Nein + departures: + customer_category: Kundenklasse + day_of_the_week_options: + friday: Freitag + monday: Montag + saturday: Samstag + sunday: Sonntag + thursday: Donnerstag + tuesday: Dienstag + wednesday: Mittwoch + no_selected: + warehouse: Kein Lager + status: Status + status_options: + in_use: Wird benutzt + not_in_use: Wird nicht benutzt + warehouse: Lager + edit: + header: Versandart + no_select: Beliebig + extranet_options: + both_in_sales_and_extranet: Lieferart wird in beiden angezeigt + only_in_extranet: Lieferart wird nur im Extranet angezeigt + only_in_sales: Lieferart wird nur im Verkauf angezeigt + index: + button_search: Suchen + header: Lieferarten + label_options: + compact_label: Komprimiert + intrade_label: Intrade + normal_label: Normal + packing_line_prohibition_options: + not_reserving_packing_line: Aufträge der Lieferart reservieren kein Packraum-/Verpackungsabteilungsfach + reserve_packing_line: Aufträge der Lieferart reservieren Packraum-/Verpackungsabteilungsfach + pickup_options: + pickup: Der Kunde holt die Aufträge ab + shipment: Aufträge werden an den Kunden geliefert + print_method_options: + batch: Losausdrucken + collective_batch: Sammel-Losausdrucken + collective_instant: Sammel-Sofortausdrucken + instant: Sofortausdrucken + skip_print: Frachbriefeingabe und -ausdrucken werden überholt + saturday_delivery_options: + not_saturday_delivery: Keine Samstagsdistribution + special_packaging_prohibition_options: + special_packaging_permitted: Liefern der Spezialverpackungen erlaubt bei der Lieferart + special_packaging_prohibition: Liefern der Spezialverpackungen nicht erlaubt bei der Lieferart + transport_unit_options: + not_transport_unit: Keinen Transporteinheittransport + transportation_insurance_type_options: + use_company_default: Standard der Firma + waybill_specification_options: + no_waybill_specification: Keine Frachtbriefspezifikation für die Lieferart ausdrucken + print_waybill_specification: Frachtbriefspezifikation für die Lieferart ausdrucken fiscal_years: create: create_success: @@ -578,6 +671,10 @@ de: forbidden: authorize: unauthorized: + data_export: + product_keywords: + generate: Excel speichern + header: Schlüsselwörter des Artikels date: abbr_day_names: - So @@ -674,6 +771,10 @@ de: month: Monat second: Sekunde year: Jahr //all are in singular now + downloads: + index: + created_at: Erstellt am + destroy: Löschen errors: cash_register: kassa_missing: @@ -852,6 +953,32 @@ de: percentage: format: format: "%n %" + pending_product_updates: + index: + deleted: Status + label: Bezeichnung + search: Suchen + sku: Artikelnummer + suppliers_sku: Artikelnummer des Lieferanten + list: + label: Bezeichnung + price: Preis + save: "Änderungen speichern" + sku: Artikelnummer + list_of_changes: + not_found: Kein Artikel gefunden + pending_columns_options: + sales_price: Verkaufspreis + short_description: Kurzbeschreibung + pending_price_options: + sales_price: Verkaufspreis + pending_update_fields: + delete: Löschen + products: + categories_selection: + brand: Marke + category: Abteilung + subcategory: Gruppe reports: revenue_expenditure: index: @@ -862,6 +989,27 @@ de: concern_accounts_receivable: Konzernforderungen aus Lieferungen und Leistungen summary: Gesamt week: Woche + stock_availability: + form: + button_run: Pdf + constraints: Begrenzung + show_data: + past: Verspätet + product: Artikel + purchases: Bestellt, noch nicht erhalten + stock: Lagerbestand + total: Gesamt + week: Woche + view_connected_sales_orders: + information: Referenz + order_number: Auftragsnummer + ordered_amount: Bestellt + product_info: Artikelnummer + shipping_address: Lieferadresse + total_amount: Gesamtsumme der Rechnung + stock_listing_csv: + index: + run: Bericht ausführen shared: excel: company: Firmendaten diff --git a/config/locales/en.yml b/config/locales/en.yml index 5db322da4..fb8db3f14 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -176,6 +176,9 @@ en: viivastyskorko: Penalty interest rate www: www ytunnus: VAT nr + delivery_method: + merahti: Freight contract + selite: Product name keyword: jarjestys: kieli: @@ -233,6 +236,8 @@ en: printteri7: prio: varasto: Storage + pending_updates: + value: Value excl VAT printer: ip: Ip jarjestys: Order @@ -292,6 +297,10 @@ en: translations: kieli: selitetark: + transport: + customer: Customer + password: Passwd + username: User models: account: Account bank_account: @@ -299,6 +308,7 @@ en: carrier: cash_register: Kassa currency: Currency + delivery_method: Delivery fiscal_year: Fiscal year head/purchase_invoice/approval: head/purchase_invoice/approved: @@ -437,6 +447,24 @@ en: visibility_options: hidden: visible: + delivery_methods: + container_options: + includes_container: 'Yes' + not_including_container: 'No' + departures: + day_of_the_week_options: + friday: Friday + monday: Monday + thursday: Thursday + tuesday: Tuesday + wednesday: Wednesday + status: Status + warehouse: Storage + edit: + header: Delivery + no_select: Any + index: + button_search: Search fiscal_years: create: create_success: @@ -674,6 +702,10 @@ en: month: Month second: Seconds year: Year + downloads: + index: + created_at: Date of creation + destroy: Delete errors: cash_register: kassa_missing: @@ -848,11 +880,51 @@ en: percentage: format: format: "%n%" + pending_product_updates: + index: + deleted: Status + label: Product name + search: Search + sku: Product number + suppliers_sku: Vendor product nr + list: + label: Product name + price: price + sku: Product number + list_of_changes: + not_found: No products found + pending_columns_options: + sales_price: Sales price + short_description: Short description + pending_price_options: + sales_price: Sales price + pending_update_fields: + delete: Delete + products: + categories_selection: + brand: Brand + category: Department reports: revenue_expenditure: index: accounts_receivable: Accounts receivable summary: Total + stock_availability: + show_data: + product: Product + purchases: Ordered, not received + total: Total + view_connected_sales_orders: + delivery_date: Delivery Date + information: Reference text + order_number: Order number + ordered_amount: Ordered + product_info: Product number + shipping_address: Delivery customer + total_amount: Amount + stock_listing_csv: + index: + run: Execute report shared: excel: user: User diff --git a/config/locales/et.yml b/config/locales/et.yml index 18389e686..8ee155899 100644 --- a/config/locales/et.yml +++ b/config/locales/et.yml @@ -176,6 +176,13 @@ et: viivastyskorko: Viivise protsent www: WWW ytunnus: KMKR Nr. + delivery_method: + jarjestys: Järjekord + jvkulu: Lunamaksekulu + kuluprosentti: Kuluprotsent + merahti: Veoleping + selite: Nimetus + tulostustapa: Väljastamisviis keyword: jarjestys: Järjekord kieli: Keel @@ -233,6 +240,8 @@ et: printteri7: prio: varasto: Ladu + pending_updates: + value: Väärtus printer: ip: ip jarjestys: Järjekord @@ -292,6 +301,10 @@ et: translations: kieli: selitetark: + transport: + customer: Klient + password: Parool + username: Kasutajatunnus models: account: Arve bank_account: Pangakonto @@ -299,6 +312,7 @@ et: carrier: cash_register: Kassa currency: Valuuta + delivery_method: Kohaletoimetamise viis fiscal_year: Aruandeperiood head/purchase_invoice/approval: head/purchase_invoice/approved: @@ -315,6 +329,7 @@ et: package_code: packing_area: printer: Printer + product/keyword: Toote märksonad qualifier: Täpsustus qualifier/cost_center: Kulukoht qualifier/project: Projekt @@ -437,6 +452,32 @@ et: visibility_options: hidden: visible: + delivery_methods: + container_options: + includes_container: Jah + not_including_container: Ei + departures: + day_of_the_week_options: + friday: Reede + monday: Esmaspäev + saturday: Laupäev + sunday: Pyhapäev + thursday: Neljapäev + tuesday: Teisipäev + wednesday: Kolmapäev + status: Staatus + status_options: + in_use: Kasutusel + not_in_use: Ei ole kasutusel + warehouse: Ladu + edit: + header: Kohaletoimetamise viis + no_select: Valikut ei ole + index: + button_search: Otsi + header: Tarnimisviisid + label_options: + normal_label: Normaalne fiscal_years: create: create_success: @@ -578,6 +619,9 @@ et: forbidden: authorize: unauthorized: + data_export: + product_keywords: + header: Toote märksonad date: abbr_day_names: - P @@ -674,6 +718,10 @@ et: month: Kuu second: Sekundit year: Aasta + downloads: + index: + created_at: Koostamise aeg + destroy: Kustuta errors: cash_register: kassa_missing: @@ -840,12 +888,54 @@ et: percentage: format: format: + pending_product_updates: + index: + deleted: Staatus + label: Nimetus + search: Otsi + sku: Tootenumber + suppliers_sku: Tarnija tootenumber + list: + label: Nimetus + price: hind + save: Salvesta muudatused + sku: Tootenumber + list_of_changes: + not_found: Yhtki toodet ei leitud + pending_columns_options: + sales_price: Myygihind + pending_price_options: + sales_price: Myygihind + pending_update_fields: + delete: Kustuta + products: + categories_selection: + brand: Märk + category: Osakond reports: revenue_expenditure: index: accounts_receivable: Laekumised myygist summary: Kokku week: Nädal + stock_availability: + form: + constraints: Piiritlemine + show_data: + product: Toode + stock: Laosaldo + total: Kokku + week: Nädal + view_connected_sales_orders: + information: Tellimuse viide + order_number: Tellimuse number + ordered_amount: Tellitud + product_info: Tootenumber + shipping_address: Tarne sihtaadress + total_amount: Arve summa + stock_listing_csv: + index: + run: Käita aruannet shared: excel: user: Kasutaja diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 65834b0e4..929557685 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -176,6 +176,13 @@ sv: viivastyskorko: www: web ytunnus: Org.Nr + delivery_method: + jarjestys: Ordning + jvkulu: Postförskottsavgift + kuluprosentti: Kostprocent + merahti: Fraktkontrakt + selite: Benämning + tulostustapa: Utskriftsmetod keyword: jarjestys: Ordning kieli: Språk @@ -233,6 +240,8 @@ sv: printteri7: prio: Prio varasto: Lager + pending_updates: + value: Värde printer: ip: ip jarjestys: Ordning @@ -292,6 +301,10 @@ sv: translations: kieli: selitetark: + transport: + customer: Kund + password: Lösenord + username: Användarnamn models: account: Konto bank_account: Bankkonto @@ -299,6 +312,7 @@ sv: carrier: cash_register: currency: Valuta + delivery_method: Leveranssätt fiscal_year: Räkenskapsår head/purchase_invoice/approval: head/purchase_invoice/approved: @@ -315,6 +329,7 @@ sv: package_code: packing_area: printer: Skrivare + product/keyword: Nyckelord Artiklar qualifier: Specifikation qualifier/cost_center: Kostnadsställe qualifier/project: Projekt @@ -437,6 +452,32 @@ sv: visibility_options: hidden: visible: + delivery_methods: + container_options: + includes_container: Ja + not_including_container: Nej + departures: + customer_category: kundklass + day_of_the_week_options: + friday: Fredag + monday: Måndag + saturday: Lördag + sunday: Söndag + thursday: Torsdag + tuesday: Tisdag + wednesday: Onsdag + status: Status + status_options: + not_in_use: ej i bruk + warehouse: Lager + edit: + header: Leveranssätt + no_select: Inget val + index: + button_search: Sök + header: Leveranssätt + label_options: + normal_label: Normal fiscal_years: create: create_success: @@ -578,6 +619,9 @@ sv: forbidden: authorize: unauthorized: + data_export: + product_keywords: + header: Nyckelord Artiklar date: abbr_day_names: - sön @@ -674,6 +718,10 @@ sv: month: Månad second: Sekund year: "År" + downloads: + index: + created_at: Skapad + destroy: Radera errors: cash_register: kassa_missing: @@ -842,12 +890,61 @@ sv: percentage: format: format: "%n%" + pending_product_updates: + index: + deleted: Status + label: Benämning + search: Sök + sku: Artikelnummer + suppliers_sku: Leverantörs Art Nr + list: + label: Benämning + price: Pris + save: Spara ändringarna + sku: Artikelnummer + list_of_changes: + not_found: Inga artiklar hittades + pending_columns_options: + sales_price: "ÅfNetto" + shop_price: Butikpris + short_description: Kort beskrivning + pending_price_options: + sales_price: "ÅfNetto" + shop_price: Butikpris + pending_update_fields: + delete: Radera + products: + categories_selection: + brand: Märke + category: Avdelning + subcategory: Grupp reports: revenue_expenditure: index: accounts_receivable: Försäljningsfordringar summary: Totalt week: Vecka + stock_availability: + form: + constraints: Begränsning + show_data: + past: Försenat + product: Artikel + purchases: På kommande + stock: Lagersaldo + total: Totalt + week: Vecka + view_connected_sales_orders: + delivery_date: Leveransdatum + information: Orderreferens + order_number: Ordernummer + ordered_amount: Beställda + product_info: Artikelnummer + shipping_address: Leveransadress + total_amount: Fakturabelopp + stock_listing_csv: + index: + run: Kör rapport shared: excel: time: Körtid From 7960028e475e0a9c901095cd1a4757c2f7325519 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 6 Nov 2015 10:53:25 +0200 Subject: [PATCH 153/189] don't change old permissions for now --- ...4159_update_delivery_method_permissions.rb | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/db/migrate/20150916134159_update_delivery_method_permissions.rb b/db/migrate/20150916134159_update_delivery_method_permissions.rb index 2c3047965..63ad8c6f8 100644 --- a/db/migrate/20150916134159_update_delivery_method_permissions.rb +++ b/db/migrate/20150916134159_update_delivery_method_permissions.rb @@ -1,21 +1,18 @@ +require File.expand_path('test/permission_helper') +include PermissionHelper + class UpdateDeliveryMethodPermissions < ActiveRecord::Migration def up - Company.find_each do |company| - Current.company = company.yhtio - - Permission.where(nimi: 'yllapito.php', alanimi: 'toimitustapa').find_each do |permission| - permission.update(nimi: 'pupenext/delivery_methods', alanimi: '') - end - end + PermissionHelper.add_item( + program: 'Ylläpito', + name: 'Toimitustavat', + uri: 'pupenext/delivery_methods' + ) end def down - Company.find_each do |company| - Current.company = company.yhtio - - Permission.where(nimi: 'pupenext/delivery_methods', alanimi: '').find_each do |permission| - permission.update(nimi: 'yllapito.php', alanimi: 'toimitustapa') - end - end + PermissionHelper.remove_all( + uri: 'pupenext/delivery_methods' + ) end end From 48dfb9a212e4b959fe0e878ebc01024921eb3e29 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 6 Nov 2015 11:29:48 +0200 Subject: [PATCH 154/189] add location model --- test/fixtures/locations.yml | 12 ++++++++++++ test/models/company_test.rb | 1 + test/models/location_test.rb | 20 ++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 test/fixtures/locations.yml create mode 100644 test/models/location_test.rb diff --git a/test/fixtures/locations.yml b/test/fixtures/locations.yml new file mode 100644 index 000000000..a515cfe78 --- /dev/null +++ b/test/fixtures/locations.yml @@ -0,0 +1,12 @@ +DEFAULTS: &DEFAULTS + yhtio: acme + muuttaja: joe + laatija: joe + luontiaika: <%= Time.now %> + muutospvm: <%= Time.now %> + +tokyo: + nimi: Acme Tokyo Headquarters + osoite: Shibuya + maa: JP + <<: *DEFAULTS diff --git a/test/models/company_test.rb b/test/models/company_test.rb index 3a447c1f8..853919d46 100644 --- a/test/models/company_test.rb +++ b/test/models/company_test.rb @@ -27,6 +27,7 @@ class CompanyTest < ActiveSupport::TestCase assert @acme.factorings.count > 0 assert @acme.fiscal_years.count > 0 assert @acme.keywords.count > 0 + assert @acme.locations.count > 0 assert @acme.manufacture_orders.count > 0 assert @acme.package_codes.count > 0 assert @acme.packages.count > 0 diff --git a/test/models/location_test.rb b/test/models/location_test.rb new file mode 100644 index 000000000..b2c49105d --- /dev/null +++ b/test/models/location_test.rb @@ -0,0 +1,20 @@ +require 'test_helper' + +class LocationTest < ActiveSupport::TestCase + fixtures %w( + delivery_methods + locations + ) + + setup do + @tokyo = locations :tokyo + end + + test 'fixtures are valid' do + assert @tokyo.valid? + end + + test 'relations' do + assert_equal 'Acme Corporation', @tokyo.company.nimi + end +end From b96d547e5a8d42ad5630114ea9149d9d72aa5a2f Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 6 Nov 2015 12:12:55 +0200 Subject: [PATCH 155/189] add delivery_methods <-> locations relation --- app/models/delivery_method.rb | 2 ++ app/models/location.rb | 2 ++ test/fixtures/locations.yml | 1 + test/models/delivery_method_test.rb | 2 ++ test/models/location_test.rb | 1 + 5 files changed, 8 insertions(+) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 9c1f1b02d..d195d9fa3 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -28,6 +28,8 @@ class DeliveryMethod < BaseModel has_many :customer_keywords, foreign_key: :avainsana, primary_key: :selite has_many :departures, foreign_key: :liitostunnus, class_name: 'DeliveryMethod::Departure' + has_and_belongs_to_many :locations, join_table: 'toimitustavat_toimipaikat', association_foreign_key: 'toimipaikka_tunnus', foreign_key: 'toimitustapa_tunnus' + validates :aktiivinen_kuljetus_kansallisuus, :maa_maara, :sisamaan_kuljetus_kansallisuus, inclusion: { in: Country.pluck(:koodi) }, allow_blank: true validates :jarjestys, numericality: { only_integer: true }, allow_blank: true validates :lahdon_selite, :sallitut_alustat, length: { maximum: 150 } diff --git a/app/models/location.rb b/app/models/location.rb index 6ce74b9c4..4e3f3df02 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,4 +1,6 @@ class Location < BaseModel + has_and_belongs_to_many :delivery_methods, join_table: 'toimitustavat_toimipaikat', association_foreign_key: 'toimitustapa_tunnus', foreign_key: 'toimipaikka_tunnus' + self.table_name = :yhtion_toimipaikat self.primary_key = :tunnus diff --git a/test/fixtures/locations.yml b/test/fixtures/locations.yml index a515cfe78..6dd1360ad 100644 --- a/test/fixtures/locations.yml +++ b/test/fixtures/locations.yml @@ -9,4 +9,5 @@ tokyo: nimi: Acme Tokyo Headquarters osoite: Shibuya maa: JP + delivery_methods: kaukokiito, kiitolinja <<: *DEFAULTS diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index fa2b4b9a6..20311876c 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -9,6 +9,7 @@ class DeliveryMethodTest < ActiveSupport::TestCase freight_contracts freights heads + locations manufacture_order/orders offer_order/orders preorder/orders @@ -47,6 +48,7 @@ def setup assert_not_equal 0, @delivery_method.waybills.count assert_not_equal 0, @delivery_method.work_orders.count assert_not_equal 0, @delivery_method.freight_contracts.count + assert_not_equal 0, @delivery_method.locations.count end test "fixtures should be valid" do diff --git a/test/models/location_test.rb b/test/models/location_test.rb index b2c49105d..244086cd4 100644 --- a/test/models/location_test.rb +++ b/test/models/location_test.rb @@ -16,5 +16,6 @@ class LocationTest < ActiveSupport::TestCase test 'relations' do assert_equal 'Acme Corporation', @tokyo.company.nimi + assert @tokyo.delivery_methods.count > 0 end end From 21c624e3ac3aa6d737c1bb03f0b341eb70473129 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 6 Nov 2015 12:36:16 +0200 Subject: [PATCH 156/189] remove unnecessary fields --- ...e_fields_from_toimitustavat_toimipaikat.rb | 24 +++++++++++++++++++ db/schema.rb | 22 +++++++---------- 2 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20151106095621_remove_fields_from_toimitustavat_toimipaikat.rb diff --git a/db/migrate/20151106095621_remove_fields_from_toimitustavat_toimipaikat.rb b/db/migrate/20151106095621_remove_fields_from_toimitustavat_toimipaikat.rb new file mode 100644 index 000000000..58d55f6e2 --- /dev/null +++ b/db/migrate/20151106095621_remove_fields_from_toimitustavat_toimipaikat.rb @@ -0,0 +1,24 @@ +class RemoveFieldsFromToimitustavatToimipaikat < ActiveRecord::Migration + def up + remove_column :toimitustavat_toimipaikat, :yhtio + remove_column :toimitustavat_toimipaikat, :laatija + remove_column :toimitustavat_toimipaikat, :muuttaja + remove_column :toimitustavat_toimipaikat, :luontiaika + remove_column :toimitustavat_toimipaikat, :muutospvm + + add_index :toimitustavat_toimipaikat, :toimitustapa_tunnus + add_index :toimitustavat_toimipaikat, :toimipaikka_tunnus + end + + def down + add_column :toimitustavat_toimipaikat, :yhtio, :string, limit: 5, default: '', null: false + add_column :toimitustavat_toimipaikat, :laatija, :string, limit: 50, default: '', null: false, after: :yhtio + add_column :toimitustavat_toimipaikat, :muuttaja, :string, limit: 50, default: '', null: false, after: :yhtio + add_column :toimitustavat_toimipaikat, :luontiaika, :datetime, after: :yhtio + add_column :toimitustavat_toimipaikat, :muutospvm, :datetime, after: :yhtio + + remove_index :toimitustavat_toimipaikat, column: :toimitustapa_tunnus + remove_index :toimitustavat_toimipaikat, column: :toimipaikka_tunnus + add_index :toimitustavat_toimipaikat, :yhtio, name: 'yhtio_index' + end +end diff --git a/db/schema.rb b/db/schema.rb index 777694faf..2ddc90c01 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20151106070812) do +ActiveRecord::Schema.define(version: 20151106095621) do create_table "abc_aputaulu", primary_key: "tunnus", force: :cascade do |t| t.string "yhtio", limit: 5, default: "", null: false @@ -592,8 +592,8 @@ t.integer "profit_account_id", limit: 4 t.integer "sales_account_id", limit: 4 t.integer "voucher_id", limit: 4 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.date "activated_at" t.date "deactivated_at" t.string "name", limit: 255 @@ -2629,16 +2629,12 @@ end create_table "toimitustavat_toimipaikat", primary_key: "tunnus", force: :cascade do |t| - t.string "yhtio", limit: 5, default: "", null: false - t.integer "toimitustapa_tunnus", limit: 4, null: false - t.integer "toimipaikka_tunnus", limit: 4, null: false - t.string "laatija", limit: 50, default: "", null: false - t.datetime "luontiaika", null: false - t.datetime "muutospvm", null: false - t.string "muuttaja", limit: 50, default: "", null: false + t.integer "toimitustapa_tunnus", limit: 4, null: false + t.integer "toimipaikka_tunnus", limit: 4, null: false end - add_index "toimitustavat_toimipaikat", ["yhtio"], name: "yhtio_index", using: :btree + add_index "toimitustavat_toimipaikat", ["toimipaikka_tunnus"], name: "index_toimitustavat_toimipaikat_on_toimipaikka_tunnus", using: :btree + add_index "toimitustavat_toimipaikat", ["toimitustapa_tunnus"], name: "index_toimitustavat_toimipaikat_on_toimitustapa_tunnus", using: :btree create_table "transports", force: :cascade do |t| t.integer "customer_id", limit: 4 @@ -2646,8 +2642,8 @@ t.string "username", limit: 255 t.string "password", limit: 255 t.string "path", limit: 255 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "transports", ["customer_id"], name: "index_transports_on_customer_id", using: :btree From 8299cef9f48a46db9cdad18f37c66774c0170cd8 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 6 Nov 2015 13:14:50 +0200 Subject: [PATCH 157/189] update location ids --- .../delivery_methods_controller.rb | 1 + .../delivery_method_controller_test.rb | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index fe3266950..f1774ecff 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -68,6 +68,7 @@ def delivery_method_params :toim_maa, :toim_nimi, :toim_nimitark, :toim_osoite, :toim_ovttunnus, :toim_postino, :toim_postitp, :tulostustapa, :ulkomaanlisa, :uudet_pakkaustiedot, :vaihtoehtoinen_vak_toimitustapa, :vak_kielto, :virallinen_selite, + location_ids: [], translations_attributes: [:id, :kieli, :selitetark, :_destroy], departures_attributes: [ :id, diff --git a/test/controllers/administration/delivery_method_controller_test.rb b/test/controllers/administration/delivery_method_controller_test.rb index 3dc4927ab..1c4de14b4 100644 --- a/test/controllers/administration/delivery_method_controller_test.rb +++ b/test/controllers/administration/delivery_method_controller_test.rb @@ -5,6 +5,7 @@ class Administration::DeliveryMethodsControllerTest < ActionController::TestCase delivery_methods delivery_method/departures packages + locations ) def setup @@ -177,4 +178,33 @@ def setup patch :update, id: @delivery_method.id, delivery_method: params end end + + test 'should add locations' do + @delivery_method.locations.delete_all + + params = { + id: @delivery_method.id, + delivery_method: { + location_ids: [@delivery_method.company.locations.first.id] + } + } + + assert_difference('@delivery_method.locations.count', 1) do + patch :update, params + end + end + + test 'should remove locations' do + assert_equal 1, @delivery_method.locations.count + + params = { + id: @delivery_method.id, + delivery_method: { + location_ids: [] + } + } + + patch :update, params + assert_equal 0, @delivery_method.locations.count + end end From 4c52feff54e4a7a1051940d76404b209b4c9e1f6 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 6 Nov 2015 13:23:49 +0200 Subject: [PATCH 158/189] add locations list --- .../delivery_methods/_basic.html.erb | 15 +++++++++++++++ config/locales/fi.yml | 1 + 2 files changed, 16 insertions(+) diff --git a/app/views/administration/delivery_methods/_basic.html.erb b/app/views/administration/delivery_methods/_basic.html.erb index 430e83c42..c232aeafe 100644 --- a/app/views/administration/delivery_methods/_basic.html.erb +++ b/app/views/administration/delivery_methods/_basic.html.erb @@ -217,6 +217,21 @@ <% end %>
+ + <% if current_company.locations.present? %> + + + + + <% end %> + diff --git a/config/locales/fi.yml b/config/locales/fi.yml index d908a8167..e8d555fd8 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -203,6 +203,7 @@ fi: lauantai: Lauantaijakelu lisakulu: Lisäkulu lisakulu_summa: Lisäkulusumma + locations: Sallitut toimipaikat logy_rahtikirjanumerot: LOGY rahtikirjanumerot maa_maara: Oletus määrämaa merahti: Rahtisopimus From 5061bd08aa9c556f6ed9854638625e6d853b1921 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 6 Nov 2015 13:30:25 +0200 Subject: [PATCH 159/189] use div --- app/views/administration/delivery_methods/_basic.html.erb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/administration/delivery_methods/_basic.html.erb b/app/views/administration/delivery_methods/_basic.html.erb index c232aeafe..4c0ed66bc 100644 --- a/app/views/administration/delivery_methods/_basic.html.erb +++ b/app/views/administration/delivery_methods/_basic.html.erb @@ -225,8 +225,10 @@ From da632c1e992eb579f1a3b716bbd4802475f93193 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 6 Nov 2015 15:48:16 +0200 Subject: [PATCH 160/189] order by jarjestys --- app/controllers/administration/delivery_methods_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/administration/delivery_methods_controller.rb b/app/controllers/administration/delivery_methods_controller.rb index f1774ecff..55deb5765 100644 --- a/app/controllers/administration/delivery_methods_controller.rb +++ b/app/controllers/administration/delivery_methods_controller.rb @@ -89,9 +89,9 @@ def delivery_method_params def searchable_columns [ + :jarjestys, :selite, :sopimusnro, - :jarjestys, ] end From 013639ce106d9009d841ac8be288cbc99fd3b58f Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 6 Nov 2015 16:09:34 +0200 Subject: [PATCH 161/189] update only if selite changed --- app/models/delivery_method.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index d195d9fa3..1d8668e10 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -196,7 +196,7 @@ def cargo_insurance_sku def update_relations msg = [] - if selite_was.present? + if selite_changed? cnt = company.delivery_methods.where(vak_kielto: selite_was).update_all(vak_kielto: selite) msg << I18n.t('administration.delivery_methods.update.delivery_methods', count: cnt) if cnt.nonzero? From a7bf0ff6748a20ab0f5d4cfe64c995a0ed022859 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 6 Nov 2015 16:12:54 +0200 Subject: [PATCH 162/189] don't translate if we search for company locale --- app/models/package.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/package.rb b/app/models/package.rb index 6ae8f7d1d..993269cce 100644 --- a/app/models/package.rb +++ b/app/models/package.rb @@ -38,6 +38,8 @@ def dimensions_are_mandatory? end def translated_description(locale) + return pakkauskuvaus if locale.downcase == Current.company.kieli.downcase + translations.find_by(kieli: locale).try(:selitetark) || pakkauskuvaus end From 70f1fd7b8c5634ee50ca9998d19fcd3ba2a5b581 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 6 Nov 2015 16:22:05 +0200 Subject: [PATCH 163/189] hide if not needed --- .../administration/delivery_methods/_form.html.erb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/administration/delivery_methods/_form.html.erb b/app/views/administration/delivery_methods/_form.html.erb index 0e82f3f5a..af44c8091 100644 --- a/app/views/administration/delivery_methods/_form.html.erb +++ b/app/views/administration/delivery_methods/_form.html.erb @@ -11,10 +11,12 @@ <%= render 'administration/translations', f: f %> -
- <%= render "administration/header", text: t('administration.delivery_methods.edit.departures.header') %> - <%= render 'departures', f: f %> -
+ <% if current_company.parameter.collection_batch_based_on_dimensions? %> +
+ <%= render "administration/header", text: t('administration.delivery_methods.edit.departures.header') %> + <%= render 'departures', f: f %> +
+ <% end %>
<%= render 'administration/actions', f: f %> From 0c3f41a4866789f00fd0a0a083029b9c5188119e Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 6 Nov 2015 16:39:39 +0200 Subject: [PATCH 164/189] don't update if new --- app/models/delivery_method.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 1d8668e10..cca50cc35 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -196,7 +196,7 @@ def cargo_insurance_sku def update_relations msg = [] - if selite_changed? + if selite_was.present? && selite_changed? cnt = company.delivery_methods.where(vak_kielto: selite_was).update_all(vak_kielto: selite) msg << I18n.t('administration.delivery_methods.update.delivery_methods', count: cnt) if cnt.nonzero? From 6ec8eecb4ebd77313fd852cc84741c7b64609866 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Fri, 6 Nov 2015 16:47:45 +0200 Subject: [PATCH 165/189] don't use shorthand because we need empty --- app/models/manufacture_order/order.rb | 2 +- app/models/offer_order/order.rb | 2 +- app/models/project_order/order.rb | 2 +- app/models/stock_transfer/order.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/manufacture_order/order.rb b/app/models/manufacture_order/order.rb index d36e1ac55..0ccaf0337 100644 --- a/app/models/manufacture_order/order.rb +++ b/app/models/manufacture_order/order.rb @@ -3,7 +3,7 @@ class ManufactureOrder::Order < Head validates :tila, inclusion: { in: ['V'] } - scope :not_manufactured, -> { where(alatila: %W(#{} K J A C)) } + scope :not_manufactured, -> { where(alatila: ['', :K, :J, :A, :C]) } # Rails requires sti_name method to return type column (tyyppi) value def self.sti_name diff --git a/app/models/offer_order/order.rb b/app/models/offer_order/order.rb index 0165a9d6a..96ff0e832 100644 --- a/app/models/offer_order/order.rb +++ b/app/models/offer_order/order.rb @@ -3,7 +3,7 @@ class OfferOrder::Order < Head validates :tila, inclusion: { in: ['T'] } - scope :printed_and_accepted, -> { where(alatila: %W(#{} A B)) } + scope :printed_and_accepted, -> { where(alatila: ['', :A, :B]) } # Rails requires sti_name method to return type column (tyyppi) value def self.sti_name diff --git a/app/models/project_order/order.rb b/app/models/project_order/order.rb index eca6aa4a4..9b1cdfad7 100644 --- a/app/models/project_order/order.rb +++ b/app/models/project_order/order.rb @@ -3,7 +3,7 @@ class ProjectOrder::Order < Head validates :tila, inclusion: { in: ['R'] } - scope :active, -> { where(alatila: %W(#{} A)) } + scope :active, -> { where(alatila: ['', :A]) } # Rails requires sti_name method to return type column (tyyppi) value def self.sti_name diff --git a/app/models/stock_transfer/order.rb b/app/models/stock_transfer/order.rb index 9cc5b5e77..b14c7539c 100644 --- a/app/models/stock_transfer/order.rb +++ b/app/models/stock_transfer/order.rb @@ -3,7 +3,7 @@ class StockTransfer::Order < Head validates :tila, inclusion: { in: ['G'] } - scope :not_delivered, -> { where(alatila: %W(#{} J KJ A C T P)) } + scope :not_delivered, -> { where(alatila: ['', :J, :KJ, :A, :C, :T, :P]) } # Rails requires sti_name method to return type column (tyyppi) value def self.sti_name From 3309f37923841c8d8ce96f11235039347902ece1 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 09:54:57 +0200 Subject: [PATCH 166/189] use symbols --- app/models/delivery_method.rb | 2 +- app/models/location.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index cca50cc35..f046fb963 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -28,7 +28,7 @@ class DeliveryMethod < BaseModel has_many :customer_keywords, foreign_key: :avainsana, primary_key: :selite has_many :departures, foreign_key: :liitostunnus, class_name: 'DeliveryMethod::Departure' - has_and_belongs_to_many :locations, join_table: 'toimitustavat_toimipaikat', association_foreign_key: 'toimipaikka_tunnus', foreign_key: 'toimitustapa_tunnus' + has_and_belongs_to_many :locations, join_table: :toimitustavat_toimipaikat, association_foreign_key: :toimipaikka_tunnus, foreign_key: :toimitustapa_tunnus validates :aktiivinen_kuljetus_kansallisuus, :maa_maara, :sisamaan_kuljetus_kansallisuus, inclusion: { in: Country.pluck(:koodi) }, allow_blank: true validates :jarjestys, numericality: { only_integer: true }, allow_blank: true diff --git a/app/models/location.rb b/app/models/location.rb index 4e3f3df02..27a2b5c18 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,5 +1,5 @@ class Location < BaseModel - has_and_belongs_to_many :delivery_methods, join_table: 'toimitustavat_toimipaikat', association_foreign_key: 'toimitustapa_tunnus', foreign_key: 'toimipaikka_tunnus' + has_and_belongs_to_many :delivery_methods, join_table: :toimitustavat_toimipaikat, association_foreign_key: :toimitustapa_tunnus, foreign_key: :toimipaikka_tunnus self.table_name = :yhtion_toimipaikat self.primary_key = :tunnus From 1fbcd29d7be0a6fd4f2320764cc64fddfc8c0783 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 09:56:03 +0200 Subject: [PATCH 167/189] sort and typecheck --- test/models/delivery_method_test.rb | 40 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 20311876c..60c9524aa 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -29,26 +29,26 @@ def setup end test 'relations' do - assert_not_equal 0, @delivery_method.customer_keywords.count - assert_not_equal 0, @delivery_method.customs.count - assert_not_equal 0, @delivery_method.departures.count - assert_not_equal 0, @delivery_method.freights.count - assert_not_equal 0, @delivery_method.manufacture_orders.count - assert_not_equal 0, @delivery_method.mode_of_transports.count - assert_not_equal 0, @delivery_method.nature_of_transactions.count - assert_not_equal 0, @delivery_method.offer_orders.count - assert_not_equal 0, @delivery_method.preorders.count - assert_not_equal 0, @delivery_method.project_orders.count - assert_not_equal 0, @delivery_method.reclamation_orders.count - assert_not_equal 0, @delivery_method.sales_order_drafts.count - assert_not_equal 0, @delivery_method.sales_orders.not_delivered.count - assert_not_equal 0, @delivery_method.sorting_point.count - assert_not_equal 0, @delivery_method.stock_transfers.not_delivered.count - assert_not_equal 0, @delivery_method.translations.count - assert_not_equal 0, @delivery_method.waybills.count - assert_not_equal 0, @delivery_method.work_orders.count - assert_not_equal 0, @delivery_method.freight_contracts.count - assert_not_equal 0, @delivery_method.locations.count + assert @delivery_method.customer_keywords.count > 0 + assert @delivery_method.customs.count > 0 + assert @delivery_method.departures.count > 0 + assert @delivery_method.freight_contracts.count > 0 + assert @delivery_method.freights.count > 0 + assert @delivery_method.locations.count > 0 + assert @delivery_method.manufacture_orders.count > 0 + assert @delivery_method.mode_of_transports.count > 0 + assert @delivery_method.nature_of_transactions.count > 0 + assert @delivery_method.offer_orders.count > 0 + assert @delivery_method.preorders.count > 0 + assert @delivery_method.project_orders.count > 0 + assert @delivery_method.reclamation_orders.count > 0 + assert @delivery_method.sales_order_drafts.count > 0 + assert @delivery_method.sales_orders.not_delivered.count > 0 + assert @delivery_method.sorting_point.count > 0 + assert @delivery_method.stock_transfers.not_delivered.count > 0 + assert @delivery_method.translations.count > 0 + assert @delivery_method.waybills.count > 0 + assert @delivery_method.work_orders.count > 0 end test "fixtures should be valid" do From aae1df41d11bf9fc95210bfa12e312ef69399a24 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 10:42:30 +0200 Subject: [PATCH 168/189] sort --- app/models/delivery_method.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index f046fb963..50a4225f8 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -3,14 +3,15 @@ class DeliveryMethod < BaseModel include Searchable with_options foreign_key: :selite do |o| + o.has_many :customs, primary_key: :poistumistoimipaikka_koodi, class_name: 'Keyword::Customs' o.has_many :mode_of_transports, primary_key: :kuljetusmuoto, class_name: 'Keyword::ModeOfTransport' o.has_many :nature_of_transactions, primary_key: :kauppatapahtuman_luonne, class_name: 'Keyword::NatureOfTransaction' - o.has_many :customs, primary_key: :poistumistoimipaikka_koodi, class_name: 'Keyword::Customs' o.has_many :sorting_point, primary_key: :lajittelupiste, class_name: 'Keyword::SortingPoint' o.has_many :translations, class_name: 'Keyword::DeliveryMethodTranslation' end with_options foreign_key: :toimitustapa, primary_key: :selite do |o| + o.has_many :freight_contracts o.has_many :freights o.has_many :manufacture_orders, class_name: 'ManufactureOrder::Order' o.has_many :offer_orders, class_name: 'OfferOrder::Order' @@ -22,7 +23,6 @@ class DeliveryMethod < BaseModel o.has_many :stock_transfers, class_name: 'StockTransfer::Order' o.has_many :waybills o.has_many :work_orders, class_name: 'WorkOrder::Order' - o.has_many :freight_contracts end has_many :customer_keywords, foreign_key: :avainsana, primary_key: :selite @@ -42,11 +42,11 @@ class DeliveryMethod < BaseModel validates :toim_postino, length: { maximum: 15 } validates :toim_postitp, :toim_maa, length: { maximum: 35 } + validate :cargo_insurance_sku, if: :has_cargo_insurance_sku? + validate :freight_sku, if: :has_freight_sku? + validate :mandatory_new_packaging_information if :package_info_entry_denied && :collective_batch validate :vaihtoehtoinen_vak_toimitustapa_validation validate :vak_kielto_validation - validate :mandatory_new_packaging_information if :package_info_entry_denied && :collective_batch - validate :freight_sku, if: :has_freight_sku? - validate :cargo_insurance_sku, if: :has_cargo_insurance_sku? before_save :defaults before_destroy :check_relations @@ -56,8 +56,8 @@ class DeliveryMethod < BaseModel float_columns :jvkulu, :erilliskasiteltavakulu, :kuljetusvakuutus, :kuluprosentti, :ulkomaanlisa, :lisakulu, :lisakulu_summa - accepts_nested_attributes_for :translations, allow_destroy: true accepts_nested_attributes_for :departures, allow_destroy: true + accepts_nested_attributes_for :translations, allow_destroy: true scope :permit_adr, -> { where(vak_kielto: '') } From 09b564df9a90c5a8a5843aa3c8901215d669171d Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 12:20:24 +0200 Subject: [PATCH 169/189] fix deliverymethod adr tests --- app/models/delivery_method.rb | 2 +- test/models/delivery_method_test.rb | 44 +++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 50a4225f8..980903fa1 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -262,7 +262,7 @@ def vak_kielto_validation errors.add :vak_kielto, I18n.t('errors.messages.inclusion') end - if vak_kielto_was.present? && vak_kielto.empty? + if vak_kielto_changed? && vak_kielto == 'K' count = company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite).count if count > 0 diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 60c9524aa..803438068 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -66,23 +66,49 @@ def setup refute @delivery_method.valid?, "Delivery method already exists" end - test 'should validate adr prohibition' do + test 'valid vak_kielto values' do @delivery_method.vak_kielto = '' assert @delivery_method.valid? @delivery_method.vak_kielto = 'K' assert @delivery_method.valid? - @delivery_method.vak_kielto = 'neko' - refute @delivery_method.valid?, "Invalid vak_kielto value" + @delivery_method.vak_kielto = 'not valid' + refute @delivery_method.valid? - deli2 = delivery_methods :kiitolinja - deli2.vaihtoehtoinen_vak_toimitustapa = 'Kaukokiito' - deli2.save! - @delivery_method.vak_kielto = 'K' - @delivery_method.save + # should allow the name of any other delivery method that accepts adr + dm = delivery_methods :kiitolinja + dm.vak_kielto = '' + dm.save! + + @delivery_method.vak_kielto = dm.selite + assert @delivery_method.valid? + + # should NOT allow the name of delivery method if it does not accept adr + dm.vak_kielto = 'K' + dm.save! + + refute @delivery_method.valid? + end + + test 'should not allow changing vak_kielto if used as alternative adr method' do + # set kaukokiito to allow adr shipments @delivery_method.vak_kielto = '' - refute @delivery_method.valid?, @delivery_method.errors.full_messages + @delivery_method.save! + + # set kiitolinja to have kaukokiito as alternative adr shipping method + dm = delivery_methods :kiitolinja + dm.vaihtoehtoinen_vak_toimitustapa = @delivery_method.selite + dm.save! + + # try to change kaukokiito to deny adr shipments + @delivery_method.vak_kielto = 'K' + + # should not be allowed + error = I18n.t 'errors.delivery_method.in_use_adr' + refute @delivery_method.valid? + assert_equal error, @delivery_method.errors.messages.first.second.first + assert_equal :vak_kielto, @delivery_method.errors.messages.first.first end test 'should validate freight sku' do From fcfbedd4582972983bb93327658a5e6f1e68e917 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 14:00:10 +0200 Subject: [PATCH 170/189] test error messages --- test/models/delivery_method_test.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 803438068..2ad6c967d 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -107,24 +107,29 @@ def setup # should not be allowed error = I18n.t 'errors.delivery_method.in_use_adr' refute @delivery_method.valid? - assert_equal error, @delivery_method.errors.messages.first.second.first - assert_equal :vak_kielto, @delivery_method.errors.messages.first.first + assert_equal error, @delivery_method.errors.messages[:vak_kielto].first end test 'should validate freight sku' do @delivery_method.rahti_tuotenumero = 'non_inventory_manageable_product' assert @delivery_method.valid?, @delivery_method.errors.full_messages + error = I18n.t 'errors.delivery_method.product_not_in_inventory_management' @delivery_method.rahti_tuotenumero = 'hammer123' - refute @delivery_method.valid?, @delivery_method.errors.full_messages + + refute @delivery_method.valid? + assert_equal error, @delivery_method.errors.messages[:rahti_tuotenumero].first end test 'should validate cargo insurance sku' do @delivery_method.kuljetusvakuutus_tuotenumero = 'non_inventory_manageable_product' - assert @delivery_method.valid?, @delivery_method.errors.full_messages + assert @delivery_method.valid? + error = I18n.t 'errors.delivery_method.product_not_in_inventory_management' @delivery_method.kuljetusvakuutus_tuotenumero = 'hammer123' - refute @delivery_method.valid?, @delivery_method.errors.full_messages + + refute @delivery_method.valid? + assert_equal error, @delivery_method.errors.messages[:kuljetusvakuutus_tuotenumero].first end test 'should validate alternative adr prohibition' do From c81b199fe37b3a307b8a455eaa57ffba99e3fa1a Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 14:48:59 +0200 Subject: [PATCH 171/189] fix unifaun online params validation --- app/models/delivery_method.rb | 9 +++++--- test/models/delivery_method_test.rb | 33 ++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 980903fa1..d69982f01 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -44,7 +44,7 @@ class DeliveryMethod < BaseModel validate :cargo_insurance_sku, if: :has_cargo_insurance_sku? validate :freight_sku, if: :has_freight_sku? - validate :mandatory_new_packaging_information if :package_info_entry_denied && :collective_batch + validate :unifaun_required_parameters validate :vaihtoehtoinen_vak_toimitustapa_validation validate :vak_kielto_validation @@ -249,8 +249,11 @@ def update_relations flash_notice = msg.join(', ') end - def mandatory_new_packaging_information - if unifaun_online? || unifaun_print_server? + def unifaun_required_parameters + # Koontierätulostus ei toimi Unifaunin kanssa ilman "uusia pakkaustietoja" + return unless unifaun_online? || unifaun_print_server? + + if !package_info_entry_allowed? && collective_batch? errors.add :base, I18n.t("errors.delivery_method.unifaun_info_missing") end end diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 2ad6c967d..3f7c20c31 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -140,12 +140,35 @@ def setup refute @delivery_method.valid?, "Invalid vaihtoehtoinen_vak_toimitustapa value" end - test 'mandatory new packaging information' do - @delivery_method.tulostustapa = 'L' - @delivery_method.uudet_pakkaustiedot = '' - @delivery_method.rahtikirja = 'rahtikirja_unifaun_uo_siirto.inc' + test 'unifaun info is present' do + error = I18n.t 'errors.delivery_method.unifaun_info_missing' - refute @delivery_method.valid?, "New packaging info is mandatory with collective batch and Unifaun Online" + # If we have collective_batch and package_info_entry_denied we cannot use unifaun online + @delivery_method.tulostustapa = :collective_batch + @delivery_method.uudet_pakkaustiedot = :package_info_entry_denied + @delivery_method.rahtikirja = :unifaun_online + + refute @delivery_method.valid? + assert_equal error, @delivery_method.errors.messages[:base].first + + # If we have collective_batch and package_info_entry_denied we cannot use unifaun print server + @delivery_method.rahtikirja = :unifaun_print_server + refute @delivery_method.valid? + assert_equal error, @delivery_method.errors.messages[:base].first + + # Not using unifaun is ok + @delivery_method.rahtikirja = :generic_a4 + assert @delivery_method.valid? + + # Unifaun with package_info_entry_allowed is ok + @delivery_method.rahtikirja = :unifaun_print_server + @delivery_method.uudet_pakkaustiedot = :package_info_entry_allowed + assert @delivery_method.valid? + + # Unifaun with batch is ok + @delivery_method.uudet_pakkaustiedot = :package_info_entry_denied + @delivery_method.tulostustapa = :batch + assert @delivery_method.valid? end test 'should be in use' do From 24d09ed37c835e457b34a1926272f50ee8aa009e Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 14:53:37 +0200 Subject: [PATCH 172/189] test error message --- test/models/delivery_method_test.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 3f7c20c31..8c8e2c0d5 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -136,8 +136,10 @@ def setup @delivery_method.vaihtoehtoinen_vak_toimitustapa = '' assert @delivery_method.valid? + error = I18n.t 'errors.messages.inclusion' @delivery_method.vaihtoehtoinen_vak_toimitustapa = 'neko' - refute @delivery_method.valid?, "Invalid vaihtoehtoinen_vak_toimitustapa value" + refute @delivery_method.valid? + assert_equal error, @delivery_method.errors[:vaihtoehtoinen_vak_toimitustapa].first end test 'unifaun info is present' do From cd5af4fd7212f459c11f4c5fde1490c90e2d878c Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 14:56:30 +0200 Subject: [PATCH 173/189] move validation conditions into validation --- app/models/delivery_method.rb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index d69982f01..5cb28d9e0 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -42,8 +42,8 @@ class DeliveryMethod < BaseModel validates :toim_postino, length: { maximum: 15 } validates :toim_postitp, :toim_maa, length: { maximum: 35 } - validate :cargo_insurance_sku, if: :has_cargo_insurance_sku? - validate :freight_sku, if: :has_freight_sku? + validate :cargo_insurance_sku + validate :freight_sku validate :unifaun_required_parameters validate :vaihtoehtoinen_vak_toimitustapa_validation validate :vak_kielto_validation @@ -175,20 +175,16 @@ def name_translated(locale) private - def has_freight_sku? - rahti_tuotenumero.present? - end - def freight_sku + return unless rahti_tuotenumero.present? + cnt = company.products.no_inventory_management.where(tuoteno: rahti_tuotenumero).count errors.add :rahti_tuotenumero, I18n.t('errors.delivery_method.product_not_in_inventory_management') if cnt.zero? end - def has_cargo_insurance_sku? - kuljetusvakuutus_tuotenumero.present? - end - def cargo_insurance_sku + return unless kuljetusvakuutus_tuotenumero.present? + cnt = company.products.no_inventory_management.where(tuoteno: kuljetusvakuutus_tuotenumero).count errors.add :kuljetusvakuutus_tuotenumero, I18n.t('errors.delivery_method.product_not_in_inventory_management') if cnt.zero? end From b63bd104a389ac03d73b41746ffe95e28e0bea2a Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 15:02:53 +0200 Subject: [PATCH 174/189] rename methods --- app/models/delivery_method.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 5cb28d9e0..1e707dade 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -42,11 +42,11 @@ class DeliveryMethod < BaseModel validates :toim_postino, length: { maximum: 15 } validates :toim_postitp, :toim_maa, length: { maximum: 35 } + validate :adr_handling + validate :alternative_adr_delivery_method validate :cargo_insurance_sku validate :freight_sku - validate :unifaun_required_parameters - validate :vaihtoehtoinen_vak_toimitustapa_validation - validate :vak_kielto_validation + validate :unifaun_parameters before_save :defaults before_destroy :check_relations @@ -245,7 +245,7 @@ def update_relations flash_notice = msg.join(', ') end - def unifaun_required_parameters + def unifaun_parameters # Koontierätulostus ei toimi Unifaunin kanssa ilman "uusia pakkaustietoja" return unless unifaun_online? || unifaun_print_server? @@ -254,7 +254,7 @@ def unifaun_required_parameters end end - def vak_kielto_validation + def adr_handling allowed = company.delivery_methods.permit_adr.shipment.pluck(:selite) + [ '', 'K' ] unless allowed.include? vak_kielto @@ -270,7 +270,7 @@ def vak_kielto_validation end end - def vaihtoehtoinen_vak_toimitustapa_validation + def alternative_adr_delivery_method allowed = company.delivery_methods.permit_adr.shipment.pluck(:selite) + [ '' ] unless allowed.include? vaihtoehtoinen_vak_toimitustapa From 85a83cab4aa1245880c6745b5dd3286f5ff416ff Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 15:32:53 +0200 Subject: [PATCH 175/189] test all cases --- app/models/delivery_method.rb | 12 +-- test/models/delivery_method_test.rb | 129 +++++++++++----------------- 2 files changed, 55 insertions(+), 86 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 1e707dade..34006da33 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -2,6 +2,8 @@ class DeliveryMethod < BaseModel include AttributeSanitator include Searchable + attr_accessor :flash_notice + with_options foreign_key: :selite do |o| o.has_many :customs, primary_key: :poistumistoimipaikka_koodi, class_name: 'Keyword::Customs' o.has_many :mode_of_transports, primary_key: :kuljetusmuoto, class_name: 'Keyword::ModeOfTransport' @@ -61,8 +63,6 @@ class DeliveryMethod < BaseModel scope :permit_adr, -> { where(vak_kielto: '') } - attr_accessor :flash_notice - self.table_name = :toimitustapa self.primary_key = :tunnus @@ -202,15 +202,15 @@ def update_relations cnt = company.customers.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << I18n.t('administration.delivery_methods.update.customers', count: cnt) if cnt.nonzero? + cnt = company.customer_keywords.where(avainsana: selite_was).update_all(avainsana: selite) + msg << I18n.t('administration.delivery_methods.update.customer_keywords', count: cnt) if cnt.nonzero? + cnt = company.sales_orders.not_delivered.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << I18n.t('administration.delivery_methods.update.not_delivered_sales_orders', count: cnt) if cnt.nonzero? cnt = company.sales_order_drafts.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << I18n.t('administration.delivery_methods.update.sales_order_drafts', count: cnt) if cnt.nonzero? - cnt = company.customer_keywords.where(avainsana: selite_was).update_all(avainsana: selite) - msg << I18n.t('administration.delivery_methods.update.customer_keywords', count: cnt) if cnt.nonzero? - cnt = company.stock_transfers.not_delivered.where(toimitustapa: selite_was).update_all(toimitustapa: selite) msg << I18n.t('administration.delivery_methods.update.not_delivered_stock_transfers', count: cnt) if cnt.nonzero? @@ -242,7 +242,7 @@ def update_relations msg << I18n.t('administration.delivery_methods.update.not_printed_waybills', count: cnt) if cnt.nonzero? end - flash_notice = msg.join(', ') + self.flash_notice = msg.to_sentence end def unifaun_parameters diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 8c8e2c0d5..d64e64bbe 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -180,110 +180,79 @@ def setup end test 'should update relations when updating selite' do - deli2 = @delivery_method.dup - deli2.selite = 'Kaukokiito2' - deli2.rahdinkuljettaja = 'Kaukokiito2' - deli2.vak_kielto = '' - deli2.vaihtoehtoinen_vak_toimitustapa = @delivery_method.selite - deli2.save! + # Set delivery method to all available relations + dm = delivery_methods :kiitolinja + dm.update! vak_kielto: @delivery_method.selite, vaihtoehtoinen_vak_toimitustapa: @delivery_method.selite + + cust = customers :stubborn_customer + cust.update! toimitustapa: @delivery_method.selite + + cust_key = customer_keywords :keyword_1 + cust_key.update! avainsana: @delivery_method.selite order = sales_order_orders :not_delivered_order_1 - order.toimitustapa = @delivery_method.selite - order.save! + order.update! toimitustapa: @delivery_method.selite draft = sales_order_drafts :not_finished_order - draft.toimitustapa = @delivery_method.selite - draft.save! + draft.update! toimitustapa: @delivery_method.selite stock = stock_transfer_orders :st_one - stock.toimitustapa = @delivery_method.selite - stock.save! + stock.update! toimitustapa: @delivery_method.selite preorder = preorder_orders :pre_one - preorder.toimitustapa = @delivery_method.selite - preorder.save! + preorder.update! toimitustapa: @delivery_method.selite offer = offer_order_orders :offer_one - offer.toimitustapa = @delivery_method.selite - offer.save! + offer.update! toimitustapa: @delivery_method.selite manufacture = manufacture_order_orders :mo_one - manufacture.toimitustapa = @delivery_method.selite - manufacture.save! + manufacture.update! toimitustapa: @delivery_method.selite work = work_order_orders :work_one - work.toimitustapa = @delivery_method.selite - work.save! + work.update! toimitustapa: @delivery_method.selite project = project_order_orders :project_one - project.toimitustapa = @delivery_method.selite - project.save! + project.update! toimitustapa: @delivery_method.selite reclamation = reclamation_order_orders :reclamation_one - reclamation.toimitustapa = @delivery_method.selite - reclamation.save! + reclamation.update! toimitustapa: @delivery_method.selite freight = freights :kaukokiito_freight - freight.toimitustapa = @delivery_method.selite - freight.save! + freight.update! toimitustapa: @delivery_method.selite freight_contract = freight_contracts :kaukokiito_freight_contract - freight_contract.toimitustapa = @delivery_method.selite - freight_contract.save! + freight_contract.update! toimitustapa: @delivery_method.selite waybill = waybills :waybill_one - waybill.toimitustapa = @delivery_method.selite - waybill.save! - - @delivery_method.selite = 'Kaukokiito3' - @delivery_method.save! - assert @delivery_method.valid?, @delivery_method.errors.full_messages - - # delivery_method - deli2.reload - assert_equal 'Kaukokiito3', deli2.vaihtoehtoinen_vak_toimitustapa - - # customers - cust = customers :stubborn_customer - assert_equal 'Kaukokiito3', cust.reload.toimitustapa - - # customer keywords - cust_key = customer_keywords :keyword_1 - assert_equal 'Kaukokiito3', cust_key.reload.avainsana - - # sales orders - assert_equal 'Kaukokiito3', order.reload.toimitustapa - assert_equal 'Kaukokiito3', draft.reload.toimitustapa - - # stock transfer orders - assert_equal 'Kaukokiito3', stock.reload.toimitustapa - - # stock transfer orders - assert_equal 'Kaukokiito3', preorder.reload.toimitustapa - - # offer order orders - assert_equal 'Kaukokiito3', offer.reload.toimitustapa - - # manufacture order orders - assert_equal 'Kaukokiito3', manufacture.reload.toimitustapa - - # work order orders - assert_equal 'Kaukokiito3', work.reload.toimitustapa - - # project order orders - assert_equal 'Kaukokiito3', project.reload.toimitustapa - - # reclamation order orders - assert_equal 'Kaukokiito3', reclamation.reload.toimitustapa - - # freights - assert_equal 'Kaukokiito3', freight.reload.toimitustapa - - # freight_contract - assert_equal 'Kaukokiito3', freight_contract.reload.toimitustapa - - # waybill - assert_equal 'Kaukokiito3', waybill.reload.toimitustapa + waybill.update! toimitustapa: @delivery_method.selite + + # Change delivery method name + new_name = 'Kaukokiito kolmoinen' + @delivery_method.update! selite: new_name + + assert_not_equal "", @delivery_method.flash_notice + + # Should change everywhere + assert_equal new_name, dm.reload.vak_kielto + assert_equal new_name, dm.vaihtoehtoinen_vak_toimitustapa + assert_equal new_name, cust.reload.toimitustapa + assert_equal new_name, cust_key.reload.avainsana + assert_equal new_name, order.reload.toimitustapa + assert_equal new_name, draft.reload.toimitustapa + assert_equal new_name, stock.reload.toimitustapa + assert_equal new_name, preorder.reload.toimitustapa + assert_equal new_name, offer.reload.toimitustapa + assert_equal new_name, manufacture.reload.toimitustapa + assert_equal new_name, work.reload.toimitustapa + assert_equal new_name, project.reload.toimitustapa + assert_equal new_name, reclamation.reload.toimitustapa + assert_equal new_name, freight.reload.toimitustapa + assert_equal new_name, freight_contract.reload.toimitustapa + assert_equal new_name, waybill.reload.toimitustapa + + # Change something elsta than the delivery method name + @delivery_method.update! virallinen_selite: new_name + assert_equal "", @delivery_method.flash_notice end test 'should have departure' do From 6d2e196de2573cc69ea6748f6c90577443fd47a9 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 15:53:56 +0200 Subject: [PATCH 176/189] clean up test --- test/models/delivery_method_test.rb | 79 +++++++++++++---------------- 1 file changed, 35 insertions(+), 44 deletions(-) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index d64e64bbe..a41340646 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -180,56 +180,45 @@ def setup end test 'should update relations when updating selite' do - # Set delivery method to all available relations - dm = delivery_methods :kiitolinja - dm.update! vak_kielto: @delivery_method.selite, vaihtoehtoinen_vak_toimitustapa: @delivery_method.selite - - cust = customers :stubborn_customer - cust.update! toimitustapa: @delivery_method.selite - - cust_key = customer_keywords :keyword_1 - cust_key.update! avainsana: @delivery_method.selite - - order = sales_order_orders :not_delivered_order_1 - order.update! toimitustapa: @delivery_method.selite - - draft = sales_order_drafts :not_finished_order - draft.update! toimitustapa: @delivery_method.selite - - stock = stock_transfer_orders :st_one - stock.update! toimitustapa: @delivery_method.selite - - preorder = preorder_orders :pre_one - preorder.update! toimitustapa: @delivery_method.selite - - offer = offer_order_orders :offer_one - offer.update! toimitustapa: @delivery_method.selite - + # setup all delivery method fixtures + dm = delivery_methods :kiitolinja + cust = customers :stubborn_customer + cust_key = customer_keywords :keyword_1 + order = sales_order_orders :not_delivered_order_1 + draft = sales_order_drafts :not_finished_order + stock = stock_transfer_orders :st_one + preorder = preorder_orders :pre_one + offer = offer_order_orders :offer_one manufacture = manufacture_order_orders :mo_one - manufacture.update! toimitustapa: @delivery_method.selite - - work = work_order_orders :work_one - work.update! toimitustapa: @delivery_method.selite - - project = project_order_orders :project_one - project.update! toimitustapa: @delivery_method.selite - + work = work_order_orders :work_one + project = project_order_orders :project_one reclamation = reclamation_order_orders :reclamation_one + freight = freights :kaukokiito_freight + contract = freight_contracts :kaukokiito_freight_contract + waybill = waybills :waybill_one + + # set delivery method to all available relations + dm.update! vak_kielto: @delivery_method.selite, vaihtoehtoinen_vak_toimitustapa: @delivery_method.selite + cust.update! toimitustapa: @delivery_method.selite + cust_key.update! avainsana: @delivery_method.selite + order.update! toimitustapa: @delivery_method.selite + draft.update! toimitustapa: @delivery_method.selite + stock.update! toimitustapa: @delivery_method.selite + preorder.update! toimitustapa: @delivery_method.selite + offer.update! toimitustapa: @delivery_method.selite + manufacture.update! toimitustapa: @delivery_method.selite + work.update! toimitustapa: @delivery_method.selite + project.update! toimitustapa: @delivery_method.selite reclamation.update! toimitustapa: @delivery_method.selite - - freight = freights :kaukokiito_freight - freight.update! toimitustapa: @delivery_method.selite - - freight_contract = freight_contracts :kaukokiito_freight_contract - freight_contract.update! toimitustapa: @delivery_method.selite - - waybill = waybills :waybill_one - waybill.update! toimitustapa: @delivery_method.selite + freight.update! toimitustapa: @delivery_method.selite + contract.update! toimitustapa: @delivery_method.selite + waybill.update! toimitustapa: @delivery_method.selite # Change delivery method name new_name = 'Kaukokiito kolmoinen' @delivery_method.update! selite: new_name + # We should have flash notice assert_not_equal "", @delivery_method.flash_notice # Should change everywhere @@ -247,11 +236,13 @@ def setup assert_equal new_name, project.reload.toimitustapa assert_equal new_name, reclamation.reload.toimitustapa assert_equal new_name, freight.reload.toimitustapa - assert_equal new_name, freight_contract.reload.toimitustapa + assert_equal new_name, contract.reload.toimitustapa assert_equal new_name, waybill.reload.toimitustapa - # Change something elsta than the delivery method name + # Change something else than the delivery method name @delivery_method.update! virallinen_selite: new_name + + # We should not a have flash notice assert_equal "", @delivery_method.flash_notice end From fea7ac1f9a23f6a274eccc268eb62fd683166be6 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 15:57:38 +0200 Subject: [PATCH 177/189] assert empty/not_empty --- test/models/delivery_method_test.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index a41340646..b5a31fe84 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -214,14 +214,14 @@ def setup contract.update! toimitustapa: @delivery_method.selite waybill.update! toimitustapa: @delivery_method.selite - # Change delivery method name - new_name = 'Kaukokiito kolmoinen' + # change the delivery method name + new_name = 'Kaukokiito kakkoinen' @delivery_method.update! selite: new_name - # We should have flash notice - assert_not_equal "", @delivery_method.flash_notice + # we should have a flash notice + assert_not_empty @delivery_method.flash_notice - # Should change everywhere + # should change everywhere assert_equal new_name, dm.reload.vak_kielto assert_equal new_name, dm.vaihtoehtoinen_vak_toimitustapa assert_equal new_name, cust.reload.toimitustapa @@ -239,11 +239,11 @@ def setup assert_equal new_name, contract.reload.toimitustapa assert_equal new_name, waybill.reload.toimitustapa - # Change something else than the delivery method name + # change something else than the delivery method name @delivery_method.update! virallinen_selite: new_name - # We should not a have flash notice - assert_equal "", @delivery_method.flash_notice + # we should not have a flash notice + assert_empty @delivery_method.flash_notice end test 'should have departure' do From d00ded3c71a2dba22e269120a8e49141101f4b35 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 16:01:12 +0200 Subject: [PATCH 178/189] remove useless test --- test/models/delivery_method_test.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index b5a31fe84..096b307de 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -56,11 +56,6 @@ def setup assert @departure.valid?, @departure.errors.full_messages end - test 'departure should have valid time' do - assert_equal '12:00:00', @departure.kerailyn_aloitusaika.strftime('%H:%M:%S'), @departure.errors.full_messages - assert_equal '13:24:59', @departure.lahdon_kellonaika.strftime('%H:%M:%S'), @departure.errors.full_messages - end - test "selite should be unique" do @delivery_method.selite = "Kiitolinja" refute @delivery_method.valid?, "Delivery method already exists" From 09103e9d5ab1329db4c450dca5d038e4a4200ec2 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Mon, 9 Nov 2015 16:07:34 +0200 Subject: [PATCH 179/189] remove unnecessary test + cleanup code --- test/models/delivery_method_test.rb | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 096b307de..e4ee58d94 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -57,8 +57,11 @@ def setup end test "selite should be unique" do - @delivery_method.selite = "Kiitolinja" - refute @delivery_method.valid?, "Delivery method already exists" + error = I18n.t 'errors.messages.taken' + @delivery_method.selite = 'Kiitolinja' + + refute @delivery_method.valid? + assert_equal error, @delivery_method.errors[:selite].first end test 'valid vak_kielto values' do @@ -73,28 +76,24 @@ def setup # should allow the name of any other delivery method that accepts adr dm = delivery_methods :kiitolinja - dm.vak_kielto = '' - dm.save! + dm.update! vak_kielto: '' @delivery_method.vak_kielto = dm.selite assert @delivery_method.valid? # should NOT allow the name of delivery method if it does not accept adr - dm.vak_kielto = 'K' - dm.save! + dm.update! vak_kielto: 'K' refute @delivery_method.valid? end test 'should not allow changing vak_kielto if used as alternative adr method' do # set kaukokiito to allow adr shipments - @delivery_method.vak_kielto = '' - @delivery_method.save! + @delivery_method.update! vak_kielto: '' # set kiitolinja to have kaukokiito as alternative adr shipping method dm = delivery_methods :kiitolinja - dm.vaihtoehtoinen_vak_toimitustapa = @delivery_method.selite - dm.save! + dm.update! vaihtoehtoinen_vak_toimitustapa: @delivery_method.selite # try to change kaukokiito to deny adr shipments @delivery_method.vak_kielto = 'K' @@ -107,7 +106,7 @@ def setup test 'should validate freight sku' do @delivery_method.rahti_tuotenumero = 'non_inventory_manageable_product' - assert @delivery_method.valid?, @delivery_method.errors.full_messages + assert @delivery_method.valid? error = I18n.t 'errors.delivery_method.product_not_in_inventory_management' @delivery_method.rahti_tuotenumero = 'hammer123' @@ -168,7 +167,7 @@ def setup assert @delivery_method.valid? end - test 'should be in use' do + test 'do not delete delivery method if it is in use' do assert_no_difference('DeliveryMethod.count') do @delivery_method.destroy end @@ -240,8 +239,4 @@ def setup # we should not have a flash notice assert_empty @delivery_method.flash_notice end - - test 'should have departure' do - assert_equal 1, @delivery_method.departures.count - end end From 0598ba179ee10acc528dd2304b107366ab9a8a85 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Tue, 10 Nov 2015 10:40:53 +0200 Subject: [PATCH 180/189] move fixtures to setup --- test/models/delivery_method_test.rb | 96 ++++++++++++++--------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index e4ee58d94..ab93cb123 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -26,6 +26,23 @@ class DeliveryMethodTest < ActiveSupport::TestCase def setup @delivery_method = delivery_methods :kaukokiito @departure = delivery_method_departures :departure_one + + # setup fixtures for all delivery method relations + @dm = delivery_methods :kiitolinja + @cust = customers :stubborn_customer + @cust_key = customer_keywords :keyword_1 + @order = sales_order_orders :not_delivered_order_1 + @draft = sales_order_drafts :not_finished_order + @stock = stock_transfer_orders :st_one + @preorder = preorder_orders :pre_one + @offer = offer_order_orders :offer_one + @manufacture = manufacture_order_orders :mo_one + @work = work_order_orders :work_one + @project = project_order_orders :project_one + @reclamation = reclamation_order_orders :reclamation_one + @freight = freights :kaukokiito_freight + @contract = freight_contracts :kaukokiito_freight_contract + @waybill = waybills :waybill_one end test 'relations' do @@ -174,39 +191,22 @@ def setup end test 'should update relations when updating selite' do - # setup all delivery method fixtures - dm = delivery_methods :kiitolinja - cust = customers :stubborn_customer - cust_key = customer_keywords :keyword_1 - order = sales_order_orders :not_delivered_order_1 - draft = sales_order_drafts :not_finished_order - stock = stock_transfer_orders :st_one - preorder = preorder_orders :pre_one - offer = offer_order_orders :offer_one - manufacture = manufacture_order_orders :mo_one - work = work_order_orders :work_one - project = project_order_orders :project_one - reclamation = reclamation_order_orders :reclamation_one - freight = freights :kaukokiito_freight - contract = freight_contracts :kaukokiito_freight_contract - waybill = waybills :waybill_one - # set delivery method to all available relations - dm.update! vak_kielto: @delivery_method.selite, vaihtoehtoinen_vak_toimitustapa: @delivery_method.selite - cust.update! toimitustapa: @delivery_method.selite - cust_key.update! avainsana: @delivery_method.selite - order.update! toimitustapa: @delivery_method.selite - draft.update! toimitustapa: @delivery_method.selite - stock.update! toimitustapa: @delivery_method.selite - preorder.update! toimitustapa: @delivery_method.selite - offer.update! toimitustapa: @delivery_method.selite - manufacture.update! toimitustapa: @delivery_method.selite - work.update! toimitustapa: @delivery_method.selite - project.update! toimitustapa: @delivery_method.selite - reclamation.update! toimitustapa: @delivery_method.selite - freight.update! toimitustapa: @delivery_method.selite - contract.update! toimitustapa: @delivery_method.selite - waybill.update! toimitustapa: @delivery_method.selite + @dm.update! vak_kielto: @delivery_method.selite, vaihtoehtoinen_vak_toimitustapa: @delivery_method.selite + @cust.update! toimitustapa: @delivery_method.selite + @cust_key.update! avainsana: @delivery_method.selite + @order.update! toimitustapa: @delivery_method.selite + @draft.update! toimitustapa: @delivery_method.selite + @stock.update! toimitustapa: @delivery_method.selite + @preorder.update! toimitustapa: @delivery_method.selite + @offer.update! toimitustapa: @delivery_method.selite + @manufacture.update! toimitustapa: @delivery_method.selite + @work.update! toimitustapa: @delivery_method.selite + @project.update! toimitustapa: @delivery_method.selite + @reclamation.update! toimitustapa: @delivery_method.selite + @freight.update! toimitustapa: @delivery_method.selite + @contract.update! toimitustapa: @delivery_method.selite + @waybill.update! toimitustapa: @delivery_method.selite # change the delivery method name new_name = 'Kaukokiito kakkoinen' @@ -216,22 +216,22 @@ def setup assert_not_empty @delivery_method.flash_notice # should change everywhere - assert_equal new_name, dm.reload.vak_kielto - assert_equal new_name, dm.vaihtoehtoinen_vak_toimitustapa - assert_equal new_name, cust.reload.toimitustapa - assert_equal new_name, cust_key.reload.avainsana - assert_equal new_name, order.reload.toimitustapa - assert_equal new_name, draft.reload.toimitustapa - assert_equal new_name, stock.reload.toimitustapa - assert_equal new_name, preorder.reload.toimitustapa - assert_equal new_name, offer.reload.toimitustapa - assert_equal new_name, manufacture.reload.toimitustapa - assert_equal new_name, work.reload.toimitustapa - assert_equal new_name, project.reload.toimitustapa - assert_equal new_name, reclamation.reload.toimitustapa - assert_equal new_name, freight.reload.toimitustapa - assert_equal new_name, contract.reload.toimitustapa - assert_equal new_name, waybill.reload.toimitustapa + assert_equal new_name, @dm.reload.vak_kielto + assert_equal new_name, @dm.vaihtoehtoinen_vak_toimitustapa + assert_equal new_name, @cust.reload.toimitustapa + assert_equal new_name, @cust_key.reload.avainsana + assert_equal new_name, @order.reload.toimitustapa + assert_equal new_name, @draft.reload.toimitustapa + assert_equal new_name, @stock.reload.toimitustapa + assert_equal new_name, @preorder.reload.toimitustapa + assert_equal new_name, @offer.reload.toimitustapa + assert_equal new_name, @manufacture.reload.toimitustapa + assert_equal new_name, @work.reload.toimitustapa + assert_equal new_name, @project.reload.toimitustapa + assert_equal new_name, @reclamation.reload.toimitustapa + assert_equal new_name, @freight.reload.toimitustapa + assert_equal new_name, @contract.reload.toimitustapa + assert_equal new_name, @waybill.reload.toimitustapa # change something else than the delivery method name @delivery_method.update! virallinen_selite: new_name From 5ff8ebc347a9188cb2b33abd94e32e02d69c3364 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Tue, 10 Nov 2015 10:50:21 +0200 Subject: [PATCH 181/189] rename fixtures to avoid confusion --- test/models/delivery_method_test.rb | 187 ++++++++++++++-------------- 1 file changed, 93 insertions(+), 94 deletions(-) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index ab93cb123..89ad4cda2 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -24,11 +24,11 @@ class DeliveryMethodTest < ActiveSupport::TestCase ) def setup - @delivery_method = delivery_methods :kaukokiito + @kaukokiito = delivery_methods :kaukokiito + @kiitolinja = delivery_methods :kiitolinja @departure = delivery_method_departures :departure_one # setup fixtures for all delivery method relations - @dm = delivery_methods :kiitolinja @cust = customers :stubborn_customer @cust_key = customer_keywords :keyword_1 @order = sales_order_orders :not_delivered_order_1 @@ -46,178 +46,177 @@ def setup end test 'relations' do - assert @delivery_method.customer_keywords.count > 0 - assert @delivery_method.customs.count > 0 - assert @delivery_method.departures.count > 0 - assert @delivery_method.freight_contracts.count > 0 - assert @delivery_method.freights.count > 0 - assert @delivery_method.locations.count > 0 - assert @delivery_method.manufacture_orders.count > 0 - assert @delivery_method.mode_of_transports.count > 0 - assert @delivery_method.nature_of_transactions.count > 0 - assert @delivery_method.offer_orders.count > 0 - assert @delivery_method.preorders.count > 0 - assert @delivery_method.project_orders.count > 0 - assert @delivery_method.reclamation_orders.count > 0 - assert @delivery_method.sales_order_drafts.count > 0 - assert @delivery_method.sales_orders.not_delivered.count > 0 - assert @delivery_method.sorting_point.count > 0 - assert @delivery_method.stock_transfers.not_delivered.count > 0 - assert @delivery_method.translations.count > 0 - assert @delivery_method.waybills.count > 0 - assert @delivery_method.work_orders.count > 0 + assert @kaukokiito.customer_keywords.count > 0 + assert @kaukokiito.customs.count > 0 + assert @kaukokiito.departures.count > 0 + assert @kaukokiito.freight_contracts.count > 0 + assert @kaukokiito.freights.count > 0 + assert @kaukokiito.locations.count > 0 + assert @kaukokiito.manufacture_orders.count > 0 + assert @kaukokiito.mode_of_transports.count > 0 + assert @kaukokiito.nature_of_transactions.count > 0 + assert @kaukokiito.offer_orders.count > 0 + assert @kaukokiito.preorders.count > 0 + assert @kaukokiito.project_orders.count > 0 + assert @kaukokiito.reclamation_orders.count > 0 + assert @kaukokiito.sales_order_drafts.count > 0 + assert @kaukokiito.sales_orders.not_delivered.count > 0 + assert @kaukokiito.sorting_point.count > 0 + assert @kaukokiito.stock_transfers.not_delivered.count > 0 + assert @kaukokiito.translations.count > 0 + assert @kaukokiito.waybills.count > 0 + assert @kaukokiito.work_orders.count > 0 end test "fixtures should be valid" do - assert @delivery_method.valid?, @delivery_method.errors.messages + assert @kaukokiito.valid?, @kaukokiito.errors.messages assert @departure.valid?, @departure.errors.full_messages end test "selite should be unique" do error = I18n.t 'errors.messages.taken' - @delivery_method.selite = 'Kiitolinja' + @kaukokiito.selite = @kiitolinja.selite - refute @delivery_method.valid? - assert_equal error, @delivery_method.errors[:selite].first + refute @kaukokiito.valid? + assert_equal error, @kaukokiito.errors[:selite].first end test 'valid vak_kielto values' do - @delivery_method.vak_kielto = '' - assert @delivery_method.valid? + @kaukokiito.vak_kielto = '' + assert @kaukokiito.valid? - @delivery_method.vak_kielto = 'K' - assert @delivery_method.valid? + @kaukokiito.vak_kielto = 'K' + assert @kaukokiito.valid? - @delivery_method.vak_kielto = 'not valid' - refute @delivery_method.valid? + @kaukokiito.vak_kielto = 'not valid' + refute @kaukokiito.valid? # should allow the name of any other delivery method that accepts adr dm = delivery_methods :kiitolinja dm.update! vak_kielto: '' - @delivery_method.vak_kielto = dm.selite - assert @delivery_method.valid? + @kaukokiito.vak_kielto = dm.selite + assert @kaukokiito.valid? # should NOT allow the name of delivery method if it does not accept adr dm.update! vak_kielto: 'K' - refute @delivery_method.valid? + refute @kaukokiito.valid? end test 'should not allow changing vak_kielto if used as alternative adr method' do # set kaukokiito to allow adr shipments - @delivery_method.update! vak_kielto: '' + @kaukokiito.update! vak_kielto: '' # set kiitolinja to have kaukokiito as alternative adr shipping method - dm = delivery_methods :kiitolinja - dm.update! vaihtoehtoinen_vak_toimitustapa: @delivery_method.selite + @kiitolinja.update! vaihtoehtoinen_vak_toimitustapa: @kaukokiito.selite # try to change kaukokiito to deny adr shipments - @delivery_method.vak_kielto = 'K' + @kaukokiito.vak_kielto = 'K' # should not be allowed error = I18n.t 'errors.delivery_method.in_use_adr' - refute @delivery_method.valid? - assert_equal error, @delivery_method.errors.messages[:vak_kielto].first + refute @kaukokiito.valid? + assert_equal error, @kaukokiito.errors.messages[:vak_kielto].first end test 'should validate freight sku' do - @delivery_method.rahti_tuotenumero = 'non_inventory_manageable_product' - assert @delivery_method.valid? + @kaukokiito.rahti_tuotenumero = 'non_inventory_manageable_product' + assert @kaukokiito.valid? error = I18n.t 'errors.delivery_method.product_not_in_inventory_management' - @delivery_method.rahti_tuotenumero = 'hammer123' + @kaukokiito.rahti_tuotenumero = 'hammer123' - refute @delivery_method.valid? - assert_equal error, @delivery_method.errors.messages[:rahti_tuotenumero].first + refute @kaukokiito.valid? + assert_equal error, @kaukokiito.errors.messages[:rahti_tuotenumero].first end test 'should validate cargo insurance sku' do - @delivery_method.kuljetusvakuutus_tuotenumero = 'non_inventory_manageable_product' - assert @delivery_method.valid? + @kaukokiito.kuljetusvakuutus_tuotenumero = 'non_inventory_manageable_product' + assert @kaukokiito.valid? error = I18n.t 'errors.delivery_method.product_not_in_inventory_management' - @delivery_method.kuljetusvakuutus_tuotenumero = 'hammer123' + @kaukokiito.kuljetusvakuutus_tuotenumero = 'hammer123' - refute @delivery_method.valid? - assert_equal error, @delivery_method.errors.messages[:kuljetusvakuutus_tuotenumero].first + refute @kaukokiito.valid? + assert_equal error, @kaukokiito.errors.messages[:kuljetusvakuutus_tuotenumero].first end test 'should validate alternative adr prohibition' do - @delivery_method.vaihtoehtoinen_vak_toimitustapa = '' - assert @delivery_method.valid? + @kaukokiito.vaihtoehtoinen_vak_toimitustapa = '' + assert @kaukokiito.valid? error = I18n.t 'errors.messages.inclusion' - @delivery_method.vaihtoehtoinen_vak_toimitustapa = 'neko' - refute @delivery_method.valid? - assert_equal error, @delivery_method.errors[:vaihtoehtoinen_vak_toimitustapa].first + @kaukokiito.vaihtoehtoinen_vak_toimitustapa = 'neko' + refute @kaukokiito.valid? + assert_equal error, @kaukokiito.errors[:vaihtoehtoinen_vak_toimitustapa].first end test 'unifaun info is present' do error = I18n.t 'errors.delivery_method.unifaun_info_missing' # If we have collective_batch and package_info_entry_denied we cannot use unifaun online - @delivery_method.tulostustapa = :collective_batch - @delivery_method.uudet_pakkaustiedot = :package_info_entry_denied - @delivery_method.rahtikirja = :unifaun_online + @kaukokiito.tulostustapa = :collective_batch + @kaukokiito.uudet_pakkaustiedot = :package_info_entry_denied + @kaukokiito.rahtikirja = :unifaun_online - refute @delivery_method.valid? - assert_equal error, @delivery_method.errors.messages[:base].first + refute @kaukokiito.valid? + assert_equal error, @kaukokiito.errors.messages[:base].first # If we have collective_batch and package_info_entry_denied we cannot use unifaun print server - @delivery_method.rahtikirja = :unifaun_print_server - refute @delivery_method.valid? - assert_equal error, @delivery_method.errors.messages[:base].first + @kaukokiito.rahtikirja = :unifaun_print_server + refute @kaukokiito.valid? + assert_equal error, @kaukokiito.errors.messages[:base].first # Not using unifaun is ok - @delivery_method.rahtikirja = :generic_a4 - assert @delivery_method.valid? + @kaukokiito.rahtikirja = :generic_a4 + assert @kaukokiito.valid? # Unifaun with package_info_entry_allowed is ok - @delivery_method.rahtikirja = :unifaun_print_server - @delivery_method.uudet_pakkaustiedot = :package_info_entry_allowed - assert @delivery_method.valid? + @kaukokiito.rahtikirja = :unifaun_print_server + @kaukokiito.uudet_pakkaustiedot = :package_info_entry_allowed + assert @kaukokiito.valid? # Unifaun with batch is ok - @delivery_method.uudet_pakkaustiedot = :package_info_entry_denied - @delivery_method.tulostustapa = :batch - assert @delivery_method.valid? + @kaukokiito.uudet_pakkaustiedot = :package_info_entry_denied + @kaukokiito.tulostustapa = :batch + assert @kaukokiito.valid? end test 'do not delete delivery method if it is in use' do assert_no_difference('DeliveryMethod.count') do - @delivery_method.destroy + @kaukokiito.destroy end end test 'should update relations when updating selite' do # set delivery method to all available relations - @dm.update! vak_kielto: @delivery_method.selite, vaihtoehtoinen_vak_toimitustapa: @delivery_method.selite - @cust.update! toimitustapa: @delivery_method.selite - @cust_key.update! avainsana: @delivery_method.selite - @order.update! toimitustapa: @delivery_method.selite - @draft.update! toimitustapa: @delivery_method.selite - @stock.update! toimitustapa: @delivery_method.selite - @preorder.update! toimitustapa: @delivery_method.selite - @offer.update! toimitustapa: @delivery_method.selite - @manufacture.update! toimitustapa: @delivery_method.selite - @work.update! toimitustapa: @delivery_method.selite - @project.update! toimitustapa: @delivery_method.selite - @reclamation.update! toimitustapa: @delivery_method.selite - @freight.update! toimitustapa: @delivery_method.selite - @contract.update! toimitustapa: @delivery_method.selite - @waybill.update! toimitustapa: @delivery_method.selite + @kiitolinja.update! vak_kielto: @kaukokiito.selite, vaihtoehtoinen_vak_toimitustapa: @kaukokiito.selite + @cust.update! toimitustapa: @kaukokiito.selite + @cust_key.update! avainsana: @kaukokiito.selite + @order.update! toimitustapa: @kaukokiito.selite + @draft.update! toimitustapa: @kaukokiito.selite + @stock.update! toimitustapa: @kaukokiito.selite + @preorder.update! toimitustapa: @kaukokiito.selite + @offer.update! toimitustapa: @kaukokiito.selite + @manufacture.update! toimitustapa: @kaukokiito.selite + @work.update! toimitustapa: @kaukokiito.selite + @project.update! toimitustapa: @kaukokiito.selite + @reclamation.update! toimitustapa: @kaukokiito.selite + @freight.update! toimitustapa: @kaukokiito.selite + @contract.update! toimitustapa: @kaukokiito.selite + @waybill.update! toimitustapa: @kaukokiito.selite # change the delivery method name new_name = 'Kaukokiito kakkoinen' - @delivery_method.update! selite: new_name + @kaukokiito.update! selite: new_name # we should have a flash notice - assert_not_empty @delivery_method.flash_notice + assert_not_empty @kaukokiito.flash_notice # should change everywhere - assert_equal new_name, @dm.reload.vak_kielto - assert_equal new_name, @dm.vaihtoehtoinen_vak_toimitustapa + assert_equal new_name, @kiitolinja.reload.vak_kielto + assert_equal new_name, @kiitolinja.vaihtoehtoinen_vak_toimitustapa assert_equal new_name, @cust.reload.toimitustapa assert_equal new_name, @cust_key.reload.avainsana assert_equal new_name, @order.reload.toimitustapa @@ -234,9 +233,9 @@ def setup assert_equal new_name, @waybill.reload.toimitustapa # change something else than the delivery method name - @delivery_method.update! virallinen_selite: new_name + @kaukokiito.update! virallinen_selite: new_name # we should not have a flash notice - assert_empty @delivery_method.flash_notice + assert_empty @kaukokiito.flash_notice end end From 4d10ddab80d9eeec6f28577377086bcff0f7c52e Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Tue, 10 Nov 2015 11:37:19 +0200 Subject: [PATCH 182/189] add new delete validations --- app/models/delivery_method.rb | 12 ++++++++++++ config/locales/fi.yml | 7 ++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 34006da33..c3fecf013 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -287,6 +287,18 @@ def check_relations allow_delete = false end + count = company.delivery_methods.where(vak_kielto: selite).count + if count.nonzero? + errors.add :base, I18n.t("errors.delivery_method.in_use_delivery_method", count: count) + allow_delete = false + end + + count = company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite).count + if count.nonzero? + errors.add :base, I18n.t("errors.delivery_method.in_use_delivery_method", count: count) + allow_delete = false + end + count = company.sales_orders.not_delivered.where(toimitustapa: selite).count if count.nonzero? errors.add :base, I18n.t("errors.delivery_method.in_use_sales_orders", count: count) diff --git a/config/locales/fi.yml b/config/locales/fi.yml index e8d555fd8..6d555f40b 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -213,7 +213,7 @@ fi: rahdinkuljettaja: Kuljetusyhtiö rahti_tuotenumero: Rahtiveloitus tuotenumero rahtikirja: Rahtikirjatyyppi - rahtikirjakopio_email: + rahtikirjakopio_email: sallitut_alustat: Sallitut keräilyalustat sallitut_maat: Sallitut maat selite: Nimitys @@ -858,7 +858,7 @@ fi: - pe - la abbr_month_names: - - + - - tammi - helmi - maalis @@ -884,7 +884,7 @@ fi: long: "%A %e. %Bta %Y" short: "%d %b" month_names: - - + - - tammikuu - helmikuu - maaliskuu @@ -964,6 +964,7 @@ fi: in_use_adr: 'HUOM: Et voi asettaa toimitustavalle VAK-kieltoa, sillä muut toimitustavat käyttävät tätä toimitustapaa vaihtoehtoisena VAK-toimitustapana' in_use_customer_keywords: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaan avainsanassa' in_use_customers: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} asiakkaalla' + in_use_delivery_method: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} toimitustavalla' in_use_freight_contracts: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtisopimuksella' in_use_freights: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} rahtimaksulla' in_use_manufacture_orders: 'HUOM: Toimitustapaa ei voi poistaa, koska se on käytössä %{count} valmistuksella' From 48f62f467d4a38ecc115e75518eee287cbbe32cf Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Tue, 10 Nov 2015 11:37:35 +0200 Subject: [PATCH 183/189] test all delete cases --- test/models/delivery_method_test.rb | 152 +++++++++++++++++++++++++++- 1 file changed, 151 insertions(+), 1 deletion(-) diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index 89ad4cda2..a348c5093 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -184,9 +184,159 @@ def setup end test 'do not delete delivery method if it is in use' do - assert_no_difference('DeliveryMethod.count') do + # set kiitolinja delivery method for all available relations + dm_name = @kiitolinja.selite + @kaukokiito.update! vak_kielto: '', vaihtoehtoinen_vak_toimitustapa: '' + @cust.update! toimitustapa: dm_name + @cust_key.update! avainsana: dm_name + @order.update! toimitustapa: dm_name + @draft.update! toimitustapa: dm_name + @stock.update! toimitustapa: dm_name + @preorder.update! toimitustapa: dm_name + @offer.update! toimitustapa: dm_name + @manufacture.update! toimitustapa: dm_name + @work.update! toimitustapa: dm_name + @project.update! toimitustapa: dm_name + @reclamation.update! toimitustapa: dm_name + @freight.update! toimitustapa: dm_name + @contract.update! toimitustapa: dm_name + @waybill.update! toimitustapa: dm_name + + kaukokiito = @kaukokiito.dup + + # We should be able to destroy kaukokiito, it's not used anywhere + assert_difference('DeliveryMethod.count', -1) do @kaukokiito.destroy end + + # Let's get kaukokiito back + kaukokiito.save! + dm_name = kaukokiito.selite + + # Set kaukokiito as alternative adr for kiitolinja + @kiitolinja.update! vak_kielto: dm_name + error = I18n.t 'errors.delivery_method.in_use_delivery_method', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito as alternative adr for kiitolinja + @kiitolinja.update! vak_kielto: '', vaihtoehtoinen_vak_toimitustapa: dm_name + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito as default for customer + @kiitolinja.update! vak_kielto: '', vaihtoehtoinen_vak_toimitustapa: '' + @cust.update! toimitustapa: dm_name + error = I18n.t 'errors.delivery_method.in_use_customers', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito as default for customer keyword + @cust.update! toimitustapa: '' + @cust_key.update! avainsana: dm_name + error = I18n.t 'errors.delivery_method.in_use_customer_keywords', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito to an order + @cust_key.update! avainsana: '' + @order.update! toimitustapa: dm_name + error = I18n.t 'errors.delivery_method.in_use_sales_orders', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito to an order draft + @order.update! toimitustapa: '' + @draft.update! toimitustapa: dm_name + error = I18n.t 'errors.delivery_method.in_use_sales_order_drafts', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito to an stock transfer + @draft.update! toimitustapa: '' + @stock.update! toimitustapa: dm_name + error = I18n.t 'errors.delivery_method.in_use_stock_transfers', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito to an preorder + @stock.update! toimitustapa: '' + @preorder.update! toimitustapa: dm_name + error = I18n.t 'errors.delivery_method.in_use_preorders', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito to an offer + @preorder.update! toimitustapa: '' + @offer.update! toimitustapa: dm_name + error = I18n.t 'errors.delivery_method.in_use_offer_orders', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito to an manufacture order + @offer.update! toimitustapa: '' + @manufacture.update! toimitustapa: dm_name + error = I18n.t 'errors.delivery_method.in_use_manufacture_orders', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito to an workorder + @manufacture.update! toimitustapa: '' + @work.update! toimitustapa: dm_name + error = I18n.t 'errors.delivery_method.in_use_work_orders', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito to an project + @work.update! toimitustapa: '' + @project.update! toimitustapa: dm_name + error = I18n.t 'errors.delivery_method.in_use_project_orders', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito to an reclamation + @project.update! toimitustapa: '' + @reclamation.update! toimitustapa: dm_name + error = I18n.t 'errors.delivery_method.in_use_reclamation_orders', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito to an freight + @reclamation.update! toimitustapa: '' + @freight.update! toimitustapa: dm_name + error = I18n.t 'errors.delivery_method.in_use_freights', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito to an freight contract + @freight.update! toimitustapa: '' + @contract.update! toimitustapa: dm_name + error = I18n.t 'errors.delivery_method.in_use_freight_contracts', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last + + # Set kaukokiito to an waybill + @contract.update! toimitustapa: '' + @waybill.update! toimitustapa: dm_name + error = I18n.t 'errors.delivery_method.in_use_waybills', count: 1 + + refute kaukokiito.destroy + assert_equal error, kaukokiito.errors.messages[:base].last end test 'should update relations when updating selite' do From e63c3e1d4cbe95278bae557e5d7ae985d3c126b1 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Tue, 10 Nov 2015 13:41:24 +0200 Subject: [PATCH 184/189] cleanup relation check --- app/models/delivery_method.rb | 123 ++++++---------------------- test/models/delivery_method_test.rb | 1 + 2 files changed, 27 insertions(+), 97 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index c3fecf013..1245754e7 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -13,6 +13,7 @@ class DeliveryMethod < BaseModel end with_options foreign_key: :toimitustapa, primary_key: :selite do |o| + o.has_many :customers, class_name: 'Customer' o.has_many :freight_contracts o.has_many :freights o.has_many :manufacture_orders, class_name: 'ManufactureOrder::Order' @@ -279,105 +280,33 @@ def alternative_adr_delivery_method end def check_relations - allow_delete = true - - count = company.customers.where(toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_customers", count: count) - allow_delete = false - end - - count = company.delivery_methods.where(vak_kielto: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_delivery_method", count: count) - allow_delete = false - end - - count = company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_delivery_method", count: count) - allow_delete = false - end - - count = company.sales_orders.not_delivered.where(toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_sales_orders", count: count) - allow_delete = false - end - - count = company.sales_order_drafts.where(toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_sales_order_drafts", count: count) - allow_delete = false - end - - count = company.freights.where(toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_freights", count: count) - allow_delete = false - end - - count = company.freight_contracts.where(toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_freight_contracts", count: count) - allow_delete = false - end - - count = company.customer_keywords.where(avainsana: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_customer_keywords", count: count) - allow_delete = false - end - - count = company.stock_transfers.not_delivered.where(toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_stock_transfers", count: count) - allow_delete = false - end - - count = company.preorders.where(toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_preorders", count: count) - allow_delete = false - end - - count = company.offer_orders.where(toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_offer_orders", count: count) - allow_delete = false - end - - count = company.manufacture_orders.where(toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_manufacture_orders", count: count) - allow_delete = false - end - - count = company.work_orders.where(toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_work_orders", count: count) - allow_delete = false - end - - count = company.project_orders.active.where(toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_project_orders", count: count) - allow_delete = false - end - - count = company.reclamation_orders.where(toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_reclamation_orders", count: count) - allow_delete = false - end - - count = company.waybills.not_printed.where(toimitustapa: selite).count - if count.nonzero? - errors.add :base, I18n.t("errors.delivery_method.in_use_waybills", count: count) - allow_delete = false + checklist = [ + { count: customers.count, error: "in_use_customers" }, + { count: sales_orders.not_delivered.count, error: "in_use_sales_orders" }, + { count: sales_order_drafts.count, error: "in_use_sales_order_drafts" }, + { count: freights.count, error: "in_use_freights" }, + { count: freight_contracts.count, error: "in_use_freight_contracts" }, + { count: customer_keywords.count, error: "in_use_customer_keywords" }, + { count: stock_transfers.not_delivered.count, error: "in_use_stock_transfers" }, + { count: preorders.count, error: "in_use_preorders" }, + { count: offer_orders.count, error: "in_use_offer_orders" }, + { count: manufacture_orders.count, error: "in_use_manufacture_orders" }, + { count: work_orders.count, error: "in_use_work_orders" }, + { count: project_orders.count, error: "in_use_project_orders" }, + { count: reclamation_orders.count, error: "in_use_reclamation_orders" }, + { count: waybills.not_printed.count, error: "in_use_waybills" }, + { count: company.delivery_methods.where(vak_kielto: selite).count, error: "in_use_delivery_method" }, + { count: company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite).count, error: "in_use_delivery_method" }, + ] + + checklist.each do |check| + count = check[:count] + error = I18n.t "errors.delivery_method.#{check[:error]}", count: count + + errors.add(:base, error) unless count.zero? end - allow_delete + checklist.all? { |check| check[:count].zero? } end def defaults diff --git a/test/models/delivery_method_test.rb b/test/models/delivery_method_test.rb index a348c5093..776644b0d 100644 --- a/test/models/delivery_method_test.rb +++ b/test/models/delivery_method_test.rb @@ -47,6 +47,7 @@ def setup test 'relations' do assert @kaukokiito.customer_keywords.count > 0 + assert @kaukokiito.customers.count > 0 assert @kaukokiito.customs.count > 0 assert @kaukokiito.departures.count > 0 assert @kaukokiito.freight_contracts.count > 0 From 50311d26fefeb6e54c34be3ee63e96ffd890e6c0 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Wed, 11 Nov 2015 16:45:18 +0200 Subject: [PATCH 185/189] a dryer way (debatable) --- app/models/delivery_method.rb | 71 ++++++++++++----------------------- 1 file changed, 24 insertions(+), 47 deletions(-) diff --git a/app/models/delivery_method.rb b/app/models/delivery_method.rb index 1245754e7..a8fd23a7e 100644 --- a/app/models/delivery_method.rb +++ b/app/models/delivery_method.rb @@ -194,53 +194,30 @@ def update_relations msg = [] if selite_was.present? && selite_changed? - cnt = company.delivery_methods.where(vak_kielto: selite_was).update_all(vak_kielto: selite) - msg << I18n.t('administration.delivery_methods.update.delivery_methods', count: cnt) if cnt.nonzero? - - cnt = company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite_was).update_all(vaihtoehtoinen_vak_toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.alternative_adr_delivery_methods', count: cnt) if cnt.nonzero? - - cnt = company.customers.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.customers', count: cnt) if cnt.nonzero? - - cnt = company.customer_keywords.where(avainsana: selite_was).update_all(avainsana: selite) - msg << I18n.t('administration.delivery_methods.update.customer_keywords', count: cnt) if cnt.nonzero? - - cnt = company.sales_orders.not_delivered.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.not_delivered_sales_orders', count: cnt) if cnt.nonzero? - - cnt = company.sales_order_drafts.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.sales_order_drafts', count: cnt) if cnt.nonzero? - - cnt = company.stock_transfers.not_delivered.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.not_delivered_stock_transfers', count: cnt) if cnt.nonzero? - - cnt = company.preorders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.preorders', count: cnt) if cnt.nonzero? - - cnt = company.offer_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.offer_orders', count: cnt) if cnt.nonzero? - - cnt = company.manufacture_orders.not_manufactured.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.not_manufactured_manufacture_orders', count: cnt) if cnt.nonzero? - - cnt = company.work_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.work_orders', count: cnt) if cnt.nonzero? - - cnt = company.project_orders.active.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.project_orders', count: cnt) if cnt.nonzero? - - cnt = company.reclamation_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.reclamation_orders', count: cnt) if cnt.nonzero? - - cnt = company.freights.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.freights', count: cnt) if cnt.nonzero? - - cnt = company.freight_contracts.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.freight_contracts', count: cnt) if cnt.nonzero? - - cnt = company.waybills.not_printed.where(toimitustapa: selite_was).update_all(toimitustapa: selite) - msg << I18n.t('administration.delivery_methods.update.not_printed_waybills', count: cnt) if cnt.nonzero? + update_list = [ + { count: company.delivery_methods.where(vak_kielto: selite_was).update_all(vak_kielto: selite), msg: 'delivery_methods' }, + { count: company.delivery_methods.where(vaihtoehtoinen_vak_toimitustapa: selite_was).update_all(vaihtoehtoinen_vak_toimitustapa: selite), msg: 'alternative_adr_delivery_methods' }, + { count: company.customers.where(toimitustapa: selite_was).update_all(toimitustapa: selite), msg: 'customers' }, + { count: company.customer_keywords.where(avainsana: selite_was).update_all(avainsana: selite), msg: 'customer_keywords' }, + { count: company.sales_orders.not_delivered.where(toimitustapa: selite_was).update_all(toimitustapa: selite), msg: 'not_delivered_sales_orders' }, + { count: company.sales_order_drafts.where(toimitustapa: selite_was).update_all(toimitustapa: selite), msg: 'sales_order_drafts' }, + { count: company.stock_transfers.not_delivered.where(toimitustapa: selite_was).update_all(toimitustapa: selite), msg: 'not_delivered_stock_transfers' }, + { count: company.preorders.where(toimitustapa: selite_was).update_all(toimitustapa: selite), msg: 'preorders' }, + { count: company.offer_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite), msg: 'offer_orders' }, + { count: company.manufacture_orders.not_manufactured.where(toimitustapa: selite_was).update_all(toimitustapa: selite), msg: 'not_manufactured_manufacture_orders' }, + { count: company.work_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite), msg: 'work_orders' }, + { count: company.project_orders.active.where(toimitustapa: selite_was).update_all(toimitustapa: selite), msg: 'project_orders' }, + { count: company.reclamation_orders.where(toimitustapa: selite_was).update_all(toimitustapa: selite), msg: 'reclamation_orders' }, + { count: company.freights.where(toimitustapa: selite_was).update_all(toimitustapa: selite), msg: 'freights' }, + { count: company.freight_contracts.where(toimitustapa: selite_was).update_all(toimitustapa: selite), msg: 'freight_contracts' }, + { count: company.waybills.not_printed.where(toimitustapa: selite_was).update_all(toimitustapa: selite), msg: 'not_printed_waybills' }, + ] + + update_list.each do |update| + count = update[:count] + error = I18n.t "administration.delivery_methods.update.#{update[:msg]}", count: count + msg << error unless count.zero? + end end self.flash_notice = msg.to_sentence From e946c0e700a7255aac650a7eed5fb394e0829356 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Wed, 11 Nov 2015 17:06:47 +0200 Subject: [PATCH 186/189] fixed height --- app/assets/stylesheets/static/pupesoft.scss | 5 +++++ .../stylesheets/static/pupesoft_legacy.css | 5 +++++ .../delivery_methods/_basic.html.erb | 16 +++++++++------- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/static/pupesoft.scss b/app/assets/stylesheets/static/pupesoft.scss index f1c3dccf0..f8f1798e0 100644 --- a/app/assets/stylesheets/static/pupesoft.scss +++ b/app/assets/stylesheets/static/pupesoft.scss @@ -267,3 +267,8 @@ table.responsive td input[type=text] { width: 70%; } } + +.fixed-height { + max-height: 200px; + overflow-y: scroll; +} diff --git a/app/assets/stylesheets/static/pupesoft_legacy.css b/app/assets/stylesheets/static/pupesoft_legacy.css index a9d9e2943..ff84b2402 100644 --- a/app/assets/stylesheets/static/pupesoft_legacy.css +++ b/app/assets/stylesheets/static/pupesoft_legacy.css @@ -72,3 +72,8 @@ ul.list-unstyled { .del { text-decoration: line-through; } + +.fixed-height { + max-height: 200px; + overflow-y: scroll; +} diff --git a/app/views/administration/delivery_methods/_basic.html.erb b/app/views/administration/delivery_methods/_basic.html.erb index 4c0ed66bc..247dc2ab0 100644 --- a/app/views/administration/delivery_methods/_basic.html.erb +++ b/app/views/administration/delivery_methods/_basic.html.erb @@ -208,13 +208,15 @@
From 9a5e426e9208865eb2421353f925de39719f15e6 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Wed, 13 Jan 2016 11:51:08 +0200 Subject: [PATCH 187/189] revert back to rails 4.2.4 as has_and_belongs_to_many breaks --- Gemfile | 2 +- Gemfile.lock | 138 +++++++++++++++++++++++++++------------------------ 2 files changed, 75 insertions(+), 65 deletions(-) diff --git a/Gemfile b/Gemfile index 49dd319c2..7d42b0589 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'rails', '~> 4.2' +gem 'rails', '4.2.4' gem 'bcrypt' gem 'jquery-rails' diff --git a/Gemfile.lock b/Gemfile.lock index bb8dbe5ad..a593ab9d0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,43 +1,43 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.5) - actionpack (= 4.2.5) - actionview (= 4.2.5) - activejob (= 4.2.5) + actionmailer (4.2.4) + actionpack (= 4.2.4) + actionview (= 4.2.4) + activejob (= 4.2.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.5) - actionview (= 4.2.5) - activesupport (= 4.2.5) + actionpack (4.2.4) + actionview (= 4.2.4) + activesupport (= 4.2.4) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.5) - activesupport (= 4.2.5) + actionview (4.2.4) + activesupport (= 4.2.4) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.5) - activesupport (= 4.2.5) + activejob (4.2.4) + activesupport (= 4.2.4) globalid (>= 0.3.0) - activemodel (4.2.5) - activesupport (= 4.2.5) + activemodel (4.2.4) + activesupport (= 4.2.4) builder (~> 3.1) - activerecord (4.2.5) - activemodel (= 4.2.5) - activesupport (= 4.2.5) + activerecord (4.2.4) + activemodel (= 4.2.4) + activesupport (= 4.2.4) arel (~> 6.0) - activesupport (4.2.5) + activesupport (4.2.4) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) arel (6.0.3) - ast (2.1.0) + ast (2.2.0) axlsx (2.0.1) htmlentities (~> 4.3.1) nokogiri (>= 1.4.1) @@ -50,13 +50,15 @@ GEM cocoon (1.2.6) codeclimate-test-reporter (0.4.8) simplecov (>= 0.7.1, < 1.0.0) - coffee-rails (4.1.0) + coffee-rails (4.1.1) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) + railties (>= 4.0.0, < 5.1.x) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.10.0) + commonjs (0.2.7) + concurrent-ruby (1.0.0) countries (1.2.2) currencies (~> 0.4.2) i18n_data (~> 0.7.0) @@ -64,7 +66,7 @@ GEM countries (~> 1.2.0) sort_alphabetical (~> 1.0) currencies (0.4.2) - dalli (2.7.4) + dalli (2.7.5) date_validator (0.8.1) activemodel docile (1.1.5) @@ -82,7 +84,7 @@ GEM execjs (2.6.0) fakeredis (0.5.0) redis (~> 3.0) - gli (2.13.3) + gli (2.13.4) globalid (0.3.6) activesupport (>= 4.1.0) highline (1.7.8) @@ -90,7 +92,7 @@ GEM http-cookie (1.0.2) domain_name (~> 0.5) i18n (0.7.0) - i18n-tasks (0.9.1) + i18n-tasks (0.9.2) activesupport (>= 4.0.2) ast (>= 2.1.0) easy_translate (>= 0.5.0) @@ -101,15 +103,22 @@ GEM term-ansicolor (>= 1.3.2) terminal-table (>= 1.5.1) i18n_data (0.7.0) - jquery-rails (4.0.5) + jquery-rails (4.1.0) rails-dom-testing (~> 1.0) railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (1.8.3) + less (2.6.0) + commonjs (~> 0.2.7) + less-rails (2.7.1) + actionpack (>= 4.0) + less (~> 2.6.0) + sprockets (> 2, < 4) + tilt libv8 (3.16.14.13) lightbox2-rails (2.7.1) railties (>= 3.1) - localeapp (0.9.3) + localeapp (1.0.2) gli i18n json @@ -120,15 +129,15 @@ GEM nokogiri (>= 1.5.9) mail (2.6.3) mime-types (>= 1.16, < 3) - mime-types (2.6.2) - mini_portile (0.6.2) + mime-types (2.99) + mini_portile2 (2.0.0) minitest (5.8.3) mono_logger (1.1.0) multi_json (1.11.2) mysql2 (0.3.20) netrc (0.11.0) - nokogiri (1.6.6.4) - mini_portile (~> 0.6.0) + nokogiri (1.6.7.1) + mini_portile2 (~> 2.0.0.rc2) parser (2.2.3.0) ast (>= 1.1, < 3.0) pdfkit (0.8.2) @@ -137,16 +146,16 @@ GEM rack rack-test (0.6.3) rack (>= 1.0) - rails (4.2.5) - actionmailer (= 4.2.5) - actionpack (= 4.2.5) - actionview (= 4.2.5) - activejob (= 4.2.5) - activemodel (= 4.2.5) - activerecord (= 4.2.5) - activesupport (= 4.2.5) + rails (4.2.4) + actionmailer (= 4.2.4) + actionpack (= 4.2.4) + actionview (= 4.2.4) + activejob (= 4.2.4) + activemodel (= 4.2.4) + activerecord (= 4.2.4) + activesupport (= 4.2.4) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.5) + railties (= 4.2.4) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) @@ -156,17 +165,17 @@ GEM rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.2) loofah (~> 2.0) - railties (4.2.5) - actionpack (= 4.2.5) - activesupport (= 4.2.5) + railties (4.2.4) + actionpack (= 4.2.4) + activesupport (= 4.2.4) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.4.2) + rake (10.5.0) redis (3.2.2) redis-namespace (1.5.2) redis (~> 3.0, >= 3.0.4) ref (2.0.0) - request_store (1.2.1) + request_store (1.3.0) resque (1.25.2) mono_logger (~> 1.0) multi_json (~> 1.0) @@ -187,19 +196,19 @@ GEM nokogiri rubyzip spreadsheet (> 0.6.4) - ruby-ole (1.2.11.8) + ruby-ole (1.2.12) rubyzip (1.0.0) - sass (3.4.19) + sass (3.4.21) sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - simple_form (3.2.0) - actionpack (~> 4.0) - activemodel (~> 4.0) - simplecov (0.10.0) + simple_form (3.2.1) + actionpack (> 4, < 5.1) + activemodel (> 4, < 5.1) + simplecov (0.11.1) docile (~> 1.1.0) json (~> 1.8) simplecov-html (~> 0.10.0) @@ -210,14 +219,15 @@ GEM tilt (>= 1.3, < 3) sort_alphabetical (1.0.2) unicode_utils (>= 1.2.2) - spreadsheet (1.0.9) + spreadsheet (1.1.1) ruby-ole (>= 1.0) - sprockets (3.4.0) + sprockets (3.5.2) + concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (2.3.3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) + sprockets-rails (3.0.0) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) term-ansicolor (1.3.2) tins (~> 1.0) terminal-table (1.5.2) @@ -227,15 +237,15 @@ GEM thor (0.19.1) thread (0.2.2) thread_safe (0.3.5) - tilt (2.0.1) - tins (1.7.0) + tilt (2.0.2) + tins (1.8.1) turbolinks (2.5.3) coffee-rails - twitter-bootstrap-rails (3.2.0) - actionpack (~> 4.1) - execjs (~> 2.2) - rails (~> 4.1) - railties (~> 4.1) + twitter-bootstrap-rails (3.2.2) + actionpack (>= 3.1) + execjs (>= 2.2.2, >= 2.2) + less-rails (>= 2.5.0) + railties (>= 3.1) tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (2.7.2) @@ -247,7 +257,7 @@ GEM unicode_utils (1.4.0) vegas (0.1.11) rack (>= 1.0.0) - wicked_pdf (1.0.1) + wicked_pdf (1.0.3) ya2yaml (0.31) PLATFORMS @@ -272,7 +282,7 @@ DEPENDENCIES minitest mysql2 (~> 0.3.18) pdfkit - rails (~> 4.2) + rails (= 4.2.4) rake request_store resque From c24aaa3995e4acc0733bae2857d326d9fe73daef Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Wed, 13 Jan 2016 11:51:29 +0200 Subject: [PATCH 188/189] use regex to test --- test/integration/browser_detection_test.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/integration/browser_detection_test.rb b/test/integration/browser_detection_test.rb index 229dc3932..f9634137e 100644 --- a/test/integration/browser_detection_test.rb +++ b/test/integration/browser_detection_test.rb @@ -4,18 +4,18 @@ class BrowserDetectionTest < ActionDispatch::IntegrationTest include LoginHelper test "browsers are detected correctly" do - bob = users(:bob) + bob = users :bob + bob.update! kayttoliittyma: "U" + login bob - bob.update(kayttoliittyma: "U") - login users(:bob) - - { "Firefox" => "pupesoft_mozilla.css", - "Trident Windows" => "pupesoft_ms_ie.css", - "Chrome Windows" => "pupesoft_ms_chrome.css" }.each do |browser, css_file| + # use regex because css file contains random assets pipeline part: filename-[randompart].css + { "Firefox" => /pupesoft_mozilla\-.+\.css/, + "Trident Windows" => /pupesoft_ms_ie\-.+\.css/, + "Chrome Windows" => /pupesoft_ms_chrome\-.+\.css/ }.each do |browser, css_file| get "/accounts", {}, { "User-Agent" => browser } - assert_includes(response.body, css_file) + assert_match css_file, response.body, "#{browser} does not include #{css_file}" end end end From ade01bb83f48f7fb92bc41f5acacc06b382992d1 Mon Sep 17 00:00:00 2001 From: Joni Kanerva Date: Wed, 13 Jan 2016 12:11:51 +0200 Subject: [PATCH 189/189] we need to skip update messages as they are dynamic --- config/i18n-tasks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 21d744460..a5e501008 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -39,5 +39,6 @@ ignore_unused: - 'administration.sum_levels.{kayttotarkoitus_options,kumulatiivinen_options}.*' - 'administration.qualifiers.{kaytossa_options}.*' - 'administration.delivery_methods.{*_options}.*' +- 'administration.delivery_methods.update.*' - 'administration.packages.{erikoispakkaus_options,yksin_eraan_options}.*' - 'simple_form.*'
<%= f.label :selite %> <%= f.text_field :selite, class: :large %>
+ <%= f.label :locations %> + + <%= f.collection_check_boxes :location_ids, current_company.locations, :tunnus, :nimi do |b| %> + <%= b.check_box %> + <%= b.label %>
+ <% end %> +
<%= f.label :lisakulu %> <%= f.text_field :lisakulu, class: :large %> <%= f.collection_check_boxes :location_ids, current_company.locations, :tunnus, :nimi do |b| %> - <%= b.check_box %> - <%= b.label %>
+
+ <%= b.check_box %> + <%= b.label %> +
<% end %>
<%= f.label :sallitut_alustat %> - <%= f.collection_check_boxes :sallitut_alustat, Package.all, :tunnus, :pakkauskuvaus, - checked: @delivery_method.sallitut_alustat.split(',') do |b| %> -
- <%= b.check_box %> - <%= b.label { b.object.pakkaus + " " + b.object.translated_description(current_user.locale) } %> -
- <% end %> +
+ <%= f.collection_check_boxes :sallitut_alustat, Package.all, :tunnus, :pakkauskuvaus, + checked: @delivery_method.sallitut_alustat.split(',') do |b| %> +
+ <%= b.check_box %> + <%= b.label { b.object.pakkaus + " " + b.object.translated_description(current_user.locale) } %> +
+ <% end %> +