Skip to content

Commit

Permalink
Feat:Room wise printing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanjusha-tridz committed Jan 14, 2024
1 parent 1efed3e commit 6de9224
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 62 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ury_pos/public/urypos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/assets/ury_pos/urypos/URY.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>URY POS</title>
<script type="module" crossorigin src="/assets/ury_pos/urypos/assets/index-098ce767.js"></script>
<script type="module" crossorigin src="/assets/ury_pos/urypos/assets/index-214798b4.js"></script>
<link rel="stylesheet" href="/assets/ury_pos/urypos/assets/index-5eb6e3fc.css">
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion ury_pos/www/urypos.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/assets/ury_pos/urypos/URY.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>URY POS</title>
<script type="module" crossorigin src="/assets/ury_pos/urypos/assets/index-098ce767.js"></script>
<script type="module" crossorigin src="/assets/ury_pos/urypos/assets/index-214798b4.js"></script>
<link rel="stylesheet" href="/assets/ury_pos/urypos/assets/index-5eb6e3fc.css">
</head>
<body>
Expand Down
144 changes: 87 additions & 57 deletions urypos/src/stores/invoiceData.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,13 @@ export const useInvoiceDataStore = defineStore("invoiceData", {
const messages = JSON.parse(alert);
const message = JSON.parse(messages[0]);

this.alert.createAlert("Message", message.message, "OK").then(() => {
router.push("/Table").then(() => {
window.location.reload();
this.alert
.createAlert("Message", message.message, "OK")
.then(() => {
router.push("/Table").then(() => {
window.location.reload();
});
});
})
} else {
this.invoiceNumber = response.message.name;
this.grandTotal = response.message.grand_total;
Expand Down Expand Up @@ -253,53 +255,88 @@ export const useInvoiceDataStore = defineStore("invoiceData", {
.catch((error) => console.error(error, "printed"));
}
} else if (this.print_type === "network") {
const sendObj = {
doctype: "POS Invoice",
name: invoiceNo,
printer_setting: this.printer,
print_format: this.print_format,
};
const printingCall = async () => {
try {
const result = await this.call.post(
if (this.auth.cashier) {
const sendObj = {
doctype: "POS Invoice",
name: invoiceNo,
printer_setting: this.printer,
print_format: this.print_format,
};
const printingCall = async () => {
const res = await this.call.post(
"ury.ury.api.ury_print.network_printing",
sendObj
);
return result.message;
} catch (error) {
console.error(error, "heeeloo");
return "";
}
};
let i = 0;
let errorMessage = "";
do {
const res = await printingCall();
if (res === "Success") {
this.notification.createNotification("Print Successful");
const sendObj = {
invoice: invoiceNo,
};
this.call
.post("ury.ury.api.ury_print.qz_print_update", sendObj)
.then(() => {
window.location.reload();

return 200;
})
.catch((error) => console.error(error));
}
errorMessage = res;
i++;
} while (i < 3);
throw {
alert: this.alert.createAlert(
"Message",
`Print failed with error ${errorMessage}`,
"OK"
),
custom: (this.isPrinting = false),
};
return res.message;
};
let i = 0;
let errorMessage = "";
do {
const res = await printingCall();
if (res === "Success") {
this.notification.createNotification("Print Successful");
const sendObj = {
invoice: invoiceNo,
};
await this.call
.post("ury.ury.api.ury_print.qz_print_update", sendObj)
.then(() => {
window.location.reload();
return 200;
});
}
errorMessage = res;
i++;
} while (i < 1);
throw {
alert: this.alert.createAlert(
"Message",
`Print failed with error ${errorMessage}`,
"OK"
),
custom: (this.isPrinting = false),
};
} else {
const networkPrint = {
invoice_id: invoiceNo,
pos_profile: this.posProfile,

};
const networkPrintPrintingCall = async () => {
const res = await this.call.post(
"ury.ury.api.ury_print.select_network_printer",
networkPrint
);
return res.message;
};
let i = 0;
let errorMessage = "";
do {
const res = await networkPrintPrintingCall();
if (res === "Success") {
this.notification.createNotification("Print Successful");
const sendObj = {
invoice: invoiceNo,
};
await this.call
.post("ury.ury.api.ury_print.qz_print_update", sendObj)
.then(() => {
window.location.reload();
return 200;
});
}
errorMessage = res;
i++;
} while (i < 1);
throw {
alert: this.alert.createAlert(
"Message",
`Print failed with error ${errorMessage}`,
"OK"
),
custom: (this.isPrinting = false),
};
}
} else {
const sendObj = {
doctype: "POS Invoice",
Expand All @@ -314,21 +351,14 @@ export const useInvoiceDataStore = defineStore("invoiceData", {

return result.message;
})
.catch((error) => console.error(error, "hiiii"));
.catch((error) => console.error(error));
}
// throw {
// custom: true,
// title: "No printer type specified",
// message: "printer_type is not specified in pos profile",
// print: (this.isPrinting = false),
// };
} catch (e) {
if (e?.custom) {
this.isPrinting = false;

return this.alert.createAlert("Error", e?.title, "OK");
}
this.isPrinting = false;
return this.alert.createAlert("Error", e?.response?.status, "Ok");
}
},

Expand Down

0 comments on commit 6de9224

Please sign in to comment.