Objednávku lze nyní označit jako objednanou.

Na schválené položky se propíš číslo objednávky.
Všechny objednávky, které schválené a objednané položky obsahují již
není možno znovu objednat.
Objednávky mazat nelze, takže mazání dokladů neřešíme.

closes #153
Verze_1.0
František Přibyl 10 years ago
parent 3b4509d0a7
commit 5b380386bd

@ -7,12 +7,12 @@ import org.zkoss.util.resource.Labels;
public class StringUtils public class StringUtils
{ {
private static String nullStr(String str) public static String nullToEmptyString(String str)
{ {
return str == null ? "" : str; return str == null ? "" : str;
} }
private static String not0ToStr(long i) private static String zeroToEmptyString(long i)
{ {
return i == 0 ? "" : String.valueOf(i); return i == 0 ? "" : String.valueOf(i);
} }
@ -60,8 +60,8 @@ public class StringUtils
public static boolean isEqualForFilter(String value, String search) public static boolean isEqualForFilter(String value, String search)
{ {
value = StringUtils.nullStr(value).toLowerCase(); value = StringUtils.nullToEmptyString(value).toLowerCase();
search = StringUtils.nullStr(search).toLowerCase(); search = StringUtils.nullToEmptyString(search).toLowerCase();
if (search.isEmpty()) if (search.isEmpty())
{ {
@ -73,8 +73,8 @@ public class StringUtils
public static boolean isIcEqualForFilter(long value, long search) public static boolean isIcEqualForFilter(long value, long search)
{ {
String compareValue = StringUtils.not0ToStr(value); String compareValue = StringUtils.zeroToEmptyString(value);
String searchValue = StringUtils.not0ToStr(search); String searchValue = StringUtils.zeroToEmptyString(search);
return compareValue.startsWith(searchValue); return compareValue.startsWith(searchValue);
} }
@ -124,7 +124,7 @@ public class StringUtils
for (int i = 0; i < list.size(); i++) for (int i = 0; i < list.size(); i++)
{ {
String item = StringUtils.nullStr(list.get(i)); String item = StringUtils.nullToEmptyString(list.get(i));
result = StringUtils.addSeparator(result, separator); result = StringUtils.addSeparator(result, separator);
result += item; result += item;
} }
@ -138,7 +138,7 @@ public class StringUtils
for (int i = 0; i < list.size(); i++) for (int i = 0; i < list.size(); i++)
{ {
String item = StringUtils.nullStr(list.get(i)); String item = StringUtils.nullToEmptyString(list.get(i));
if (!item.isEmpty()) if (!item.isEmpty())
{ {

@ -0,0 +1,8 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.RequirementItem;
public interface RequirementItemDao extends BaseDao<RequirementItem>
{
}

@ -0,0 +1,8 @@
package info.bukova.isspst.dao.jpa;
import info.bukova.isspst.dao.RequirementItemDao;
import info.bukova.isspst.data.RequirementItem;
public class RequirementItemDaoJPA extends BaseDaoJPA<RequirementItem> implements RequirementItemDao
{
}

@ -19,7 +19,7 @@ import org.hibernate.annotations.LazyCollectionOption;
@Entity @Entity
@Table(name = "ORDERS") @Table(name = "ORDERS")
public class Order extends BaseData public class Order extends BaseData implements Cloneable
{ {
@Column(name = "NUMSER") @Column(name = "NUMSER")
@ -292,4 +292,28 @@ public class Order extends BaseData
this.invoiceTotal = invoiceTotal; this.invoiceTotal = invoiceTotal;
} }
public boolean isIcludedRequirementItemFromAnotherOrder()
{
for (OrderItem oItem : this.getItems())
{
RequirementItem rItem = oItem.getReqItem();
if (rItem != null)
{
String orderNum = rItem.getOrderNum();
boolean isIncluded = !((orderNum == null) || (orderNum.isEmpty()));
return isIncluded;
}
}
return false;
}
@Override
public Object clone() throws CloneNotSupportedException
{
Order cloned = (Order) super.clone();
cloned.setTotal(new BigDecimal(this.getTotal().toString()));
return cloned;
}
} }

@ -56,6 +56,9 @@ public class RequirementItem
@Column(name = "DELIVERED") @Column(name = "DELIVERED")
private Boolean delivered; private Boolean delivered;
@Column(name = "ORDERNUM")
private String orderNum;
public int getId() public int getId()
{ {
return id; return id;
@ -187,4 +190,14 @@ public class RequirementItem
public void setDelivered(Boolean delivered) { public void setDelivered(Boolean delivered) {
this.delivered = delivered; this.delivered = delivered;
} }
public String getOrderNum()
{
return orderNum;
}
public void setOrderNum(String orderNum)
{
this.orderNum = orderNum;
}
} }

@ -42,6 +42,7 @@ public class OrderFilter implements Filter<Order>
@Override @Override
public boolean matchesSafely(Order item) public boolean matchesSafely(Order item)
{ {
boolean foundOrdered = (item.isOrdered() == condition.isOrdered());
boolean foundNumSer = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser()); boolean foundNumSer = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser());
boolean foundOrderDate = DateTimeUtils.isEqualByDateForFilter(item.getOrderDate(), condition.getOrderDate()); boolean foundOrderDate = DateTimeUtils.isEqualByDateForFilter(item.getOrderDate(), condition.getOrderDate());
boolean foundTotal = true;// BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(), boolean foundTotal = true;// BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(),
@ -56,7 +57,8 @@ public class OrderFilter implements Filter<Order>
boolean foundInvoiceAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getAddress(), condition.getAddress()); boolean foundInvoiceAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getAddress(), condition.getAddress());
boolean foundOwnedBy = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy()); boolean foundOwnedBy = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription()); boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
return (foundNumSer return (foundOrdered
&& foundNumSer
&& foundOrderDate && foundOrderDate
&& foundTotal && foundTotal
&& foundDeliveryDate && foundDeliveryDate

@ -35,7 +35,7 @@ public class ApprovedServiceImpl extends AbstractService<JoinedItem> implements
{ {
List<Workgroup> wgList = workgroupService.getUserCentres(userService.getCurrent()); List<Workgroup> wgList = workgroupService.getUserCentres(userService.getCurrent());
Query q = queryDao Query q = queryDao
.getQuery("select item from RequirementItem item left join item.requirement rq join rq.centre c where rq.kind is not null and rq.state = :state and c in (:wgList)"); .getQuery("select item from RequirementItem item left join item.requirement rq join rq.centre c where rq.kind is not null and rq.state = :state and c in (:wgList) and (item.orderNum Is Null or item.orderNum = '')");
q.setParameterList("wgList", wgList); q.setParameterList("wgList", wgList);
q.setParameter("state", RequirementState.APPROVED); q.setParameter("state", RequirementState.APPROVED);
List<JoinedItem> items = new ArrayList<JoinedItem>(); List<JoinedItem> items = new ArrayList<JoinedItem>();

@ -22,4 +22,5 @@ public interface OrderService extends Service<Order> {
public BigDecimal calcSumTotalFromItems(List<OrderItem> items); public BigDecimal calcSumTotalFromItems(List<OrderItem> items);
public void updateApprovedItems(Order order, boolean orderedChanged);
} }

@ -1,9 +1,11 @@
package info.bukova.isspst.services.approved; package info.bukova.isspst.services.approved;
import info.bukova.isspst.dao.RequirementItemDao;
import info.bukova.isspst.data.AddressEmb; import info.bukova.isspst.data.AddressEmb;
import info.bukova.isspst.data.JoinedItem; import info.bukova.isspst.data.JoinedItem;
import info.bukova.isspst.data.Order; import info.bukova.isspst.data.Order;
import info.bukova.isspst.data.OrderItem; import info.bukova.isspst.data.OrderItem;
import info.bukova.isspst.data.RequirementItem;
import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.LazyLoader;
@ -23,7 +25,10 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
@Autowired @Autowired
private GlobalSettingsService globalSettings; private GlobalSettingsService globalSettings;
@Autowired
private RequirementItemDao requirementItemDao;
@Override @Override
@PreAuthorize("hasPermission(this, 'PERM_ADD')") @PreAuthorize("hasPermission(this, 'PERM_ADD')")
public Order createOrder(List<JoinedItem> items) { public Order createOrder(List<JoinedItem> items) {
@ -171,4 +176,24 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
return sumTotal; return sumTotal;
} }
@Transactional
public void updateApprovedItems(Order order, boolean orderedChanged)
{
if (orderedChanged)
{
for (OrderItem item : order.getItems())
{
RequirementItem rItem = item.getReqItem();
if (rItem != null)
{
rItem.setOrderNum(order.isOrdered() ? order.getNumser() : null);
requirementItemDao.modify(rItem);
}
}
}
super.update(order);
}
} }

@ -17,6 +17,8 @@ public class DocumentViewModel
{ {
protected BigDecimalConverter standardBigDecimalConverter; protected BigDecimalConverter standardBigDecimalConverter;
protected BoolConverter standardBoolConverter;
public BigDecimalConverter getStandardBigDecimalConverter() public BigDecimalConverter getStandardBigDecimalConverter()
{ {
return standardBigDecimalConverter; return standardBigDecimalConverter;
@ -27,10 +29,21 @@ public class DocumentViewModel
this.standardBigDecimalConverter = standardBigDecimalConverter; this.standardBigDecimalConverter = standardBigDecimalConverter;
} }
public BoolConverter getStandardBoolConverter()
{
return standardBoolConverter;
}
public void setStandardBoolConverter(BoolConverter standardBoolConverter)
{
this.standardBoolConverter = standardBoolConverter;
}
@Init @Init
public void initDocumentViewModel() public void initDocumentViewModel()
{ {
this.standardBigDecimalConverter = new BigDecimalConverter(); this.standardBigDecimalConverter = new BigDecimalConverter();
this.standardBoolConverter = new BoolConverter();
} }
@Command @Command

@ -51,6 +51,11 @@ public class OrderForm extends FormViewModel<Order>
protected List<OrderItem> syncOrderItems; protected List<OrderItem> syncOrderItems;
/**
* Obsah záznamu před editací
*/
protected Order recordBeforeEdit;
@Init(superclass = true) @Init(superclass = true)
public void initOrderForm() public void initOrderForm()
{ {
@ -78,6 +83,16 @@ public class OrderForm extends FormViewModel<Order>
} }
this.syncOrderItems = this.getDataBean().getItems(); this.syncOrderItems = this.getDataBean().getItems();
try
{
this.recordBeforeEdit = (Order) this.getDataBean().clone();
}
catch (CloneNotSupportedException e)
{
log.error("Nelze provést hlubokou kopii objednávky!");
e.printStackTrace();
}
} }
public OrderFormValidator getOrderFormValidator() public OrderFormValidator getOrderFormValidator()
@ -165,6 +180,16 @@ public class OrderForm extends FormViewModel<Order>
this.syncOrderItems = syncOrderItems; this.syncOrderItems = syncOrderItems;
} }
public Order getRecordBeforeEdit()
{
return recordBeforeEdit;
}
public void setRecordBeforeEdit(Order recordBeforeEdit)
{
this.recordBeforeEdit = recordBeforeEdit;
}
@Command @Command
@NotifyChange("dataBean") @NotifyChange("dataBean")
public void doFillSuppAddress() public void doFillSuppAddress()
@ -252,4 +277,14 @@ public class OrderForm extends FormViewModel<Order>
// Calculate total price at form // Calculate total price at form
this.calcAndUpdateFormTotalPrice(form); this.calcAndUpdateFormTotalPrice(form);
} }
@Override
protected void doSave()
{
// Zjisti, zda se změnil příznak objednávky (objednáno/neobjednáno)
boolean orderedChanged = (this.recordBeforeEdit.isOrdered() != this.getDataBean().isOrdered());
// Aktualizovat příznak schválených položek, aby se nemohli vložit do
// jiných objednávek
orderService.updateApprovedItems(this.getDataBean(), orderedChanged);
}
} }

