⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 taxwareutl.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        } catch (DataFileException e) {            Debug.logError(e, module);            throw new TaxwareException("Cannot load datafile.");        }        return df;    }    public static void loadLib() throws TaxwareException {        try {            System.loadLibrary("taxcommon");        } catch (UnsatisfiedLinkError e) {            Debug.logError(e, module);            throw new TaxwareException("Cannot load libtaxcommon.so/taxcommon.dll.", e);        }    }    private StringBuffer taxCalc(StringBuffer outBuffer) throws DataFileException, TaxwareException {        StringBuffer inBuffer = new StringBuffer();        int result = callTaxware(outBuffer.toString(), inBuffer);        if (Debug.verboseOn()) Debug.logVerbose("Taxware Return: " + result, module);        if (result != 1)            throw new TaxwareException("Taxware processing failed (" + result + ")");        if (Debug.verboseOn()) Debug.logVerbose("::Return String::", module);        if (Debug.verboseOn()) Debug.logVerbose("\"" + inBuffer.toString() + "\"", module);        return inBuffer;    }    private int callTaxware(String inString, StringBuffer outBuffer) throws TaxwareException {        try {            return taxcommon.CalculateTax(inString, outBuffer);        } catch (Exception e) {            throw new TaxwareException("Problems running JNI wrapper.", e);        }    }    private void checkFields() throws TaxwareException {        if (!setShipping)            throw new TaxwareException("Shipping amount has not been set.");        if (shipToAddress == null)            throw new TaxwareException("Shipping address has not been set.");        if (records.size() == 0)            throw new TaxwareException("No items have been defined.");    }    private int processOutFile(StringBuffer retBuffer) throws DataFileException, TaxwareException {        DataFile retHead = createDataFile("TaxwareInHead");        DataFile retItem = createDataFile("TaxwareInItem");        String headStr = retBuffer.toString().substring(0, 283);        String itemStr = retBuffer.toString().substring(284);        if (Debug.verboseOn()) Debug.logVerbose("Return Size: " + retBuffer.length(), module);        GenericDelegator delegator = shipToAddress.getDelegator();        retHead.readDataFile(headStr);        retItem.readDataFile(itemStr);        List retRecords = retItem.getRecords();        Iterator i = retRecords.iterator();        if (Debug.verboseOn()) Debug.logVerbose("Returned Records: " + retRecords.size(), module);        if (Debug.verboseOn()) Debug.logVerbose("Sent Items: " + records.size(), module);        while (i.hasNext()) {            Record rec = (Record) i.next();            ModelRecord model = rec.getModelRecord();            // make the adjustment lists            if (itemAdjustments.size() < records.size()) {                List currentItem = new ArrayList();                if (rec.getDouble("TAX_AMT_COUNTRY").doubleValue() > 0) {                    if (Debug.verboseOn()) Debug.logVerbose("Country Tax Amount: " + rec.getDouble("TAX_AMT_COUNTRY"), module);                    Double rate = new Double(rec.getDouble("TAX_RATE_COUNTRY").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_COUNTRY").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_COUNTRY") != null ? rec.getString("JUR_COUNTRY").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    currentItem.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_COUNTRY"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }                if (rec.getDouble("TAX_AMT_STATE").doubleValue() > 0) {                    Double rate = new Double(rec.getDouble("TAX_RATE_STATE").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_STATE").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_STATE") != null ? rec.getString("JUR_STATE").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    currentItem.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_STATE"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }                if (rec.getDouble("TAX_AMT_COUNTY").doubleValue() > 0) {                    Double rate = new Double(rec.getDouble("TAX_RATE_COUNTY").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_COUNTY").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_COUNTY_CODE") != null ? rec.getString("JUR_COUNTY_CODE").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    currentItem.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_COUNTY"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }                if (rec.getDouble("TAX_AMT_CITY").doubleValue() > 0) {                    Double rate = new Double(rec.getDouble("TAX_RATE_CITY").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_CITY").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_CITY") != null ? rec.getString("JUR_CITY").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    currentItem.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_CITY"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }                if (rec.getDouble("TAX_AMT_SEC_STATE").doubleValue() > 0) {                    Double rate = new Double(rec.getDouble("TAX_RATE_SEC_STATE").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_SEC_STATE").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_SEC_STATE") != null ? rec.getString("JUR_SEC_STATE").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    currentItem.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_SEC_STATE"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }                if (rec.getDouble("TAX_AMT_SEC_COUNTY").doubleValue() > 0) {                    Double rate = new Double(rec.getDouble("TAX_RATE_SEC_COUNTY").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_SEC_COUNTY").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_SEC_COUNTY_CODE") != null ? rec.getString("JUR_SEC_COUNTY_CODE").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    currentItem.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_SEC_COUNTY"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }                if (rec.getDouble("TAX_AMT_SEC_CITY").doubleValue() > 0) {                    Double rate = new Double(rec.getDouble("TAX_RATE_SEC_CITY").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_SEC_CITY").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_SEC_CITY") != null ? rec.getString("JUR_SEC_CITY").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    currentItem.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_SEC_CITY"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }                // add a list of adjustments to the adjustment list                itemAdjustments.add(currentItem);            } else if (orderAdjustments.size() == 0) {                if (rec.getDouble("TAX_AMT_COUNTRY").doubleValue() > 0) {                    Double rate = new Double(rec.getDouble("TAX_RATE_COUNTRY").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_COUNTRY").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_COUNTRY") != null ? rec.getString("JUR_COUNTRY").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    orderAdjustments.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_COUNTRY"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }                if (rec.getDouble("TAX_AMT_STATE").doubleValue() > 0) {                    Double rate = new Double(rec.getDouble("TAX_RATE_STATE").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_STATE").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_STATE") != null ? rec.getString("JUR_STATE").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    orderAdjustments.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_STATE"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }                if (rec.getDouble("TAX_AMT_COUNTY").doubleValue() > 0) {                    Double rate = new Double(rec.getDouble("TAX_RATE_COUNTY").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_COUNTY").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_COUNTY_CODE") != null ? rec.getString("JUR_COUNTY_CODE").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    orderAdjustments.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_COUNTY"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }                if (rec.getDouble("TAX_AMT_CITY").doubleValue() > 0) {                    Double rate = new Double(rec.getDouble("TAX_RATE_CITY").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_CITY").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_CITY") != null ? rec.getString("JUR_CITY").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    orderAdjustments.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_CITY"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }                if (rec.getDouble("TAX_AMT_SEC_STATE").doubleValue() > 0) {                    Double rate = new Double(rec.getDouble("TAX_RATE_SEC_STATE").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_SEC_STATE").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_SEC_STATE") != null ? rec.getString("JUR_SEC_STATE").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    orderAdjustments.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_SEC_STATE"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }                if (rec.getDouble("TAX_AMT_SEC_COUNTY").doubleValue() > 0) {                    Double rate = new Double(rec.getDouble("TAX_RATE_SEC_COUNTY").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_SEC_COUNTY").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_SEC_COUNTY_CODE") != null ? rec.getString("JUR_SEC_COUNTY_CODE").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    orderAdjustments.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_SEC_COUNTY"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }                if (rec.getDouble("TAX_AMT_SEC_CITY").doubleValue() > 0) {                    Double rate = new Double(rec.getDouble("TAX_RATE_SEC_CITY").doubleValue() * 100);                    String type = rec.getString("TAX_TYPE_SEC_CITY").equals("S") ? "SALES TAX" : "USE TAX";                    String jur = rec.get("JUR_SEC_CITY") != null ? rec.getString("JUR_SEC_CITY").trim() : "";                    String comments = jur + "|" + type + "|" + rate.toString();                    orderAdjustments.add(delegator.makeValue("OrderAdjustment",                            UtilMisc.toMap("amount", rec.getDouble("TAX_AMT_SEC_CITY"),                                "orderAdjustmentTypeId", "SALES_TAX", "comments", comments)));                }            } else {                throw new TaxwareException("Invalid number of return adjustments.");            }            for (int a = 0; a < model.fields.size(); a++) {                ModelField mf = (ModelField) model.fields.get(a);                String name = mf.name;                String value = rec.getString(name);                if (Debug.verboseOn()) Debug.logVerbose("Field: " + name + " => " + value, module);            }        }        return retRecords.size();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -