Monday, July 13, 2015

Calculate Tax by the Tax Slab

I tried in the Internet to see the Tier based tax calculation , Though it looks simple i didnt get any correct solution.
Then I started wrote that logic and thought of publishing it here.


Lets assume , The give amount is Rs. 640 and we need to calculate Tax for that.

Tax Slabs are given below


Tier Range Percentage
1-30010
301-60020
601-100030
1001 and above40


The Tax Calculation for the given Amount Rs. 640 should be like this

           for the first 300 Rs                                            Tax    :                  30
           Second Tier   up to 600 Rs                               Tax    :                   60
          Last /  Third Tier    up to 40 Rs                          Tax   :                   12


Total Tax Amount :  102

The method to do this operation given below



private static void calculate( double salary) {

    TierRange[] tierRanges = new TierRange[] {

            new TierRange(1, 300, 1.25), new TierRange(301, 600, 1.75), new TierRange(601, 1000, 2.25),
            new TierRange(1001, 999999, 2.75),

    };
    double  given = salary;

    double amount = 0.0;

    if (given == 0) {
        amount = 0;
    } else {

        for (TierRange tierRange : tierRanges) {

            int calcValue = 0;
            if (given >= tierRange.low && given <= tierRange.high) {
                calcValue = (given - tierRange.low) + 1;
                amount += (calcValue * tierRange.value);
                System.out.println(given+"  "+calcValue+"  "+amount+" "+(calcValue * tierRange.value));
                break;
            } else {
                calcValue = (tierRange.high - tierRange.low) + 1;
                amount += (calcValue * tierRange.value);
                System.out.println(given+"  "+calcValue+"  "+amount+" "+(calcValue * tierRange.value));
            }

        }
    }


TierRange is a class which contains 3 fields low , high and percentage .



The same can be done using a Stored Procedure also

       

Assume Tier Ranges comes from a Table called

BILL_ADMIN.TIER_TEMPLATE

The query to fetch the Tier Range given below

SELECT TIER_START , TIER_END , RATE_PU FROM BILL_ADMIN.TIER_TEMPLATE;


TIER_START   --- Low Range
 TIER_END      ----  High Range
 RATE_PU       --- Rate Percentage


create or replace PROCEDURE BILLINGCALCPROC
IS

T_GIVEN NUMBER;
T_TIER_START NUMBER ;
T_TIER_END NUMBER;
T_RATE_PU NUMBER;
T_CALCVAL NUMBER;
T_BILL_ID VARCHAR2(30);
T_AMOUNT NUMBER;

CURSOR BILL_CALC
IS
SELECT TOTAL_UNIT, BILL_ID FROM BILL_ADMIN.MONTHLY_INVOICE ;
CURSOR TIER_RANGE
IS
SELECT TIER_START , TIER_END , RATE_PU FROM BILL_ADMIN.TIER_TEMPLATE;


BEGIN

OPEN BILL_CALC;
LOOP
FETCH BILL_CALC INTO T_GIVEN ,T_BILL_ID;
EXIT
WHEN BILL_CALC%NOTFOUND;
T_AMOUNT := 0;
IF (T_GIVEN=0) THEN
UPDATE BILL_ADMIN.MONTHLY_INVOICE SET AMOUNT = 0 WHERE BILL_ID = T_BILL_ID;
ELSE
OPEN TIER_RANGE;
LOOP
FETCH TIER_RANGE INTO T_TIER_START ,T_TIER_END, T_RATE_PU;
EXIT
WHEN TIER_RANGE%NOTFOUND;
T_CALCVAL := 0;
IF(T_GIVEN >= T_TIER_START AND T_GIVEN <= T_TIER_END) THEN
T_CALCVAL := (T_GIVEN - T_TIER_START ) +1;
T_AMOUNT := T_AMOUNT + (T_CALCVALT_RATE_PU);
UPDATE BILL_ADMIN.MONTHLY_INVOICE
SET AMOUNT = T_AMOUNT
WHERE BILL_ID = T_BILL_ID;
GOTO LOOP_END;
ELSE
T_CALCVAL := (T_TIER_END - T_TIER_START ) +1;
T_AMOUNT := T_AMOUNT + (T_CALCVALT_RATE_PU);
END IF;
END LOOP;
<>
CLOSE TIER_RANGE;
END IF;
END LOOP;
CLOSE BILL_CALC;
COMMIT;
END;


This is for the Refernce .



Thursday, March 26, 2015

Make in India - My Version



I am living in a House  with nice backyard.  It has good ambiance, no noise pollution or air pollution.
It has very good water sources too .


One day , I  invited a businessman to my home and offered him to use my backyard for rent.
He agreed. He came with 1000 Rs investment money to my home. He offered Rs. 150 as rent to use my backyard and one more Rs. 150 for me to work as Employee for him.  I too happily agreed for that.


Businessman purchased raw materials for Rs.700 , started manufacturing work in my backyard. He has completed the manufacturing work and the final product is ready now.


He sold the final product to me and my neighbor , each costs Rs. 600.  He finally left with money Rs 1200. He got 20%  profit. I got employment and rent from him . I felt my lifestyle got improved .


Do you think this is a happy ending story  ?


Oh sorry ,please wait,  i missed to tell few things in this story.
The manufacturing work created few other things too


  • It created air pollution and noise pollution
  • It took plenty of water resources also
  • it left out huge of amount Chemical waste in my backyard which will not go away for years.
  • Last but not the least , the manufactured product is a Gun or Bomb. ( I hope everybody knows Make in India is not for consumer products , it is to manufacture weapons in India ).


Now , please decide what kind of story it is and do we really need “Make In India”.




                      










Thursday, February 26, 2015

Network Drive Mapping for Windows Services

This Article will explain about the steps need to be followed to use the Network Shared folders in the
Windows Services .

When we see the " Directory Path Invalid  " error during the Service start up, most of solutions
comes in Google search will tell us to use the UNC (Universal Naming Convention) Path for instead of Shared Folder mapping.

But sometimes the UNC path is not a perfect solution, especially in my  case where it has $ symbol in that path.  The Shared folder is from one windows server and it has a $ symbol in the path .

The UNC path with the $ symbol is not  accepted by the Apache  HTTP server while publishing the directory using the Alias name.

So what we did to resolve this issue.

the solution is we should have  a Drive letter for the mapped Shared Folder and it should be with the user
NT AUTHORITY / SYSTEM ..

Here is the one time setup to resolve this issue.


1. Download the Sysinternals Suite to the system from Microsoft website.
2.  Unzip the suite and keep it in some folder. (Ex C:\tmp)
3. Open the Command prompt using Run as Administrator .
4. type whoami in the command prompt it will show ur user id .
5. Go to Sysinternals suite folder and execute the following command
                      psexec -i -s comd.exe
        It will open a new command prompt.
       if check user id using the command whoami  .. It will display NT AUTHORITY \SYSTEM.
6. In the new command prompt execute the mapping command

        Syntax
                            net use DRIVELETTER: UNCPath /persistent:yes /savecre

       Ex  :
                            net use L: \\server1\folder1  /persistent /savecre

7. Now a New Drive will be available in the My Computer with the Title "Disconnected Network Drive"
    Don't worry about the title it is connected and you can access the files.
    Except  the user System for all others it will display as Disconnected Network Drive .
8. Now go to Apache HTTP Server Config file (httpd.conf)  which is available in the installed folder
   under conf directory .
 
     The Directory directive used to publish the files to the browser can use the newly created Drive path.



In case if you want to have the drive connected every time you logged in , you can add the step
6 command in a batch file.

Open the Control Panel --> Administrative Tools --> Scheduled Tasks - Schedule a Task and should run as "SYSTEM" .

That's all !!!
 Now start the HTTP Server and it will serve you those files.




Sunday, July 6, 2014

An Introduction to Visual IVR

The first thing coming to your mind when you are about to call a customer care, the  pre recorded or dynamically generated audio.  At sometimes you would have felt that Why these people don't change the style of messages .
        
     Interactive voice response (IVR) is a technology that allows a computer to interact with humans through the use of voice (Automatic Speech Recognition -ASR ) and DTMF (Dual Tone Multiple Frequency ) tones input via keypad, which is commonly used among customers and companies. Before get to know about the alternatives we have let's see what are the common problems we face with our current methods
When the world was limited with traditional Copper line phone people find it easy  ,still finding  it easy though the current world is  powered by smart phones? . Are we not in a position to create them with the awareness on the new technology ? which will make the work more simpler and easier.

Navigating an IVR is uncomfortable, waiting to hear all the right options to make sure you select the right one.  whether you have to go for 1 or 8 or others will be a  big question , any change in the menu tree will need very careful listening. In case of voice recognition , voice is necessarily linear, which makes any IVR time consuming and uninteresting. Otherwise we will end of hearing one more automated response of  " Sorry, I didn’t understand".

Trust me , IVR and  mobile phones are not made for each other . Constantly The caller needs to pull the phone away from their ear to press the right choice . In between he should not disconnect the call or the network should not break.
Now  ,  the better solution  is   ,  Visual IVR, as per wiki ,  Visual Interactive Voice Response  is conceptually similar to voice Interactive voice response (IVR) but with the addition of visual menus to enhance the experience. The user interacts with a visual interface by touch or click commands on his mobile or computer screen.  Visual IVR is sometimes known as Graphical Content Routing (GCR).
Now We  can expand the IVR experience by providing visually guided menus on your website or on your customer’s Smartphone. Visual IVR provides your customers with a convenient menu driven interface to your IVR. This allows your users to quickly select the options they need, saving them time, and   money.
Sample Visual IVR from http://www.radishsystems.com/for-developers/for-ivr-developers/

The advantages will be ,
  • scanning a screen is quicker than listening to lengthy menus and remembering the right choice
  • customers will no longer have to simultaneously use their telephone keypad and listen to lengthy menus in an effort to remember which number corresponds to which category.
  • We no need to build the Visual IVR from the scratch , It reuses the same Voice XML (“VXML”) scripts that your current IVR runs on to provide seamless experience to the Customer .
  • Updating the basic information like contact address , email id , phone number can be done better than IVR.

In addition to all the benefits of IVR , Visual IVR gives more options for the non-tech-savvy users to access their information easier way.

Thursday, August 20, 2009

No to Boys in Nursing Studies -- Is it Correct ?

Please refer the below link before reading . http://timesofindia.indiatimes.com/articleshow/4912815.cms

I know you all will be busy and will not have time to read :-)

