Wednesday, August 16, 2017

Logic Behind GST Identification Numbers



Implementation of the Goods and Services Tax (GST) is a crucial reform in the Indian economy. Such a comprehensive overhaul of the tax assessment and reporting systems has not taken place anytime in the country’s economic history. Its impact on the economy is thought to be second only to the liberalization and globalization initiatives in 1991.

Every tax payer in GST is given a 15-digit GST identification number (GSTIN). We will now look at the logic behind each of the numbers. And, it is even possible to correctly surmise a firm’s GSTIN with very few inputs.

A typical GST number will be like this. Small case and upper case letters are interchangeable.

Digits 1 and 2

The first two digits are the state code in which the company is registered. These codes are taken from Indian Census Data 2011. Every state and union territory has a two-digit unique code. The codes can be obtained from this link http://censusindia.gov.in/Census_Data_2001/PLCN/plcn.html

In the above example, 34 is the code for Pondicherry

Digits 3 to 12

These 10 digits are the company’s Income Tax Permanent Account Number (PAN).

In the above example, AABCB5576G is the PAN of Bharat Sanchar Nigam Ltd (BSNL)

Digit 13

This number is based on the number of registrations of a company in a state for different business purposes, if any. This will be an alphanumeric character. Up to 9 registrations, 1 to 9 is given. When the 10th registration is made, ‘A’ is allocated. This can go on up to ‘Z’ in which case there will be 35 registrations in the state for the same PAN. 35 is the maximum number of registrations possible for a firm on the same PAN in a state.

In the above case, this is BSNL’s first registration in Pondicherry

Digit 14

This digit is reserved for future use and is currently filled with ‘Z’

Digit 15

This is the trickiest digit of all the fifteen! It is a checksum calculated on the values of the first fourteen digits.

Before explaining the details of manually calculating the checksum, see the following diagram showing the character array and corresponding values.

Take the first character in the example, which is ‘3’. The place value of ‘3’ in the character array is 3 itself. Multiply it by a factor, which is 1 for all odd digits in the GSTIN (that is, for digits 1, 3, 5, 7, 9, 11 and 13) and is 2 for all even digits (digits 2, 4, 6, 8, 10, 12 and 14). Multiplying the factor, we get 3 itself (that is, 3 x 1). Divide it by 36 and see what is the quotient. Leave out the remainder. In this case, this will be 0/36, which is 0 itself. Let’s call this step 1. Again divide the multiplied value by 36 and see what is the remainder (3 in this case). Let’s call this step 2 and add the numbers obtained in steps 1 and 2, which is 0+3 = 3. Let’s keep this number aside as step a1.

Repeat this for the second digit ‘4’. Here, being the second digit, factor is ‘2’. Multiplying the factor, we get 8 (that is, 4 x 2). Divide it by 36 and see what is the quotient. Leave out the remainder. In this case, this will be 8/36, which is 0 itself. Let’s call this step 1. Again divide the multiplied value by 36 and see what is the remainder (8 in this case). Let’s call this step 2 and add the numbers obtained in steps 1 and 2, which is 0+8 = 8. Let’s keep this number aside as step a2.

Third character is ‘A’. Place value is 10. Factor is 1. In Step 1, we get 0, and step 2 we get 10 itself. Adding step 1 and 2, we get 10. Let’s keep this as step a3.

Fourth character is ‘A’. Place value is 10. Factor is 2. Multiplied value is 10x2=20. In Step 1, we get 0, and step 2 we get 20 itself. Adding step 1 and 2, we get 20. Let’s keep this as step a4.

Fifth character is ‘B’. Place value is 11, Factor is 1. We get 11 as step a5.

Sixth character is ‘C’. Place value is 12, Factor is 2. We get 24 as step a6.

Seventh character is ‘B’. Place value is 11, Factor is 1. We get 11 as step a7.

Eighth character is ‘5’. Place value is 5, Factor is 2. We get 10 as step a8.

Ninth character is ‘5’. Place value is 5, Factor is 1. We get 5 as step a9.

Tenth character is ‘7’. Place value is 7, Factor is 2. We get 14 as step a10.

Eleventh character is ‘6’. Place value is 6, Factor is 1. We get 6 as step a11.

Twelfth character is ‘G’. Place value is 16, Factor is 2. We get 32 as step a12.

Thirteenth character is ‘1’. Place value is 1, Factor is 1. We get 1 as step a13.

Fourteenth character is ‘Z’. Place value is 35. Factor is 2. Multiplied value is 35x2=70. In Step 1, we get 70/36=1 and step 2 we get 34 as remainder. Adding step 1 and 2, we get 35. Let’s keep this as step a14.

Now, add all the numbers obtained in steps a1 to a14 = 3 + 8 + 10 + 20 + 11 + 24 + 11 + 10 + 5 + 14 + 6 + 32 + 1 + 35 = 190. Let’s call this step 15A.

Divide the sum obtained in step 15A by 36 and see what’s the remainder. This is 10, in this case (190/36 gives 10 as remainder). Let’s call this step 15B.

Deduct the number obtained in step 15B from 36. Here, this is 36-10=26. Let’s call this step 15C.

Now, divide the number obtained in 15C with 36 and see what’s the remainder. Dividing 26 by 36, we get 26 itself as remainder.

Look up the character with place value 26 in the character array. It is ‘Q’ and hence it is the checksum digit.

If you think the explanation I gave is cumbersome, see this few lines of code in Java which says the same thing. How elegant and precise is software!

public static String getGSTINWithCheckDigit(String gstinWOCheckDigit) throws Exception {
int factor = 2; int sum = 0;
int checkCodePoint = 0;
char[] cpChars; char[] inputChars;

cpChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
inputChars= gstinWOCheckDigit.trim().toUpperCase().toCharArray();
int mod = cpChars.length;
   for (int i = inputChars.length - 1; i >= 0; i--) {
   int codePoint = -1;
   for (int j = 0; j < cpChars.length; j++) {
   if (cpChars[j] == inputChars[i]) {
      codePoint = j;
     }}
   int digit = factor * codePoint;
   factor = (factor == 2) ? 1 : 2;
   digit = (digit / mod) + (digit % mod);
   sum += digit;
   }
   checkCodePoint = (mod - (sum % mod)) % mod;
   return gstinWOCheckDigit + cpChars[checkCodePoint];
   }}

By the way, I don’t know Java. My humble and little experience is with VB, but the logic is clearly visible.

As a practice example, try to find out the checksum digit of the following GSTIN (first 14 characters are given).


Sunday, June 25, 2017

Reforms are not enough for The Economist



Finding a mention in The Economist weekly magazine is usually a harrowing thing for state leaders. Very rarely do anyone get praised for what they had done. Such rare admiration generally occurs long after they had retired or had been removed from power and when The Economist goes after the fallacies of their successor. This week’s issue of the magazine appears with the cover of Narendra Modi riding the tiger of economic reforms. On closer inspection, the tiger appears to be made of paper and the word ‘illusion’ come into view. It presents two major articles on India – the state of reforms and the environment ministry’s directive, regulating supply of cattle for slaughter.

The articles list out the accusations against the government – the foremost being that he is a good administrator, but a poor reformer. The counts on which he had failed are so general in nature, that can be leveled against any government that ruled post-colonial India. The shortcomings are listed as follows.
 

1. Lending to industry is contracting, for the first time in 20 years (isn’t this due to the rise in NPA of banks?)
2. He should be working to simplify the over-exacting labour law
3. Less repressive approach to protests in Kashmir
4. Obligation of banks to make at least 40% of all loans to “priority sectors” such as farms and small businesses
5. The electricity firms remain fundamentally unprofitable, because authorities refuse to end the practice of giving farmers free power
6. Fares remain absurdly cheap for political reasons
7. Companies deemed to earn excessive profits are hounded: makers of stents, pharmaceuticals and seeds have been forced to cut prices recently
8. Waiver of farmers’ loans will bring short-term relief but make it harder for farmers to borrow in future

On the other hand, the magazine grudgingly concedes some credit for the Modi regime. First among them is the absence of corruption at least at the highest levels of government. It even admits reluctantly that Modi and his party is likely to retain power in the next election slated to be in 2019. The points which are deemed advantageous are as follows


1. A good administrator but not a good reformer
2. Corruption seems to have abated, at least at the highest levels of government
3. Deserve credit for bringing macroeconomic stability
4. Double-digit inflation and ballooning current-account deficits have been absent
5. Liberalisation of investment rules has helped to attract record amounts of foreign cash
6. The stock market has boomed
7. A new bankruptcy law, introduced in May 2016, may enable the enforcement of lending contracts
8. Made it possible to get subsidies straight to the needy, cutting out venal intermediaries, who in the past pilfered up to three-quarters of the money in the system
  
Now, if we balance the pros and cons suggested by The Economist, to which side the balance will swing?

Monday, March 27, 2017

A Cheerless Place

First impressions are very important. When a traveler encounters a foreign land, the very first thoughts that arise in him are on the strange differences that he sees in front of his eyes from what he was familiar at home. Here's an excerpt from Vivant Denon, the French artist, writer, diplomat, author and archeologist. He accompanied Napoleon Bonaparte to his expedition to Egypt in 1798 and made numerous sketches of the monuments of ancient art, sometimes under the very fire of the enemy. He notes down the profound dissimilarities between Egypt and his home country, France. The portrait of Egypt is as a cheerless place dominated by Islam. However, we must also keep in mind that these are the comments made by an invader just about to colonize a Middle-Eastern country. He describes Egypt as

