Esempio n. 1
0
  @Test
  public void testPayroll() throws Exception {
    Vendor vendor = new Vendor(entityManager);
    Patient patient = new Patient(entityManager).setVendor(vendor);
    Nurse nurse =
        new Nurse(entityManager)
            .setPayFlat(100)
            .setPayRate(40)
            .setPayFlat2HrSoc(95)
            .setPayRate2HrSoc(60)
            .setPayFlat2HrRoc(90)
            .setPayRate2HrRoc(50);
    DateTime timeIn = DateTime.now().minusHours(2);
    DateTime timeOut = DateTime.now();
    Appointment appointment =
        new Appointment(entityManager)
            .setPatient(patient)
            .setNurse(nurse)
            .setStart(DateTime.now())
            .setTimeInD(timeIn)
            .setTimeOutD(timeOut);
    assertEquals(2.0, appointment.getLoggedHours(), 0.0);
    assertEquals(GenData.ACCOUNTING_TYPE_SOC_2HR.get(entityManager), appointment.getPayingType());
    assertEquals(95.0, appointment.getPayFlat(), 0.0);
    assertEquals(0.0, appointment.getPayHours(), 0.0);
    assertEquals(60.0, appointment.getPayRate(), 0.0);
    assertEquals(95.0, appointment.getPaymentTotal(), 0.0);

    appointment.setTimeInD(timeIn.minusHours(1));
    assertEquals(3.0, appointment.getLoggedHours(), 0.0);
    assertEquals(GenData.ACCOUNTING_TYPE_HOURLY.get(entityManager), appointment.getPayingType());
    assertEquals(0.0, appointment.getPayFlat(), 0.0);
    assertEquals(40.0, appointment.getPayRate(), 0.0);
    assertEquals(3.0, appointment.getPayHours(), 0.0);
    assertEquals(120.0, appointment.getPaymentTotal(), 0.0);

    appointment.setPayingType(GenData.ACCOUNTING_TYPE_FIXED.get(entityManager));
    assertEquals(GenData.ACCOUNTING_TYPE_FIXED.get(entityManager), appointment.getPayingType());
    assertEquals(3.0, appointment.getLoggedHours(), 0.0);
    assertEquals(100.0, appointment.getPayFlat(), 0.0);
    assertEquals(0.0, appointment.getPayHours(), 0.0);
    assertEquals(0.0, appointment.getPayRate(), 0.0);
    assertEquals(100.0, appointment.getPaymentTotal(), 0.0);

    appointment.setTimeInD(timeIn.plusMinutes(105));
    appointment.setPayingType(GenData.ACCOUNTING_TYPE_FIXED.get(entityManager));
    assertEquals(GenData.ACCOUNTING_TYPE_FIXED.get(entityManager), appointment.getPayingType());
    assertEquals(.25, appointment.getLoggedHours(), 0.0);
    assertEquals(100.0, appointment.getPayFlat(), 0.0);
    assertEquals(0.0, appointment.getPayHours(), 0.0);
    assertEquals(0.0, appointment.getPayRate(), 0.0);
    assertEquals(100.0, appointment.getPaymentTotal(), 0.0);

    appointment.setTimeInD(timeIn.minusHours(1));
    appointment.setPayingType(GenData.ACCOUNTING_TYPE_SOC_2HR.get(entityManager));
    assertEquals(GenData.ACCOUNTING_TYPE_SOC_2HR.get(entityManager), appointment.getPayingType());
    assertEquals(3.0, appointment.getLoggedHours(), 0.0);
    assertEquals(95.0, appointment.getPayFlat(), 0.0);
    assertEquals(1.0, appointment.getPayHours(), 0.0);
    assertEquals(60.0, appointment.getPayRate(), 0.0);
    assertEquals(155.0, appointment.getPaymentTotal(), 0.0);

    appointment.setTimeInD(timeIn.minusMinutes(30));
    appointment.setPayingType(GenData.ACCOUNTING_TYPE_ROC_2HR.get(entityManager));
    assertEquals(GenData.ACCOUNTING_TYPE_ROC_2HR.get(entityManager), appointment.getPayingType());
    assertEquals(2.5, appointment.getLoggedHours(), 0.0);
    assertEquals(90.0, appointment.getPayFlat(), 0.0);
    assertEquals(.5, appointment.getPayHours(), 0.0);
    assertEquals(50.0, appointment.getPayRate(), 0.0);
    assertEquals(115.0, appointment.getPaymentTotal(), 0.0);

    appointment.setTimeInD(timeIn.plusMinutes(30));
    appointment.setPayingType(GenData.ACCOUNTING_TYPE_ROC_2HR.get(entityManager));
    assertEquals(GenData.ACCOUNTING_TYPE_ROC_2HR.get(entityManager), appointment.getPayingType());
    assertEquals(1.5, appointment.getLoggedHours(), 0.0);
    assertEquals(90.0, appointment.getPayFlat(), 0.0);
    assertEquals(0.0, appointment.getPayHours(), 0.0);
    assertEquals(50.0, appointment.getPayRate(), 0.0);
    assertEquals(90.0, appointment.getPaymentTotal(), 0.0);
  }