Let me give the Brief Intro about the topic.

Till 2007 , Govt. of Tamil Nadu permitted 10 % of seat for Boys in Nursing Courses.

From Last Year onwards they decided to make it ALL-GIRLS courses ( அனைத்து மகளிர் காவல் நிலையம் மாதிரி ) . One boy whose application rejected by the authorities due to this rule , challenged it in High Court.

Based on the points given by the Government , HC Judge Suguna ( Lady Judge? முடியல :-( ) accepted the Govt. Rule and dismissed the writ petition of the Male Student.

Two Major points mentioned by Govt.

1. As per the New Syllabus midwifery had been made a mandatory to complete the training.

Which boys can not be completed because women wont accept to have a boy in labour ward .

2. We have enough Male Nurses to provide Essential services in ( jail, ortho department, mental health hospitals and operation theatres ) till 2045 .

Lets analyse the issue point by point . And my questions are

1. They accepted the their service required in several places where Female nurse can not go.

How many male Nurses available with less than age 24 in Tamil Nadu? ( Because to be in service till 2045 , his Age should be in the limit ) . is the Count enough to service the Whole tamil Nadu ?

Just by a logical thinking we can say the count should be very less and Govt . gave a wrong information .

2. Lets assume , Some train accident happened in interior Forest , how many female nurses ready to go and help the Doctors where there may not be enough Lights , Tents are available .

Even if they say Female Nurses can do , Is it advisable to take them to those areas ? Most of time giving protection to them and taking care their basic needs will be big problem for us . Isn't it?

We know In Police also , they wont allow female PCs to go alone in emergency situation also .

They will go with some Male constables for safety purpose.

3. Who will work in Remote village Hospitals ( Where most of the time only Nurses will be Doctors ) ? Is it possible to get their help in Mid Nights due to some emergency ? Can we ask them to come and do some help to some more interior place ? During this time only the Pharmacist is helping now .

4. When a Male Doctor can do surgery / delivery for women , why cant a Male Nurse assist him ?

5. In Border Security Forces recently Women are joined . They allowed to avoid few trainings because that will be very much difficult for them ( as a women ) . Why cant they do the same kind relaxation for the Boys in Nursing Training ?

6 . Male patients wont feel uncomfortable with Female Nurses ? ( of course no :-) ) , but just think in that perspective.

Just to allow 10% of Seats in Nursing , they are making this much problem :-( . Too bad.

No Male representative in to decide the syllabus for Nursing i think.

So what you think about this ?