Module:Ml.wiki.ProjectExpenses

From Meta, a Wikimedia project coordination wiki
Module documentation
--========================================================
-- ml.wiki.ProjectExpenses : This is a module containing all lua templates
--for creating Expense sheets for various Wikimedia outreach and conference events.
--Created for ml.wikipedia.org and sister projects
--Please contact user:Viswaprabha for suggestions and modifications. Thanks!
--2013/11/13
--=========================================================
--A set of routines to create an event expense form easily.
--A set of tables are created, each one a section of the event/program, with its own header, item rows and footer.
--The preparations, entry and calculation of data (for the inputs) can be done in a off-line or collaborated spreadsheet
--and directly imported to the mediawiki page of interest.
--=========================================================


local p = {}
--------------------------------

function p.getAllArgs( frame ) -- This will be used for validation of input values 
    buf = {}
    for name, value in frame:argumentPairs() do
        if #buf ~= 0 then
            table.insert( buf, ', ' )
        end
        table.insert( buf, name .. '=' .. value )
    end
    return table.concat( buf )
end

---------------------------------------------------------------------
function p.QuantityEstimateHeader(frame) -- Adds a section Header with Section Number, SectionName (Malayalam), SectionName(English)
local sectionname  = frame.args[1]
local w3,w4,w5, w6,w7,w10, w20 = "width =\"30\"", "width =\"40\"","width =\"50\"","width =\"60\"","width =\"70\"","width =\"100\"","width =\"200\""
local s = ""
s = s .."{| class=\"wikitable\" style=\"border: 1px solid black\" cellpadding=\"5\"\n"
s = s .."|-\n"
s = s .."| style = \"height: 30px; background: #99ff99\" colspan = \"27\" align = \"center\" | \'\'\'<big>" .. sectionname.. "</big>\'\'\'\n"
s = s .."|-style = \"background: #88bb88; align:center\"\n"
s = s .."!  |Date"
s = s .."!! |Time"
s = s .."!! |Source"
s = s .."!! |Code"
s = s .."!! |Item "
s = s .."!! colspan = \"2\"	|Rate"
s = s .."!! colspan = \"9\"	|Quantity"
s = s .."!! colspan = \"9\"	|Amount"
s = s .."!! |Notes\n"
s = s .."|- style = \"background: #bbffbb; align:center\"\n"
s = s .."|  " ..w6.. " 	 || " ..w4.. " 	| || " ..w5.. " 	| || " ..w4.. " 	| || " ..w20.. " 	| || " ..w4.. " background=\"#ddffdd\" 	|INR || " ..w4.. " background=\"#ddffdd\"	|US$"
s = s .."|| " ..w3.. " 	|VA || " ..w3.. "	|LP || " ..w3.. "	|RP || " ..w3.. " 	|NP || " ..w3.. " 	|SP || " ..w3.. " 	|CG || " ..w3.. " 	|HA || " ..w3.. " 	|MR || " ..w4.. " background=\"#ddffdd\" |\'\'\'Total\'\'\'"
s = s .."|| " ..w4.. " 	|VA || " ..w4.. "	|LP || " ..w4.. "	|RP || " ..w4.. " 	|NP || " ..w4.. " 	|SP || " ..w4.. " 	|CG || " ..w4.. " 	|H4 || " ..w4.. " 	|MR || " ..w6.. " background=\"#ddffdd\" |\'\'\'Total\'\'\'"
s = s .."|| " ..w20.. "|	\n"

return s
end




