Expense Master Sheet - Google Sheet
Expense Master Sheet - Google Sheet
1. Robust, Well Detailed Documented and Robust Well Detailed Commented Explaining
everything in steps and tasks outlined.
2. Logger.Logs at every point, every data generated or extracted.
4. A List of all Dependencies including:
Only The Sheets Used, Only list The Columns or Fields used in the Script
Operations and their Zero-based index grouped into Conditional and Main, do not
list fields that are no useful in the whole script.
The indexes should be able to be edited to affect changes in the rest of the
script.
Stored Hashes Used
A toggle for turning duplicate On or Off with Default "True"
5. All First rows are Headers, Ensure an Explicit Statement, that no first row or
header row should be appended, this should be at every point.
6. Add validation to skip any row that matches the column header titles.
6. One Function called "ExpenseMasterFunction" which when run, everything runs.
A. Sheet Information
These are the following sheets and their columns in zero-based index:
"Request Info" Sheet
Request ID (Column A, Index 0)
Request Time (Column B, Index 1)
Request By (Column C, Index 2)
Received By (Column D, Index 3)
Purpose (Column E, Index 4)
Category (Column F, Index 5)
Supplier Name (Column G, Index 6)
Supplier Phone (Column H, Index 7)
Supplier Email (Column I, Index 8)
Supplier Region (Column J, Index 9)
Supplier Country (Column K, Index 10)
Supplier Address (City, Town, Street) (Column L, Index 11)
Transaction Type (Column M, Index 12)
Amount (Column N, Index 13)
Account Number (Column O, Index 14)
Account Name (Column P, Index 15)
Approval By (Column Q, Index 16)
Date of Payment (Column R, Index 17)
Timestamp (Column S, Index 18)
Status (Column T, Index 19)
Task 0: EnsureCorrectRequestID
A. Ensure that Request ID (Column A, Index 0) in "Request Info" Sheet is in the
form of Request No.1, Request No.2 and so on.
Find the maximum number existing, then update a row which doesn't have that format
irrespective of order.
So if the max is Request No.10, then Request No.11 is updated in a row whose
Request ID (Column A, Index 0) is not in that format.
Always ignore Empty Rows.
B. If duplicate Request ID (Column A, Index 0) in "Approval Info" occur, Delete one
and its corresponding row
C. If duplicate Request ID (Column A, Index 0) in "Payment Info" occur, Delete one
and its corresponding row
Condition:
Other Tasks can be performed only if:
1. All Request ID (Column A, Index 0) in "Request Info" Sheet has the format
"Request No.## where ## means the appropriate number
2. No Duplicate Request ID (Column A, Index 0) in "Approval Info" Sheet occur
3. No Duplicate Request ID (Column A, Index 0) in "Payment Info" Sheet occur
Task 1: StatusUpdateField
Data in Status Field is updated based on data in Conditional Field or variable.
Update Field:
Status (Column T, Index 19) in "Request Info" Sheet
Values: "Pending", "Approved", "Declined", "Paid"
Update corresponding Timestamp (Column S, Index 18) with current DateTime in the
format DD/MM/YYYY @ HH:MM always when Status (Column T, Index 19) is updated.
2. Extract and store data from rows in the "Approval Info" sheet with Status
(Column G, Index 6) == "Approved" into the following variables:
Request ID (Column A, Index 0) in ApprovedRequestID
Description (Column B, Index 1) in ApprovedrequestDescription
Approval By (Column C, Index 2) in ApprovedrequestApprovalBy
Amount (Column D, Index 3) in ApprovedrequestAmount
Approved (Column E, Index 4) in ApprovedrequestApproval
3. Extract data in rows in "Request Info" Sheet, whose Request ID (Column A, Index
0) matches value of ApprovedRequestID and store in variables.
Store the following data into the variables:
Extract Account Number (Column O, Index 14) and attach ' at the beginning and store
as ApprovedrequestAccountNumber, e.g. 466575 into '466575 and stored in
ApprovedrequestAccountNumber
Account Name (Column P, Index 15) as ApprovedrequestAccountName
B.
1. Extract Request ID (Column A, Index 0) in "Payment Info" Sheet whose value
cannot be found in the Request ID (Column A, Index 0) of the "Approval Info" Sheet,
store as outlierApprovedRequestID
2. Remove rows in "Payment Info" Sheet whose Request ID (Column A, Index 0) matches
the value in outlierApprovedRequestID
3. Remove value in StoredApprovedRequestID which matches outlierApprovedRequestID.
C.
1. In the "Payment Info" sheet, find all rows where the Request ID (Column A, Index
0) matches a Request ID in the "Approval Info" sheet where the Approved field
(Column E, Index 4) is "No" and store as NotApprovedRequestID
2. Remove rows in "Payment Info" Sheet whose Request ID (Column A, Index 0) matches
the value in NotApprovedRequestID
3. Remove value in StoredApprovedRequestID which matches NotApprovedRequestID.
D.
1. In the "Payment Info" sheet, find all rows where the Request ID (Column A, Index
0) matches a Request ID in the "Approval Info" sheet where the Approved field
(Column E, Index 4) is "Pending" and store as PendingApprovedRequestID
2. Remove rows in "Payment Info" Sheet whose Request ID (Column A, Index 0) matches
the value in PendingApprovedRequestID
3. Remove value in StoredApprovedRequestID which matches PendingApprovedRequestID.