From 253feea363f5255ca01e3a543ed1aa2ecd62b322 Mon Sep 17 00:00:00 2001 From: lev-web Date: Sat, 20 Jan 2024 00:20:20 +0300 Subject: [PATCH 01/55] :art: used item name for dispaly instead of date --- .../src/pages/dashboard/billing/create-invoice/Appointments.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front-end/src/pages/dashboard/billing/create-invoice/Appointments.js b/front-end/src/pages/dashboard/billing/create-invoice/Appointments.js index 211293ec..6d833eec 100644 --- a/front-end/src/pages/dashboard/billing/create-invoice/Appointments.js +++ b/front-end/src/pages/dashboard/billing/create-invoice/Appointments.js @@ -37,7 +37,7 @@ const Appointments = ({patient_id, setSelectedAppointments}) => {
} - label={appointment.date_created.substring(0,10)} + label={appointment.item_name} onChange={(event) => handleCheckboxChange(event, appointment)} />
From 94e1347291739fc5b3076fb3b1b255b985b33cb4 Mon Sep 17 00:00:00 2001 From: lev-web Date: Sat, 20 Jan 2024 00:20:38 +0300 Subject: [PATCH 02/55] :art: sum to onclude prescribed drugs sum --- .../billing/create-invoice/ReviewInvoice.js | 62 +++++++++---------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/front-end/src/pages/dashboard/billing/create-invoice/ReviewInvoice.js b/front-end/src/pages/dashboard/billing/create-invoice/ReviewInvoice.js index 7beaf5c9..03c1e0b4 100644 --- a/front-end/src/pages/dashboard/billing/create-invoice/ReviewInvoice.js +++ b/front-end/src/pages/dashboard/billing/create-invoice/ReviewInvoice.js @@ -12,7 +12,8 @@ import { ErrorMessage, Field, Form, Formik, FormikProps } from 'formik'; import * as Yup from "yup"; const ReviewInvoice = ({ selectedOption, selectedAppointments, selectedLabRequests, selectedPrescribedDrugs, }) => { - const [appointmentSum, setAppointmentSum] = useState(0) + const [appointmentSum, setAppointmentSum] = useState(0); + const [prescribedDrugsSum, setPrescribedDrugsSum] = useState(0); const { invoices } = useSelector((store) => store.billing); const auth = useAuth() const invoiceRef = useRef(); @@ -39,6 +40,16 @@ const ReviewInvoice = ({ selectedOption, selectedAppointments, selectedLabReques } + const totalPrescribedDrugsSum = () => { + let fees = [] + selectedPrescribedDrugs.forEach((item)=>{ + fees.push(parseInt(item.sale_price)) + }) + + setPrescribedDrugsSum(sumArray(fees)) + + } + const saveInvoiceItem = async (payloadInvoiceItemData) => { console.log('INVOICE ITEM PAYLOAD', payloadInvoiceItemData) try { @@ -87,34 +98,6 @@ const ReviewInvoice = ({ selectedOption, selectedAppointments, selectedLabReques }); }; - // const saveNewInvoice = async (formValue, helpers) => { - // generatePdf().then( async (pdf) => { - // console.log(pdf) - // try { - // const payloadData = { - // ...formValue, - // invoice_date: "2024-01-16", - // invoice_amount: "-319", - // status: "pending", - // invoice_file: "pdf", - // invoice_number: invoices.length + 1 - // } - // if (selectedAppointments.length <= 0 && selectedLabRequests <= 0 && selectedPrescribedDrugs <= 0) { - // toast.error("Select atleast one item"); - // return; - // } - - // const response = await billingInvoices(auth, payloadData) - // console.log(response) - // toast.success("invoice saved successfully") - // router.push('/dashboard/billing') - // }catch (err) { - // toast.error(err); - // } - - // }); - // } - const saveInvoice = async (formValue) => { const payloadData = { @@ -149,6 +132,7 @@ const ReviewInvoice = ({ selectedOption, selectedAppointments, selectedLabReques useEffect(()=>{ if(auth){ totalAppointmentSum() + totalPrescribedDrugsSum() dispatch(getAllInvoices(auth)); } },[selectedOption, selectedAppointments, selectedLabRequests, selectedPrescribedDrugs, auth]) @@ -189,7 +173,7 @@ const ReviewInvoice = ({ selectedOption, selectedAppointments, selectedLabReques