@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; }
protected void setTaxCodeToItems(TAXCode value) { List<ClientTransactionItem> items = this.get(ITEMS).getValue(); List<ClientTransactionItem> accounts = get(ACCOUNTS).getValue(); List<ClientTransactionItem> allrecords = new ArrayList<ClientTransactionItem>(); allrecords.addAll(items); allrecords.addAll(accounts); for (ClientTransactionItem clientTransactionItem : allrecords) { clientTransactionItem.setTaxCode(value.getID()); } }
private void createDefaultTaxCodes() { Account vatPayable = createAccount( Account.TYPE_OTHER_CURRENT_LIABILITY, AccounterServerConstants.LIABLITY_VATPAYABLE, Account.CASH_FLOW_CATEGORY_OPERATING); // Creating default TaxAgecny for Brazil company Session session = HibernateUtil.getCurrentSession(); TAXAgency defaultVATAgency = new TAXAgency(); defaultVATAgency.setActive(Boolean.TRUE); defaultVATAgency.setTaxType(TAXAgency.TAX_TYPE_VAT); defaultVATAgency.setName("Mehrwertsteuer Tax Agency"); defaultVATAgency.setVATReturn(0); defaultVATAgency.setPurchaseLiabilityAccount(vatPayable); defaultVATAgency.setSalesLiabilityAccount(vatPayable); defaultVATAgency.setDefault(true); defaultVATAgency.setCompany(company); session.save(defaultVATAgency); TAXItem vat8TaxItem = new TAXItem(company); vat8TaxItem.setName("MwSt. 8%"); vat8TaxItem.setActive(true); vat8TaxItem.setDescription("MwSt. 8%"); vat8TaxItem.setTaxRate(8.0); vat8TaxItem.setTaxAgency(defaultVATAgency); vat8TaxItem.setVatReturnBox(null); vat8TaxItem.setDefault(true); vat8TaxItem.setPercentage(true); session.save(vat8TaxItem); TAXItem vat4TaxItem = new TAXItem(company); vat4TaxItem.setName("MwSt. 4%"); vat4TaxItem.setActive(true); vat4TaxItem.setDescription("MwSt. 4%"); vat4TaxItem.setTaxRate(4.0); vat4TaxItem.setTaxAgency(defaultVATAgency); vat4TaxItem.setVatReturnBox(null); vat4TaxItem.setDefault(true); vat4TaxItem.setPercentage(true); session.save(vat4TaxItem); TAXItem vat2_8TaxItem = new TAXItem(company); vat2_8TaxItem.setName("MwSt. 2.8%"); vat2_8TaxItem.setActive(true); vat2_8TaxItem.setDescription("MwSt. 2.8%"); vat2_8TaxItem.setTaxRate(2.8); vat2_8TaxItem.setTaxAgency(defaultVATAgency); vat2_8TaxItem.setVatReturnBox(null); vat2_8TaxItem.setDefault(true); vat2_8TaxItem.setPercentage(true); session.save(vat2_8TaxItem); TAXItem vatzeroTaxItem = new TAXItem(company); vatzeroTaxItem.setName("Zero-Rate MwSt. 0.0%"); vatzeroTaxItem.setActive(true); vatzeroTaxItem.setDescription("Zero-Rate MwSt. 0.0%"); vatzeroTaxItem.setTaxRate(0.0); vatzeroTaxItem.setTaxAgency(defaultVATAgency); vatzeroTaxItem.setVatReturnBox(null); vatzeroTaxItem.setDefault(true); vatzeroTaxItem.setPercentage(true); session.save(vatzeroTaxItem); TAXItem vatExemptTaxItem = new TAXItem(company); vatExemptTaxItem.setName("USt.-frei."); vatExemptTaxItem.setActive(true); vatExemptTaxItem.setDescription("USt.-frei"); vatExemptTaxItem.setTaxRate(0); vatExemptTaxItem.setTaxAgency(defaultVATAgency); vatExemptTaxItem.setVatReturnBox(null); vatExemptTaxItem.setDefault(true); vatExemptTaxItem.setPercentage(true); session.save(vatExemptTaxItem); // Creating TaxCodes TAXCode vat8Code = new TAXCode(company); vat8Code.setName("MwSt. 8%"); vat8Code.setDescription("MwSt. 8%"); vat8Code.setTaxable(true); vat8Code.setActive(true); vat8Code.setTAXItemGrpForPurchases(vat8TaxItem); vat8Code.setTAXItemGrpForSales(vat8TaxItem); vat8Code.setDefault(true); session.save(vat8Code); TAXCode vat2_8Code = new TAXCode(company); vat2_8Code.setName("MwSt. 2.8%"); vat2_8Code.setDescription("MwSt. 2.8%"); vat2_8Code.setTaxable(true); vat2_8Code.setActive(true); vat2_8Code.setTAXItemGrpForPurchases(vat2_8TaxItem); vat2_8Code.setTAXItemGrpForSales(vat2_8TaxItem); vat2_8Code.setDefault(true); session.save(vat2_8Code); TAXCode vat4Code = new TAXCode(company); vat4Code.setName("MwSt. 4%"); vat4Code.setDescription("MwSt. 4%"); vat4Code.setTaxable(true); vat4Code.setActive(true); vat4Code.setTAXItemGrpForPurchases(vat4TaxItem); vat4Code.setTAXItemGrpForSales(vat4TaxItem); vat4Code.setDefault(true); session.save(vat4Code); TAXCode vatZeroCode = new TAXCode(company); vatZeroCode.setName("MwSt. 4%"); vatZeroCode.setDescription("MwSt. 4%"); vatZeroCode.setTaxable(true); vatZeroCode.setActive(true); vatZeroCode.setTAXItemGrpForPurchases(vatzeroTaxItem); vatZeroCode.setTAXItemGrpForSales(vatzeroTaxItem); vatZeroCode.setDefault(true); session.save(vatZeroCode); TAXCode vatExemptCode = new TAXCode(company); vatExemptCode.setName("USt.-frei."); vatExemptCode.setDescription("USt.-frei."); vatExemptCode.setTaxable(true); vatExemptCode.setActive(true); vatExemptCode.setTAXItemGrpForPurchases(vatExemptTaxItem); vatExemptCode.setTAXItemGrpForSales(vatExemptTaxItem); vatExemptCode.setDefault(true); session.save(vatExemptCode); }