Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Make a guess for the correct code value for the provided vat rate. Guessing is necessary as
     * the correct code is not part of the XML invoice.
     * 
     * @param vatRate
     * @return
     */
    public static int guessVatCode(String vatRate) {
        if (vatRate != null && !vatRate.isEmpty()) {
            double scale = Double.parseDouble(vatRate);
            // make a guess for the correct code
            if (scale == 0)
                return 0;
            else if (scale < 7)
                return 2;
            else
                return 1;
        }
        return 0;
    }
}