Fakturovaná částka na objednávkách se nyní počítá z položek.

closes #152, #154
Verze_1.0
František Přibyl 10 years ago
parent 5b380386bd
commit 18920701a7

@ -301,8 +301,9 @@ public class Order extends BaseData implements Cloneable
if (rItem != null)
{
String orderNum = rItem.getOrderNum();
boolean isIncluded = !((orderNum == null) || (orderNum.isEmpty()));
return isIncluded;
boolean isIncluded = ((orderNum != null) && !orderNum.isEmpty());
boolean isFromAnotherOrder = (isIncluded && !this.numser.equals(orderNum));
return isFromAnotherOrder;
}
}

@ -45,6 +45,9 @@ public class OrderItem {
@Column(name = "DESCRIPTION")
private String description;
@Column(name = "TOTALINVOICE", precision = 15, scale = 4)
private BigDecimal totalInvoice;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "REQUIREMENT_ITEM_ID")
private RequirementItem reqItem;
@ -68,6 +71,7 @@ public class OrderItem {
this.munit = reqItem.getMunit();
this.total = reqItem.getTotal();
this.description = reqItem.getDescription();
this.totalInvoice = BigDecimal.ZERO;
}
public int getId() {
@ -142,6 +146,16 @@ public class OrderItem {
this.description = description;
}
public BigDecimal getTotalInvoice()
{
return totalInvoice;
}
public void setTotalInvoice(BigDecimal totalInvoice)
{
this.totalInvoice = totalInvoice;
}
public RequirementItem getReqItem() {
return reqItem;
}

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

@ -177,6 +177,30 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
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
public void updateApprovedItems(Order order, boolean orderedChanged)
{

@ -278,6 +278,36 @@ public class OrderForm extends FormViewModel<Order>
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
protected void doSave()
{

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE xml>
<language-addon>
<addon-name>CzechSortListheader</addon-name>
<language-name>xul/html</language-name>

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<language-addon>
<!-- The name of this addon. It must be unique -->
<addon-name>ckezbind</addon-name>

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<language-addon>
<addon-name>mapa</addon-name>
<language-name>xul/html</language-name>

@ -1,3 +1,4 @@
<!DOCTYPE xml>
<taglib>
<uri>http://www.zkoss.org/demo/integration/security</uri>
<description>

@ -66,7 +66,7 @@ html, body {
overflow: hidden;
}
.form-caption {
.form-caption, .form-caption-highlight {
overflow: hidden;
font-weight: bold;
font-size: 20px;
@ -82,6 +82,14 @@ html, body {
padding-right: 5px;
}
.form-caption-highlight {
background-color: red;
}
.form-caption-highlight-content {
float: left;
}
/*
html, body { background-color: red; }
#screen { background-color: lightgreen; }

@ -326,6 +326,11 @@
hflex="15"
sort="czech(description)"
label="${labels.RequirementItemDescription}" />
<listheader
hflex="7"
align="right"
sort="auto(totalInvoice)"
label="${labels.OrderFormInvoiceTotal}" />
<listheader
hflex="5"
sort="auto(reqItem.orderNum)"
@ -341,6 +346,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.totalInvoice) @converter(vm.standardBigDecimalConverter)" />
<listcell label="@load(each.reqItem.orderNum)" />
</listitem>
</template>

@ -120,6 +120,7 @@
<cell>
<textbox
id="idOrderInvoiceTotal"
readonly="true"
width="150px"
value="@bind(fx.invoiceTotal) @converter(vm.standardBigDecimalConverter)" />
</cell>
@ -542,6 +543,11 @@
hflex="15"
sort="czech(description)"
label="${labels.RequirementItemDescription}" />
<listheader
hflex="7"
align="right"
sort="auto(totalInvoice)"
label="${labels.OrderFormInvoiceTotal}" />
<listheader
hflex="5"
sort="auto(reqItem.orderNum)"
@ -581,6 +587,15 @@
value="@bind(each.total) @converter(vm.standardBigDecimalConverter)" />
</listcell>
<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)" />
</listitem>
</template>

Loading…
Cancel
Save