Skip to content

Commit

Permalink
Ok 662 astu lomakkeen nimi maksulle (#1623)
Browse files Browse the repository at this point in the history
* Lomakkeen nimi käännöksillä metadatana maksulle

* Maksulinkin locale pathiin

* Siirretty tutu-form? ja astu-form? application-selectors nimiavaruuteen
  • Loading branch information
hajoa authored Oct 29, 2024
1 parent 9bd4e7b commit 5e11a47
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 23 deletions.
2 changes: 1 addition & 1 deletion resources/ataru-oph.properties
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ url.valintalaskenta-ui.valintojen-toteuttaminen.hakemus = ${valintalaskenta-ui.b

maksut-service = ${url-virkailija}/maksut

maksut-service.hakija-get-by-secret = ${url-hakija}/maksut-ui?secret=$1&locale=$2
maksut-service.hakija-get-by-secret = ${url-hakija}/maksut-ui/$2?secret=$1
maksut-service.hakija-create = ${url-hakija}/maksut/api/lasku

maksut-service.virkailija-create = ${maksut-service}/api/lasku
Expand Down
12 changes: 9 additions & 3 deletions src/cljc/ataru/schema/maksut_schema.cljc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns ataru.schema.maksut-schema
(:require [schema.core :as s]))
(:require [schema.core :as s]
[ataru.schema.localized-schema :as localized-schema]))

(s/defschema PaymentStatus
(s/enum
Expand Down Expand Up @@ -34,11 +35,15 @@
:origin s/Str
:reference s/Str
(s/optional-key :secret) s/Str
(s/optional-key :paid_at) s/Str})
(s/optional-key :paid_at) s/Str
(s/optional-key :metadata) s/Any})

(s/defschema Laskut
[Lasku])

(s/defschema LaskuMetadataCreate
{:form-name localized-schema/LocalizedStringOptional})

(s/defschema LaskuCreate
(s/constrained
{(s/optional-key :order-id) s/Str
Expand All @@ -52,7 +57,8 @@
:reference s/Str
(s/optional-key :locale) (s/maybe Locale)
(s/optional-key :message) (s/maybe s/Str)
(s/optional-key :index) (s/constrained s/Int #(<= 1 % 2) 'valid-maksu-index)}
(s/optional-key :index) (s/constrained s/Int #(<= 1 % 2) 'valid-maksu-index)
(s/optional-key :metadata) LaskuMetadataCreate}
(fn [{:keys [due-date due-days]}]
(or due-date due-days))
'must-have-either-due-date-or-due-days))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@
(boolean
(and
(not-empty tutu-forms)
(some #(= tutu-key %) tutu-forms)))))
(some #(= tutu-key %) tutu-forms)))))

(defn tutu-form? [form]
(or
(= "payment-type-tutu" (get-in form [:properties :payment :type]))
(get-tutu-form? (:key form))))

(defn astu-form? [form]
(= "payment-type-astu" (get-in form [:properties :payment :type])))
11 changes: 2 additions & 9 deletions src/cljs/ataru/virkailija/application/handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
[ataru.virkailija.application.application-list.virkailija-application-list-handlers :as virkailija-application-list-handlers]
[ataru.virkailija.application.application-search-control-handlers :as asch]
[ataru.virkailija.application.application-selectors :refer [get-tutu-form?
tutu-form?
astu-form?
hakukohde-oids-from-selected-hakukohde-or-hakukohderyhma
selected-hakukohde-oid-set]]
[ataru.virkailija.application.mass-review.virkailija-mass-review-handlers]
Expand Down Expand Up @@ -349,14 +351,6 @@
(clj-string/split #",")
(cljs-util/get-unselected-review-states states)))

(defn- tutu-form? [form]
(or
(= "payment-type-tutu" (get-in form [:properties :payment :type]))
(get-tutu-form? (:key form))))

(defn- astu-form? [form]
(= "payment-type-astu" (get-in form [:properties :payment :type])))

(reg-event-db
:application/set-filters-from-query
(fn [db [_ form-key]]
Expand All @@ -369,7 +363,6 @@
tutu-form? review-states/application-hakukohde-processing-states
astu-form? review-states/application-hakukohde-processing-states-astu
:else review-states/application-hakukohde-processing-states-normal)]
(print form)
(-> db
(assoc-in [:application :attachment-state-filter]
(extract-unselected-review-states-from-query
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
(ns ataru.virkailija.application.payment.payment-handlers
(:require [ataru.virkailija.application.application-selectors :refer [get-payment-amount-input
get-payment-note-input]]
get-payment-note-input
tutu-form?
astu-form?]]
[ataru.virkailija.virkailija-ajax :as ajax]
[cljs-time.format :as f]
[clojure.string :refer [ends-with?]]
Expand Down Expand Up @@ -78,14 +80,24 @@
:override-args {:params data}))
{}))

(defn- get-origin [form]
(cond
(tutu-form? form) "tutu"
(astu-form? form) "astu"))

(re-frame/reg-event-fx
:payment/send-decision-invoice
(fn [{db :db} [_ application-key payment-type]]
(fn [{db :db} [_ application-key]]
(let [{:keys [due_date]} (get-in db [:payment :inputs application-key])
application (get-in db [:application :selected-application-and-form :application])
application-and-form (get-in db [:application :selected-application-and-form])
application (:application application-and-form)
form (:form application-and-form)
get-field (fn [key] (->> (:answers application) key :value))
message (get-payment-note-input db application-key)
amount (get-payment-amount-input db application-key)
origin (get-origin form)
metadata (when (= origin "astu")
{:form-name (:name form)})
data {:reference application-key
:first-name (get-field :first-name)
:last-name (get-field :last-name)
Expand All @@ -95,7 +107,7 @@
:message message
:due-date due_date
:due-days 14
:origin payment-type
:origin origin
:index 2}]

(ajax/http :post
Expand All @@ -104,7 +116,10 @@

:id :send-decision-invoice
:handler-args {:application-key application-key}
:override-args {:params data}))
:override-args {:params (cond->
data
(not-empty metadata)
(assoc :metadata metadata))}))
{}))

(re-frame/reg-fx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@
[:span [:i.zmdi.zmdi-spinner.spin]]
@(subscribe [:editor/virkailija-translation :maksupyynto-kasittelymaksu-button]))]]))

(defn- send-decision-invoice-button [application-key decision-pay-status payment-type]
(defn- send-decision-invoice-button [application-key decision-pay-status]
(let [filled? (subscribe [:payment/inputs-filled? application-key])
loading? (subscribe [:state-query [:request-handles :send-decision-invoice]])
can-edit? (subscribe [:state-query [:application :selected-application-and-form :application :can-edit?]])]
[:button.application-handling__tutu-payment-send-button.application-handling__button
{:on-click #(dispatch [:payment/send-decision-invoice application-key payment-type])
{:on-click #(dispatch [:payment/send-decision-invoice application-key])
:disabled (or @loading? (not @filled?) (not @can-edit?))
:class (if (and @filled? @can-edit? (not @loading?))
"application-handling__send-information-request-button--enabled application-handling__send-information-request-button--cursor-pointer"
Expand Down Expand Up @@ -206,7 +206,7 @@
[:div @(subscribe [:editor/virkailija-translation :maksupyynto-message])]
[decision-payment-note application-key]

[send-decision-invoice-button application-key decision-pay-status "tutu"]
[send-decision-invoice-button application-key decision-pay-status]
])])
]))

Expand Down Expand Up @@ -279,5 +279,5 @@
(= :overdue decision-pay-status) false
(#{:processing :decision-fee-outstanding} state) true)
[:<>
[send-decision-invoice-button application-key decision-pay-status "astu"]])])
[send-decision-invoice-button application-key decision-pay-status]])])
]))

0 comments on commit 5e11a47

Please sign in to comment.