Repository: GeorgeKalash/ArgusFE
Pull request #1243: AR-3256
Author: login: imtithalhalalo
Created: 2025-05-29T12:35:38Z | Merged: 2025-05-30T07:21:52Z

payment voucher

- Amount field to be thousand seperator
- to add combo Payment Reason
- filter Payment Reason


Diff:
diff --git a/src/components/Shared/apiMappings.js b/src/components/Shared/apiMappings.js
index de44497238..d283b7ae71 100644
--- a/src/components/Shared/apiMappings.js
+++ b/src/components/Shared/apiMappings.js
@@ -1055,5 +1055,15 @@ export const apiMappings = {
       { key: 'reference', value: 'Reference' },
       { key: 'name', value: 'Name' }
     ]
-  }
+  },
+    [ResourceIds.PaymentReasons]: {
+    type: COMBOBOX,
+    endpoint: FinancialRepository.PaymentReasons.qry,
+    valueField: 'recordId',
+    displayField: ['reference', 'name'],
+    columnsInDropDown: [
+      { key: 'reference', value: 'Reference' },
+      { key: 'name', value: 'Name' }
+    ]
+  },
 }
diff --git a/src/pages/fi-payment-vouchers/forms/FiPaymentVouchersForm.js b/src/pages/fi-payment-vouchers/forms/FiPaymentVouchersForm.js
index f6884ed52a..fea5ea2bd3 100644
--- a/src/pages/fi-payment-vouchers/forms/FiPaymentVouchersForm.js
+++ b/src/pages/fi-payment-vouchers/forms/FiPaymentVouchersForm.js
@@ -77,7 +77,8 @@ export default function FiPaymentVouchersForm({ labels, maxAccess: access, recor
       plantId: parseInt(plantId),
       contactId: null,
       isVerified: false,
-      sourceReference: ''
+      sourceReference: '',
+      paymentReasonId: null
     },
     maxAccess,
     enableReinitialize: false,
@@ -547,7 +548,12 @@ export default function FiPaymentVouchersForm({ labels, maxAccess: access, recor
               />
             </Grid>
             <Grid item xs={6}>
-              <CustomTextField name='accountGroupName' label={labels.accountGroup} value={formik.values.accountGroupName} readOnly />
+              <CustomTextField
+                name='accountGroupName'
+                label={labels.accountGroup}
+                value={formik.values.accountGroupName}
+                readOnly
+              />
             </Grid>
             <Grid item xs={6}>
               <ResourceComboBox
@@ -639,7 +645,6 @@ export default function FiPaymentVouchersForm({ labels, maxAccess: access, recor
                 readOnly={isPosted || isCancelled}
                 value={formik.values.amount}
                 maxAccess={maxAccess}
-                thousandSeparator={false}
                 onChange={async e => {
                   const updatedRateRow = getRate({
                     amount: e.target.value ?? 0,
@@ -706,6 +711,20 @@ export default function FiPaymentVouchersForm({ labels, maxAccess: access, recor
                 disabled={formik.values.paymentMethod != 3}
               />
             </Grid>
+
+            <Grid item xs={6}>
+              <CustomTextField
+                name='sourceReference'
+                label={labels.sourceReference}
+                value={formik.values.sourceReference}
+                onChange={formik.handleChange}
+                onClear={() => formik.setFieldValue('sourceReference', '')}
+                maxLength='20'
+                readOnly={isPosted || isCancelled}
+                maxAccess={maxAccess}
+                error={formik.touched.sourceReference && Boolean(formik.errors.sourceReference)}
+              />
+            </Grid>
             <Grid item xs={6}>
               <CustomTextArea
                 name='notes'
@@ -721,15 +740,23 @@ export default function FiPaymentVouchersForm({ labels, maxAccess: access, recor
               />
             </Grid>
             <Grid item xs={6}>
-              <CustomTextField
-                name='sourceReference'
-                label={labels.sourceReference}
-                value={formik.values.sourceReference}
-                onChange={formik.handleChange}
-                onClear={() => formik.setFieldValue('sourceReference', '')}
-                maxLength='20'
+              <ResourceComboBox
+                endpointId={FinancialRepository.PaymentReasons.qry}
+                name='paymentReasonId'
+                readOnly={isPosted || isCancelled}
+                label={labels.paymentReasons}
+                valueField='recordId'
+                displayField={['reference', 'name']}
+                columnsInDropDown={[
+                  { key: 'reference', value: 'Reference' },
+                  { key: 'name', value: 'Name' }
+                ]}
+                values={formik.values}
                 maxAccess={maxAccess}
-                error={formik.touched.sourceReference && Boolean(formik.errors.sourceReference)}
+                onChange={(event, newValue) => {
+                  formik.setFieldValue('paymentReasonId', newValue?.recordId || null)
+                }}
+                error={formik.touched.paymentReasonId && Boolean(formik.errors.paymentReasonId)}
               />
             </Grid>
           </Grid>
diff --git a/src/repositories/FinancialRepository.js b/src/repositories/FinancialRepository.js
index 57e2c91147..5b8d7be892 100644
--- a/src/repositories/FinancialRepository.js
+++ b/src/repositories/FinancialRepository.js
@@ -225,6 +225,7 @@ export const FinancialRepository = {
     snapshot: service + 'snapshotTFR'
   },
   PaymentReasons: {
+    qry: service + 'qryPR',
     get: service + 'getPR',
     del: service + 'delPR',
     set: service + 'setPR',


Reviews:
user: login: Ghinwa-Arab
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-05-30T06:30:56Z
user: login: Ghinwa-Arab
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-05-30T06:40:03Z
user: login: Ghinwa-Arab
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-05-30T06:40:25Z
user: login: imtithalhalalo
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-05-30T06:45:07Z
user: login: Ghinwa-Arab
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-05-30T07:21:39Z

Review comments:
diff_hunk: @@ -1055,5 +1055,16 @@ export const apiMappings = {
       { key: 'reference', value: 'Reference' },
       { key: 'name', value: 'Name' }
     ]
-  }
+  },
+    [ResourceIds.PaymentReasons]: {
+    type: COMBOBOX,
+    endpoint: FinancialRepository.PaymentReasons.qry,
+    parameters: `_params=&_startAt=0&_pageSize=1000`,
path: src/components/Shared/apiMappings.js
user: login: Ghinwa-Arab
body: this api doesn't request parameters, remove them
created_at: 2025-05-30T06:30:56Z
author_association: COLLABORATOR
diff_hunk: @@ -706,6 +710,19 @@ export default function FiPaymentVouchersForm({ labels, maxAccess: access, recor
                 disabled={formik.values.paymentMethod != 3}
               />
             </Grid>
+
path: src/pages/fi-payment-vouchers/forms/FiPaymentVouchersForm.js
user: login: Ghinwa-Arab
body: u didn't add paymentReasonId & sourceReference to formik initial values?
created_at: 2025-05-30T06:40:03Z
author_association: COLLABORATOR
diff_hunk: @@ -706,6 +710,19 @@ export default function FiPaymentVouchersForm({ labels, maxAccess: access, recor
                 disabled={formik.values.paymentMethod != 3}
               />
             </Grid>
+
+            <Grid item xs={6}>
+              <CustomTextField
+                name='sourceReference'
+                label={labels.sourceReference}
+                value={formik.values.sourceReference}
+                onChange={formik.handleChange}
path: src/pages/fi-payment-vouchers/forms/FiPaymentVouchersForm.js
user: login: Ghinwa-Arab
body: add readOnly={isPosted || isCancelled}
created_at: 2025-05-30T06:40:24Z
author_association: COLLABORATOR
diff_hunk: @@ -706,6 +710,19 @@ export default function FiPaymentVouchersForm({ labels, maxAccess: access, recor
                 disabled={formik.values.paymentMethod != 3}
               />
             </Grid>
+
path: src/pages/fi-payment-vouchers/forms/FiPaymentVouchersForm.js
user: login: imtithalhalalo
body: sourceReference added just paymentReasonId 
created_at: 2025-05-30T06:45:07Z
author_association: COLLABORATOR

PR comments:
user: login: vercel[bot]
created_at: 2025-05-29T12:35:43Z
body: [vc]: #6oaRnR/OitBJPr6cs87aDJh1PcYIxRNFSmvxm6V6pX0=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJhcmd1cy1mZSIsImluc3BlY3RvclVybCI6Imh0dHBzOi8vdmVyY2VsLmNvbS9nZW9yZ2Uta2FsYXNocy1wcm9qZWN0cy9hcmd1cy1mZS9HQUN6TWhZVUNLVDduVFU4REFoc2hwTDdFTm1DIiwicHJldmlld1VybCI6ImFyZ3VzLWZlLWdpdC1hci0zMjU2LWdlb3JnZS1rYWxhc2hzLXByb2plY3RzLnZlcmNlbC5hcHAiLCJuZXh0Q29tbWl0U3RhdHVzIjoiREVQTE9ZRUQiLCJsaXZlRmVlZGJhY2siOnsicmVzb2x2ZWQiOjAsInVucmVzb2x2ZWQiOjAsInRvdGFsIjowLCJsaW5rIjoiYXJndXMtZmUtZ2l0LWFyLTMyNTYtZ2VvcmdlLWthbGFzaHMtcHJvamVjdHMudmVyY2VsLmFwcCJ9LCJyb290RGlyZWN0b3J5IjpudWxsfV19
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Comments | Updated (UTC) |
| :--- | :----- | :------ | :------- | :------ |
| **argus-fe** | ✅ Ready ([Inspect](https://vercel.com/george-kalashs-projects/argus-fe/GACzMhYUCKT7nTU8DAhshpL7ENmC)) | [Visit Preview](https://argus-fe-git-ar-3256-george-kalashs-projects.vercel.app) | 💬 [**Add feedback**](https://vercel.live/open-feedback/argus-fe-git-ar-3256-george-kalashs-projects.vercel.app?via=pr-comment-feedback-link) | May 30, 2025 6:54am |


author_association: NONE
user: login: Ghinwa-Arab
created_at: 2025-05-30T06:39:14Z
body: ![image](https://github.com/user-attachments/assets/61398524-164a-433b-bbd3-b22da8f107b9)

1. document type should be readOnly in editMode
2. source reference should be readOnly if record is posted
author_association: COLLABORATOR