0% found this document useful (0 votes)
3 views4 pages

Expense Master Sheet - Google Sheet

The document outlines the creation of a comprehensive Google Apps Script for managing expense requests, approvals, and payments across three sheets: 'Request Info', 'Approval Info', and 'Payment Info'. It includes detailed tasks for ensuring correct formatting, updating status fields, appending and deleting rows, and syncing data between sheets, with specific conditions for duplicates and validations. The script is designed to be robust, well-documented, and includes logging at every step, along with a toggle for handling duplicates.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Expense Master Sheet - Google Sheet

The document outlines the creation of a comprehensive Google Apps Script for managing expense requests, approvals, and payments across three sheets: 'Request Info', 'Approval Info', and 'Payment Info'. It includes detailed tasks for ensuring correct formatting, updating status fields, appending and deleting rows, and syncing data between sheets, with specific conditions for duplicates and validations. The script is designed to be robust, well-documented, and includes logging at every step, along with a toggle for handling duplicates.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Create an Appscript with the following characteristics:

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)

"Approval Info" Sheet


Request ID (Column A, Index 0)
Description (Column B, Index 1)
Approval By (Column C, Index 2)
Amount (Column D, Index 3)
Approved (Column E, Index 4)
Timestamp (Column F, Index 5)
Status (Column G, Index 6)

"Payment Info" Sheet


Request ID (Column A, Index 0)
Description (Column B, Index 1)
Account Number (Column C, Index 2)
Account Name (Column D, Index 3)
Amount (Column E, Index 4)
Paid (Column F, Index 5)
Timestamp (Column G, Index 6)
Status (Column H, Index 7)
B. Automative Tasks:

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.

In Request Info Sheet:


Conditional fields :
Approved (Column E, Index 4) in "Approval Info" Sheet
Paid (Column F, Index 5) in "Payment Info" Sheet

Update Field:
Status (Column T, Index 19) in "Request Info" Sheet
Values: "Pending", "Approved", "Declined", "Paid"

Update Status (Column T, Index 19) when:


A. Approved (Column E, Index 4) == "Yes" and Paid (Column F, Index 5) == "Yes" then
Status (Column T, Index 19) == "Paid"
B. Approved (Column E, Index 4) == "Yes" and Paid (Column F, Index 5) == "Pending"
then Status (Column T, Index 19) == "Approved".
C. Approved (Column E, Index 4) == "No" and Paid (Column F, Index 5) == "No" then
Status (Column T, Index 19) == "Declined"
D. Approved (Column E, Index 4) == "No" and Paid (Column F, Index 5) == "Pending"
then Status (Column T, Index 19) == "Declined"
E. Approved (Column E, Index 4) and Paid (Column F, Index 5) == "Pending", then
Status (Column T, Index 19) == "Pending"

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.

Task 2: Append and Delete Rows

Step 1: Extract Data and Store in Variables.


1. Extract and store data from rows in the "Request Info" sheet into the following
variables:
Request ID (Column A, Index 0) in requestID
Request Time (Column B, Index 1) in requestTime
Request By (Column C, Index 2) in requestBy
Approval By (Column Q, Index 16) in requestApprovalBy
Amount (Column N, Index 13) in requestAmount
Concatenate("Request By ", requestBy) and store in requestDescription

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

Step 2: Append Rows

Append the following into the rows of "Approval Info" Sheet


requestID, requestDescription, requestApprovalBy, requestAmount, "Pending"

Append the following into the rows of "Payment Info" Sheet


ApprovedRequestID, ApprovedrequestDescription, ApprovedrequestAccountNumber,
ApprovedrequestAccountName, ApprovedrequestAmount, "Pending"

Step 3: Prevent Duplicate Rows


For Data Appended into:
"Approval Info" Sheet, requestID is the primary key
"Payment Info" Sheet, ApprovedRequestID is the primary key.
Hash:
requestID appended into the "Approval Info" Sheet and store as StoredrequestID
ApprovedRequestID appended into the "Approval Info" Sheet and store as
StoredApprovedRequestID
Condition:
When the requestID == StoredrequestID, then the corresponding requestDescription,
requestApprovalBy, requestAmount for the requestID is not appended.
When the ApprovedRequestID == StoredApprovedRequestID, then the corresponding
ApprovedrequestDescription, ApprovedrequestAccountNumber,
ApprovedrequestAccountName ApprovedrequestAmount is not appended.

Step 4: Sync Sheets with Source Sheet


A.
1. Extract Request ID (Column A, Index 0) in "Approval Info" Sheet whose value
cannot be found in the Request ID (Column A, Index 0) of the "Request Info" Sheet,
store as outlierrequestID
2. Remove rows in "Approval Info" Sheet whose Request ID (Column A, Index 0)
matches the value in outlierrequestID
3. Remove value in StoredrequestID which matches outlierrequestID

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.

E. If a Request ID (Column A, Index 0) in "Approval Info" Sheet whose corresponding


Approved (Column E, Index 4) == "Pending", Changes made in dependent fields in
"Request Info" Sheet in rows with the same Request ID (Column A, Index 0) will
change in the "Approval Info" Sheet

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy