Skip to content
Merged

Dev #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions dashboard/src/components/MenuPage/MultiCurrencyDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,8 @@ export default function MultiCurrencyDialog({
if (isNaN(amount) || amount === 0) return 0;

// Exchange rate is FROM payment currency TO company currency
// So to convert payment amount to base currency: multiply by rate
// Example: 100 EUR * 1.1 (EUR to USD rate) = 110 USD
console.log(`Converting ${amount} ${key} to base using rate ${ratesAtOpen[key]}`);
console.log("the real zwg"+amount *ratesAtOpen[key])
// So to convert payment amount to base currency: divide by rate
// Example: 431.60 ZWG / 33.2 (ZWG to USD rate) = 13 USD
return amount / ratesAtOpen[key];
};

Expand All @@ -242,9 +240,8 @@ export default function MultiCurrencyDialog({
const getAmountDue = (key) => {
if (!ratesAtOpen || !ratesAtOpen[key]) return 0;
// Exchange rate is FROM payment currency TO company currency
// So to convert base currency to payment currency: divide by rate
// Example: 100 USD / 1.1 (EUR to USD rate) = 90.91 EUR
console.log("the remaining base: "+remainingBase+"rate at open: "+ratesAtOpen)
// So to convert base currency to payment currency: multiply by rate
// Example: 13 USD * 33.2 (ZWG to USD rate) = 431.60 ZWG
return remainingBase * ratesAtOpen[key];
};
return (
Expand Down
6 changes: 3 additions & 3 deletions dashboard/src/components/MenuPage/PaymentDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default function PaymentDialog({
try {
// const invoiceJson = await get_invoice_json(transactionName);
console.log("Invoice JSON returned from backend MULTIPLE");
window.open(`api/method/havano_restaurant_pos.api.download_invoice_json?name=${transactionName}`, "_blank");
window.open(`/api/method/havano_restaurant_pos.api.download_invoice_json?name=${transactionName}`, "_blank");

// Convert JSON to string
const jsonStr = JSON.stringify(invoiceJson, null, 2);
Expand Down Expand Up @@ -253,7 +253,7 @@ export default function PaymentDialog({
console.log("Table payment processed:", res.sales_invoice);
// Print invoice if available
if (res.sales_invoice) {
window.open(`api/method/havano_restaurant_pos.api.download_invoice_json?name=${res.sales_invoice}`, "_blank");
window.open(`/api/method/havano_restaurant_pos.api.download_invoice_json?name=${res.sales_invoice}`, "_blank");
}
// Notify payment success callback AFTER payment is fully complete
if (typeof onPaid === "function") {
Expand Down Expand Up @@ -287,7 +287,7 @@ export default function PaymentDialog({
console.log("Payment successful bro:", res.sales_invoice);
// const invoiceJson = await get_invoice_json(res.sales_invoice);
// console.log("Invoice JSON returned from backend:", invoiceJson);
window.open(`api/method/havano_restaurant_pos.api.download_invoice_json?name=${res.sales_invoice}`, "_blank");
window.open(`/api/method/havano_restaurant_pos.api.download_invoice_json?name=${res.sales_invoice}`, "_blank");

// Convert JSON to string
// const jsonStr = JSON.stringify(invoiceJson, null, 2);
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/hooks/useMultiCurrencyPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function useMultiCurrencyPayment() {
setSuccess(true);
try {
console.log("Fetching invoice JSON for multiple:", res.sales_invoice);
window.open(`api/method/havano_restaurant_pos.api.download_invoice_json?name=${res.sales_invoice}`, "_blank");
window.open(`/api/method/havano_restaurant_pos.api.download_invoice_json?name=${res.sales_invoice}`, "_blank");
// const invoiceJson = await get_invoice_json(res.sales_invoice);
// // Convert JSON to string
// const jsonStr = JSON.stringify(invoiceJson, null, 2);
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/layouts/MainLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Header from "./components/Header"
const MainLayout = () => {
return (
<div className="h-screen flex flex-col">
{/* <Header className="shrink-0" /> */}
{/* <Header className="shrink-0" /> */}

<div className="flex-1 overflow-y-auto bg-secondary-background py-4 scrollbar-hide">
<Outlet />
Expand Down
21 changes: 21 additions & 0 deletions dashboard/src/layouts/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ const Footer = () => {
<Container>
<div className="py-4">
<div className="flex items-center justify-between">
{/* App Icon - Link to main Frappe app */}
<a
href="/app"
className="flex items-center justify-center w-10 h-10 rounded-lg hover:bg-gray-100 transition-colors"
title="Go to App"
>
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-6 w-6 text-gray-700 hover:text-primary"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
strokeWidth={2}
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"
/>
</svg>
</a>
{navLinks.map((link) => {
if (!link.active) {
return (
Expand Down
10 changes: 10 additions & 0 deletions havano_restaurant_pos/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
__version__ = "0.0.1"

# Apply trial balance currency conversion fix when module is imported
# This ensures the fix is applied as soon as the app is loaded
try:
from havano_restaurant_pos.overrides import apply_trial_balance_fix
apply_trial_balance_fix()
except Exception:
# Silently fail if override cannot be applied (e.g., during app installation)
# The fix will be applied via after_migrate hook as well
pass
Loading
Loading