public void transferMoney(Long sourceAccountId, Long targetAccountId, BigDecimal amount) { Account source = accountDAO.getById(sourceAccountId); Account target = accountDAO.getById(targetAccountId); if (source.getBalance().compareTo(amount) < 0) { throw new NotEnoughMoneyException(); } source.decrementBalance(amount); target.incrementBalance(amount); auditDAO.insertTransaction(sourceAccountId, targetAccountId, amount); // other business logic }
public org.hl7.fhir.instance.model.Account convertAccount(org.hl7.fhir.dstu3.model.Account src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.instance.model.Account tgt = new org.hl7.fhir.instance.model.Account(); copyDomainResource(src, tgt); for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(convertIdentifier(t)); tgt.setName(src.getName()); tgt.setType(convertCodeableConcept(src.getType())); tgt.setStatus(convertAccountStatus(src.getStatus())); tgt.setActivePeriod(convertPeriod(src.getActive())); tgt.setBalance(convertMoney(src.getBalance())); // tgt.setCoveragePeriod(convertPeriod(src.getCoveragePeriod())); tgt.setSubject(convertReference(src.getSubject())); tgt.setOwner(convertReference(src.getOwner())); tgt.setDescription(src.getDescription()); return tgt; }
@Override public Base makeProperty(int hash, String name) throws FHIRException { switch (hash) { case -1618432855: return addIdentifier(); case -892481550: return getStatusElement(); case 3575610: return getType(); case 3373707: return getNameElement(); case -1867885268: return getSubject(); case -991726143: return getPeriod(); case -1422950650: return getActive(); case -339185956: return getBalance(); case -351767064: return addCoverage(); case 106164915: return getOwner(); case -1724546052: return getDescriptionElement(); case -188629045: return addGuarantor(); default: return super.makeProperty(hash, name); } }
public org.hl7.fhir.dstu3.model.Account convertAccount(org.hl7.fhir.instance.model.Account src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Account tgt = new org.hl7.fhir.dstu3.model.Account(); copyDomainResource(src, tgt); for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(convertIdentifier(t)); if (src.hasName()) tgt.setName(src.getName()); if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); tgt.setStatus(convertAccountStatus(src.getStatus())); tgt.setActive(convertPeriod(src.getActivePeriod())); tgt.setBalance(convertMoney(src.getBalance())); // tgt.setCoveragePeriod(convertPeriod(src.getCoveragePeriod())); tgt.setSubject(convertReference(src.getSubject())); tgt.setOwner(convertReference(src.getOwner())); tgt.setDescription(src.getDescription()); return tgt; }
switch (hash) { case -1618432855: // identifier this.getIdentifier().add(castToIdentifier(value)); // Identifier return value; case -892481550: // status value = new AccountStatusEnumFactory().fromType(castToCode(value)); this.status = (Enumeration) value; // Enumeration<AccountStatus> return value; case 3575610: // type this.type = castToCodeableConcept(value); // CodeableConcept return value; case 3373707: // name this.name = castToString(value); // StringType return value; case -1867885268: // subject this.subject = castToReference(value); // Reference return value; case -991726143: // period this.period = castToPeriod(value); // Period return value; case -1422950650: // active this.active = castToPeriod(value); // Period return value; case -339185956: // balance this.balance = castToMoney(value); // Money return value; case -351767064: // coverage this.getCoverage().add((CoverageComponent) value); // CoverageComponent return value;
@Override @Loggable(value = LogLevel.TRACE) @Transactional public void updateBalance(String id, BigDecimal amount) { Account acc = (Account) sessionFactory.getCurrentSession().get(Account.class, id, LockMode.UPGRADE); acc.setBalance(acc.getBalance().subtract(amount)); save(acc); }
public class TestProgram { public static void main(String[] args) throws FileNotFoundException { Date date= new Date(); Account account1 = new Account(5648, 27000, date); account1.withdraw(7500); account1.deposit(11000); System.out.println("Your current balance is" +account1.getBalance()); System.out.println("Monthly interest is"+ account1.getAnnualInterestRate()); System.out.println("The account was created on" + account1.getDateCreated()); } }
double wAmount = new Double(jtfWithdraw.getText().trim()).doubleValue(); double tAmount = new Double(jtfTransfer.getText().trim()).doubleValue(); double cAmount = cAcc.getBalance(); double sAmount = sAcc.getBalance(); cAmount = cAcc.getDeposit(dAmount); break; case 2: sAmount = sAcc.getDeposit(dAmount); break; case 3: cAmount = cAcc.getWithdrawal(wAmount); break; case 4: sAmount = sAcc.getWithdrawal(wAmount); break; case 5: cAmount = cAcc.getTransfer(tAmount); sAmount = sAcc.getDeposit(tAmount); break; case 6: sAmount = sAcc.getTransfer(tAmount); cAmount = cAcc.getDeposit(tAmount); break;
public class AvailableCreditListener { @PostLoad @PostPersist @PostUpdate public void calculateAvailableCredit(Account account) { account.setAvailableCredit( account.getBalance().add( account.getOverdraftLimit())); } }
public Account addAccountTarget() { Account r = new Account(); if (this.accountTarget == null) this.accountTarget = new ArrayList<Account>(); this.accountTarget.add(r); return r; } /** * @return {@link #hospitalization} (Details about the admission to a healthcare service.) */ public EncounterHospitalizationComponent getHospitalization() {
int totalBalance = 0; for(Account account: accounts){ if (account instanceof Saving) { totalBalance = totalBalance + account.getBalance(); } }
/** * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist */ public Identifier getIdentifierFirstRep() { if (getIdentifier().isEmpty()) { addIdentifier(); } return getIdentifier().get(0); }
Account account = (Account) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {Account.class, Serializable.class}, new ExampleInvocationHandler()); // method chaining for the win! account.deposit(5000).deposit(4000).deposit(-2500); System.out.println("Balance: " + account.getBalance());
counter ++; System.out.println("Account details for Account '"+counter+"' :\n"); System.out.println("Account Number : "+ acc.getAccNo() +" Balance :" + acc.getBalance() );
@Override public Base addChild(String name) throws FHIRException { if (name.equals("identifier")) { return addIdentifier(); return addCoverage(); return addGuarantor();
public Account copy() { Account dst = new Account(); copyValues(dst); if (identifier != null) { dst.identifier = new ArrayList<Identifier>(); for (Identifier i : identifier) dst.identifier.add(i.copy()); }; dst.status = status == null ? null : status.copy(); dst.type = type == null ? null : type.copy(); dst.name = name == null ? null : name.copy(); dst.subject = subject == null ? null : subject.copy(); dst.period = period == null ? null : period.copy(); dst.active = active == null ? null : active.copy(); dst.balance = balance == null ? null : balance.copy(); if (coverage != null) { dst.coverage = new ArrayList<CoverageComponent>(); for (CoverageComponent i : coverage) dst.coverage.add(i.copy()); }; dst.owner = owner == null ? null : owner.copy(); dst.description = description == null ? null : description.copy(); if (guarantor != null) { dst.guarantor = new ArrayList<GuarantorComponent>(); for (GuarantorComponent i : guarantor) dst.guarantor.add(i.copy()); }; return dst; }
public org.hl7.fhir.instance.model.Account convertAccount(org.hl7.fhir.dstu3.model.Account src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.instance.model.Account tgt = new org.hl7.fhir.instance.model.Account(); copyDomainResource(src, tgt); for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(convertIdentifier(t)); tgt.setName(src.getName()); tgt.setType(convertCodeableConcept(src.getType())); tgt.setStatus(convertAccountStatus(src.getStatus())); tgt.setActivePeriod(convertPeriod(src.getActive())); tgt.setBalance(convertMoney(src.getBalance())); // tgt.setCoveragePeriod(convertPeriod(src.getCoveragePeriod())); tgt.setSubject(convertReference(src.getSubject())); tgt.setOwner(convertReference(src.getOwner())); tgt.setDescription(src.getDescription()); return tgt; }
public org.hl7.fhir.dstu3.model.Account convertAccount(org.hl7.fhir.instance.model.Account src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Account tgt = new org.hl7.fhir.dstu3.model.Account(); copyDomainResource(src, tgt); for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(convertIdentifier(t)); if (src.hasName()) tgt.setName(src.getName()); if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); tgt.setStatus(convertAccountStatus(src.getStatus())); tgt.setActive(convertPeriod(src.getActivePeriod())); tgt.setBalance(convertMoney(src.getBalance())); // tgt.setCoveragePeriod(convertPeriod(src.getCoveragePeriod())); tgt.setSubject(convertReference(src.getSubject())); tgt.setOwner(convertReference(src.getOwner())); tgt.setDescription(src.getDescription()); return tgt; }
@Override public Base setProperty(String name, Base value) throws FHIRException { if (name.equals("identifier")) { this.getIdentifier().add(castToIdentifier(value)); } else if (name.equals("status")) { value = new AccountStatusEnumFactory().fromType(castToCode(value)); this.status = (Enumeration) value; // Enumeration<AccountStatus> } else if (name.equals("type")) { this.type = castToCodeableConcept(value); // CodeableConcept } else if (name.equals("name")) { this.name = castToString(value); // StringType } else if (name.equals("subject")) { this.subject = castToReference(value); // Reference } else if (name.equals("period")) { this.period = castToPeriod(value); // Period } else if (name.equals("active")) { this.active = castToPeriod(value); // Period } else if (name.equals("balance")) { this.balance = castToMoney(value); // Money } else if (name.equals("coverage")) { this.getCoverage().add((CoverageComponent) value); } else if (name.equals("owner")) { this.owner = castToReference(value); // Reference } else if (name.equals("description")) { this.description = castToString(value); // StringType } else if (name.equals("guarantor")) { this.getGuarantor().add((GuarantorComponent) value); } else return super.setProperty(name, value);
Account temp = findAccount(accountID, 0, size, lastPos); if (temp!= null) { temp.setBalance(temp.getBalance() + adjustment); //updates temp currentBalance } else { System.out.println("No account found. "); }