Update PelayananPasienServiceImpl.java
Perbaikan validasi tmt, belum mapping paket dan belum mapping kelas saat diskon paket
This commit is contained in:
parent
e52bce7054
commit
343e23c27a
@ -2219,7 +2219,7 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
|
||||
VoucherPaket voucher = voucherPaketDao.findByKode(kodeVoucher);
|
||||
if (CommonUtil.isNullOrEmpty(voucher))
|
||||
throw new ServiceVOException("Kode voucher tidak ditemukan");
|
||||
if (voucher.getTmt().before(new Date()))
|
||||
if (voucher.getTmt().after(new Date()))
|
||||
throw new ServiceVOException("Kode voucher baru dapat dipakai mulai "
|
||||
+ new SimpleDateFormat("dd MMMM yyyy HH:mm:ss", new Locale("in", "ID"))
|
||||
.format(voucher.getTmt()));
|
||||
@ -2238,17 +2238,20 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
|
||||
throw new ServiceVOException("Kode voucher tidak sesuai dengan pasien yang diperuntukkan");
|
||||
}
|
||||
{
|
||||
List<Integer> listId = dtoList.stream().map(TagihanPendaftaranDto::getIdProduk)
|
||||
.collect(Collectors.toList());
|
||||
List<MapProdukPaketToProduk> detail = mapProdukPaketToProdukDao
|
||||
.findAllByPaketId(voucher.getPaket().getId());
|
||||
Optional<MapProdukPaketToProduk> byProduk = detail.stream()
|
||||
.filter(d -> !listId.contains(d.getProduk().getId())).findFirst();
|
||||
List<Integer> listIdDetail = detail.stream().map(MapProdukPaketToProduk::getProdukId)
|
||||
.collect(Collectors.toList());
|
||||
Optional<TagihanPendaftaranDto> byProduk = dtoList.stream()
|
||||
.filter(dto -> !listIdDetail.contains(dto.getIdProduk()))
|
||||
.filter(dto -> !dto.getIdProduk().equals(voucher.getPaketId())).findFirst();
|
||||
if (byProduk.isPresent())
|
||||
throw new ServiceVOException("Produk " + byProduk.get().getProduk().getNamaProduk()
|
||||
throw new ServiceVOException("Produk " + byProduk.get().getNamaProduk()
|
||||
+ " tidak dapat didiskon karena belum dilakukan mapping /"
|
||||
+ " tidak termasuk detail paket yang dapat diskon");
|
||||
detail.forEach(d -> {
|
||||
List<Integer> listIdDto = dtoList.stream().map(TagihanPendaftaranDto::getIdProduk)
|
||||
.filter(dto -> !dto.equals(voucher.getPaketId())).collect(Collectors.toList());
|
||||
detail.stream().filter(d -> listIdDto.contains(d.getProdukId())).forEach(d -> {
|
||||
List<Map<String, Object>> maps = hargaNettoProdukByKelasDao.checkExisting(voucher.getKelasId(),
|
||||
d.getProdukPaketId());
|
||||
if (CommonUtil.isNullOrEmpty(maps) && maps.isEmpty())
|
||||
@ -2263,7 +2266,7 @@ public class PelayananPasienServiceImpl extends BaseVoServiceImpl implements Pel
|
||||
dto.ifPresent(tagihanPendaftaranDto -> {
|
||||
p.setHargaDiscount(tagihanPendaftaranDto.getHargaDiskon());
|
||||
p.setJasa(tagihanPendaftaranDto.getHargaJasa());
|
||||
p.setIsPasien(tagihanPendaftaranDto.getIsPaket());
|
||||
p.setIsPaket(tagihanPendaftaranDto.getIsPaket());
|
||||
});
|
||||
});
|
||||
pelayananPasienDao.save(listPelayanan);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user