Skip to content

Commit

Permalink
fix: handle salary slip download failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal committed Dec 1, 2023
1 parent c977fec commit 8daaba4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion frontend/src/views/salary_slip/Detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,11 @@ function downloadPDF() {
if (response.ok) {
return response.blob()
} else {
downloadError.value = `Failed to download PDF: ${response.statusText}`
downloadError.value = "Failed to download PDF"
}
})
.then((blob) => {
if (!blob) return
const blobUrl = window.URL.createObjectURL(blob)
const link = document.createElement("a")
link.href = blobUrl
Expand Down
6 changes: 5 additions & 1 deletion hrms/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,11 @@ def download_salary_slip(name: str):
from frappe.utils.print_format import download_pdf

default_print_format = frappe.get_meta("Salary Slip").default_print_format or "Standard"
download_pdf("Salary Slip", name, format=default_print_format)

try:
download_pdf("Salary Slip", name, format=default_print_format)
except Exception:
frappe.throw("Failed to download Salary Slip PDF")

base64content = base64.b64encode(frappe.local.response.filecontent)
content_type = frappe.local.response.type
Expand Down

0 comments on commit 8daaba4

Please sign in to comment.