---------------------------------------------------------------------
function p.QuantityEstimateItem(frame) --Adds a n itemrow
local date, time, source, code= frame.args[1], frame.args[2], frame.args[3],frame.args[4]
local  item,INR,USD =  frame.args[5], frame.args[6], frame.args[7]
local VolunteerQ,LocalQ,RemoteQ,NationalQ,StudentQ= frame.args[8],frame.args[9], frame.args[10], frame.args[11], frame.args[12]
local GuestQ,HelperQ,MediaQ,TotalQ =  frame.args[13],frame.args[14], frame.args[15], frame.args[16]
local VolunteerA,LocalA,RemoteA,NationalA,StudentA = frame.args[17], frame.args[18],frame.args[19], frame.args[20],frame.args[21]
local GuestA,HelperA,MediaA,TotalA, notes = frame.args[22], frame.args[23],frame.args[24], frame.args[25], frame.args[26]
local s = "|- style = \"align:right\"\n"
	s = s .. "|  align = \"right\" | " .. date
	s = s .. "|| align = \"right\" | " .. time
	s = s .. "|| align = \"left\"  | " .. source
	s = s .. "|| align = \"left\"  | " .. code
	s = s .. "|| style = \"background: #ddffdd; align:left\"  | " .. item
	s = s .. "|| style = \"background: #ddffdd;\" align = \"right\" | \'\'\'" .. INR .. "\'\'\'"
	s = s .. "|| style = \"background: #ddffdd;\" align = \"right\"  | \'\'\'" .. USD.. "\'\'\'"
	s = s .. "|| align = \"right\"  | " .. VolunteerQ
	s = s .. "|| align = \"right\"  | " .. LocalQ
	s = s .. "|| align = \"right\"  | " .. RemoteQ
	s = s .. "|| align = \"right\"  | " .. NationalQ
	s = s .. "|| align = \"right\"  | " .. StudentQ
	s = s .. "|| align = \"right\"  | " .. GuestQ
	s = s .. "|| align = \"right\"  | " .. HelperQ
	s = s .. "|| align = \"right\"  | " .. MediaQ
	s = s .. "|| style = \"background: #ddffdd;\" align = \"right\"| \'\'\'" .. TotalQ.. "\'\'\'"
	s = s .. "|| align = \"right\"  | " .. VolunteerA
	s = s .. "|| align = \"right\"  | " .. LocalA
	s = s .. "|| align = \"right\"  | " .. RemoteA
	s = s .. "|| align = \"right\"  | " .. NationalA
	s = s .. "|| align = \"right\"  | " .. StudentA
	s = s .. "|| align = \"right\"  | " .. GuestA
	s = s .. "|| align = \"right\"  | " .. HelperA
	s = s .. "|| align = \"right\"  | " .. MediaA
	s = s .. "|| style = \"background: #ddffdd;\" align = \"right\" | <big>\'\'\'" .. TotalA .. "\'\'\'</big>"
	s = s .. "|| align = \"left\"  | " .. notes
		
	
return s
end
---------------------------------------------------------------------
function p.QuantityEstimateFooter(frame) -- Adds a section Footer
local s = "\n|-\n|}"
return s
end
---------------------------------------------------------------------
function p.QuantityEstimateLegend(frame) -- Adds a legend line
local s = ";Legend:\n:\'\'\'INR\'\'\' = Indian Rupees;  \'\'\'VA\'\'\' = Voluntary Assistants;  \'\'\'LP\'\'\' = Local Participants;  \'\'\'RP\'\'\' = Regional Participants;  \'\'\'NP\'\'\' = National Participants;  \'\'\'SP\'\'\' = Student Participants; \'\'\'CG\'\'\' = Chief Guests; \'\'\'HA\'\'\' = Helper Assistants; \'\'\'MR\'\'\'= Media Representatives)\n"
return s
end

