Fakturovaná částka na objednávkách se nyní počítá z položek.
closes #152, #154
This commit is contained in:
@@ -301,8 +301,9 @@ public class Order extends BaseData implements Cloneable
|
|||||||
if (rItem != null)
|
if (rItem != null)
|
||||||
{
|
{
|
||||||
String orderNum = rItem.getOrderNum();
|
String orderNum = rItem.getOrderNum();
|
||||||
boolean isIncluded = !((orderNum == null) || (orderNum.isEmpty()));
|
boolean isIncluded = ((orderNum != null) && !orderNum.isEmpty());
|
||||||
return isIncluded;
|
boolean isFromAnotherOrder = (isIncluded && !this.numser.equals(orderNum));
|
||||||
|
return isFromAnotherOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ public class OrderItem {
|
|||||||
@Column(name = "DESCRIPTION")
|
@Column(name = "DESCRIPTION")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
@Column(name = "TOTALINVOICE", precision = 15, scale = 4)
|
||||||
|
private BigDecimal totalInvoice;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "REQUIREMENT_ITEM_ID")
|
@JoinColumn(name = "REQUIREMENT_ITEM_ID")
|
||||||
private RequirementItem reqItem;
|
private RequirementItem reqItem;
|
||||||
@@ -68,6 +71,7 @@ public class OrderItem {
|
|||||||
this.munit = reqItem.getMunit();
|
this.munit = reqItem.getMunit();
|
||||||
this.total = reqItem.getTotal();
|
this.total = reqItem.getTotal();
|
||||||
this.description = reqItem.getDescription();
|
this.description = reqItem.getDescription();
|
||||||
|
this.totalInvoice = BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@@ -142,6 +146,16 @@ public class OrderItem {
|
|||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTotalInvoice()
|
||||||
|
{
|
||||||
|
return totalInvoice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalInvoice(BigDecimal totalInvoice)
|
||||||
|
{
|
||||||
|
this.totalInvoice = totalInvoice;
|
||||||
|
}
|
||||||
|
|
||||||
public RequirementItem getReqItem() {
|
public RequirementItem getReqItem() {
|
||||||
return reqItem;
|
return reqItem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,5 +22,7 @@ public interface OrderService extends Service<Order> {
|
|||||||
|
|
||||||
public BigDecimal calcSumTotalFromItems(List<OrderItem> items);
|
public BigDecimal calcSumTotalFromItems(List<OrderItem> items);
|
||||||
|
|
||||||
|
public BigDecimal calcSumTotalInvoiceFromItems(List<OrderItem> items);
|
||||||
|
|
||||||
public void updateApprovedItems(Order order, boolean orderedChanged);
|
public void updateApprovedItems(Order order, boolean orderedChanged);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,6 +177,30 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
|
|||||||
return sumTotal;
|
return sumTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal calcSumTotalInvoiceFromItems(List<OrderItem> items)
|
||||||
|
{
|
||||||
|
BigDecimal sumTotal = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
if (items != null)
|
||||||
|
{
|
||||||
|
for (OrderItem item : items)
|
||||||
|
{
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
BigDecimal total = item.getTotalInvoice();
|
||||||
|
|
||||||
|
if (total != null)
|
||||||
|
{
|
||||||
|
sumTotal = sumTotal.add(total);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sumTotal;
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void updateApprovedItems(Order order, boolean orderedChanged)
|
public void updateApprovedItems(Order order, boolean orderedChanged)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -278,6 +278,36 @@ public class OrderForm extends FormViewModel<Order>
|
|||||||
this.calcAndUpdateFormTotalPrice(form);
|
this.calcAndUpdateFormTotalPrice(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void calcAndUpdateFormTotalInvoicePrice(SimpleForm form)
|
||||||
|
{
|
||||||
|
if (form != null)
|
||||||
|
{
|
||||||
|
BigDecimal sumTotal = orderService.calcSumTotalInvoiceFromItems(this.getDataBean().getItems());
|
||||||
|
form.setField("invoiceTotal", sumTotal);
|
||||||
|
BindUtils.postNotifyChange(null, null, form, "*");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
@NotifyChange({ "selectedItem", "syncOrderItems" })
|
||||||
|
public void recalculateTotalInvoice(@BindingParam("form") SimpleForm form, @BindingParam("changed") String source)
|
||||||
|
{
|
||||||
|
if (this.selectedItem == null)
|
||||||
|
{
|
||||||
|
log.warn("Zavolat z formuláře onFocus pro nastavení vybrané položky!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((source != null) && (source.equals("totalInvoice")))
|
||||||
|
{
|
||||||
|
// Calculate total price at form
|
||||||
|
this.calcAndUpdateFormTotalInvoicePrice(form);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.warn("Dopracovat přepočet fakturované částky objednávky i pro další případy!");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doSave()
|
protected void doSave()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE xml>
|
||||||
<language-addon>
|
<language-addon>
|
||||||
<addon-name>CzechSortListheader</addon-name>
|
<addon-name>CzechSortListheader</addon-name>
|
||||||
<language-name>xul/html</language-name>
|
<language-name>xul/html</language-name>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE xml>
|
||||||
<language-addon>
|
<language-addon>
|
||||||
<!-- The name of this addon. It must be unique -->
|
<!-- The name of this addon. It must be unique -->
|
||||||
<addon-name>ckezbind</addon-name>
|
<addon-name>ckezbind</addon-name>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE xml>
|
||||||
<language-addon>
|
<language-addon>
|
||||||
<addon-name>mapa</addon-name>
|
<addon-name>mapa</addon-name>
|
||||||
<language-name>xul/html</language-name>
|
<language-name>xul/html</language-name>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE xml>
|
||||||
<taglib>
|
<taglib>
|
||||||
<uri>http://www.zkoss.org/demo/integration/security</uri>
|
<uri>http://www.zkoss.org/demo/integration/security</uri>
|
||||||
<description>
|
<description>
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ html, body {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-caption {
|
.form-caption, .form-caption-highlight {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
@@ -82,6 +82,14 @@ html, body {
|
|||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-caption-highlight {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
.form-caption-highlight-content {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
html, body { background-color: red; }
|
html, body { background-color: red; }
|
||||||
#screen { background-color: lightgreen; }
|
#screen { background-color: lightgreen; }
|
||||||
|
|||||||
@@ -326,6 +326,11 @@
|
|||||||
hflex="15"
|
hflex="15"
|
||||||
sort="czech(description)"
|
sort="czech(description)"
|
||||||
label="${labels.RequirementItemDescription}" />
|
label="${labels.RequirementItemDescription}" />
|
||||||
|
<listheader
|
||||||
|
hflex="7"
|
||||||
|
align="right"
|
||||||
|
sort="auto(totalInvoice)"
|
||||||
|
label="${labels.OrderFormInvoiceTotal}" />
|
||||||
<listheader
|
<listheader
|
||||||
hflex="5"
|
hflex="5"
|
||||||
sort="auto(reqItem.orderNum)"
|
sort="auto(reqItem.orderNum)"
|
||||||
@@ -341,6 +346,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.totalInvoice) @converter(vm.standardBigDecimalConverter)" />
|
||||||
<listcell label="@load(each.reqItem.orderNum)" />
|
<listcell label="@load(each.reqItem.orderNum)" />
|
||||||
</listitem>
|
</listitem>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -120,6 +120,7 @@
|
|||||||
<cell>
|
<cell>
|
||||||
<textbox
|
<textbox
|
||||||
id="idOrderInvoiceTotal"
|
id="idOrderInvoiceTotal"
|
||||||
|
readonly="true"
|
||||||
width="150px"
|
width="150px"
|
||||||
value="@bind(fx.invoiceTotal) @converter(vm.standardBigDecimalConverter)" />
|
value="@bind(fx.invoiceTotal) @converter(vm.standardBigDecimalConverter)" />
|
||||||
</cell>
|
</cell>
|
||||||
@@ -542,6 +543,11 @@
|
|||||||
hflex="15"
|
hflex="15"
|
||||||
sort="czech(description)"
|
sort="czech(description)"
|
||||||
label="${labels.RequirementItemDescription}" />
|
label="${labels.RequirementItemDescription}" />
|
||||||
|
<listheader
|
||||||
|
hflex="7"
|
||||||
|
align="right"
|
||||||
|
sort="auto(totalInvoice)"
|
||||||
|
label="${labels.OrderFormInvoiceTotal}" />
|
||||||
<listheader
|
<listheader
|
||||||
hflex="5"
|
hflex="5"
|
||||||
sort="auto(reqItem.orderNum)"
|
sort="auto(reqItem.orderNum)"
|
||||||
@@ -581,6 +587,15 @@
|
|||||||
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>
|
||||||
|
<textbox
|
||||||
|
inplace="true"
|
||||||
|
sclass="grid-textbox-max-right"
|
||||||
|
readonly="false"
|
||||||
|
onFocus="@command('onFocusItem', item=each, ctrl=self)"
|
||||||
|
onChange="@command('recalculateTotalInvoice', form=fx, changed='totalInvoice')"
|
||||||
|
value="@bind(each.totalInvoice) @converter(vm.standardBigDecimalConverter)" />
|
||||||
|
</listcell>
|
||||||
<listcell label="@load(each.reqItem.orderNum)" />
|
<listcell label="@load(each.reqItem.orderNum)" />
|
||||||
</listitem>
|
</listitem>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user