Skip to content

Commit

Permalink
Remove backend, set currency, add translations
Browse files Browse the repository at this point in the history
  • Loading branch information
ODORA0 committed Feb 22, 2024
1 parent 22927c8 commit 4f6fd77
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"prettier": "prettier --config prettier.config.js --write \"src/**/*.{ts,tsx,css,scss}\" \"e2e/**/*.ts\"",
"release": "lerna version --no-git-tag-version",
"serve": "webpack serve --mode=development",
"start": "openmrs develop --backend https://uat.kenyahmis.org/ ",
"start": "openmrs develop",
"test-e2e": "playwright test",
"test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests",
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js",
Expand Down
17 changes: 15 additions & 2 deletions src/bill-history/bill-history.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
TableRow,
Tile,
} from '@carbon/react';
import { isDesktop, useLayoutType, usePagination } from '@openmrs/esm-framework';
import { isDesktop, useConfig, useLayoutType, usePagination } from '@openmrs/esm-framework';
import {
CardHeader,
EmptyDataIllustration,
Expand All @@ -44,6 +44,8 @@ const BillHistory: React.FC<BillHistoryProps> = ({ patientUuid }) => {
const { paginated, goTo, results, currentPage } = usePagination(bills, PAGE_SIZE);
const { pageSizes } = usePaginationInfo(PAGE_SIZE, bills?.length, currentPage, results?.length);

const { defaultCurrency } = useConfig();

const headerData = [
{
header: t('visitTime', 'Visit time'),
Expand All @@ -66,10 +68,21 @@ const BillHistory: React.FC<BillHistoryProps> = ({ patientUuid }) => {
const setBilledItems = (bill) =>
bill.lineItems.reduce((acc, item) => acc + (acc ? ' & ' : '') + (item.billableService || item.item || ''), '');

const formatCurrency = (amount) => {
const currencyCode = defaultCurrency._default || 'UGX';

return new Intl.NumberFormat(undefined, {
style: 'currency',
currency: currencyCode,
minimumFractionDigits: 0,
maximumFractionDigits: 0,
}).format(amount);
};

const rowData = results?.map((bill) => ({
id: bill.uuid,
uuid: bill.uuid,
billTotal: bill.totalAmount,
billTotal: formatCurrency(bill.totalAmount),
visitTime: bill.dateCreated,
identifier: bill.identifier,
billedItems: setBilledItems(bill),
Expand Down
6 changes: 4 additions & 2 deletions translations/am.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"actions": "Actions",
"addBill": "Add bill item(s)",
"addBillableServices": "Add Billable Services",
"addNewBillableService": "Add new billable service",
"addNewService": "Add new service",
Expand All @@ -14,6 +15,7 @@
"billedTo": "Billed to",
"billErrorService": "Bill service error",
"billing": "Billing",
"billingHistory": "Billing History",
"billItem": "Bill item",
"billItems": "Bill Items",
"billList": "Bill list",
Expand All @@ -31,7 +33,6 @@
"checkFilters": "Check the filters above",
"discard": "Discard",
"discount": "Discount",
"drug": "Drug",
"enterAmount": "Enter amount",
"enterConcept": "Associated concept",
"enterReferenceNumber": "Enter ref. number",
Expand Down Expand Up @@ -60,7 +61,6 @@
"noMatchingBillsToDisplay": "No matching bills to display",
"noMatchingItemsToDisplay": "No matching items to display",
"noMatchingServicesToDisplay": "No matching services to display",
"nonDrug": "Non drug",
"noResultsFor": "No results for",
"noServicesToDisplay": "There are no services to display",
"ok": "OK",
Expand Down Expand Up @@ -91,13 +91,15 @@
"selectPaymentMethod": "Select payment method",
"sellingAmount": "Enter selling price",
"sellingPrice": "Selling Price",
"service": "Service",
"serviceMetrics": "Service Metrics",
"serviceName": "Service Name",
"serviceShortName": "Short Name",
"servicesList": "Services list",
"serviceType": "Service Type",
"shortName": "Short Name",
"status": "Service Status",
"stockItem": "Stock Item",
"total": "Total",
"totalAmount": "Total Amount",
"totalTendered": "Total Tendered",
Expand Down
6 changes: 4 additions & 2 deletions translations/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"actions": "Actions",
"addBill": "Add bill item(s)",
"addBillableServices": "Add Billable Services",
"addNewBillableService": "Add new billable service",
"addNewService": "Add new service",
Expand All @@ -14,6 +15,7 @@
"billedTo": "Billed to",
"billErrorService": "Bill service error",
"billing": "Billing",
"billingHistory": "Billing History",
"billItem": "Bill item",
"billItems": "Bill Items",
"billList": "Bill list",
Expand All @@ -31,7 +33,6 @@
"checkFilters": "Check the filters above",
"discard": "Discard",
"discount": "Discount",
"drug": "Drug",
"enterAmount": "Enter amount",
"enterConcept": "Associated concept",
"enterReferenceNumber": "Enter ref. number",
Expand Down Expand Up @@ -60,7 +61,6 @@
"noMatchingBillsToDisplay": "No matching bills to display",
"noMatchingItemsToDisplay": "No matching items to display",
"noMatchingServicesToDisplay": "No matching services to display",
"nonDrug": "Non drug",
"noResultsFor": "No results for",
"noServicesToDisplay": "There are no services to display",
"ok": "OK",
Expand Down Expand Up @@ -91,13 +91,15 @@
"selectPaymentMethod": "Select payment method",
"sellingAmount": "Enter selling price",
"sellingPrice": "Selling Price",
"service": "Service",
"serviceMetrics": "Service Metrics",
"serviceName": "Service Name",
"serviceShortName": "Short Name",
"servicesList": "Services list",
"serviceType": "Service Type",
"shortName": "Short Name",
"status": "Service Status",
"stockItem": "Stock Item",
"total": "Total",
"totalAmount": "Total Amount",
"totalTendered": "Total Tendered",
Expand Down
6 changes: 4 additions & 2 deletions translations/es.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"actions": "Actions",
"addBill": "Add bill item(s)",
"addBillableServices": "Add Billable Services",
"addNewBillableService": "Add new billable service",
"addNewService": "Add new service",
Expand All @@ -14,6 +15,7 @@
"billedTo": "Billed to",
"billErrorService": "Bill service error",
"billing": "Billing",
"billingHistory": "Billing History",
"billItem": "Bill item",
"billItems": "Bill Items",
"billList": "Bill list",
Expand All @@ -31,7 +33,6 @@
"checkFilters": "Check the filters above",
"discard": "Discard",
"discount": "Discount",
"drug": "Drug",
"enterAmount": "Enter amount",
"enterConcept": "Associated concept",
"enterReferenceNumber": "Enter ref. number",
Expand Down Expand Up @@ -60,7 +61,6 @@
"noMatchingBillsToDisplay": "No matching bills to display",
"noMatchingItemsToDisplay": "No matching items to display",
"noMatchingServicesToDisplay": "No matching services to display",
"nonDrug": "Non drug",
"noResultsFor": "No results for",
"noServicesToDisplay": "There are no services to display",
"ok": "OK",
Expand Down Expand Up @@ -91,13 +91,15 @@
"selectPaymentMethod": "Select payment method",
"sellingAmount": "Enter selling price",
"sellingPrice": "Selling Price",
"service": "Service",
"serviceMetrics": "Service Metrics",
"serviceName": "Service Name",
"serviceShortName": "Short Name",
"servicesList": "Services list",
"serviceType": "Service Type",
"shortName": "Short Name",
"status": "Service Status",
"stockItem": "Stock Item",
"total": "Total",
"totalAmount": "Total Amount",
"totalTendered": "Total Tendered",
Expand Down
6 changes: 4 additions & 2 deletions translations/fr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"actions": "Actions",
"addBill": "Add bill item(s)",
"addBillableServices": "Add Billable Services",
"addNewBillableService": "Add new billable service",
"addNewService": "Add new service",
Expand All @@ -14,6 +15,7 @@
"billedTo": "Billed to",
"billErrorService": "Bill service error",
"billing": "Billing",
"billingHistory": "Billing History",
"billItem": "Bill item",
"billItems": "Bill Items",
"billList": "Bill list",
Expand All @@ -31,7 +33,6 @@
"checkFilters": "Check the filters above",
"discard": "Discard",
"discount": "Discount",
"drug": "Drug",
"enterAmount": "Enter amount",
"enterConcept": "Associated concept",
"enterReferenceNumber": "Enter ref. number",
Expand Down Expand Up @@ -60,7 +61,6 @@
"noMatchingBillsToDisplay": "No matching bills to display",
"noMatchingItemsToDisplay": "No matching items to display",
"noMatchingServicesToDisplay": "No matching services to display",
"nonDrug": "Non drug",
"noResultsFor": "No results for",
"noServicesToDisplay": "There are no services to display",
"ok": "OK",
Expand Down Expand Up @@ -91,13 +91,15 @@
"selectPaymentMethod": "Select payment method",
"sellingAmount": "Enter selling price",
"sellingPrice": "Selling Price",
"service": "Service",
"serviceMetrics": "Service Metrics",
"serviceName": "Service Name",
"serviceShortName": "Short Name",
"servicesList": "Services list",
"serviceType": "Service Type",
"shortName": "Short Name",
"status": "Service Status",
"stockItem": "Stock Item",
"total": "Total",
"totalAmount": "Total Amount",
"totalTendered": "Total Tendered",
Expand Down
6 changes: 4 additions & 2 deletions translations/he.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"actions": "Actions",
"addBill": "Add bill item(s)",
"addBillableServices": "Add Billable Services",
"addNewBillableService": "Add new billable service",
"addNewService": "Add new service",
Expand All @@ -14,6 +15,7 @@
"billedTo": "Billed to",
"billErrorService": "Bill service error",
"billing": "Billing",
"billingHistory": "Billing History",
"billItem": "Bill item",
"billItems": "Bill Items",
"billList": "Bill list",
Expand All @@ -31,7 +33,6 @@
"checkFilters": "Check the filters above",
"discard": "Discard",
"discount": "Discount",
"drug": "Drug",
"enterAmount": "Enter amount",
"enterConcept": "Associated concept",
"enterReferenceNumber": "Enter ref. number",
Expand Down Expand Up @@ -60,7 +61,6 @@
"noMatchingBillsToDisplay": "No matching bills to display",
"noMatchingItemsToDisplay": "No matching items to display",
"noMatchingServicesToDisplay": "No matching services to display",
"nonDrug": "Non drug",
"noResultsFor": "No results for",
"noServicesToDisplay": "There are no services to display",
"ok": "OK",
Expand Down Expand Up @@ -91,13 +91,15 @@
"selectPaymentMethod": "Select payment method",
"sellingAmount": "Enter selling price",
"sellingPrice": "Selling Price",
"service": "Service",
"serviceMetrics": "Service Metrics",
"serviceName": "Service Name",
"serviceShortName": "Short Name",
"servicesList": "Services list",
"serviceType": "Service Type",
"shortName": "Short Name",
"status": "Service Status",
"stockItem": "Stock Item",
"total": "Total",
"totalAmount": "Total Amount",
"totalTendered": "Total Tendered",
Expand Down
6 changes: 4 additions & 2 deletions translations/km.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"actions": "Actions",
"addBill": "Add bill item(s)",
"addBillableServices": "Add Billable Services",
"addNewBillableService": "Add new billable service",
"addNewService": "Add new service",
Expand All @@ -14,6 +15,7 @@
"billedTo": "Billed to",
"billErrorService": "Bill service error",
"billing": "Billing",
"billingHistory": "Billing History",
"billItem": "Bill item",
"billItems": "Bill Items",
"billList": "Bill list",
Expand All @@ -31,7 +33,6 @@
"checkFilters": "Check the filters above",
"discard": "Discard",
"discount": "Discount",
"drug": "Drug",
"enterAmount": "Enter amount",
"enterConcept": "Associated concept",
"enterReferenceNumber": "Enter ref. number",
Expand Down Expand Up @@ -60,7 +61,6 @@
"noMatchingBillsToDisplay": "No matching bills to display",
"noMatchingItemsToDisplay": "No matching items to display",
"noMatchingServicesToDisplay": "No matching services to display",
"nonDrug": "Non drug",
"noResultsFor": "No results for",
"noServicesToDisplay": "There are no services to display",
"ok": "OK",
Expand Down Expand Up @@ -91,13 +91,15 @@
"selectPaymentMethod": "Select payment method",
"sellingAmount": "Enter selling price",
"sellingPrice": "Selling Price",
"service": "Service",
"serviceMetrics": "Service Metrics",
"serviceName": "Service Name",
"serviceShortName": "Short Name",
"servicesList": "Services list",
"serviceType": "Service Type",
"shortName": "Short Name",
"status": "Service Status",
"stockItem": "Stock Item",
"total": "Total",
"totalAmount": "Total Amount",
"totalTendered": "Total Tendered",
Expand Down

0 comments on commit 4f6fd77

Please sign in to comment.