---------------------------------------------------------------------
---==================================================================
---------------------------------------------------------------------
function p.ExpenseSummaryHeader(frame) -- Adds a section Header with Section Number, SectionName (Malayalam), SectionName(English)
local sectionname  = frame.args[1]
local s = ""
s = s .."{| class=\"wikitable\" style=\"border: 1px solid black\" cellpadding=\"5\"\n"
s = s .."|-\n"
s = s .."| style = \"height: 40px; background: #b6d7ff\" colspan = \"8\" align = \"center\" | \'\'\'<big>" .. sectionname.. "</big>\'\'\'\n"
s = s .."|-\n"
s = s .."!! width=\"50\" |Code"
s = s .."!! width=\"20\"|No."
s = s .."!! width= \"500\" |Item"
s = s .."!! width = \"80\" | "
s = s .."!! width = \"90\"|INR"
s = s .."!! width= \"70\" |US$"
s = s .."!! width = \"60\" |%age"
s = s .."!! width = \"400\" |Notes"
return s
end
---------------------------------------------------------------------
function p.ExpenseSummaryItem(frame) --Adds a n itemrow
local code, number, description, qty, amount,amountDollar,share,itemnote = frame.args[1], frame.args[2], frame.args[3],frame.args[4], frame.args[5], frame.args[6], frame.args[7], frame.args[8]
local s = "|-\n|"
	s = s .. "  align = \"center\" | " .. code
	s = s .. "|| align = \"right\" | " .. number
	s = s .. "|| align = \"left\"  | " .. description
	s = s .. "|| align = \"left\"  | " .. qty
	s = s .. "|| align = \"right\" | " .. amount
	s = s .. "|| align = \"right\" | " .. amountDollar
	s = s .. "|| align = \"right\" | " .. share
	s = s .. "|| align = \"left\"  | " .. itemnote 
return s
end
---------------------------------------------------------------------
function p.ExpenseSummaryFooter(frame) -- Adds a section Footer (Must enter total manually!)
local TotalINR, TotalDollar, TotalPercent, Notes  = frame.args[1], frame.args[2], frame.args[3], frame.args[4]
local s = "|- \n"
	s = s .. "|Colspan = \"4\"  style=\"background: black; color: yellow; \" align = \"center\"|\'\'\'Total\'\'\'"
	s = s .. "|| style=\"background: black; color: yellow; \" align = \"right\"|\'\'\'" .. TotalINR .. "\'\'\'"
	s = s .. "|| style=\"background: black; color: yellow; \" align = \"right\" |\'\'\'" .. TotalDollar .. "\'\'\'"
	s = s .. "|| style=\"background: black; color: yellow; \" align = \"right\" |\'\'\'" .. TotalPercent .. "\'\'\'"
	s = s .. "|| style=\"background: black; color: yellow; \" align = \"left\" | " .. Notes  
	s = s .. "\n|}\n"
return s
end
---------------------------------------------------------------------
--===================================================================
---------------------------------------------------------------------
function p.ExpenseDetailHeader(frame) -- Adds a section Header with Section Number, SectionName (Malayalam), SectionName(English)
local sectionname  = frame.args[1]
local s = ""
s = s .."{| class=\"wikitable\" style=\"border: 1px solid black\" cellpadding=\"5\"\n"
s = s .."|-\n"
s = s .."| style = \"height: 40px; background: #b6d7ff\" colspan = \"8\" align = \"center\" | \'\'\'<big>" .. sectionname.. "</big>\'\'\'\n"
s = s .."|-\n"
s = s .."!! width=\"50\" |Code"
s = s .."!! width=\"20\"|No."
s = s .."!! width= \"500\" |Item"
s = s .."!! width = \"80\" |Quantity "
s = s .."!! width = \"90\"|INR"
s = s .."!! width= \"70\" |US$"
s = s .."!! width = \"60\" |Rate"
s = s .."!! width = \"400\" |Notes"
return s
end
---------------------------------------------------------------------
function p.ExpenseDetailItem(frame) --Adds a n itemrow
local code, number, description, quantity, amount,amountDollar,rate,itemnote = frame.args[1], frame.args[2], frame.args[3],frame.args[4], frame.args[5], frame.args[6], frame.args[7], frame.args[8]
local s = "|-\n|"
	s = s .. "  align = \"center\" | " .. code
	s = s .. "|| align = \"right\" | " .. number
	s = s .. "|| align = \"left\"  | " .. description
	s = s .. "|| align = \"left\"  | " .. quantity
	s = s .. "|| align = \"right\" | " .. amount
	s = s .. "|| align = \"right\" | " .. amountDollar
	s = s .. "|| align = \"right\" | " .. rate
	s = s .. "|| align = \"left\"  | " .. itemnote 
