Last active
September 7, 2023 20:45
-
-
Save droganov/b94c02dde3f6690caff4b3f5a31d7cac to your computer and use it in GitHub Desktop.
Spreadsheets formula for calculating the tax base in Georgian Lari
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Larry(date, summ, currency) { | |
try { | |
var formattedDate = Utilities.formatDate(date, Session.getScriptTimeZone(), "yyyy-MM-dd"); | |
var apiUrl = "https://nbg.gov.ge/gw/api/ct/monetarypolicy/currencies/en/json/?currencies=" + currency + "&date=" + formattedDate; | |
var response = UrlFetchApp.fetch(apiUrl); | |
var data = JSON.parse(response.getContentText()); | |
var rate = data[0].currencies[0].rate; | |
var summ = parseFloat(summ.toString().replace(",", ".")); | |
var result = summ * rate; | |
return result; | |
} catch (error) { | |
return String(error); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Paste the code to
Extensions
>Apps Script
Run it and give permissions to fetch data.
Use as a formula:
=Larry(A2;B2;C2)
Example sheet.