Skip to content

Commit 3908367

Browse files
committed
fix: fetching exchange rate fails when expense currency changes from company currency
- also simplify value emit in Link field
1 parent 6972cea commit 3908367

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

frontend/src/components/Link.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ const searchText = ref("")
4343
const value = computed({
4444
get: () => props.modelValue,
4545
set: (val) => {
46-
const newVal =
47-
val && typeof val === "object" && val.value !== undefined
48-
? val.value
49-
: val
50-
emit("update:modelValue", newVal || "")
46+
if (typeof val === "string") {
47+
emit("update:modelValue", val)
48+
} else {
49+
emit("update:modelValue", val?.value || "")
50+
}
5151
},
5252
})
5353

frontend/src/views/expense_claim/Form.vue

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
:currency="currency"
4444
:isReadOnly="isReadOnly || isFormReadOnly"
4545
/>
46-
46+
4747
</template>
4848
</FormView>
4949
</ion-content>
@@ -93,7 +93,6 @@ const expenseClaim = ref({
9393
doctype: "Expense Claim",
9494
})
9595
96-
const currency = computed(() => expenseClaim.value.currency)
9796
const companyCurrency = computed(() => getCompanyCurrency(expenseClaim.value.company))
9897
9998
// get form fields
@@ -326,7 +325,7 @@ function applyFilters(field) {
326325
account_type: "Payable",
327326
company: expenseClaim.value.company,
328327
is_group: 0,
329-
account_currency: currency.value,
328+
account_currency: expenseClaim.value.currency,
330329
}
331330
} else if (field.fieldname === "cost_center") {
332331
field.linkFilters = {
@@ -503,16 +502,10 @@ function setExchangeRate() {
503502
(field) => field.fieldname === "exchange_rate"
504503
)
505504
506-
if (currency.value === companyCurrency.value) {
507-
expenseClaim.value.exchange_rate = 1
508-
if (exchange_rate_field) exchange_rate_field.hidden = 1
509-
}
510-
if (!expenseClaim.value.exchange_rate) {
511-
exchangeRate.fetch({
512-
from_currency: currency.value,
513-
to_currency: companyCurrency.value,
514-
})
515-
}
505+
exchangeRate.fetch({
506+
from_currency: expenseClaim.value.currency,
507+
to_currency: companyCurrency.value,
508+
})
516509
if (exchange_rate_field) exchange_rate_field.hidden = 0
517510
}
518511
</script>

roster/src/components/Link.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ const searchText = ref("");
5151
const value = computed({
5252
get: () => props.modelValue,
5353
set: (val) => {
54-
const newVal = val && typeof val === "object" && val.value !== undefined ? val.value : val;
55-
console.log(newVal);
56-
emit("update:modelValue", newVal || "");
54+
if (typeof val === "string") {
55+
emit("update:modelValue", val);
56+
} else {
57+
emit("update:modelValue", val?.value || "");
58+
}
5759
},
5860
});
5961

0 commit comments

Comments
 (0)