Entrepreneur Geek

Nirav Mehta on life, technology and future

Archive for the ‘Technology’ Category

Importing Paypal transactions into Tally accounting software

with 2 comments

We use Paypal to receive payments from customers. We maintain our financial accounts using Tally. Imagine copying over Paypal transactions into a separate accounting software – manually. You are creating all ledger accounts one by one. Ensuring spellings are correct, accounting heads are right and you are not missing any names in between. You’re numb by the time you’ve created 500th account, but still have another 500 to go. You drag yourself through the process. Over the next few days, you create sales and receipt vouchers for each sale. But hey, did you forget that the sales are in US Dollars, but income tax returns have to be filed in Indian Rupees? You now convert all amounts to suitable Rupee values. You probably use some Excel formulas to make it easier, but you still need to get those entries in Tally. Few more days of work, uh?

Urgh… It would be a nightmare to do this manually

This is the first financial year where we are submitting our returns, and I wanted to make sure everything is impeccable. My wife has extensive experience with Tally and she told me she could quickly make these entries.

I laughed, I knew it was not so easy, and that she was over optimistic!

There is no way this is done manually, I said to myself.

Lazy Programmers Automate Things

Being a lazy programmer, I wanted to automate this. Automating mundane tasks like this has numerous advantage. First, we will save a lot of data entry time (and headache). Second, we will save this time and headache every time in future we wanted to bring our accounts up to date. Third, it will avoid data entry errors. And forth, I will get to learn a bit more of Tally.

(To give you a bit of background on this, I have graduated in Commerce with Bookkeeping as my main subject, but I don’t remember any of it now. I always liked programming better! At the same time, I pity the accountants, seeing them working doubly hard just copying data from one source to another.)

It was my long time dream to import data in Tally. I was always told it’s possible to export from Tally to Excel, but not vice versa.

Time to break the myths!

Strategy 1: Import Excel Data to Tally

I looks around the web to find if someone else had similar problems and came up with some solution. And sure, I found UDI Magic by RTSLink.

RTSLink creates excellent software to import Excel to Tally, SQL Server / MySQL / DBF and virtually any database to Tally. The have a free utility called UDI Magic that allows importing Excel data to Tally.

I felt ecstatic. I found my solution so quickly! The next day, I downloaded UDI Magic and gave it a spin.

I found it worked really well. I could create ledger masters, sales transactions, stock transactions and a lot more with this software. It takes Excel data, converts it to XML and imports it to Tally using RTSLink DLL.

I decided I will convert my Paypal data to CSV. From CSV to Excel in a format UDI Magic can understand. And then to Tally.

This was a perfect solution. But had two problems.

  1. I will still need to convert Paypal data into a format UDI Magic could understand
  2. UDI Magic is a trial software. It works for 30 times / 30 days and expires.

Now I could keep installing it on different machines whenever I needed or try some other hackery to get around the expiry limitation. But I said, heck, why not be clean? Why not push my conversion system a bit further and convert to Tally XML itself?

Strategy 2: Solve the problem once and for all – Write a script to convert Paypal data (residing in MySQL) to UDI XML for Tally

I thought it would be easy. I know PHP and XML like the back of my hand. I can put together a converter in an hour.

Alas. It was not that quick. It took me 8 hours to write the converter. It still does not handle Purchases (I got tired, and did not have so many purchase transactions). But at the end of the day, I was able to import close to 600 master ledgers and about 900 vouchers in Tally in under a minute. That was sweet!

So how does this work?

Here is an overview

  1. Login to Paypal. Go to History. Download CSV reports – along with shopping cart details. If it takes too long to download full year’s transactions, download monthly batches.
  2. Download PaypalToTally.zip – unzip the contents to your local web server directory
  3. Create paypal_history table in your MySQL DB using paypal_history.sql file.
  4. Import Paypal transactions to this table using phpMyAdmin – Import Data.
  5. Ensure data is imported correctly. Fix problems if any.
  6. Configure database details and other configuration options in config.inc.php
  7. Make sure “data” folder is writeable (chmod 666)
  8. Hit the index.php via browser!
  9. Ensure generated XML files are valid. (You can open them with browser)
  10. Open Tally. Open the company you want to import to.
  11. Import Ledgers using Import Masters option under “Gateway of Tally”
  12. Verify it worked.
  13. Import transaction vouchers using “Import Vouchers” option
  14. Verify it worked!
  15. Enjoy!

Your Mileage May Vary

I wrote these scripts to solve a specific problem – import sales data from our Paypal account to Tally. Such that Tally shows all customers, their payments and products purchased. You will need to modify these scripts to suit your needs. These scripts support Web Accept Payments, Shopping Cart Payments and won’t record Refunded items. But they won’t import Purchases or simple Payments Received  / Sent (via Send Money tab in Paypal).

You can modify these scripts to import data from any database. If you add any features, do let me know!

Common Problems / Troubleshooting

  • Ensure the financial year is set correctly. Dates in import files must be within current financial year in Tally.
  • Make sure starting voucher number is set correctly. Vouchers won’t import otherwise.
  • If only some of the data gets imported (Tally quits importing at certain percentage), check the imported data. Find out last imported transaction. Locate it in the XML file. You have some problem with the transaction after this.
  • These scripts don’t import Purchase information yet.

Free Download

In a hurry? Download PaypalToTally.zip from here.

References

  • RTS Link website was extremely helpful. Especially their explanation of Sales vouchers XML and Receipts XML.
  • You may need a Tally expert around. My wife cleared some of my confusions about Debit and Credits ;-)

Using Paypal? You may like Putler

Do you use Paypal for your business? Then you may even like Putler – a Paypal Reporting, Monitoring and Planning tool.

Thank you, share your experiences

I hope these scripts prove useful to you. Thank you for trying them out! They saved us many days of work. If you like them, post a comment with your experience!

Written by Nirav

March 24th, 2010 at 11:09 pm

Showing Flex Preloader near the top of your Application

with 2 comments

Flex comes with a reasonably good preloader (DownloadProgressBar) that shows in application center while the swf is loading and initializing. I had an application that is taller than browser’s view port height. This means the preloader will show below the fold – making it invisible to users who don’t scroll down. Even when the preloader is visible, it “feels” it’s just not in the right position.

I knew I could write some custom preloader, but I did not have the time / need for it. After reading a bit of documentation and diving in the DownloadProgressBar source code, I figured the solution was actually very easy.

Here’s the custom preloader source code that shows download progress bar for your Flex application near its top.

MyDownloadProgressBar.as

package com.components
{
  import flash.events.ProgressEvent;
  import mx.preloaders.DownloadProgressBar;

  public class MyDownloadProgressBar extends DownloadProgressBar
  {
    public function MyDownloadProgressBar()
    {
      super();
      // Set the download label.
      downloadingLabel="Downloading..."
      // Set the initialization label.
      initializingLabel="Initializing..."
    }

    // Override to return true so progress bar appears during initialization.
    override protected function showDisplayForInit(elapsedTime:int, count:int):Boolean {
      return true;
    }

    // Override to return true so progress bar appears during download.
    override protected function showDisplayForDownloading(elapsedTime:int, event:ProgressEvent):Boolean {
      return true;
    }

    // Override initialize so that we can position the loader
    override public function initialize():void {
      super.initialize();
      center(stageWidth, (stageHeight > 250) ? 250 : stageHeight);
    }
  }
}

The critical part is initialize function. super.initialize(); calls DownloadProgressBar‘s initialization routine – which centers the preloader. We then call center again, but modifying the height parameter. If application size is more than 250 pixels, the preloader will be centered vertically within 250 pixels from top.

The only other code you need to write to make this work, is to tell your Application to use this preloader.

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
	preloader="com.components.MyDownloadProgressBar">

Note: Remember to place the first code as MyDownloadProgressBar.as within a com/components folder under your main application.mxml file.

That made me happy! But if you are looking for more, you can also check out:

Hope you enjoy!

Written by Nirav

March 19th, 2010 at 6:17 pm

Flex Regular Expression Online Testing / Learning Tool

with one comment

When it comes to Regular Expressions, I start feeling giddy. Even after using them a lot on many projects, I never remember the qualifiers and syntax. It’s always RTFM for me when I need to use some regular expressions in my code.

And that happened again today. I looked around the manual and searched online for a “quick fix” on the regular expression I needed. And I found a very interesting online Regular Expression trial / demo / learn by exploring tool. It’s made in Flex (and I needed RegExp for Flex) and helped me develop the RegExp I needed in a couple of minutes. (ok, I am still slow, but I found it!)

Thank you Remus Stratulat for creating this useful tool! BTW, he also has a similar tool for JavaScript Regular Expressions.

Click on the image below or here and jump to online regular expression checking tool.

Online Regular Expression Checking Tool for Flex and JavaScript

Online Regular Expression Checking Tool for Flex and JavaScript

Written by Nirav

January 17th, 2010 at 5:38 pm

Finding number of lines in files recursively

without comments

I wanted to find the number of lines from a set of files – spread out in nested directories. The shell command “wc” is best for finding number of words / lines in files but it does not have an argument for recursive searching.

Here’s a quick shell command sequence that will find you the line count from all files in a directory – recursively.

find /topleveldirectory/ -type f -exec wc -l {} \; | awk '{total += $1} END{print total}'

Replace “/topleveldirectory/” with your directory of choice. Leave it as “.” to find from current directory and below.

Found on Unix.com

Written by Nirav

December 25th, 2009 at 10:07 am

Posted in Apple,GNU/Linux

Tagged with , ,

Coding Clean and Semantic Templates

without comments

If you are the guy who uses<div> tag for everything, this post is for you. It focuses on how you can write clean HTML code by using semantic markups and minimize the use of <div> tag. Have you ever edited someone’s templates, don’t those messy tags drive you crazy? Not only writing clean templates can benefit yourself, but your team as well. It will save you time when you have to debug and edit (particularly the large projects).

This post is a collection of some simple yet effective techniques. Read all tips over on Web Designer Wall.

Written by Nirav

December 17th, 2009 at 10:56 am