Update SlipGajiService
Pembuatan service update detail slip gaji karena perubahan data pegawai
This commit is contained in:
parent
b2210f374c
commit
81341e9fa0
@ -1,7 +1,6 @@
|
||||
package com.jasamedika.medifirst2000.dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
@ -8,8 +8,10 @@ import com.jasamedika.medifirst2000.dto.SlipGajiDto;
|
||||
*/
|
||||
public interface SlipGajiService {
|
||||
void init();
|
||||
|
||||
|
||||
void save(SlipGajiDto dto);
|
||||
|
||||
|
||||
void updateDetail(SlipGajiDto dto);
|
||||
|
||||
SlipGajiDto get(Integer pegawaiId);
|
||||
}
|
||||
|
||||
@ -124,13 +124,15 @@ public class SlipGajiServiceImpl implements SlipGajiService {
|
||||
@Override
|
||||
public void save(SlipGajiDto dto) {
|
||||
SlipGaji.SlipGajiBuilder slipGaji = SlipGaji.builder();
|
||||
if (CommonUtil.isNotNullOrEmpty(dto.getId()))
|
||||
slipGaji.id(dto.getId());
|
||||
slipGaji.pegawai(pegawaiDao.findById(dto.getIdPegawai()));
|
||||
slipGaji.bulan(new Date(dto.getBulan()));
|
||||
SlipGaji savedSlip = slipGajiDao.save(slipGaji.build());
|
||||
if (CommonUtil.isNotNullOrEmpty(savedSlip)) {
|
||||
{
|
||||
List<SlipGajiDetail> listDetail = new ArrayList<>();
|
||||
if (CommonUtil.isNullOrEmpty(dto.getId())) {
|
||||
List<MapPegawaiJabatanToUnitKerja> listMapping = mappingJabatanDao.findByPegawaiId(dto.getIdPegawai());
|
||||
List<SlipGajiDetail> listDetail = new ArrayList<>();
|
||||
listMapping.forEach(j -> {
|
||||
SlipGajiDetail.SlipGajiDetailBuilder detail = SlipGajiDetail.builder();
|
||||
detail.slipGaji(savedSlip);
|
||||
@ -148,6 +150,8 @@ public class SlipGajiServiceImpl implements SlipGajiService {
|
||||
}
|
||||
{
|
||||
PenerimaanGaji.PenerimaanGajiBuilder penerimaan = PenerimaanGaji.builder();
|
||||
if (CommonUtil.isNotNullOrEmpty(dto.getId()))
|
||||
penerimaan.id(savedSlip.getId());
|
||||
penerimaan.gaji(dto.getGaji());
|
||||
penerimaan.remunerasiKinerja(dto.getRemunerasiKinerja());
|
||||
penerimaan.remunerasiTambahan(dto.getRemunerasiTambahan());
|
||||
@ -160,6 +164,8 @@ public class SlipGajiServiceImpl implements SlipGajiService {
|
||||
}
|
||||
{
|
||||
PenguranganGaji.PenguranganGajiBuilder pengurangan = PenguranganGaji.builder();
|
||||
if (CommonUtil.isNotNullOrEmpty(dto.getId()))
|
||||
pengurangan.id(savedSlip.getId());
|
||||
pengurangan.pphGaji(dto.getPphGaji());
|
||||
pengurangan.pphRemunerasi(dto.getPphRemunerasi());
|
||||
pengurangan.pphFeeForService(dto.getPphFeeForService());
|
||||
@ -177,6 +183,33 @@ public class SlipGajiServiceImpl implements SlipGajiService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDetail(SlipGajiDto dto) {
|
||||
{
|
||||
List<SlipGajiDetail> listExistedDetail = slipGajiDetailDao.findBySlipGaji(dto.getId());
|
||||
slipGajiDetailDao.delete(listExistedDetail);
|
||||
}
|
||||
SlipGaji existedSlipGaji = slipGajiDao.findOne(dto.getId());
|
||||
if (CommonUtil.isNotNullOrEmpty(existedSlipGaji)) {
|
||||
List<MapPegawaiJabatanToUnitKerja> listMapping = mappingJabatanDao.findByPegawaiId(dto.getIdPegawai());
|
||||
List<SlipGajiDetail> listDetail = new ArrayList<>();
|
||||
listMapping.forEach(j -> {
|
||||
SlipGajiDetail.SlipGajiDetailBuilder detail = SlipGajiDetail.builder();
|
||||
detail.slipGaji(existedSlipGaji);
|
||||
if (CommonUtil.isNotNullOrEmpty(j.getJabatan()))
|
||||
detail.jabatan(j.getJabatan());
|
||||
if (CommonUtil.isNotNullOrEmpty(j.getUnitKerjaPegawai()))
|
||||
detail.unitKerja(j.getUnitKerjaPegawai());
|
||||
if (CommonUtil.isNotNullOrEmpty(j.getSubUnitKerjaPegawai()))
|
||||
detail.subUnitKerja(j.getSubUnitKerjaPegawai());
|
||||
if (CommonUtil.isNotNullOrEmpty(j.getGrade()))
|
||||
detail.grade(j.getGrade());
|
||||
listDetail.add(detail.build());
|
||||
});
|
||||
slipGajiDetailDao.save(listDetail);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SlipGajiDto get(Integer pegawaiId) {
|
||||
Optional<SlipGaji> slipGaji = slipGajiDao.findByPegawai(pegawaiId);
|
||||
|
||||
@ -11,6 +11,9 @@ import com.jasamedika.medifirst2000.helper.Caption;
|
||||
* @since Jan 20, 2023
|
||||
*/
|
||||
public class SlipGajiDto {
|
||||
@Caption(value = "ID Slip Gaji")
|
||||
private String id;
|
||||
|
||||
@NotNull(message = "ID Pegawai must not be null")
|
||||
@Caption(value = "ID Pegawai")
|
||||
private Integer idPegawai;
|
||||
@ -90,13 +93,15 @@ public class SlipGajiDto {
|
||||
public SlipGajiDto() {
|
||||
}
|
||||
|
||||
public SlipGajiDto(Integer idPegawai, String namaPegawai, String jabatan, String unitKerja, String subUnitKerja,
|
||||
String grade, Long bulan, BigDecimal gaji, BigDecimal remunerasiKinerja, BigDecimal remunerasiTambahan,
|
||||
BigDecimal feeForService, BigDecimal feeForOnSite, BigDecimal uangMakan, BigDecimal uangLembur,
|
||||
BigDecimal pphGaji, BigDecimal pphRemunerasi, BigDecimal pphFeeForService, BigDecimal pphFeeForOnSite,
|
||||
BigDecimal pphUangMakan, BigDecimal pphUangLembur, BigDecimal iuranWajibKoperasi,
|
||||
BigDecimal potonganPinjamanKoperasi, BigDecimal potonganObat, BigDecimal biayaRawatInap,
|
||||
BigDecimal biayaRawatJalan) {
|
||||
public SlipGajiDto(String id, Integer idPegawai, String namaPegawai, String jabatan, String unitKerja,
|
||||
String subUnitKerja, String grade, Long bulan, BigDecimal gaji, BigDecimal remunerasiKinerja,
|
||||
BigDecimal remunerasiTambahan, BigDecimal feeForService, BigDecimal feeForOnSite, BigDecimal uangMakan,
|
||||
BigDecimal uangLembur, BigDecimal pphGaji, BigDecimal pphRemunerasi, BigDecimal pphFeeForService,
|
||||
BigDecimal pphFeeForOnSite, BigDecimal pphUangMakan, BigDecimal pphUangLembur,
|
||||
BigDecimal iuranWajibKoperasi, BigDecimal potonganPinjamanKoperasi, BigDecimal potonganObat,
|
||||
BigDecimal biayaRawatInap, BigDecimal biayaRawatJalan) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.idPegawai = idPegawai;
|
||||
this.namaPegawai = namaPegawai;
|
||||
this.jabatan = jabatan;
|
||||
@ -124,6 +129,14 @@ public class SlipGajiDto {
|
||||
this.biayaRawatJalan = biayaRawatJalan;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getIdPegawai() {
|
||||
return idPegawai;
|
||||
}
|
||||
@ -329,6 +342,7 @@ public class SlipGajiDto {
|
||||
}
|
||||
|
||||
public static class SlipGajiDtoBuilder {
|
||||
private String id;
|
||||
private Integer idPegawai;
|
||||
private String namaPegawai;
|
||||
private String jabatan;
|
||||
@ -358,6 +372,11 @@ public class SlipGajiDto {
|
||||
public SlipGajiDtoBuilder() {
|
||||
}
|
||||
|
||||
public SlipGajiDtoBuilder id(final String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SlipGajiDtoBuilder idPegawai(final Integer idPegawai) {
|
||||
this.idPegawai = idPegawai;
|
||||
return this;
|
||||
@ -484,10 +503,10 @@ public class SlipGajiDto {
|
||||
}
|
||||
|
||||
public SlipGajiDto build() {
|
||||
return new SlipGajiDto(this.idPegawai, this.namaPegawai, this.jabatan, this.unitKerja, this.subUnitKerja,
|
||||
this.grade, this.bulan, this.gaji, this.remunerasiKinerja, this.remunerasiTambahan,
|
||||
this.feeForService, this.feeForOnSite, this.uangMakan, this.uangLembur, this.pphGaji,
|
||||
this.pphRemunerasi, this.pphFeeForService, this.pphFeeForOnSite, this.pphUangMakan,
|
||||
return new SlipGajiDto(this.id, this.idPegawai, this.namaPegawai, this.jabatan, this.unitKerja,
|
||||
this.subUnitKerja, this.grade, this.bulan, this.gaji, this.remunerasiKinerja,
|
||||
this.remunerasiTambahan, this.feeForService, this.feeForOnSite, this.uangMakan, this.uangLembur,
|
||||
this.pphGaji, this.pphRemunerasi, this.pphFeeForService, this.pphFeeForOnSite, this.pphUangMakan,
|
||||
this.pphUangLembur, this.iuranWajibKoperasi, this.potonganPinjamanKoperasi, this.potonganObat,
|
||||
this.biayaRawatInap, this.biayaRawatJalan);
|
||||
}
|
||||
|
||||
@ -69,9 +69,10 @@ public class PenerimaanGaji implements Serializable {
|
||||
public PenerimaanGaji() {
|
||||
}
|
||||
|
||||
public PenerimaanGaji(SlipGaji slipGaji, BigDecimal gaji, BigDecimal remunerasiKinerja,
|
||||
public PenerimaanGaji(String id, SlipGaji slipGaji, BigDecimal gaji, BigDecimal remunerasiKinerja,
|
||||
BigDecimal remunerasiTambahan, BigDecimal feeForService, BigDecimal feeForOnSite, BigDecimal uangMakan,
|
||||
BigDecimal uangLembur) {
|
||||
this.id = id;
|
||||
this.slipGaji = slipGaji;
|
||||
this.gaji = gaji;
|
||||
this.remunerasiKinerja = remunerasiKinerja;
|
||||
@ -163,6 +164,7 @@ public class PenerimaanGaji implements Serializable {
|
||||
}
|
||||
|
||||
public static class PenerimaanGajiBuilder {
|
||||
private String id;
|
||||
private SlipGaji slipGaji;
|
||||
private BigDecimal gaji;
|
||||
private BigDecimal remunerasiKinerja;
|
||||
@ -175,6 +177,11 @@ public class PenerimaanGaji implements Serializable {
|
||||
public PenerimaanGajiBuilder() {
|
||||
}
|
||||
|
||||
public PenerimaanGajiBuilder id(final String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PenerimaanGajiBuilder slipGaji(final SlipGaji slipGaji) {
|
||||
this.slipGaji = slipGaji;
|
||||
return this;
|
||||
@ -216,8 +223,8 @@ public class PenerimaanGaji implements Serializable {
|
||||
}
|
||||
|
||||
public PenerimaanGaji build() {
|
||||
return new PenerimaanGaji(this.slipGaji, this.gaji, this.remunerasiKinerja, this.remunerasiTambahan,
|
||||
this.feeForService, this.feeForOnSite, this.uangMakan, this.uangLembur);
|
||||
return new PenerimaanGaji(this.id, this.slipGaji, this.gaji, this.remunerasiKinerja,
|
||||
this.remunerasiTambahan, this.feeForService, this.feeForOnSite, this.uangMakan, this.uangLembur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,10 +85,11 @@ public class PenguranganGaji implements Serializable {
|
||||
public PenguranganGaji() {
|
||||
}
|
||||
|
||||
public PenguranganGaji(SlipGaji slipGaji, BigDecimal pphGaji, BigDecimal pphRemunerasi, BigDecimal pphFeeForService,
|
||||
BigDecimal pphFeeForOnSite, BigDecimal pphUangMakan, BigDecimal pphUangLembur,
|
||||
public PenguranganGaji(String id, SlipGaji slipGaji, BigDecimal pphGaji, BigDecimal pphRemunerasi,
|
||||
BigDecimal pphFeeForService, BigDecimal pphFeeForOnSite, BigDecimal pphUangMakan, BigDecimal pphUangLembur,
|
||||
BigDecimal iuranWajibKoperasi, BigDecimal potonganPinjamanKoperasi, BigDecimal potonganObat,
|
||||
BigDecimal biayaRawatInap, BigDecimal biayaRawatJalan) {
|
||||
this.id = id;
|
||||
this.slipGaji = slipGaji;
|
||||
this.pphGaji = pphGaji;
|
||||
this.pphRemunerasi = pphRemunerasi;
|
||||
@ -216,6 +217,7 @@ public class PenguranganGaji implements Serializable {
|
||||
}
|
||||
|
||||
public static class PenguranganGajiBuilder {
|
||||
private String id;
|
||||
private SlipGaji slipGaji;
|
||||
private BigDecimal pphGaji;
|
||||
private BigDecimal pphRemunerasi;
|
||||
@ -232,6 +234,11 @@ public class PenguranganGaji implements Serializable {
|
||||
public PenguranganGajiBuilder() {
|
||||
}
|
||||
|
||||
public PenguranganGajiBuilder id(final String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PenguranganGajiBuilder slipGaji(final SlipGaji slipGaji) {
|
||||
this.slipGaji = slipGaji;
|
||||
return this;
|
||||
@ -293,7 +300,7 @@ public class PenguranganGaji implements Serializable {
|
||||
}
|
||||
|
||||
public PenguranganGaji build() {
|
||||
return new PenguranganGaji(this.slipGaji, this.pphGaji, this.pphRemunerasi, this.pphFeeForService,
|
||||
return new PenguranganGaji(this.id, this.slipGaji, this.pphGaji, this.pphRemunerasi, this.pphFeeForService,
|
||||
this.pphFeeForOnSite, this.pphUangMakan, this.pphUangLembur, this.iuranWajibKoperasi,
|
||||
this.potonganPinjamanKoperasi, this.potonganObat, this.biayaRawatInap, this.biayaRawatJalan);
|
||||
}
|
||||
|
||||
@ -48,7 +48,8 @@ public class SlipGaji implements Serializable {
|
||||
public SlipGaji() {
|
||||
}
|
||||
|
||||
public SlipGaji(Pegawai pegawai, Date bulan) {
|
||||
public SlipGaji(String id, Pegawai pegawai, Date bulan) {
|
||||
this.id = id;
|
||||
this.pegawai = pegawai;
|
||||
this.bulan = bulan;
|
||||
}
|
||||
@ -86,12 +87,18 @@ public class SlipGaji implements Serializable {
|
||||
}
|
||||
|
||||
public static class SlipGajiBuilder {
|
||||
private String id;
|
||||
private Pegawai pegawai;
|
||||
private Date bulan;
|
||||
|
||||
public SlipGajiBuilder() {
|
||||
}
|
||||
|
||||
public SlipGajiBuilder id(final String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SlipGajiBuilder pegawai(final Pegawai pegawai) {
|
||||
this.pegawai = pegawai;
|
||||
return this;
|
||||
@ -103,7 +110,7 @@ public class SlipGaji implements Serializable {
|
||||
}
|
||||
|
||||
public SlipGaji build() {
|
||||
return new SlipGaji(this.pegawai, this.bulan);
|
||||
return new SlipGaji(this.id, this.pegawai, this.bulan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ public class SlipGajiController {
|
||||
return new ResponseEntity<>(true, HttpStatus.CREATED);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,18 @@ public class SlipGajiController {
|
||||
return new ResponseEntity<>(true, HttpStatus.CREATED);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/detail/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> updateDetail(@RequestBody @Valid SlipGajiDto dto) {
|
||||
try {
|
||||
slipGajiService.updateDetail(dto);
|
||||
return new ResponseEntity<>(true, HttpStatus.CREATED);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user