Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip subject parsed from FS API #481

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/fs/message_draft.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
103 changes: 103 additions & 0 deletions test/fixtures/files/fs/Accountants_main_FS_prehlad_0924.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<dokument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<hlavicka>
<dic><![CDATA[1122334455 ]]></dic>
<druhPrehladu>
<riadny><![CDATA[1]]></riadny>
<opravny><![CDATA[0]]></opravny>
</druhPrehladu>
<zdanovacieObdobie>
<mesiac><![CDATA[09]]></mesiac>
<rok><![CDATA[2024]]></rok>
</zdanovacieObdobie>
<datumZisteniaOP><![CDATA[]]></datumZisteniaOP>
<fo>
<priezvisko><![CDATA[]]></priezvisko>
<meno><![CDATA[]]></meno>
<titul><![CDATA[]]></titul>
<titulZa><![CDATA[]]></titulZa>
</fo>
<po>
<obchodneMeno><![CDATA[Accountants main FS]]></obchodneMeno>
<pravnaForma><![CDATA[112]]></pravnaForma>
</po>
<sidlo>
<ulica><![CDATA[Ulica]]></ulica>
<cislo><![CDATA[40]]></cislo>
<psc><![CDATA[00000]]></psc>
<obec><![CDATA[Bratislava]]></obec>
<stat><![CDATA[Slovenská republika]]></stat>
</sidlo>
<podava>
<priezvisko><![CDATA[]]></priezvisko>
<meno><![CDATA[]]></meno>
<titul><![CDATA[]]></titul>
<titulZa><![CDATA[]]></titulZa>
<rodneCislo><![CDATA[]]></rodneCislo>
<datumNarodenia><![CDATA[]]></datumNarodenia>
<dic><![CDATA[]]></dic>
<obchodneMeno><![CDATA[]]></obchodneMeno>
<pravnaForma><![CDATA[]]></pravnaForma>
<ulica><![CDATA[]]></ulica>
<cislo><![CDATA[]]></cislo>
<psc><![CDATA[]]></psc>
<obec><![CDATA[]]></obec>
<stat><![CDATA[]]></stat>
</podava>
<tel><![CDATA[0900000000]]></tel>
<email><![CDATA[[email protected]]]></email>
</hlavicka>
<telo>
<cast1>
<r00><![CDATA[143760.13]]></r00>
<r01>
<datum><![CDATA[30.10.2024]]></datum>
<suma><![CDATA[22223.69]]></suma>
</r01>
<r01a>
<mesiacRok><![CDATA[]]></mesiacRok>
<suma><![CDATA[]]></suma>
</r01a>
<r02><![CDATA[]]></r02>
<r03><![CDATA[]]></r03>
<r04><![CDATA[22223.69]]></r04>
<r05><![CDATA[-3550.00]]></r05>
<r06><![CDATA[]]></r06>
<r07><![CDATA[]]></r07>
<r08><![CDATA[18673.69]]></r08>
<r08b><![CDATA[0]]></r08b>
</cast1>
<cast2>
<rA><![CDATA[3550.00]]></rA>
<rB><![CDATA[3550.00]]></rB>
<rC><![CDATA[]]></rC>
<rD><![CDATA[]]></rD>
<rE><![CDATA[]]></rE>
<rF><![CDATA[]]></rF>
</cast2>
<cast3>
<poukazatBonus>
<ziadam><![CDATA[0]]></ziadam>
<suma><![CDATA[]]></suma>
</poukazatBonus>
<poukazatPremiu>
<ziadam><![CDATA[0]]></ziadam>
<suma><![CDATA[]]></suma>
</poukazatPremiu>
<poukazatBonusNaUroky>
<ziadam><![CDATA[0]]></ziadam>
<suma><![CDATA[]]></suma>
</poukazatBonusNaUroky>
<sposobPlatby>
<poukazka><![CDATA[0]]></poukazka>
<ucet><![CDATA[0]]></ucet>
</sposobPlatby>
<IBAN><![CDATA[]]></IBAN>
</cast3>
</telo>
<vyhotovil>
<meno><![CDATA[x y]]></meno>
<tel><![CDATA[+421900000000]]></tel>
<datumVyhotovenia><![CDATA[15.10.2024]]></datumVyhotovenia>
</vyhotovil>
</dokument>
9 changes: 9 additions & 0 deletions test/fixtures/fs/forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 18 additions & 0 deletions test/models/fs/message_draft_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading