# Tax Request

{% code title="tax\_request" overflow="wrap" lineNumbers="true" %}

```javascript
function sendEmail(e) {
  var sheetName = e.range.getSheet().getName();
  var submitterEmail = e.values[1]; // Adjust according to the actual position of the email in the form responses

  if(sheetName === "Tax Request") {
    var itemValues = e.namedValues;
    var subject = "Faktur Pajak Request - "+ itemValues["Contact Name"]?.[0] +" - "+ itemValues["Company Name"]?.[0]; // Using optional chaining

var emailBody = `
<html>
  <head>
    <style>
      table {
        width: 100%;
        border-collapse: collapse;
      }
      th, td {
        border: 1px solid #ddd;
        padding: 8px;
        text-align: left;
      }
      th {
        background-color: #f2f2f2;
      }
    </style>
  </head>
  <body>
    <p>Hi <b>${itemValues["Contact Name"]?.[0]}</b>,</p>
    <p>Thank you for filling out the form. Here are the details of your inquiry:</p>
    <table>
      <tr><th>Field</th><th>Detail</th></tr>
      <tr><td>Company Name</td><td>${itemValues["Company Name"]?.[0]}</td></tr>
      <tr><td>Company Address</td><td>${itemValues["Company Address"]?.[0]}</td></tr>
      <tr><td>Tax Identification Number (NPWP)</td><td>${itemValues["Tax Identification Number (NPWP)"]?.[0]}</td></tr>
      <tr><td>Company Phone Number</td><td>${itemValues["Company Phone Number "]?.[0]}</td></tr>
      <tr><td>KYZN Branch</td><td>${itemValues["KYZN Branch"]?.[0]}</td></tr>
      <tr><td>Invoice Number</td><td>${itemValues["Invoice Number"]?.[0]}</td></tr>
      <tr><td>Transaction Date</td><td>${itemValues["Transaction Date"]?.[0]}</td></tr>
      <tr><td>Description of Services</td><td>${itemValues["Description of Services"]?.[0]}</td></tr>
      <tr><td>Contact Name</td><td>${itemValues["Contact Name"]?.[0]}</td></tr>
      <tr><td>Position</td><td>${itemValues["Position"]?.[0]}</td></tr>
      <tr><td>Contact Phone Number</td><td>${itemValues["Contact Phone Number"]?.[0]}</td></tr>
    </table>
    <p>Our Finance Team will review your inquiry and provide feedback within 7 business days or before the 15th of each month. If you have any questions, please contact us at <a href="https://wa.me/6285174420088">+62851-7442-0088</a> (Whatsapp Only).</p>
    <p>Regards,<br>KYZN Team</p>
  </body>
</html>
`;

// When sending the email, specify the htmlBody parameter with the content above
MailApp.sendEmail({
  to: submitterEmail,
  subject: subject,
  cc:"hi@kyzn.life,ca@kyzn.life, fc@kyzn.life, finance@kyzn.life",
  name: "KYZN Information Center",
  htmlBody: emailBody, // Ensure this is used instead of body parameter for HTML content
});

  }
}

function onEdit(e) {
  var range = e.range;
  var sheet = range.getSheet();
  var sheetName = sheet.getName();
  var editedRow = range.getRow();
  var editedColumn = range.getColumn();
  var statusColumn = 14; // Column N
  var fileLinkColumn = 15; // Column O

  if(sheetName === "Tax Request" && editedColumn === statusColumn) {
    var status = sheet.getRange(editedRow, statusColumn).getValue();
    var fileLink = sheet.getRange(editedRow, fileLinkColumn).getValue();
    var submitterEmail = sheet.getRange(editedRow, 2).getValue(); // Assuming email is in Column B
    var companyName = sheet.getRange(editedRow, 3).getValue(); // Adjust according to the actual position
    var contactName = sheet.getRange(editedRow, 11).getValue(); // Adjust according to the actual position


    if(status === "Done" && fileLink) {
    var subject = "Faktur Pajak Request - "+contactName+" - "+companyName; // Using optional chaining
      var emailBody = // Use the HTML content from above, replacing placeholders with actual values
        `<html>
          <head>
            <style>
              p {line-height: 1.6;}
            </style>
          </head>
          <body>
            <div class="container">
              <p>Hi <b>${contactName}</b>!,</p>
              <p>We are pleased to inform you that your request for Faktur Pajak has been <b style="color:#32CD32;">processed successfully</b>. Thank you for your patience throughout this period.</p>
              <p>Your Faktur Pajak is now available and can be accessed through the link below:</p>
              <p><a href="${fileLink}" target="_blank">Access Your Faktur Pajak</a></p>
              <p>Should you need any further assistance or have any questions, please feel free to get in touch with us via <a href="https://wa.me/6285174420088">+62851-7442-0088</a> (Whatsapp Only).</p>
              <p>We appreciate your cooperation and look forward to serving you again.</p>
              <p>Best Regards,<br>KYZN Finance Team</p>
            </div>
          </body>
        </html>`;

      MailApp.sendEmail({
        to: submitterEmail,
        subject: subject,
        cc:"hi@kyzn.life,ca@kyzn.life, fc@kyzn.life, finance@kyzn.life",
        name: "KYZN Information Center",
        htmlBody: emailBody,
      });
    }
  }
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://work.bahrul.me/work/kyzn/sops-and-flow/tax-request.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
