Skip to content

Commit

Permalink
fix(ember): add formatting for circulation column
Browse files Browse the repository at this point in the history
  • Loading branch information
Yelinz committed Jun 22, 2023
1 parent c8457bd commit 579ea6f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions ember/app/caluma-query/models/work-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export default class CustomWorkItemModel extends WorkItemModel {
id
question {
slug
meta
... on ChoiceQuestion {
options {
edges {
Expand Down
8 changes: 2 additions & 6 deletions ember/app/ui/cases/detail/index/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import redoWorkItemMutation from "mysagw/gql/mutations/redo-work-item.graphql";
import reopenCaseMutation from "mysagw/gql/mutations/reopen-case.graphql";
import getCaseQuery from "mysagw/gql/queries/get-case.graphql";
import downloadFile from "mysagw/utils/download-file";
import formatCurrency from "mysagw/utils/format-currency";
import CaseValidations from "mysagw/validations/case";

export default class CasesDetailIndexController extends Controller {
Expand Down Expand Up @@ -128,12 +129,7 @@ export default class CasesDetailIndexController extends Controller {
let value = answer.node[`${answer.node.__typename}Value`];

if (answer.node.question.meta.waehrung) {
value = new Intl.NumberFormat("de-CH", {
style: "currency",
currency: answer.node.question.meta.waehrung,
})
.format(value)
.replace(".00", ".-");
value = formatCurrency(value, answer.node.question.meta.waehrung);
}

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { get } from "@ember/object";
import Component from "@glimmer/component";

import formatCurrency from "mysagw/utils/format-currency";

export default class AnswerValue extends Component {
get value() {
const value = this.args.value.parentWorkItem ?? this.args.value;
Expand All @@ -20,6 +22,13 @@ export default class AnswerValue extends Component {
).node.label;
}

if (answer.question.meta?.waehrung) {
return formatCurrency(
answer[`${answer.__typename}Value`],
answer.question.meta.waehrung
);
}

return answer[`${answer.__typename}Value`];
}
}
8 changes: 8 additions & 0 deletions ember/app/utils/format-currency.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function formatCurrency(value, currency) {
return new Intl.NumberFormat("de-CH", {
style: "currency",
currency,
})
.format(value)
.replace(".00", ".-");
}
2 changes: 1 addition & 1 deletion ember/translations/work-items/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ work-items:
documentNumber: "Referenz"
circulationComment: "Bemerkung"
circulationDecision: "Entscheid"
circulationAmount: "Betrag"
circulationAmount: "Betrag (WiMa)"
distributionPlan: "Verteilplan"

saveSuccess: "Aufgabe gespeichert"
Expand Down
2 changes: 1 addition & 1 deletion ember/translations/work-items/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ work-items:
documentNumber: "Number"
circulationComment: "Comment"
circulationDecision: "Decision"
circulationAmount: "Amount"
circulationAmount: "Amount (WiMa)"
distributionPlan: "Distribution plan"

saveSuccess: "Task successfully saved"
Expand Down
2 changes: 1 addition & 1 deletion ember/translations/work-items/fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ work-items:
documentNumber: "Référence"
circulationComment: "Remarque"
circulationDecision: "Décision"
circulationAmount: "Somme"
circulationAmount: "Somme (WiMa)"
distributionPlan: "Plan de distribution"

saveSuccess: "Tâche enregistrée"
Expand Down

0 comments on commit 579ea6f

Please sign in to comment.