@ -279,6 +279,7 @@ false=Ne
Information=Informace Information=Informace
Order=Objednávka Order=Objednávka
Orders=Objednávky Orders=Objednávky
OrderAbr=Obj.
MaterialRequirement=Požadavek na materiál MaterialRequirement=Požadavek na materiál
MaterialRequirements=Požadavky na materiál MaterialRequirements=Požadavky na materiál

@ -219,6 +219,10 @@
<property name="sessionFactory" ref="sessionFactory"/> <property name="sessionFactory" ref="sessionFactory"/>
</bean> </bean>
<bean id="requirementItemDao" class="info.bukova.isspst.dao.jpa.RequirementItemDaoJPA">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="numericSeriesDao" class="info.bukova.isspst.dao.jpa.NumberSeriesDaoJPA"> <bean id="numericSeriesDao" class="info.bukova.isspst.dao.jpa.NumberSeriesDaoJPA">
<property name="sessionFactory" ref="sessionFactory"/> <property name="sessionFactory" ref="sessionFactory"/>
</bean> </bean>

@ -27,9 +27,13 @@
model="@load(vm.dataList)"> model="@load(vm.dataList)">
<listhead menupopup="auto"> <listhead menupopup="auto">
<listheader <listheader
hflex="10" hflex="3"
sort="auto(ordered)"
label="${labels.OrderAbr}" />
<listheader
hflex="7"
sort="czech(numser)" sort="czech(numser)"
label="${labels.OrderFormNumber}" /> label="${labels.number}" />
<listheader <listheader
hflex="10" hflex="10"
sort="auto(orderDate)" sort="auto(orderDate)"
@ -79,6 +83,19 @@
label="${labels.OrderFormDescription}" /> label="${labels.OrderFormDescription}" />
</listhead> </listhead>
<auxhead visible="@load(vm.filter)"> <auxhead visible="@load(vm.filter)">
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<checkbox
label="${labels.OrderFormOrdered}"
checked="@bind(vm.filterTemplate.ordered)"
onClick="@command('doFilter')" />
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
<auxheader> <auxheader>
<div sclass="find-grid-cell"> <div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox"> <div sclass="find-grid-divtextbox">
@ -251,6 +268,7 @@
</auxhead> </auxhead>
<template name="model"> <template name="model">
<listitem> <listitem>
<listcell label="@load(each.ordered) @converter(vm.standardBoolConverter)" />
<listcell label="@load(each.numser)" /> <listcell label="@load(each.numser)" />
<listcell label="@load(each.orderDate) @converter('formatedDate', format=labels.DateFormat)" /> <listcell label="@load(each.orderDate) @converter('formatedDate', format=labels.DateFormat)" />
<listcell label="@load(each.total) @converter(vm.standardBigDecimalConverter)" /> <listcell label="@load(each.total) @converter(vm.standardBigDecimalConverter)" />
@ -308,6 +326,10 @@
hflex="15" hflex="15"
sort="czech(description)" sort="czech(description)"
label="${labels.RequirementItemDescription}" /> label="${labels.RequirementItemDescription}" />
<listheader
hflex="5"
sort="auto(reqItem.orderNum)"
label="${labels.OrderAbr}" />
</listhead> </listhead>
<template name="model"> <template name="model">
<listitem> <listitem>
@ -319,6 +341,7 @@
<listcell label="@load(each.unitPrice) @converter(vm.standardBigDecimalConverter)" /> <listcell label="@load(each.unitPrice) @converter(vm.standardBigDecimalConverter)" />
<listcell label="@load(each.total) @converter(vm.standardBigDecimalConverter)" /> <listcell label="@load(each.total) @converter(vm.standardBigDecimalConverter)" />
<listcell label="@load(each.description)" /> <listcell label="@load(each.description)" />
<listcell label="@load(each.reqItem.orderNum)" />
</listitem> </listitem>
</template> </template>
</listbox> </listbox>

