|
|
@ -9,7 +9,6 @@ import info.bukova.isspst.services.requirement.RequirementService;
|
|
|
|
import info.bukova.isspst.services.requirement.RequirementTypeService;
|
|
|
|
import info.bukova.isspst.services.requirement.RequirementTypeService;
|
|
|
|
import info.bukova.isspst.services.users.UserService;
|
|
|
|
import info.bukova.isspst.services.users.UserService;
|
|
|
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
|
|
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
|
|
|
import info.bukova.isspst.ui.BigDecimalConverter;
|
|
|
|
|
|
|
|
import info.bukova.isspst.ui.FormViewModel;
|
|
|
|
import info.bukova.isspst.ui.FormViewModel;
|
|
|
|
import info.bukova.isspst.validators.RequirementFormValidator;
|
|
|
|
import info.bukova.isspst.validators.RequirementFormValidator;
|
|
|
|
|
|
|
|
|
|
|
@ -64,8 +63,6 @@ public class RequirementForm extends FormViewModel<Requirement>
|
|
|
|
|
|
|
|
|
|
|
|
private int selItemIndex;
|
|
|
|
private int selItemIndex;
|
|
|
|
|
|
|
|
|
|
|
|
private BigDecimalConverter bigDecimalConverter;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private RequirementFormValidator requirementFormValidator;
|
|
|
|
private RequirementFormValidator requirementFormValidator;
|
|
|
|
|
|
|
|
|
|
|
|
private List<RequirementItem> syncItems;
|
|
|
|
private List<RequirementItem> syncItems;
|
|
|
@ -97,16 +94,6 @@ public class RequirementForm extends FormViewModel<Requirement>
|
|
|
|
this.selItemIndex = selItemIndex;
|
|
|
|
this.selItemIndex = selItemIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public BigDecimalConverter getBigDecimalConverter()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return bigDecimalConverter;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setBigDecimalConverter(BigDecimalConverter bigDecimalConverter)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.bigDecimalConverter = bigDecimalConverter;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public RequirementFormValidator getRequirementFormValidator()
|
|
|
|
public RequirementFormValidator getRequirementFormValidator()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return requirementFormValidator;
|
|
|
|
return requirementFormValidator;
|
|
|
@ -121,7 +108,6 @@ public class RequirementForm extends FormViewModel<Requirement>
|
|
|
|
public void initRequirementForm()
|
|
|
|
public void initRequirementForm()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.setSelItemIndex(-1);
|
|
|
|
this.setSelItemIndex(-1);
|
|
|
|
this.setBigDecimalConverter(new BigDecimalConverter());
|
|
|
|
|
|
|
|
this.setRequirementFormValidator(new RequirementFormValidator());
|
|
|
|
this.setRequirementFormValidator(new RequirementFormValidator());
|
|
|
|
this.setSyncItems(this.getDataBean().getItems());
|
|
|
|
this.setSyncItems(this.getDataBean().getItems());
|
|
|
|
requirementService.loadType(getDataBean());
|
|
|
|
requirementService.loadType(getDataBean());
|
|
|
@ -150,12 +136,26 @@ public class RequirementForm extends FormViewModel<Requirement>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void calcAndUpdateFormTotalPrice(SimpleForm form)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (form != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
BigDecimal sumTotal = requirementService.calcSumTotalFromItems(this.getDataBean().getItems());
|
|
|
|
|
|
|
|
form.setField("sumTotal", sumTotal);
|
|
|
|
|
|
|
|
BindUtils.postNotifyChange(null, null, form, "*");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Command
|
|
|
|
@Command
|
|
|
|
@NotifyChange({ "dataBean", "selItemIndex" })
|
|
|
|
@NotifyChange({ "syncItems", "selItemIndex" })
|
|
|
|
public void removeItem(@BindingParam("item") RequirementItem item)
|
|
|
|
public void removeItem(@BindingParam("form") SimpleForm form, @BindingParam("item") RequirementItem item)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.getDataBean().getItems().remove(item);
|
|
|
|
if (item != null)
|
|
|
|
this.setSelItemIndex(-1);
|
|
|
|
{
|
|
|
|
|
|
|
|
this.getDataBean().getItems().remove(item);
|
|
|
|
|
|
|
|
this.setSelItemIndex(-1);
|
|
|
|
|
|
|
|
this.calcAndUpdateFormTotalPrice(form);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GlobalCommand("insertSelectedItem")
|
|
|
|
@GlobalCommand("insertSelectedItem")
|
|
|
@ -207,35 +207,15 @@ public class RequirementForm extends FormViewModel<Requirement>
|
|
|
|
// Recalculate selected item
|
|
|
|
// Recalculate selected item
|
|
|
|
if ((source != null) && (source.equals("total")))
|
|
|
|
if ((source != null) && (source.equals("total")))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
BigDecimal quantity = this.selectedItem.getQuantity();
|
|
|
|
this.selectedItem = requirementService.calcItemValuesFromItemTotal(this.selectedItem);
|
|
|
|
|
|
|
|
|
|
|
|
if (quantity.equals(BigDecimal.ZERO))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.selectedItem.setUnitPrice(BigDecimal.ZERO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.selectedItem.setUnitPrice(this.selectedItem.getTotal().divide(quantity, 2, BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.selectedItem.setTotal(this.selectedItem.getQuantity().multiply(this.selectedItem.getUnitPrice()));
|
|
|
|
this.selectedItem = requirementService.calcTotalInItem(this.selectedItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate total price at form
|
|
|
|
// Calculate total price at form
|
|
|
|
if (form != null)
|
|
|
|
this.calcAndUpdateFormTotalPrice(form);
|
|
|
|
{
|
|
|
|
|
|
|
|
BigDecimal sumTotal = new BigDecimal(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (RequirementItem item : this.getDataBean().getItems())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sumTotal = sumTotal.add(item.getTotal());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
form.setField("sumTotal", sumTotal);
|
|
|
|
|
|
|
|
BindUtils.postNotifyChange(null, null, form, "*");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Command
|
|
|
|
@Command
|
|
|
|