Skip to content

Commit

Permalink
OK-719 sanity check spec for not overriding virkailija set obligation
Browse files Browse the repository at this point in the history
  • Loading branch information
vaeinoe committed Dec 18, 2024
1 parent 4fb1c2d commit 170b6c0
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@
application-key "payment-obligation" hakukohde])
first)))

(defn- store-not-obligated-review [application-key hakukohde]
(jdbc/with-db-transaction [conn {:datasource (db/get-datasource :db)}]
(jdbc/insert! conn "application_hakukohde_reviews"
{:application_key application-key
:requirement "payment-obligation"
:hakukohde hakukohde
:state "not-obligated"})))


(defn- clear! []
(jdbc/with-db-transaction [conn {:datasource (db/get-datasource :db)}]
(jdbc/delete! conn :applications [])
Expand Down Expand Up @@ -461,4 +470,20 @@
payment (first (payment/get-raw-payments [application-key]))
obligation (get-payment-obligation-review application-key "payment-info-test-kk-fisv-hakukohde")]
(should= (:awaiting payment/all-states) (:state payment))
(should-be-nil obligation))))
(should-be-nil obligation)))

(it "should not override a non-automatic obligation"
(let [application-id (unit-test-db/init-db-fixture
form-fixtures/payment-exemption-test-form
application-fixtures/application-without-hakemusmaksu-exemption
nil)
application-key (:key (application-store/get-application application-id))
_ (store-not-obligated-review application-key "payment-info-test-kk-hakukohde")
_ (updater-job/update-kk-payment-status-for-person-handler
{:person_oid test-person-oid :term test-term :year test-year} runner)
payment (first (payment/get-raw-payments [application-key]))
obligation (get-payment-obligation-review application-key "payment-info-test-kk-hakukohde")]
(should= (:awaiting payment/all-states) (:state payment))
(should= {:application_key application-key, :requirement "payment-obligation",
:state "not-obligated", :hakukohde "payment-info-test-kk-hakukohde"}
(select-keys obligation [:application_key :requirement :state :hakukohde])))))

0 comments on commit 170b6c0

Please sign in to comment.