Opraveno duplicitní vkládání záznamů do agendy Fakturace požadavků, v případě, že se požadavek upraví a znovu schválí.

closes #252
Verze_3.0
Josef Rokos 9 years ago
parent cd6a6cf5a6
commit 768d3ee874

@ -1,7 +1,7 @@
package info.bukova.isspst.data;
import java.math.BigDecimal;
import java.util.List;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@ -11,16 +11,15 @@ import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import java.math.BigDecimal;
import java.util.List;
@Entity
@Table(name = "INVOICING")
public class Invoicing extends BaseData implements Cloneable
{
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "REQUIREMENT_ID")
private Requirement requirement;

@ -1,6 +1,7 @@
package info.bukova.isspst.services.invoicing;
import info.bukova.isspst.data.Invoicing;
import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.Service;
@ -20,4 +21,6 @@ public interface InvoicingService extends Service<Invoicing> {
public List<Invoicing> getPendingList();
public List<Invoicing> getArchiveList();
public Invoicing getForRequirement(Requirement req);
}

@ -2,18 +2,18 @@ package info.bukova.isspst.services.invoicing;
import info.bukova.isspst.data.Invoicing;
import info.bukova.isspst.data.InvoicingItem;
import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.LazyLoader;
import java.math.BigDecimal;
import java.util.List;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
public class InvoicingServiceImpl extends AbstractOwnedService<Invoicing> implements
InvoicingService {
@ -92,4 +92,13 @@ public class InvoicingServiceImpl extends AbstractOwnedService<Invoicing> implem
Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where inv.completed = true order by rq.numser");
return q.list();
}
@Override
@Transactional
public Invoicing getForRequirement(Requirement req) {
Query query = dao.getQuery("select invoice from Invoicing invoice join invoice.requirement rq where rq.id = :reqId");
query.setParameter("reqId", req.getId());
return (Invoicing) query.uniqueResult();
}
}

@ -11,8 +11,8 @@ import info.bukova.isspst.data.Workflow;
import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.invoicing.InvoicingService;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
@ -244,11 +244,19 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requireme
@Override
@Transactional
public BigDecimal getInvoicedAmount(Requirement req) {
Query query = dao.getQuery("select invoice from Invoicing invoice join invoice.requirement rq where rq.id = :reqId");
query.setParameter("reqId", req.getId());
Invoicing inv = invoicingService.getForRequirement(req);
return inv != null ? inv.getTotalInvoiced() : null;
}
Invoicing inv = (Invoicing) query.uniqueResult();
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
public void update(Requirement entity) {
super.update(entity);
Invoicing inv = invoicingService.getForRequirement(entity);
return inv != null ? inv.getTotalInvoiced() : null;
if (inv != null) {
invoicingService.delete(inv);
}
}
}

Loading…
Cancel
Save