Last active
January 8, 2020 10:03
-
-
Save totomz/509bbb539de383b589e8079e496b53d0 to your computer and use it in GitHub Desktop.
Tamperonkey script for fattureincloud
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
// ==UserScript== | |
// @name CostAllocations | |
// @namespace https://allocation-costs.my-ideas.it/ | |
// @version 0.1 | |
// @description Semplifica la getione dei cost center e tags su fatture in cloud | |
// @author Tommaso Doninelli | |
// @match https://secure.fattureincloud.it/expenses-new | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
// Cost types | |
// Serve a distinguere i costi fissi dai costi variabili | |
// Dai costi fissi scorporo il costo del personale **dipendente**, le consulezne esterne non continuative non sono dipendenti | |
const cost_categories = [ | |
'', | |
'Other Fixed', | |
'Personell', | |
'COGS' // Direct costs attributable to the sold goods: Packaging, Shipping, Direct Marketing costs (CAC). | |
]; | |
pippo(cost_categories, 'Categoria:', 'category'); | |
//$('#category').parent().append(`<ul><li>${cost_categories.join('</li><li>')}</li></ul>`); | |
// Cost Center | |
// Mi serve a rispondere alla domanda "quanto ho speso | |
const cost_centers = [ | |
'', | |
'G&A', // Travel Expenses, productivity tools, legals and accountants | |
'Marketing', // Online and offline. Add info to the notes | |
'R&D' // Tech equipment, Cloud and Services (if fixed), External Workforce | |
]; | |
pippo(cost_centers, 'costo (?):', 'cost_center'); | |
//$('#cost_center').parent().append(`<ul><li>${cost_centers.join('</li><li>')}</li></ul>`); | |
// Descrizione - additional tags | |
const tags = [ | |
'', | |
'consulting', | |
'productivity tools', // Office HubSpot, JIRA | |
'office/rents/utilities', | |
'cloud services - IAAS', | |
]; | |
pippo(tags, 'Descrizione:', 'description'); | |
function pippo(values, labelText, targetId){ | |
const opions = values.map(tag => { | |
return `<option value="${tag}">${tag}</option>`; | |
}); | |
const id = `pippo_${parseInt(Math.random()*100000)}`; | |
$(`label:contains("${labelText}")`).after(`<select id="${id}">${opions.join('')}</select>`) | |
$(`#${id}`).change(function(e){ | |
console.log("dio"); | |
console.log(`${id}`); | |
console.log($(`#${id}`).val()); | |
$(`#${targetId}`).val($(`#${id}`).val()); | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment