## Service tax and tips

This came about because I don’t like ++’s behind prices. If you tell me the price of the food is \$14.90, then when I’m paying, it’d better be just \$14.90. I don’t like doing mental arithmetic gymnastics. I also don’t like whipping out my phone to use the calculator.

It’s probably the main reason why I don’t go to fancy restaurants. It’s not so much the high price (though it’s a big factor), but that I feel deceived about the price. The listed price is not the price I have to pay.

### Consumption tax

The Goods and Service Tax (GST) was established in Singapore, 1994. It started out as 3% in April 1994, then 4% in January 2003, then 5% January 2004, and is currently 7% from July 2007 onwards.

This caused some confusion because what used to be “round” prices now became weird. \$5 became \$5.15, and pray you had a human calculator with you if a price was something weird, like \$4.95.

Because the GST is a consumption tax, it generally applies to everything. From food to clothes to electronic gadgets. Almost every price is affected.

The progression from 3% to 7% made things worse. I remember having to design and code a software system to deal with taxes. Based on the date of the transaction, a different tax rate had to be used. For example, in December 2002 it would be 3%, but January 2003 it would be 4%.

Because it generally confused the Singapore consumer, most shops simply incorporated the GST into their prices. Instead of saying an item costs \$4.95 with 7% GST, the listed price is \$5.30 (actual is \$5.2965). The consumer doesn’t have to do any mental calculations.

It is also particularly fortunate that the Singapore 1 cent is no longer issued, because then businesses forced their prices to be rounded to the nearest 5 cents. Apparently, even 5 cent coins are no longer issued, we might see prices rounded to 10 cents. This rounding will come into play later on.

Also, if you’re in America, death to pennies… It costs more to produce a penny than a penny is worth.

### Waiting tips

It is not common in Singapore (or Asia in general) to tip a waiter or waitress. I think East Asians and South-East Asians believe that it’s their job. Any tips are a bonus, not a given.

I’ve read that in Western countries, particularly in America, the wage for waiters and waitresses are lousy. Some wait staff survive a month because they had tips.

The tip is another unknown factor in my calculation of payment. How much to tip? I would much rather you work everything I have to pay into the price, and I decide beforehand whether I want to consume food and beverage at your eating establishment.

While I’m against exploitative wages, I also don’t want to fire up the neurons needed to calculate the appropriate tip amount.

Besides, the tips given to the waiter or waitress probably don’t even go directly to them. The tips go to a general pool, where it’s either spent on something for all the wait staff, or divided evenly amongst the wait staff. This also generally discourages staff not to be extra attentive to customers, since all their colleagues gain at their expense.

### One lump price

So for most Singapore businesses, the GST is included in the price. The consumer is charged at one price, and the business has to calculate the correct GST to pay the Singapore government. Remember, tax evasion is a criminal offense.

However, there are 2 ways to calculate the GST. One is to calculate the GST portion first, the other is to calculate the sales price first.

For example, \$14.90 with GST included. Using 7% as the GST, we divide \$14.90 by 107 (because \$14.90 is 107% of the sales price) and then multiply by 7 to get the GST amount. Which is \$0.97 (rounded from \$0.9748). So the sales price is \$14.95 – \$0.97 = \$13.93.

In the second case, the sales price is \$14.90 / 107 * 100 = \$13.93 (rounded from 13.925). And so the GST amount is \$14.90 – \$13.93 = \$0.97

So far that seemed fine. Both calculations give the same results. Aahhh, but what if the government don’t care to accept values not in multiples of 5 cents? Or what if the business fudges the calculations a bit?

If you round the GST amount \$0.97 to \$1, then the final sales price is \$13.90.

If you round the sales price \$13.93 to \$13.95, then the GST amount is \$0.95, which makes the GST rate as \$0.95/\$14.90 * 100 = 6.38%. Not quite the 7%.

I’m not saying businesses do this manipulation (which is easy if you have transaction history and just tilt calculations in your favour), but rounding is the bane of financial applications.

### 10% service tax

Because Singapore (or Asia in general) don’t have a practice of tipping the wait staff, I think that’s why businesses set a 10% flat service charge. Basically, 10% of the meal price work as tips.

While I don’t have a complaint about this, I do complain that a \$14.90 meal can become \$17.45 (rounded from \$17.433). How? Because the service tax and GST weren’t included. Thus the final price is \$14.90 * (10% + 7%)

I don’t care if there’s a big asterisk or ++ at the end of your price. I hate reading footnotes directed from asterisks. And ++’s? They just scream clever/obnoxious/brilliant/crafty to me. Why do you think programmers prefer pre-increment (++i) than post-increment (i++) for readability?

### Making it easier for me

I was telling this to my mom, and she had an answer (she’s a sales person). Businesses don’t include all those taxes into one price because it’s easier for them to calculate their service tax and GST.

If \$17.45 was the listed price, they’d have to back-calculate. The GST amount would be \$17.45 / 117 * 7 = \$1.04. The service tax would be \$17.45 / 117 * 10 = \$1.49.

If they only work with \$14.90 as the only price, then it’s a “simple” matter of \$14.90 * 10% = \$1.49 for service tax, and \$14.90 * 7% = \$1.04 (or \$1.05?).

I don’t really care. Your business probably handles hundreds and thousands of transactions every day. You’re not going to do this by hand. You have a fancy financial application that does it for you. Your financial application doesn’t care if it needs to do one more arithmetic operation per transaction. Computers crunch numbers for breakfast. Your financial revenue report will still look pretty.

You know, I don’t really know the point of this article. Probably a rant. Make it easier for me, ok? Or at least be more honest with your prices. I might just patronise your eating establishment more frequently.

## Special drawing rights

No, it has nothing to do with paintings. And it’s “special” in the sense of “unique” as in “His appearance? Let’s just say he has a … unique look.”, or “different” as in “Oh no we didn’t unfriend each other. We just had … different opinions.”.

It’s actually a form of currency. Ok, no, a claim to currency. For example, an American dollar is USD 1, and a Singapore dollar is SGD 1. In this case, it’s SDR 1.

At first, I thought it’s a special case of Singapore dollar. You know, Singapore DollaR (I really thought some marketing staff or programmer made a mistake of currency abbreviations). I encountered it when I maintained an accounting software back when I was at a telecommunications company. The currencies supported were USD, SGD, AUD (the company had a wholly owned subsidiary in Australia) and SDR.

I remembered asking my supervisor why we had accounts with outstanding amounts in SDR. The amounts hadn’t been paid in years. You’d think the billing department would’ve wanted to settle accounts so we could all move on with our lives. It seemed obvious the account owners had no intention of ever paying the company in SDR (or whatever value of SDR in appropriate currencies then. Or ever).

So SDRs are a basket of currencies, currently of euros, Japanese yen, pound sterlings and the US dollar. It works something like a world currency, but not quite. It’s not widely used because (from Wikipedia):

One reason SDRs may not see much use as foreign exchange reserve assets is that they must be exchanged into a currency before use.

Meaning something like you’ve got to exchange 50000 Starbuck points to \$5 before you can use it to buy a cappuccino.

This is due in part to the fact private parties do not hold SDRs, they are only used and held by IMF member countries, the IMF itself, and a select few organizations licensed to do so by the IMF.

Meaning normal people like you and I don’t even know about SDRs in the first place.

While all that is very interesting, I have a more important question. Why did the people who wanted the accounting software allow SDR in the first place? Didn’t they know SDRs are very illiquid (you can’t just use it as cash)? Few people, ok, scratch that, since individuals probably don’t have access to SDRs. Few organisations and companies would be using SDR as a form of currency. Why was SDR supported in the first place?

The people who wanted the software might be at fault. They might just have wanted to support that one customer who wanted the option to pay in SDR. The software developers were also at fault. They should have advised the software commissioners (that’s a new term) to remove SDR as a support option.

An accounting software used for tens of thousands of customers, and an option was built into the software to support a few of those customers. This kind of decision makes for all sorts of bugs and maintenance problems, so I really hope a lot of thought went into this.

If we programmers simply create software according to the specs laid down by users, then you can see why users don’t think we’re important. They can just outsource to some exotic place in Asia where programmers are hired on the dime.

We need to think. We need to analyse. We need to question. That’s the value we add as creative professionals, software developers, programmers and what-have-you.

## The Dragon Bubble

I’ve been, uh, flipping through some books lately. As far as I understand it, they were written by economists, financial analysts and political journalists. And there was this general idea of the seemingly unstoppable growth of China crashing down.

Look, I’m just a mathematician and programmer. I don’t know much about statistics, or demographic studies, or sociology, or economics, or global financial analysis. I just pick up a book that looks interesting and start reading, ok?

UPDATE: Here are some of the books I, uh, flipped:

Here’s the gist of what I understood:

• China’s massive growth hinges a lot on manufacturing and building real estate (commercial buildings, factories).
• Manufacturing and building new buildings need lots of raw materials.
• Countries providing steel, copper and other raw materials are riding on China’s growth.
• China’s manufacturing and building works on the assumption that the infrastructure is needed for future expansion.
• China doesn’t have a big enough domestic consumption for that infrastructure.
• The recent global financial crisis has stunted, if not removed, other countries’ enthusiasm for overseas investment (say in China).
• China is set to become the world’s largest manufacturer of things.
• A monopoly of China being the largest manufacturer may not be in the interests of everyone. I’ve read of toxic plastic toys, deadly baby milk formula powders, and suicidal iPhone factory workers.
• We may be following “Be liberal in our input, but be stringent in our output”, but China’s not. See China’s Internet censorship laws.
• China is set to consume lots of energy, as her people get lifted from poverty. The “getting out of poverty” thing is good. It’s just that the world isn’t ready with more energy. It sounds unfair, as there are arguments that 1st World countries (in particular, America) enjoyed unbridled (and rampant) use of energy (coal, oil), yet other countries can’t (when it’s their “turn”). We need those alternative and affordable sources of energy, like yesterday.
• China has bought (as well as other countries) lots of America’s debt, mainly in the form of Treasury bonds.

Please note that this isn’t a China bashing. And note that those authors are American (I think). They weren’t “attacking” China, so much as pointing out probable situations.

So as far as I understand it, China’s growth is fueled primarily by outside investors. It’s domestic consumption is marginal. Jobs are outsourced to China because it’s cheaper there. Manufacturing is done in China because it’s cheaper there, what with the infrastructure the Chinese government had encouraged into place, and the influx of raw materials due to other favourable conditions (such as being cheaper there. Have I mentioned that?).

Here’s a possible situation. America is arrested by her (unimaginably high and increasing) debt crisis, and curbs her consumerist behaviour with less imports (not just from China). Europe has her own debt crisis to deal with. Globally, everyone is affected, because (that I’ve read) 25% of the global economy is due to the exchange of US dollar. China starts to see less investments in manufacturing and building. Australia doesn’t have a strong demand from China for copper, and starts looking somewhere else to invest in. Whatever it is, China’s growth slows and eventually bursts.

Thus the Dragon Bubble.

So who rises? Apparently India and Russia. India, because her measures to lift her people out of poverty are somewhat more stable. People get educated, and get jobs (Is your call centre based in India? Is your development work augmented by, if not outsourced entirely to, Indian developers?). But India still has her old caste system firmly in place, and it will take some time for the growth to spread. But India also has a population just as large as China. And she speaks English.

