Created
May 16, 2017 15:09
-
-
Save stelf/82bb2de3220e87b898ab88155c7951dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<objectdefs> | |
<most module_alias="m" use_prefix="true"> | |
<protocol_return parent_objectdef="most.protocol_stock"> | |
<ref_sale> | |
<category>most.related.protocols</category> | |
<sort_id>189</sort_id> | |
<data_source>relation</data_source> | |
<is_obligatory>false</is_obligatory> | |
<is_inmaintbl>true</is_inmaintbl> | |
<related_objectdef>most.protocol_sale</related_objectdef> | |
<rel_display_string_order>official_date."date"</rel_display_string_order> | |
<rel_display_columns>most.protocol.code</rel_display_columns> | |
<rel_display_columns>most.protocol.quantity</rel_display_columns> | |
<rel_display_columns>most.protocol_sale.returned_quantity</rel_display_columns> | |
<rel_display_columns>most.protocol_sale.stable_quantity</rel_display_columns> | |
<name> | |
<en-US>Ref. Sale</en-US> | |
</name> | |
<name> | |
<de-DE>Aus Belieferung</de-DE> | |
</name> | |
<name> | |
<bg-BG>От Зареждане</bg-BG> | |
</name> | |
<on_insert_value> | |
<object code="most.item.ref_sale:on_insert_delete" module="core" objectdef="vscript"> | |
<script_code> | |
<value> | |
<![CDATA[ | |
if (this["items"] != null) { | |
java.log.warn("ref_sale:update:: clear [" + this.code + "] from its items' protocols properties."); | |
this.items.remove(); | |
} | |
if (this["ref_sale"] != null && this.ref_sale.stock != null) { | |
this.stock = this.ref_sale.stock; | |
this.opg = this.ref_sale.opg; | |
this.opg_string = this.ref_sale.opg_string; | |
} else { | |
if (this["stock"] != null) this.stock.remove(); | |
if (this["opg"] != null) this.opg.remove(); | |
if (this["opg_string"] != null) this.opg_string.remove(); | |
} | |
]]> | |
</value> | |
</script_code> | |
</object> | |
</on_insert_value> | |
<on_delete_value> | |
<object code="most.item.ref_sale:on_insert_delete" module="core" objectdef="vscript"/> | |
</on_delete_value> | |
<on_update_value> | |
<object code="most.item.ref_sale:on_update_value" module="core" objectdef="vscript"> | |
<script_code> | |
<value><![CDATA[ | |
// clear referenced protocols in items | |
if (this["items"] != null) { | |
java.log.warn("ref_sale:update:: clear [" + this.code + "] from its items' protocols properties."); | |
this.items.remove(); | |
} | |
if (this["ref_sale"] != null && this.ref_sale["stock"] != null) { | |
this.stock = this.ref_sale.stock; | |
} else { | |
if (this["stock"] != null) this.stock.remove(); | |
} | |
]]></value> | |
</script_code> | |
</object> | |
</on_update_value> | |
<relation_filter> | |
<object code="most.protocol_return.ref_sale" module="core" objectdef="relation_filter"> | |
<get_related_objectdef_condition> | |
<value> | |
<object code="relation_filter:most.protocol_return.ref_sale:get_related_objectdef_condition" module="core" objectdef="vscript"> | |
<params> | |
<value> | |
<object code="object" module="core" objectdef="script_param"/> | |
</value> | |
<value> | |
<object code="property" module="core" objectdef="script_param"/> | |
</value> | |
</params> | |
<script_code> | |
<value> | |
<![CDATA[ | |
if (object.customer == null || object.article == null || object.quantity == null || object.quantity <= 0) | |
return "0=1"; | |
var cond = [ | |
"official_date is not null", | |
"customer.code = :CUS", | |
"article.code = :ART", | |
"id < :RID", | |
"stable_quantity >= :QTY" | |
]; | |
var sel = db.most.protocol_sale.SELECT(cond.join(" and ")); | |
sel["CUS"] = object.customer.code; | |
sel["ART"] = object.article.code; | |
sel["QTY"] = object.quantity; | |
sel["RID"] = object.id; | |
var arr=[]; | |
for (var e : sel.VALUE) { | |
arr.push(e.id); | |
java.log.warn("ref_sale:update:: select [" + e.code + "] for possible sales select."); | |
} | |
return (arr.is_empty) ? "0=1" : "id IN ("+arr.join(",")+")"; | |
]]> | |
</value> | |
</script_code> | |
</object> | |
</value> | |
</get_related_objectdef_condition> | |
</object> | |
</relation_filter> | |
</ref_sale> | |
</protocol_return> | |
</most> | |
</objectdefs> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment