Create a Newspaper Invoice System in Google Sheets
Hey there, Google Sheets enthusiasts! Want to streamline your newspaper invoicing process? This Google Apps Script solution creates a user-friendly invoice system right in your spreadsheet. It manages subscribers, generates invoices, and exports them as PDFs. Below, you’ll find two code blocks (Code.gs and InvoiceForm.html) that you can copy and use in your own Google Sheet, along with step-by-step instructions on how to set it up.
What This Invoice System Does
This system includes:
- A custom HTML form to input subscriber details and invoice items.
- A Subscribers sheet to store customer data (phone, name, address, email, etc.).
- An Invoice sheet that generates a formatted invoice.
- An export to PDF feature that saves invoices to Google Drive and emails them.
- A custom menu in Google Sheets to trigger invoice creation.
Step-by-Step Setup Instructions
- Create a New Google Sheet:
- Open Google Sheets and create a new spreadsheet (e.g., "Newspaper Invoice System").
- Save it to your Google Drive.
- Open the Apps Script Editor:
- In your Google Sheet, go to Extensions > Apps Script.
- Add the Google Apps Script Code:
- In the Apps Script editor, clear any code in
Code.gs
. - Copy the code below (Code Block 1) and paste it into
Code.gs
. - Save the file (Ctrl + S) and name the project (e.g., "Invoice System").
- In the Apps Script editor, clear any code in
- Add the HTML Form:
- In the Apps Script editor, go to File > New > HTML file.
- Name it
InvoiceForm
(exact name required). - Copy the code below (Code Block 2) and paste it into
InvoiceForm.html
. - Save the file.
- Set Up Permissions:
- Click Run in the Apps Script editor to execute the
onOpen
function. - Authorize the script by reviewing and granting permissions (Sheets, Drive, Gmail).
- A custom menu (Invoice System) will appear in your Google Sheet.
- Click Run in the Apps Script editor to execute the
- Set Up Sample Data (Optional):
- Go to Invoice System > Setup Sample Data in the menu.
- This creates a
Subscribers
sheet with sample data. Edit it to add your own subscribers.
How to Use the Invoice System
- Open the Form:
- Go to Invoice System > Create Invoice to open the HTML form.
- Fill Out the Form:
- Phone Number: Enter a 10-digit phone number from the
Subscribers
sheet. - Due Date: Select a date (defaults to 30 days from today).
- Items: Add items (e.g., "Daily Newspaper") with description, quantity, and rate. Use + Add Item or Remove as needed.
- Tax: Enter tax amount (optional, defaults to 0).
- Click Create Invoice.
- Phone Number: Enter a 10-digit phone number from the
- View the Invoice:
- The script creates an
Invoice
sheet with formatted details (invoice number, date, items, totals in ₹).
- The script creates an
- Export to PDF:
- The invoice is saved as a PDF in a
NewspaperInvoices
folder in Google Drive. - It’s emailed to your Google account’s email address.
- A confirmation shows the PDF’s Drive link.
- The invoice is saved as a PDF in a
- Manage Subscribers:
- Edit the
Subscribers
sheet to add or update customer data (Phone, Name, Address, Email, Subscription Type).
- Edit the
Code Blocks to Copy
Below are the two code blocks. Click the Copy button for each to copy the code to your clipboard, then paste it into the appropriate file in your Apps Script editor.
Tips and Troubleshooting
- Validation: The form ensures a 10-digit phone number and at least one item.
- PDF Export: PDFs are saved in A4 format without gridlines and emailed to your Google account.
- Errors:
- "Sheet not found": Let the script create the
Invoice
sheet or ensure it exists. - "Subscriber not found": Check that the phone number is in the
Subscribers
sheet. - PDF not emailed: Verify Gmail permissions and your account’s email.
- "Sheet not found": Let the script create the
- Customize: Change currency in
fillInvoiceDetails
(e.g.,'$#,##0.00'
) or edit CSS inInvoiceForm.html
for styling.
Why This System is Awesome
This invoice system is free, automated, and customizable. It’s perfect for small newspaper agencies or anyone managing subscriptions. Copy the code, follow the steps, and start creating professional invoices today!
Have questions or need help? Leave a comment below, and I’ll get back to you. Happy invoicing!
No comments:
Post a Comment