"a land of deep silence. After landing at Alexandria, it seemed to the French that there was no conversation in the streets, no laughter, no scampering children or barking dogs. Egypt seemed profoundly melancholy, unwelcoming and inward-looking, and for many of the French soldiers this was the dominant image they would retain of North Africa - particularly of Islam. The first image that came into view was of a vast cemetery, covered by countless tombs of white marble against a white soil; a few skinny women, draped in long, torn clothing, were like ghosts as they wandered among these monuments; the silence was broken only by the screeching of kites as they circled over this sanctuary of death. It was a bleak image that, in the minds of the French, contrasted starkly with the colour and gaiety of the European cities they had left behind".

(Excerpts from 'Napoleon' by Alan Forrest)

Monday, January 30, 2017

Supreme Court and Jallikkattu



The Mughal emperors styled themselves as ‘the shadow of god on earth’ (zill-e-Allahi). Even though real power was shorn off the later Mughals, ordinary litigants continued to consult them out of old habit to settle the disputes among the public. Once, a washerman from the other side of the Yamuna river approached Bahadur Shah II, the last of the Mughals. However, the god’s shadow had to send him back with a frank admission of his lack of jurisdiction over the other bank of the river that still flowed insouciantly under the ramparts of his own fort.

India’s Supreme Court is steadily losing its authority by repeatedly engaging itself in litigation in which its arbitration is least sought by anyone concerned. It had been steadily moving forward with a great appetite for writs and indiscriminate interpretations of the constitution. However, it seems to have landed itself in great trouble on the issue of Jallikkattu in Tamil Nadu. The court is now in the unenviable position of the matador who had caught the bull by its horns – they are not able to subdue the raging bull, nor able to let it go without causing injury to themselves. When a Public Interest Litigation was conveniently filed by an animal welfare organization, a few judges found it expedient to ban a form of public amusement that had assumed cult status and the paraphernalia of a religious ritual to many Tamils. But the public opted to defy the apex court and came out en masse to organize large scale protests in the streets, crippling public life with it.

The learned judges first outlawed the use of sun-control films in cars and other vehicles. No one knows how or whether the use of sun films violated any prevailing law of the land and at the same time, removal of films could slash fuel efficiency by up to 5%. But the people obliged when the court gave strict orders to the police to enforce the ban and removed those films for which they had paid their hard-earned money earlier to install. If you can use a curtain made of cloth in the car, what was the big deal with sun-control film? Then came the strange rule that new judges will be selected by the old ones – the collegium system which is sharply criticized even inside the judiciary. Newly promoted judges ensured lucrative positions for the outgoing ones as a mark of gratitude. Thus, the Supreme Court took the reins of BCCI. If the court goes by the dictum of assuming the administration of a body in which corruption is alleged, wouldn’t they take over the control of the country’s executive as well? The nagging question of judicial corruption would still remain.

The next revelation was to play the national anthem in movie theaters before the show begins. Whether you like it or not, the law states that you should stand up and pay respect to the anthem (whether you feel it or not). But, what was the rationale behind playing the anthem in all the movie theaters of the country? Jallikkattu was the latest in a series of the Supreme Court’s overtures. But this time, the court had to cow down before the public outcry against it. Unless they are restrained under some kind of leash, they’d ban the celebratory procession of elephants next.

But there is a clear danger lurking in the spontaneous outbreak of protests. All regimes are mortally afraid of mass movements without a leader or organized by a party. The Jasmine Revolutions of the Arab countries were the realization of the popular will that was long suppressed in those autocracies. But if we allow such leaderless rebellions to win their course in India, our social structure will soon collapse and we will be led down the slippery slope of mob psychology! Remember what happened to Piggy and Ralph in Golding’s Lord of the Flies?

Sunday, January 15, 2017

Solutions to Some Windows 7 Annoyances

1. Folder Settings not remembered (14-01-2017)

Windows remembers each folder settings like viewing style (large thumbnails, list, details etc) and the sorting order (date- or name-wise). Sometimes, this is lost and is a nuisance for the user as each time he has to set these parameters to arrange the files in the order we like most.

Windows remembers by default the settings of 500 folders. If the number of folders you customize increases, it loses track. An option is to set the figure manually to a higher value, say 1000 or 2000
 
Here is a solution which works for Win 7.

a) Open Registry Editor and navigate to HKEY_CURRENT_USER \ Software \ Classes \ Local Settings \ Software \ Microsoft \ Windows \ Shell 

b) In the right-hand side, right click > New > DWORD (32-bit value) and name it BagMRU Size

c) Right-click BagMRU Size and click Modify

d) Enter value, say, 1000 and re-boot