use of com.autentia.tnt.businessobject.BillPayment in project TNTConcept by autentia.
the class BillExpirationDateBean method createBillPayment.
public String createBillPayment(Bill bill) {
final BillPayment item = new BillPayment();
item.setBill(bill);
if (bill.getBillPayment() == null) {
bill.setBillPayment(new HashSet());
}
bill.getBillPayment().add(item);
return null;
}
use of com.autentia.tnt.businessobject.BillPayment in project TNTConcept by autentia.
the class BillAndBillPaymentTest method testLastPayment.
/**
* Inserción de tres pagos para comprobar que la factura vence el dia que vence el ultimo pago
* o cobro
*/
@Test
public void testLastPayment() {
final BillDAO billDAO = (BillDAO) SpringUtilsForTesting.getSpringBean("daoBill");
insertInitialData();
// se crean 3 fechas para los pagos, el 1 de enero, el 1 de julio y el 31 de diciembre de 2000
final Calendar _2000enero01 = Calendar.getInstance();
_2000enero01.set(2000, Calendar.JANUARY, 1);
final Calendar _2000julio01 = Calendar.getInstance();
_2000julio01.set(2000, Calendar.JULY, 1);
final Calendar _2000diciembre31 = Calendar.getInstance();
_2000diciembre31.set(2000, Calendar.DECEMBER, 31);
// se crean 3 pagos y se les ponen fechas
final BillPayment firstPayment = new BillPayment();
firstPayment.setAmount(new BigDecimal(1000));
firstPayment.setExpirationDate(_2000julio01.getTime());
firstPayment.setBill(bill);
bill.getBillPayment().add(firstPayment);
final BillPayment secondPayment = new BillPayment();
secondPayment.setAmount(new BigDecimal(1000));
secondPayment.setExpirationDate(_2000diciembre31.getTime());
secondPayment.setBill(bill);
bill.getBillPayment().add(secondPayment);
final BillPayment thirdPayment = new BillPayment();
thirdPayment.setAmount(new BigDecimal(1000));
thirdPayment.setExpirationDate(_2000enero01.getTime());
thirdPayment.setBill(bill);
bill.getBillPayment().add(thirdPayment);
// se fuerza el guardado en base de datos de los pagos ya que el calculo del ultimo plazo
// se realiza mediante un mapeo de tipo formula
sessionFactory.getCurrentSession().getTransaction().commit();
sessionFactory.getCurrentSession().beginTransaction();
// se recupera la factura y con ello se recalcula el campo de tipo formula
bill = billDAO.loadById(bill.getId());
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String fechaFactura = sdf.format(bill.getExpiration());
String fecha31Diciembre = sdf.format(_2000diciembre31.getTime());
if (!fechaFactura.equals(fecha31Diciembre)) {
fail("la factura deberia finalizar el " + fecha31Diciembre + " en vez de el " + fechaFactura);
}
}
use of com.autentia.tnt.businessobject.BillPayment in project TNTConcept by autentia.
the class BillManager method insertBillInCreditTitle.
public void insertBillInCreditTitle(final Bill bill, final CreditTitle creditTitle, boolean createBillPayment) {
// la factura cambia de estado a 'incluida en pagaré' [bugzilla:2620]
bill.setState(BillState.IN_CREDITTITLE);
// Al asociar un pagaré a una factura no debería ser obligatorio que aparezca un nuevo vencimiento en la factura [bugzilla:3016]
if (createBillPayment) {
// se crea un pago de dicha factura en la fecha y cantidades indicadas en el pagaré [bugzilla:2641]
final BillPayment payment = new BillPayment();
payment.setBill(bill);
payment.setAmount(creditTitle.getAmount().abs());
payment.setExpirationDate(creditTitle.getExpirationDate());
bill.getBillPayment().add(payment);
}
this.updateEntity(bill);
}
use of com.autentia.tnt.businessobject.BillPayment in project TNTConcept by autentia.
the class BillAndBillPaymentTest method testCreateBillWithOnlyOnePayment.
/**
* Inserción de sólo un pago
*/
@Test
public void testCreateBillWithOnlyOnePayment() {
final BillDAO billDAO = (BillDAO) SpringUtilsForTesting.getSpringBean("daoBill");
insertInitialData();
final BillPayment payment = new BillPayment();
payment.setAmount(new BigDecimal(1000));
payment.setExpirationDate(new Date());
payment.setBill(bill);
bill.getBillPayment().add(payment);
billDAO.update(bill);
if (bill.getBillPayment().size() != 1) {
fail("la factura deberia tener 1 pago, pero tiene " + bill.getBillPayment().size());
}
}
use of com.autentia.tnt.businessobject.BillPayment in project TNTConcept by autentia.
the class BillExpirationDateBean method updateExpirationDate.
// private Set<BillPayment> billPayment = new LinkedHashSet<BillPayment>();
public void updateExpirationDate() {
// TODO extract login name to a properties file
authenticateAs(ConfigurationUtil.getDefault().getAdminUser());
List<Bill> bills = BillManager.getDefault().getAllEntities(null, new SortCriteria("name"));
for (Bill b : bills) {
Date creationDate = b.getCreationDate();
creationDate.setMonth(creationDate.getMonth() + 1);
if (!b.getBillPayment().isEmpty()) {
for (BillPayment bp : b.getBillPayment()) {
bp.setExpirationDate(creationDate);
}
} else {
// creamos el billPayment para el expirationDate
createBillPayment(b);
for (BillPayment bp : b.getBillPayment()) {
bp.setExpirationDate(creationDate);
}
}
}
}
Aggregations