jp-shared 1.1.15 → 1.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jp-shared",
3
- "version": "1.1.15",
3
+ "version": "1.1.16",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -6,7 +6,7 @@ module.exports.invoiceEmailTemplate = ({
6
6
  totalAmount = "470.82",
7
7
  totalAmountWords = "Four Hundred Seventy Rupees and Eighty-Two Paise Only",
8
8
  gstPercentage = "18",
9
- gstAmount = "6",
9
+ gstAmount ,
10
10
  companyAddress,
11
11
  companyName,
12
12
  gstNumber,
@@ -14,6 +14,7 @@ module.exports.invoiceEmailTemplate = ({
14
14
  supportEmail,
15
15
  supportMobile,
16
16
  termsUrl,
17
+
17
18
  }) => {
18
19
  return `
19
20
  <!DOCTYPE html>
@@ -77,7 +78,7 @@ module.exports.invoiceEmailTemplate = ({
77
78
  item.description
78
79
  }</td>
79
80
  <td style="border: 1px solid #000; padding: 10px; text-align: center;">${
80
- Number(item.amount).toFixed(2)
81
+ item.amount
81
82
  }</td>
82
83
  </tr>`
83
84
  )
@@ -88,7 +89,9 @@ module.exports.invoiceEmailTemplate = ({
88
89
  </tr>
89
90
  <tr>
90
91
  <td colspan="2" style="text-align: right; border: 1px solid #000; padding: 10px;"><strong>Total Amount</strong></td>
91
- <td style="border: 1px solid #000; padding: 10px; text-align: center;"><strong>${totalAmount}</strong></td>
92
+ <td style="border: 1px solid #000; padding: 10px; text-align: center;"><strong>${
93
+ Number(totalAmount).toFixed(2)
94
+ }</strong></td>
92
95
  </tr>
93
96
  </tbody>
94
97
  </table>
@@ -53,15 +53,17 @@ const sendInvoice = async (invoiceInput) => {
53
53
  // Destructure the validated value
54
54
  const {
55
55
  recruiterEmail,
56
- gstAmount,
57
- totalAmount,
58
- amount,
59
56
  gstPercentage,
57
+ amount,
60
58
  billNumber,
61
59
  jobId,
62
60
  planName,
63
61
  } = value;
64
62
 
63
+ // Calculate GST and total amount
64
+ const gstAmount = parseFloat(((amount * gstPercentage) / 100).toFixed(2));
65
+ const totalAmount = parseFloat((amount + gstAmount).toFixed(2));
66
+
65
67
  // Check if the required environment variables are set
66
68
  if (!process.env.EMAIL || !process.env.EMAIL_PASSWORD) {
67
69
  const errorMsg = "Email credentials are not set in environment variables.";
@@ -80,10 +82,10 @@ const sendInvoice = async (invoiceInput) => {
80
82
  billNo: billNumber,
81
83
  jobId,
82
84
  items: [{ description: `${planName}`, amount: `${amount}` }],
83
- totalAmount,
85
+ totalAmount :totalAmount.toFixed(2),
84
86
  totalAmountWords: toWords.convert(totalAmount, { currency: true }),
85
87
  gstPercentage,
86
- gstAmount,
88
+ gstAmount: gstAmount.toFixed(2),
87
89
  ...OUR_ORG_INFO,
88
90
  };
89
91