@ -42,6 +42,16 @@
<column /> <column />
</columns> </columns>
<rows vflex="max"> <rows vflex="max">
<row>
<cell sclass="row-title"></cell>
<cell>
<checkbox
id="idOrderOrdered"
disabled="@load(fx.icludedRequirementItemFromAnotherOrder)"
label="${labels.OrderFormOrdered}"
checked="@bind(fx.ordered)" />
</cell>
</row>
<row> <row>
<cell sclass="row-title">${labels.OrderFormNumber} :</cell> <cell sclass="row-title">${labels.OrderFormNumber} :</cell>
<cell> <cell>
@ -532,6 +542,10 @@
hflex="15" hflex="15"
sort="czech(description)" sort="czech(description)"
label="${labels.RequirementItemDescription}" /> label="${labels.RequirementItemDescription}" />
<listheader
hflex="5"
sort="auto(reqItem.orderNum)"
label="${labels.OrderAbr}" />
</listhead> </listhead>
<template name="model"> <template name="model">
<listitem> <listitem>
@ -542,7 +556,7 @@
<textbox <textbox
inplace="true" inplace="true"
sclass="grid-textbox-max-right" sclass="grid-textbox-max-right"
readonly="${not sec:isAllGranted('ROLE_ADMIN')}" readonly="true"
onFocus="@command('onFocusItem', item=each, ctrl=self)" onFocus="@command('onFocusItem', item=each, ctrl=self)"
onChange="@command('recalculate', form=fx, changed='quantity')" onChange="@command('recalculate', form=fx, changed='quantity')"
value="@bind(each.quantity) @converter(vm.standardBigDecimalConverter)" /> value="@bind(each.quantity) @converter(vm.standardBigDecimalConverter)" />
@ -567,6 +581,7 @@
value="@bind(each.total) @converter(vm.standardBigDecimalConverter)" /> value="@bind(each.total) @converter(vm.standardBigDecimalConverter)" />
</listcell> </listcell>
<listcell label="@load(each.description)" /> <listcell label="@load(each.description)" />
<listcell label="@load(each.reqItem.orderNum)" />
</listitem> </listitem>
</template> </template>
</listbox> </listbox>

Loading…
Cancel
Save