diff --git a/app/models/fs/message_draft.rb b/app/models/fs/message_draft.rb index df66f84a7..18b9d9abf 100644 --- a/app/models/fs/message_draft.rb +++ b/app/models/fs/message_draft.rb @@ -32,7 +32,7 @@ def self.create_and_validate_with_fs_form(form_files: [], author:, fs_client: Fs form_files.each do |form_file| form_content = form_file.read.force_encoding("UTF-8") form_information = fs_client.api.parse_form(form_content) - dic = form_information['subject'] + dic = form_information['subject']&.strip fs_form_identifier = form_information['form_identifier'] box = Fs::Box.with_enabled_message_drafts_import.find_by("settings ->> 'dic' = ?", dic) diff --git a/test/fixtures/files/fs/Accountants_main_FS_prehlad_0924.xml b/test/fixtures/files/fs/Accountants_main_FS_prehlad_0924.xml new file mode 100644 index 000000000..56adf6e6f --- /dev/null +++ b/test/fixtures/files/fs/Accountants_main_FS_prehlad_0924.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/fixtures/fs/forms.yml b/test/fixtures/fs/forms.yml index 2e7716ca3..49f19feb7 100644 --- a/test/fixtures/fs/forms.yml +++ b/test/fixtures/fs/forms.yml @@ -20,3 +20,12 @@ VP_DANv24: slug: VP_DANv24 number_identifier: 583 +PREHLADv24: + identifier: '795_777' + name: Prehľad o zrazených a odvedených preddavkoch na daň za zdaňovacie obdobie 2024 + group_name: Správa daní/Daň zo závislej činnosti - platiteľ dane/Prehľad o zrazených a odvedených preddavkoch na daň za zdaňovacie obdobie 2024 + subtype_name: Riadny + signature_required: true + ez_signature: true + slug: PREHLADv24 + number_identifier: 573 diff --git a/test/models/fs/message_draft_test.rb b/test/models/fs/message_draft_test.rb index 3e3b435f4..8787de5ad 100644 --- a/test/models/fs/message_draft_test.rb +++ b/test/models/fs/message_draft_test.rb @@ -26,4 +26,22 @@ class Fs::MessageDraftTest < ActiveSupport::TestCase assert message_draft.form_object.tags.include?(author.tenant.signer_group.signature_requested_from_tag) assert message_draft.thread.tags.include?(author.tenant.signer_group.signature_requested_from_tag) end + + test "create_and_validate_with_fs_form method strips DIC (matches box even if extra spaces within DIC in XML file)" do + author = users(:accountants_basic) + + fs_api = Minitest::Mock.new + fs_api.expect :parse_form, { + "subject" => "1122334455 ", + "form_identifier" => "795_777" + }, + [file_fixture("fs/Accountants_main_FS_prehlad_0924.xml").read] + + FsEnvironment.fs_client.stub :api, fs_api do + Fs::MessageDraft.create_and_validate_with_fs_form(form_files: [fixture_file_upload("fs/Accountants_main_FS_prehlad_0924.xml", "application/xml")], author: author) + end + + message_draft = Fs::MessageDraft.last + assert message_draft.thread.box.eql?(boxes(:fs_accountants)) + end end