This commit is contained in:
Sibunnayak 2024-11-06 17:55:00 +05:30
parent f8a9673e24
commit d197cb2c43
2 changed files with 36 additions and 21 deletions

View File

@ -57,15 +57,22 @@ const OpeningInventoryReports = () => {
const handleDownloadReport = async () => { const handleDownloadReport = async () => {
try { try {
const response = await axios.get(`/api/report/opening-inventory/download`, { const response = await axios.get(
`/api/report/opening-inventory/download`,
{
headers: { headers: {
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
}, },
responseType: 'arraybuffer', // Ensure that we handle the response as binary data responseType: "arraybuffer", // Ensure that we handle the response as binary data
}); }
);
// Step 1: Convert the response data into a Blob // Step 1: Convert the response data into a Blob
const url = window.URL.createObjectURL(new Blob([response.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })); const url = window.URL.createObjectURL(
new Blob([response.data], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
})
);
// Step 2: Create a download link and trigger the download // Step 2: Create a download link and trigger the download
const link = document.createElement("a"); const link = document.createElement("a");
@ -326,10 +333,14 @@ const OpeningInventoryReports = () => {
{product.brand || "Brand Not selected"} {product.brand || "Brand Not selected"}
</td> </td>
<td className="text-start"> <td className="text-start">
{product.allPdAndRd} {parseFloat(product.allPdAndRd).toFixed(2)}
</td>
<td className="text-start">
{parseFloat(product.allPDs).toFixed(2)}
</td>
<td className="text-start">
{parseFloat(product.allRDs).toFixed(2)}
</td> </td>
<td className="text-start">{product.allPDs}</td>
<td className="text-start">{product.allRDs}</td>
</tr> </tr>
)) ))
) : ( ) : (

View File

@ -328,10 +328,14 @@ const StockReports = () => {
{product.brand || "Brand Not selected"} {product.brand || "Brand Not selected"}
</td> </td>
<td className="text-start"> <td className="text-start">
{product.allPdAndRd} {parseFloat(product.allPdAndRd).toFixed(2)}
</td>
<td className="text-start">
{parseFloat(product.allPDs).toFixed(2)}
</td>
<td className="text-start">
{parseFloat(product.allRDs).toFixed(2)}
</td> </td>
<td className="text-start">{product.allPDs}</td>
<td className="text-start">{product.allRDs}</td>
</tr> </tr>
)) ))
) : ( ) : (