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
{
private static String nullStr(String str)
public static String nullToEmptyString(String str)
{
return str == null ? "" : str;
}
private static String not0ToStr(long i)
private static String zeroToEmptyString(long i)
{
return i == 0 ? "" : String.valueOf(i);
}
@ -60,8 +60,8 @@ public class StringUtils
public static boolean isEqualForFilter(String value, String search)
{
value = StringUtils.nullStr(value).toLowerCase();
search = StringUtils.nullStr(search).toLowerCase();
value = StringUtils.nullToEmptyString(value).toLowerCase();
search = StringUtils.nullToEmptyString(search).toLowerCase();
if (search.isEmpty())
{
@ -73,8 +73,8 @@ public class StringUtils
public static boolean isIcEqualForFilter(long value, long search)
{
String compareValue = StringUtils.not0ToStr(value);
String searchValue = StringUtils.not0ToStr(search);
String compareValue = StringUtils.zeroToEmptyString(value);
String searchValue = StringUtils.zeroToEmptyString(search);
return compareValue.startsWith(searchValue);
}
@ -124,7 +124,7 @@ public class StringUtils
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 += item;
}
@ -138,7 +138,7 @@ public class StringUtils
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())
{

@ -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
@Table(name = "ORDERS")
public class Order extends BaseData
public class Order extends BaseData implements Cloneable
{
@Column(name = "NUMSER")
@ -292,4 +292,28 @@ public class Order extends BaseData
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")
private Boolean delivered;
@Column(name = "ORDERNUM")
private String orderNum;
public int getId()
{
return id;
@ -187,4 +190,14 @@ public class RequirementItem
public void setDelivered(Boolean 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
public boolean matchesSafely(Order item)
{
boolean foundOrdered = (item.isOrdered() == condition.isOrdered());
boolean foundNumSer = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser());
boolean foundOrderDate = DateTimeUtils.isEqualByDateForFilter(item.getOrderDate(), condition.getOrderDate());
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 foundOwnedBy = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
return (foundNumSer
return (foundOrdered
&& foundNumSer
&& foundOrderDate
&& foundTotal
&& foundDeliveryDate

@ -35,7 +35,7 @@ public class ApprovedServiceImpl extends AbstractService<JoinedItem> implements
{
List<Workgroup> wgList = workgroupService.getUserCentres(userService.getCurrent());
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.setParameter("state", RequirementState.APPROVED);
List<JoinedItem> items = new ArrayList<JoinedItem>();

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

@ -1,9 +1,11 @@
package info.bukova.isspst.services.approved;
import info.bukova.isspst.dao.RequirementItemDao;
import info.bukova.isspst.data.AddressEmb;
import info.bukova.isspst.data.JoinedItem;
import info.bukova.isspst.data.Order;
import info.bukova.isspst.data.OrderItem;
import info.bukova.isspst.data.RequirementItem;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.LazyLoader;
@ -23,7 +25,10 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
@Autowired
private GlobalSettingsService globalSettings;
@Autowired
private RequirementItemDao requirementItemDao;
@Override
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
public Order createOrder(List<JoinedItem> items) {
@ -171,4 +176,24 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
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 BoolConverter standardBoolConverter;
public BigDecimalConverter getStandardBigDecimalConverter()
{
return standardBigDecimalConverter;
@ -27,10 +29,21 @@ public class DocumentViewModel
this.standardBigDecimalConverter = standardBigDecimalConverter;
}
public BoolConverter getStandardBoolConverter()
{
return standardBoolConverter;
}
public void setStandardBoolConverter(BoolConverter standardBoolConverter)
{
this.standardBoolConverter = standardBoolConverter;
}
@Init
public void initDocumentViewModel()
{
this.standardBigDecimalConverter = new BigDecimalConverter();
this.standardBoolConverter = new BoolConverter();
}
@Command

@ -51,6 +51,11 @@ public class OrderForm extends FormViewModel<Order>
protected List<OrderItem> syncOrderItems;
/**
* Obsah záznamu před editací
*/
protected Order recordBeforeEdit;
@Init(superclass = true)
public void initOrderForm()
{
@ -78,6 +83,16 @@ public class OrderForm extends FormViewModel<Order>
}
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()
@ -165,6 +180,16 @@ public class OrderForm extends FormViewModel<Order>
this.syncOrderItems = syncOrderItems;
}
public Order getRecordBeforeEdit()
{
return recordBeforeEdit;
}
public void setRecordBeforeEdit(Order recordBeforeEdit)
{
this.recordBeforeEdit = recordBeforeEdit;
}
@Command
@NotifyChange("dataBean")
public void doFillSuppAddress()
@ -252,4 +277,14 @@ public class OrderForm extends FormViewModel<Order>
// Calculate total price at 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
Order=Objednávka
Orders=Objednávky
OrderAbr=Obj.
MaterialRequirement=Požadavek na materiál
MaterialRequirements=Požadavky na materiál

@ -219,6 +219,10 @@
<property name="sessionFactory" ref="sessionFactory"/>
</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">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

@ -27,9 +27,13 @@
model="@load(vm.dataList)">
<listhead menupopup="auto">
<listheader
hflex="10"
hflex="3"
sort="auto(ordered)"
label="${labels.OrderAbr}" />
<listheader
hflex="7"
sort="czech(numser)"
label="${labels.OrderFormNumber}" />
label="${labels.number}" />
<listheader
hflex="10"
sort="auto(orderDate)"
@ -79,6 +83,19 @@
label="${labels.OrderFormDescription}" />
</listhead>
<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>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
@ -251,6 +268,7 @@
</auxhead>
<template name="model">
<listitem>
<listcell label="@load(each.ordered) @converter(vm.standardBoolConverter)" />
<listcell label="@load(each.numser)" />
<listcell label="@load(each.orderDate) @converter('formatedDate', format=labels.DateFormat)" />
<listcell label="@load(each.total) @converter(vm.standardBigDecimalConverter)" />
@ -308,6 +326,10 @@
hflex="15"
sort="czech(description)"
label="${labels.RequirementItemDescription}" />
<listheader
hflex="5"
sort="auto(reqItem.orderNum)"
label="${labels.OrderAbr}" />
</listhead>
<template name="model">
<listitem>
@ -319,6 +341,7 @@
<listcell label="@load(each.unitPrice) @converter(vm.standardBigDecimalConverter)" />
<listcell label="@load(each.total) @converter(vm.standardBigDecimalConverter)" />
<listcell label="@load(each.description)" />
<listcell label="@load(each.reqItem.orderNum)" />
</listitem>
</template>
</listbox>

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

Loading…
Cancel
Save