diff --git a/frontend/src/components/Settings/Transactions/TransactionDetails.vue b/frontend/src/components/Settings/Transactions/TransactionDetails.vue
index efd2cc88..38989a7b 100644
--- a/frontend/src/components/Settings/Transactions/TransactionDetails.vue
+++ b/frontend/src/components/Settings/Transactions/TransactionDetails.vue
@@ -55,17 +55,18 @@
:label="__('Member')"
doctype="User"
v-model="transactionData.member"
- :required="true"
+ :required="!!fieldMeta.member?.reqd"
/>
@@ -90,17 +93,18 @@
:label="__('Currency')"
v-model="transactionData.currency"
doctype="Currency"
- :required="true"
+ :required="!!fieldMeta.currency?.reqd"
/>
@@ -113,21 +117,25 @@
v-if="transactionData.coupon"
:label="__('Coupon Code')"
v-model="transactionData.coupon"
+ :required="!!fieldMeta.coupon?.reqd"
/>
@@ -140,17 +148,27 @@
:label="__('Address')"
v-model="transactionData.address"
doctype="Address"
- :required="true"
+ :required="!!fieldMeta.address?.reqd"
+ />
+
+
-
-
@@ -171,6 +189,10 @@ const show = defineModel('show')
const props = defineProps<{
transactions: any
data: any
+ fieldMeta: Record<
+ string,
+ { reqd?: number; default?: string; description?: string }
+ >
}>()
const saveTransaction = () => {
@@ -211,48 +233,49 @@ const updateTransaction = () => {
}
const openDetails = () => {
- if (props.data) {
- const docType = props.data.payment_for_document_type
- const docName = props.data.payment_for_document
- if (docType && docName) {
- router.push({
- name: docType == 'LMS Course' ? 'CourseDetail' : 'BatchDetail',
- params: {
- [docType == 'LMS Course' ? 'courseName' : 'batchName']: docName,
- },
- })
- }
+ const docType = transactionData.value?.payment_for_document_type
+ const docName = transactionData.value?.payment_for_document
+ if (docType && docName) {
+ router.push({
+ name: docType == 'LMS Course' ? 'CourseDetail' : 'BatchDetail',
+ params: {
+ [docType == 'LMS Course' ? 'courseName' : 'batchName']: docName,
+ },
+ })
show.value = false
}
}
-const emptyTransactionData = {
+const getDefault = (fieldname: string) =>
+ props.fieldMeta[fieldname]?.default || null
+
+const getEmptyTransactionData = () => ({
payment_received: false,
payment_for_certificate: false,
- member: null,
- billing_name: null,
- source: null,
- payment_for_document_type: null,
- payment_for_document: null,
+ member: getDefault('member'),
+ billing_name: getDefault('billing_name'),
+ source: getDefault('source'),
+ payment_for_document_type: getDefault('payment_for_document_type'),
+ payment_for_document: getDefault('payment_for_document'),
member_consent: false,
- currency: null,
- amount: null,
- amount_with_gst: null,
- coupon: null,
- coupon_code: null,
- discount_amount: null,
- original_amount: null,
- order_id: null,
- payment_id: null,
- gstin: null,
- pan: null,
- address: null,
-}
+ currency: getDefault('currency'),
+ amount: getDefault('amount'),
+ amount_with_gst: getDefault('amount_with_gst'),
+ coupon: getDefault('coupon'),
+ coupon_code: getDefault('coupon_code'),
+ discount_amount: getDefault('discount_amount'),
+ original_amount: getDefault('original_amount'),
+ order_id: getDefault('order_id'),
+ payment_id: getDefault('payment_id'),
+ gstin: getDefault('gstin'),
+ pan: getDefault('pan'),
+ address: getDefault('address'),
+})
watch(
() => props.data,
(newVal) => {
- transactionData.value = newVal ? { ...newVal } : emptyTransactionData
+ transactionData.value = newVal ? { ...newVal } : getEmptyTransactionData()
},
{ immediate: true }
)
diff --git a/frontend/src/components/Settings/Transactions/Transactions.vue b/frontend/src/components/Settings/Transactions/Transactions.vue
index d2045b8a..eeb0d2a5 100644
--- a/frontend/src/components/Settings/Transactions/Transactions.vue
+++ b/frontend/src/components/Settings/Transactions/Transactions.vue
@@ -3,6 +3,7 @@
v-if="step == 'new'"
:transactions="transactions"
:data="data"
+ :fieldMeta="fieldMeta.data || {}"
v-model:show="show"
@updateStep="updateStep"
/>
@@ -17,13 +18,14 @@
v-else-if="step == 'details'"
:transactions="transactions"
:data="data"
+ :fieldMeta="fieldMeta.data || {}"
v-model:show="show"
@updateStep="updateStep"
/>