And learn Mandarin (or Chinese)!. Just in case the Dragon manages to burst through its bubble and has claws in every country in the world. If you can’t speak the tongue of the Dragon, you can’t understand and talk with the Dragon. I’m fine, since I’m bilingual in English and Chinese (as well as C# and VB.NET *smile*).

What about Russia? It turns out that the reason is due to Russia’s possession of oil (lands). Western Siberia, I believe. Hey, I just flip through interesting-looking books.

A couple of definitions to continue with a more light-hearted story. Offshoring is when your company has an office in another country, and your company tasks that office with work. That office is still under your company, perhaps as a wholly owned subsidiary. Outsourcing is when your company tasks an outside company with work. The outside company is involved with your company only so far as being paid is concerned.

Let me tell you a short story. In a previous employment, I had to work with an offshore office in China. That offshore office belonged to a wholly owned subsidiary of my employer, and the subsidiary specialised in IT work. The point was that it’s cheaper for the Chinese there to do certain work than hiring, say, me to do it.

In hindsight, my previous employer entered the offshore/outsource game late. The balance sheet looked great in the short term, but as time went by, and difficulties in coordinating development work increased, the cost savings started to be less prominent.

Hey I understand what you may be going through, or seeing around you. Jobs flying out of your country to “cheaper” countries such as China, India and Philippines. So to make the process easier for you, understand this: If a task can be systematised such that anyone can do it, that task will be systematised so that anyone can do it. If your job consists of checklists doable by paying someone else cheaper, you don’t have that job anymore. Worse, if a task can be automated by computer software, consider it gone.

The offshore team assigned to my team was great. The programmers there did well, once you explained the business requirements and the programming requirements enough to them. But I felt my colleagues here (in Singapore) can explain things too far. One of them went so far as to write the actual SQL statement for use in the code. I felt that was unduly unnecessary.

The more interesting part of the story happened to a colleague’s team. There was a Chinese candidate slated for work in a week’s time. The candidate was a fresh graduate and was hired and assigned to my colleague’s team. The offshore office even sent the candidate’s resume to us. We spent about half an hour marvelling and commenting at the resume written in Chinese, because we’ve never seen one not in English.

One day before the candidate was to report for work, my colleague received notice from the offshore office that the candidate had quit. What? The candidate quit before even starting work? Apparently, a particular university had accepted the candidate, and the candidate decided to pursue a Master’s degree. I don’t know whether to laugh or be outraged.

I intended to write this as a pithy Seth Godin-like post, but apparently I failed. Utterly. I decided not to redact what I’ve written.

## Revenue sharing and operations research – part 3

This is a mini-series on how revenue sharing and operations research are linked. You might want to read part 1 on the specific business problem I was solving, and part 2 for the mathematical formulation of the problem. In this final part, I’ll tell you what was the solution eventually used.

First, although I said it was basically an assignment problem in part 1, on further thought, I don’t believe it is. What I was thinking was “how to assign that \$0.01 such that there are no rounding errors”. Thus the “assignment” part. I apologise for any confusion.

Second, I said the financial/maths formulation was an integer problem. But the values are money values with decimal values, right? How can it be an integer problem? Because it has to also be correct up to 2 decimal places. That means fixed arithmetic. Therefore it becomes an integer problem. Just think of the values as cents (instead of dollars correct up to 2 decimal places).

Now, if you’ve read part 2 (and I applaud you if you actually sat through that mass of maths formulations), you should have guessed that using operations research to solve the business problem was not advisable. It might not even be suitable.

However, the problem still needed to be solved. How do you get rid of any extra or missing money?

### More maths…

Going back to the example I gave in part 1, there were 3 products with revenue to be split between 2 parties. So there were 6 parts. If each part generated a rounding error of +\$0.01, then there was a maximum potential difference of \$0.06 between the original revenue to be shared and the sum of the parts after revenue sharing calculations.

I remind you that whatever solution I came up with had to make mathematical sense and financial sense to the programmers and the users. There are actually 2 goals:

• To have the sum of the parts be equal to the original revenue amount
• To have each part’s amount (after rounding) be as close to the calculated value as possible

The 1st goal ensures no summation errors. After revenue sharing, there are no extra or missing money amounts. This part is actually easy to fulfill. The 2nd goal is fulfilled with a bit of adjustments. So here’s the solution.

### The easy-to-understand maths solution

We split the revenue accordingly to each part first, rounding each part’s amount to 2 decimal places. Then we sort each part in ascending order. Then we sum all the part’s amounts together. If there’s a discrepancy, we correct the discrepancy by adjusting the largest amount. This calls for an example.

Here’s the original example used. Total revenue for the 3 products are:

• ProductA: \$63.13
• ProductB: \$20.75
• ProductC: \$16.12

Assuming a 30-70 percentage split, we have:

• ProductA: \$18.94 (us), \$44.19 (them)
• ProductB: \$6.23 (us), \$14.53 (them)
• ProductC: \$4.84 (us), \$11.28 (them)

Sorting all the parts in ascending order, we have:

• ProductC: \$4.84 (us)
• ProductB: \$6.23 (us)
• ProductC: \$11.28 (them)
• ProductB: \$14.53 (them)
• ProductA: \$18.94 (us)
• ProductA: \$44.19 (them)

The sum of the parts’ amounts is \$100.01, which is not equal to the original revenue being shared (\$100). The discrepancy is a +\$0.01. So we adjust the largest amount. Specifically, we deduct \$0.01 from the largest amount (because our discrepancy is positive).

So the revenue share for the content provider for ProductA becomes \$44.18, and thus the sum of the parts become \$100.

This method ensures that the sum of the each part’s amounts is still equal to the original revenue, which is very important (because this is a financial operation!). This satisfies the 1st goal.

And for each part, the amount is rounded to the nearest 2 decimal place. So each part’s amount is as close to the calculated split value as possible. The only exception is the largest amount might be off a little.

Now I chose the largest amount to “absorb” any rounding discrepancy precisely because it is the largest amount. Note that the term “largest” refers to the magnitude, so if you happen to deal with negative values (it happens, even in financial situations. Consider debt as an example), use the maths absolute function to do the sorting.

Any discrepancy can be mathematically shown to be at most equal to (number of parts) multiply by \$0.01 (rounding error).

D <= ± (N * \$0.01) where D is the discrepancy and N equals the number of parts. Note that the discrepancy is bounded, which is the mathematical way of saying it has an upper and lower limit (or bound). Note also that in a fraction, a larger numerator means a larger fraction and a smaller numerator means a smaller fraction. A larger denominator means a smaller fraction and a smaller denominator means a larger fraction.

Now, whatever the discrepancy value is, it is bounded, it is fixed, and it is a small value. If we want any amount to “absorb” this discrepancy, then the larger the amount, the smaller the resulting error fraction or error percentage.

For example, if the discrepancy is \$0.01 and the amount is \$1, the resulting error percentage is 1% (\$0.01 / \$1.00 * 100%). If the amount is \$5, the resulting error percentage becomes 0.2% (\$0.01 / \$5.00 * 100%).

Suppose the discrepancy is \$0.02. We could spread the discrepancy error among the largest 2 amounts, each amount absorbing \$0.01. But this makes the programming a little more complicated than it is. Also, it makes the algorithm a bit “dynamic”, which makes tracing any calculations by a programmer or user difficult.

### Implementing it in code

All the revenue amounts were stored in the database. Because of this, I recommended that any revenue sharing calculations be done within the database environment itself. Namely, with stored procedures running SQL statements.

Benefits of using stored procedures within the database environment:

• Can sort values easily (use the SORT BY clause)
• Can handle dynamic number of values (with temp tables or the original tables)
• Some calculations can be grouped into a single UPDATE statement
• All the values are in the database!

The last benefit means there’s little switching of context from the database environment to the… whatever environment. In that project, it was scheduled Unix shell scripts combined with C programs that called the stored procedures. We didn’t want the context to switch back to a Unix environment to do calculations. Doing calculations in the Unix environment with C might be fast, but there are many content providers and many products. The context switching might eat up any performance benefits. Besides, having the calculations in a few stored procedures mean better modularity and separation of functions.

### Further considerations

Because we’re in the business of … uh, doing business, we might want the customer to have a better deal. Or at least an easier report to read.

In the method above, we sorted the amounts in ascending order, regardless of whether it’s us or them. So it could well mean that the largest revenue share of the content provider be used to absorb the discrepancy.

This might mean when they read the revenue sharing report, they might question why that amount is \$44.18 instead of \$44.19. It might be just \$0.01 to you, but it’s still money!

What we can do is sort the amounts by theirs first, then ours. And within each, sort by ascending order. So we could have this instead:

• ProductC: \$11.28 (them)
• ProductB: \$14.53 (them)
• ProductA: \$44.19 (them)
• ProductC: \$4.84 (us)
• ProductB: \$6.23 (us)
• ProductA: \$18.94 (us)

In this case, we adjust our revenue share for ProductA to be \$18.93 (instead of \$18.94) so the revenue sum is correct. Basically, we absorb any discrepancy, using our largest revenue share amount.

And that’s the end of the discussion of revenue sharing: the business part, the maths part and the implementing/programming part. Let me know if you have any questions.

## Good grades no longer enough?

Here’s a quote from an article of The Seattle Times:

Valedictorians with straight-A’s were denied admission, while out-of-state students with lower grades were accepted.

The reason?

The decision is based squarely on economics: Nonresident students in effect subsidize the education of Washington residents, providing a much-needed boost in revenue at a time the UW could see its funding cut by \$200 million over the next biennium.

It’s not ideal. Revenue, budgets and other financial concerns affect the direction of education.

I wrote an article on the merits of a debtless university education. However minute or major, money has an impact on how educational institutes are run. Perhaps it’s the focus of the university’s educational efforts (maybe putting more money into “money-making” departments such as business, medical and legal). Perhaps it’s the decision to take in more students who pay more in tuition fees. And lower the number of student intake with perfectly good grades but don’t pay as much in tuition fees.