Esempio n. 2
0
  @Test
  public void testBilling() throws Exception {
    Vendor vendor =
        new Vendor(null)
            .setBillingFlat(200)
            .setBillingRate(50)
            .setBillingFlat2HrSoc(220)
            .setBillingRate2HrSoc(70)
            .setBillingFlat2HrRoc(210)
            .setBillingRate2HrRoc(60);
    Patient patient = new Patient(null).setVendor(vendor);
    Nurse nurse = new Nurse(null);
    DateTime timeIn = DateTime.now().minusHours(2);
    DateTime timeOut = DateTime.now();
    Appointment appointment =
        new Appointment(null)
            .setPatient(patient)
            .setNurse(nurse)
            .setStart(DateTime.now())
            .setTimeInD(timeIn)
            .setTimeOutD(timeOut);
    assertEquals(GenData.ACCOUNTING_TYPE_SOC_2HR.get(entityManager), appointment.getBillingType());
    assertEquals(2.0, appointment.getLoggedHours(), 0.0);
    assertEquals(220.0, appointment.getBillingFlat(), 0.0);
    assertEquals(0.0, appointment.getBilledHours(), 0.0);
    assertEquals(70.0, appointment.getBillingRate(), 0.0);
    assertEquals(220.0, appointment.getBillingTotal(), 0.0);

    appointment.setTimeInD(timeIn.minusHours(1));
    assertEquals(GenData.ACCOUNTING_TYPE_HOURLY.get(entityManager), appointment.getBillingType());
    assertEquals(3.0, appointment.getLoggedHours(), 0.0);
    assertEquals(0.0, appointment.getBillingFlat(), 0.0);
    assertEquals(50.0, appointment.getBillingRate(), 0.0);
    assertEquals(150.0, appointment.getBillingTotal(), 0.0);

    appointment.setBillingType(GenData.ACCOUNTING_TYPE_FIXED.get(entityManager));
    assertEquals(GenData.ACCOUNTING_TYPE_FIXED.get(entityManager), appointment.getBillingType());
    assertEquals(3.0, appointment.getLoggedHours(), 0.0);
    assertEquals(200.0, appointment.getBillingFlat(), 0.0);
    assertEquals(0.0, appointment.getBilledHours(), 0.0);
    assertEquals(0.0, appointment.getBillingRate(), 0.0);
    assertEquals(200.0, appointment.getBillingTotal(), 0.0);

    appointment.setTimeInD(timeIn.plusMinutes(105));
    appointment.setBillingType(GenData.ACCOUNTING_TYPE_FIXED.get(entityManager));
    assertEquals(GenData.ACCOUNTING_TYPE_FIXED.get(entityManager), appointment.getBillingType());
    assertEquals(.25, appointment.getLoggedHours(), 0.0);
    assertEquals(200.0, appointment.getBillingFlat(), 0.0);
    assertEquals(0.0, appointment.getBilledHours(), 0.0);
    assertEquals(0.0, appointment.getBillingRate(), 0.0);
    assertEquals(200.0, appointment.getBillingTotal(), 0.0);

    appointment.setTimeInD(timeIn.minusHours(1));
    appointment.setBillingType(GenData.ACCOUNTING_TYPE_SOC_2HR.get(entityManager));
    assertEquals(GenData.ACCOUNTING_TYPE_SOC_2HR.get(entityManager), appointment.getBillingType());
    assertEquals(3.0, appointment.getLoggedHours(), 0.0);
    assertEquals(220.0, appointment.getBillingFlat(), 0.0);
    assertEquals(1.0, appointment.getBilledHours(), 0.0);
    assertEquals(70.0, appointment.getBillingRate(), 0.0);
    assertEquals(290.0, appointment.getBillingTotal(), 0.0);

    appointment.setTimeInD(timeIn.minusMinutes(30));
    appointment.setBillingType(GenData.ACCOUNTING_TYPE_ROC_2HR.get(entityManager));
    assertEquals(GenData.ACCOUNTING_TYPE_ROC_2HR.get(entityManager), appointment.getBillingType());
    assertEquals(2.5, appointment.getLoggedHours(), 0.0);
    assertEquals(210.0, appointment.getBillingFlat(), 0.0);
    assertEquals(.5, appointment.getBilledHours(), 0.0);
    assertEquals(60.0, appointment.getBillingRate(), 0.0);
    assertEquals(240.0, appointment.getBillingTotal(), 0.0);

    appointment.setTimeInD(timeIn.plusMinutes(30));
    appointment.setBillingType(GenData.ACCOUNTING_TYPE_ROC_2HR.get(entityManager));
    assertEquals(GenData.ACCOUNTING_TYPE_ROC_2HR.get(entityManager), appointment.getBillingType());
    assertEquals(1.5, appointment.getLoggedHours(), 0.0);
    assertEquals(210.0, appointment.getBillingFlat(), 0.0);
    assertEquals(0.0, appointment.getBilledHours(), 0.0);
    assertEquals(60.0, appointment.getBillingRate(), 0.0);
    assertEquals(210.0, appointment.getBillingTotal(), 0.0);

    appointment.setPropertyValue("TIME_IN", "20:10");
    appointment.setPropertyValue("TIME_OUT", "03:10");
    appointment.setBillingType(GenData.ACCOUNTING_TYPE_HOURLY.get(entityManager));
    assertEquals(7, appointment.getLoggedHours(), 0.0);
    assertEquals(0.0, appointment.getBillingFlat(), 0.0);
    assertEquals(7, appointment.getBilledHours(), 0.0);
    assertEquals(50.0, appointment.getBillingRate(), 0.0);
    assertEquals(350.0, appointment.getBillingTotal(), 0.0);
  }