@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; }
private void setAccountValue() { Object value = getValue(); if (value != null) { Session currentSession = HibernateUtil.getCurrentSession(); Account account = (Account) value; account = (Account) currentSession.load(Account.class, account.getID()); super.setValue(account); } }
@Override protected Result onCompleteProcess(Context context) { List<ClientTransactionItem> items = get(ITEMS).getValue(); List<ClientTransactionItem> accounts = get(ACCOUNTS).getValue(); if (items.isEmpty() && accounts.isEmpty()) { return new Result(); } Vendor supplier = get(VENDOR).getValue(); creditCardCharge.setVendor(supplier.getID()); Contact contact = get(CONTACT).getValue(); creditCardCharge.setContact(toClientContact(contact)); ClientFinanceDate date = get(DATE).getValue(); creditCardCharge.setDate(date.getDate()); creditCardCharge.setType(ClientTransaction.TYPE_CREDIT_CARD_CHARGE); String number = get(NUMBER).getValue(); creditCardCharge.setNumber(number); String paymentMethod = get(PAYMENT_METHOD).getValue(); creditCardCharge.setPaymentMethod(paymentMethod); String phone = get(PHONE).getValue(); creditCardCharge.setPhone(phone); Account account = get(PAY_FROM).getValue(); creditCardCharge.setPayFrom(account.getID()); ClientFinanceDate deliveryDate = get(DELIVERY_DATE).getValue(); creditCardCharge.setDeliveryDate(deliveryDate); items.addAll(accounts); creditCardCharge.setTransactionItems(items); ClientCompanyPreferences preferences = context.getPreferences(); if (preferences.isTrackTax() && !preferences.isTaxPerDetailLine()) { TAXCode taxCode = get(TAXCODE).getValue(); for (ClientTransactionItem item : items) { item.setTaxCode(taxCode.getID()); } } creditCardCharge.setCurrency(supplier.getCurrency().getID()); creditCardCharge.setCurrencyFactor((Double) get(CURRENCY_FACTOR).getValue()); String memo = get(MEMO).getValue(); creditCardCharge.setMemo(memo); updateTotals(context, creditCardCharge, false); create(creditCardCharge, context); return null; }
@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; }