@Override public JSONObject migrate(CompanyPreferences obj, MigratorContext context) throws JSONException { JSONObject commonSettings = new JSONObject(); commonSettings.put( "id", context.get(CompanyMigrator.COMMON_SETTINGS, CompanyMigrator.COMMON_SETTINGS_OLD_ID)); JSONArray currencies = new JSONArray(); for (Currency currency : context.getCompany().getCurrencies()) { JSONObject currencyJson = new JSONObject(); currencyJson.put("identity", currency.getFormalName()); currencies.put(currencyJson); } commonSettings.put("accountingCurrencies", currencies); return commonSettings; }
@Override public JSONObject migrate(CompanyPreferences obj, MigratorContext context) throws JSONException { JSONObject commonSettings = new JSONObject(); commonSettings.put("autoApplycredits", false); commonSettings.put("useBillable", true); commonSettings.put("industryType", getIndustryType(obj.getIndustryType())); commonSettings.put("taxId", obj.getTaxId()); commonSettings.put( "productAndServicesTrackingByCustomer", obj.isProductandSerivesTrackingByCustomerEnabled()); boolean enabledMultiCurrency = obj.isEnabledMultiCurrency(); commonSettings.put("multipleCurrency", enabledMultiCurrency); // commonSettings.put("tIN", obj.isEnabledMultiCurrency()); // commonSettings.put("tAN", obj.isEnabledMultiCurrency()); // commonSettings.put("pAN", obj.isEnabledMultiCurrency()); commonSettings.put( "depreciationStartDate", obj.getDepreciationStartDate().getAsDateObject().getTime()); commonSettings.put("companyName", obj.getTradingName()); String legalName = obj.getLegalName(); if (legalName != null) { commonSettings.put("companyHasLegalName", true); commonSettings.put("legalName", legalName); } else { commonSettings.put("companyHasLegalName", false); } Address tradingAddress = obj.getTradingAddress(); JSONObject jsonAddress = new JSONObject(); jsonAddress.put("street", tradingAddress.getStreet()); jsonAddress.put("city", tradingAddress.getCity()); jsonAddress.put("stateOrProvince", tradingAddress.getStateOrProvinence()); jsonAddress.put("zipOrPostalCode", tradingAddress.getZipOrPostalCode()); jsonAddress.put("country", tradingAddress.getCountryOrRegion()); commonSettings.put("tradingAddress", jsonAddress); commonSettings.put("companyHasRegisteredAddress", obj.isShowRegisteredAddress()); Company company = context.getCompany(); // commonSettings.put("registeredAddress", jsonAddress); commonSettings.put( "accountPayable", context.get("Account", company.getAccountsPayableAccount().getID())); commonSettings.put( "accountReceivable", context.get("Account", company.getAccountsReceivableAccount().getID())); // commonSettings.put("centralSalesTaxPayable",); Account salariesPayableAccount = company.getSalariesPayableAccount(); if (salariesPayableAccount != null) { commonSettings.put("salariesPayable", context.get("Account", salariesPayableAccount.getID())); } commonSettings.put( "taxFiled", context.get("Account", company.getTAXFiledLiabilityAccount().getID())); commonSettings.put( "openingBalances", context.get("Account", company.getOpeningBalancesAccount().getID())); commonSettings.put( "exchangeLossorGain", context.get("Account", company.getExchangeLossOrGainAccount().getID())); commonSettings.put( "costOfGoodsSold", context.get("Account", company.getCostOfGoodsSold().getID())); // Dummy Enble for TAx AGENCY MIGRATION commonSettings.put("chargeOrTrackTax", true); commonSettings.put("taxItemInTransactions", "OnePerTransaction"); commonSettings.put("enableTrackingTaxPaid", true); return commonSettings; }
@Override public JSONObject migrate(Item item, MigratorContext context) throws JSONException { JSONObject jsonObject = new JSONObject(); CommonFieldsMigrator.migrateCommonFields(item, jsonObject, context); jsonObject.put("name", item.getName()); jsonObject.put("isSubItemOf", item.isSubItemOf()); Item parentItem = item.getParentItem(); if (parentItem != null) { jsonObject.put("subItemOf", context.get("Item", parentItem.getID())); } jsonObject.put("iSellThisService", item.isISellThisItem()); jsonObject.put("salesDescription", item.getSalesDescription()); jsonObject.put("salesPrice", item.getSalesPrice()); Account incomeAccount = item.getIncomeAccount(); if (incomeAccount != null) { jsonObject.put("incomeAccount", context.get("Account", incomeAccount.getID())); } jsonObject.put("isTaxable", item.isTaxable()); jsonObject.put("isCommissionItem", item.isCommissionItem()); jsonObject.put("standardCost", item.getStandardCost()); ItemGroup itemGroup = item.getItemGroup(); if (itemGroup != null) { jsonObject.put("itemGroup", context.get("ItemGroup", itemGroup.getID())); } jsonObject.put("inActive", !item.isActive()); jsonObject.put("iBuyThisService", item.isIBuyThisItem()); jsonObject.put("purchaseDescription", item.getPurchaseDescription()); jsonObject.put("purchasePrice", item.getPurchasePrice()); Account expenseAccount = item.getExpenseAccount(); if (expenseAccount != null) { jsonObject.put("expenseAccount", context.get("Account", expenseAccount.getID())); } Vendor preferredVendor = item.getPreferredVendor(); if (preferredVendor != null) { jsonObject.put("preferredVendor", context.get("Vendor", preferredVendor.getID())); } jsonObject.put("vendorServiceNumber", item.getVendorItemNumber()); jsonObject.put("itemType", PicklistUtilMigrator.getItemTypeIdentifier(item.getType())); // assertAccount Account assestsAccount = item.getAssestsAccount(); if (assestsAccount != null) { jsonObject.put("assetAccount", context.get("Account", assestsAccount.getID())); } Quantity reorderPoint = item.getReorderPoint(); if (reorderPoint != null) { double value = reorderPoint.getValue(); Unit unit = reorderPoint.getUnit(); if (unit != null) { jsonObject.put("reOrderPoint", unit.getFactor() * value); } else { jsonObject.put("reOrderPoint", value); } } Account costOfGoodsSold = item.getExpenseAccount(); if (costOfGoodsSold != null) { jsonObject.put("costOfGoodsSold", context.get("Account", costOfGoodsSold.getID())); } Warehouse warehouse = item.getWarehouse(); if (warehouse != null) { jsonObject.put("warehouse", context.get("Warehouse", warehouse.getID())); } Measurement measurement = item.getMeasurement(); if (measurement != null) { jsonObject.put("measurement", context.get("Measurement", measurement.getID())); } jsonObject.put("averageCost", item.getAverageCost()); return jsonObject; }