Module:WCI2016.PEG

From Meta, a Wikimedia project coordination wiki
Module documentation
Note: This instance is meant particularly for a single grant request. Any modification here will also cause a change in the appearance of the actual grant application page. Therefore, if someone wants to make use of these scripts for another grant application, please take a copy of this and use that one. Please do not modify any part of this within this module itself, as it will disrupt the original grant documents it is intended to generate.  

WCI2016.PEG[edit]

This is a module containing all lua templates for creating expense and budget sheets for various Wikimedia outreach and conference events. This particular instance is created for WCI2016 (WikiConference India - 2016)project. Please contact Viswaprabha for suggestions and modifications. Thanks! (As on 2016/02/25) ViswaPrabhaവിശ്വപ്രഭtalk 01:27, 25 February 2016 (UTC)

Description[edit]

This module contains a set of routines to create an event expense form easily. The aim is to generate a set of preformatted wikitables, each one with its own header lines, item rows and footer lines. The preparations, entry and calculation of data (to be filled within the numerical and text cells as inputs) can be done in an off-line or collaborated spreadsheet program, enabling fast and easy calculations. The data thus evolved can then be directly copy/pasted to the meta page (for grant requests, reports etc.) or any other mediawiki page of interest as the desired final output. Any numerical modification, correction or updates can thus be immediately incorporated into the target grant request (or report) page without having to go through rather cumbersome wiki-table edits.


List of functions[edit]

Part 1[edit]

  • function p.QEHeader(frame) -- Adds a section Header with Section Number and SectionName for the 'Quantity Estimate' form.
  • function p.QEItem(frame) --Adds an item row to the 'Quantity Estimate' form
  • function p.QEFooter(frame) -- Adds a section Footer to the 'Quantity Estimate' form
  • function p.QELegend(frame) -- Adds a legend line to the 'Quantity Estimate' form.

Part 2[edit]

  • function p.ESHeader(frame) -- Adds a section Header with Section Number and Section Name to the 'Expenses Summary' form.
  • function p.ESItem(frame) --Adds a n itemrow to the 'Expenses Summary' form.
  • function p.ESFooter(frame) -- Adds a section Footer to the 'Expenses Summary' form.
[Please note that the 'Total Sum' on this line must be added manually. This is to avoid the code being overly complicated].

Part 3[edit]

  • function p.EDHeader(frame) -- Adds a section Header with Section Number and SectionName to the 'Expenses in Detail' form.
  • function p.EDItem(frame) --Adds a n itemrow to the 'Expenses in Detail' form.
  • function p.EDFooter(frame) -- Adds a section Footer to the 'Expenses in Detail' form.
[Please note that the 'Total Sum' on this line must be added manually. This is to avoid the code being overly complicated].

(Invoke each function to generate an appropriate line as required in the wikified report format. (For eg:)


Sources of revenue
Code No. Item INR US$ %age Notes

--=============================================================================
-- WCI2016.PEG : This is a module containing all lua templates for creating
--Expense and budget sheets for various Wikimedia outreach and conference events.
--------------------------------------------------------------------------------
--- PART 0. Global stuff
--------------------------------------------------------------------------------

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


--------------------------------------------------------------------------------
--- PART 1. The following will generate a 'Quantity Estimate' form.
--------------------------------------------------------------------------------

function p.QEHeader(frame) -- Adds a section Header with Section Number and SectionName for the 'Quantity Estimate' form.
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 = \"28\" 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 = \"10\"	|Quantity"
s = s .."!! colspan = \"10\"	|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.. " 	|M || "..w3.. "	|V || "..w3.. "	|L || " ..w3.. "	|R || " ..w3.. " 	|SD || " ..w3.. " 	|SP || " ..w3.. " 	|CG || " ..w3.. " 	|HA || " ..w3.. " 	|MR || " ..w4.. " background=\"#ddffdd\" |\'\'\'Total\'\'\'"
s = s .."|| " ..w4.. " 	|M || "..w4.. "	|V || "..w4.. "	|L || " ..w4.. "	|R || " ..w4.. " 	|SD || " ..w4.. " 	|SP || " ..w4.. " 	|CG || " ..w4.. " 	|HA || " ..w4.. " 	|MR || " ..w6.. " background=\"#ddffdd\" |\'\'\'Total\'\'\'"
s = s .."|| " ..w20.. "|	\n"

return s
end


--------------------------------------------------------------------------------
function p.QEItem(frame) --Adds a n itemrow to the 'Quantity Estimate' form
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 MusterQ, VolunteerQ,LocalQ,RemoteQ,NationalQ,StudentQ= frame.args[8],frame.args[9], frame.args[10], frame.args[11], frame.args[12], frame.args[13]
local GuestQ,HelperQ,MediaQ,TotalQ =  frame.args[14],frame.args[15], frame.args[16], frame.args[17]
local MusterA,VolunteerA,LocalA,RemoteA,NationalA,StudentA = frame.args[18],frame.args[19], frame.args[20],frame.args[21],frame.args[22], frame.args[23] 
local GuestA,HelperA,MediaA,TotalA, notes = frame.args[24], frame.args[25], frame.args[26],frame.args[27], frame.args[28] 

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\"  | " .. MusterQ
	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\"  | " .. MusterA
	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.QEFooter(frame) -- Adds a section Footer to the 'Quantity Estimate' form
local s = "\n|-\n|}"
return s
end
--------------------------------------------------------------------------------
function p.QELegend(frame) -- Adds a legend line to the 'Quantity Estimate' form.
local s = ";Legend:\n:\'\'\'INR\'\'\' = Indian Rupees;  \'\'\'M\'\'\' = Mustered count; \'\'\'V\'\'\' = Voluntary Assistants;  \'\'\'L\'\'\' = Local Participants;  \'\'\'R\'\'\' = Remote Participants;  \'\'\'SD\'\'\' = Special Delegates;  \'\'\'SP\'\'\' = Student Participants; \'\'\'CG\'\'\' = Chief Guests; \'\'\'HA\'\'\' = Helper Assistants; \'\'\'MR\'\'\'= Media Representatives\n"
return s
end

--------------------------------------------------------------------------------
--- PART 2. The following will generate an 'Expenses Summary' form.
--------------------------------------------------------------------------------

function p.ESHeader(frame) -- Adds a section Header with Section Number and Section Name to the 'Expenses Summary' form.
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.ESItem(frame) --Adds a n itemrow to the 'Expenses Summary' form.
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.ESFooter(frame) -- Adds a section Footer (Must enter total manually!) to the 'Expenses Summary' form.
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

--------------------------------------------------------------------------------
--- Part 3. The following will generate an 'Expenses in Detail' form.
--------------------------------------------------------------------------------

function p.EDHeader(frame) -- Adds a section Header with Section Number and SectionName to the 'Expenses in Detail' form.
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.EDItem(frame) --Adds a n itemrow to the 'Expenses in Detail' form.
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.EDFooter(frame) -- Adds a section Footer (Must enter total manually!) to the 'Expenses in Detail' form.
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

--------------------------------------------------------------------------------
return p
--==============================================================================