return s
end
---------------------------------------------------------------------
function p.ExpenseDetailFooter(frame) -- Adds a section Footer (Must enter total manually!)
local TotalINR, TotalDollar,  Notes  = frame.args[1], frame.args[2], frame.args[3]
local s = "|- \n"
	s = s .. "|Colspan = \"4\"  style=\"background: black; color: yellow; \" align = \"center\"|\'\'\'Total\'\'\'"
	s = s .. "|| style=\"background: black; color: yellow; \" align = \"right\"|\'\'\'" .. TotalINR .. "\'\'\'"
	s = s .. "|| style=\"background: black; color: yellow; \" align = \"right\" |\'\'\'" .. TotalDollar .. "\'\'\'"
	s = s .. "|| style=\"background: black; color: yellow; \" align = \"right\" | "
	s = s .. "|| style=\"background: black; color: yellow; \" align = \"left\" | " .. Notes  
	s = s .. "\n|}\n"
return s
end
---------------------------------------------------------------------
--===================================================================
---------------------------------------------------------------------
function p.ExpenseDetailHeaderEx(frame) -- Adds a section Header with Section Number, SectionName (Malayalam), SectionName(English)
local sectionname  = frame.args[1]
local s = ""
s = s .."{| class=\"wikitable\" style=\"border: 1px solid black\" cellpadding=\"5\"\n"
s = s .."|-\n"
s = s .."| style = \"height: 40px; background: #b6d7ff\" colspan = \"9\" align = \"center\" | \'\'\'<big>" .. sectionname.. "</big>\'\'\'\n"
s = s .."|-\n"
s = s .."!! width=\"50\" |Code"
s = s .."!! width=\"20\"|No."
s = s .."!! width=\"150\"|Date."
s = s .."!! width= \"400\" |Item"
s = s .."!! width = \"80\" |Quantity "
s = s .."!! width = \"90\"|INR"
s = s .."!! width= \"70\" |US$"
s = s .."!! width = \"50\" |Rate"
s = s .."!! width = \"350\" |Notes"
return s
end
---------------------------------------------------------------------
function p.ExpenseDetailItemEx(frame) --Adds a n itemrow
local code, number,dateq, description, quantity, amount,amountDollar,rate,itemnote = frame.args[1], frame.args[2], frame.args[3],frame.args[4], frame.args[5], frame.args[6], frame.args[7], frame.args[8], frame.args[9]
local s = "|-\n|"
	s = s .. "  align = \"center\" | " .. code
	s = s .. "|| align = \"left\" | " .. number
	s = s .. "|| align = \"right\" | " .. dateq
	s = s .. "|| align = \"left\"  | " .. description
	s = s .. "|| align = \"right\"  | " .. quantity
	s = s .. "|| align = \"right\" | " .. amount
	s = s .. "|| align = \"right\" | " .. amountDollar
	s = s .. "|| align = \"right\" | " .. rate
	s = s .. "|| align = \"left\"  | " .. itemnote 
return s
end
function p.ExpenseDetailFooterEx(frame) -- Adds a section Footer (Must enter total manually!)
local Totext, TotalINR, TotalDollar,  Notes  = frame.args[1], frame.args[2], frame.args[3],frame.args[4]
local s = "|- \n"
	s = s .. "|Colspan = \"5\"  style=\"background: #444; color: yellow; \" align = \"center\"|\'\'\'" .. Totext .. "\'\'\'"
	s = s .. "|| style=\"background: #444; color: yellow; \" align = \"right\"|\'\'\'" .. TotalINR .. "\'\'\'"
	s = s .. "|| style=\"background: #444; color: yellow; \" align = \"right\" |\'\'\'" .. TotalDollar .. "\'\'\'"
	s = s .. "|| style=\"background: #444; color: yellow; \" align = \"right\" | "
	s = s .. "|| style=\"background: #444; color: yellow; \" align = \"left\" | " .. Notes  
return s
end
function p.ExpenseDetailFooterClose(frame)
	local s = "\n|}\n"
return s
end
---------------------------------------------------------------------
return p
--=========================================================