When we want to cancel a document that includes items with lots or create a return ticket, we follow the following procedure:
- We open the invoice we want to cancel
- We select the batches of the type we want to return and press disconnect from batches
- We normally cancel the document by copying, for example, to a special cancellation note, return slip or credit card. Thus the items are removed from the warehouse
It is good to select the documents that we import the goods in the EMDI settings
Automatic disconnection from batches
When issuing a Return Notice, it is possible to automatically disconnect the items from the lots. A necessary condition is that a position/lot has been selected in each line of the item.
For this function, paste the following code into the settings in the corresponding document
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
-- doc -- -- doc -- execute block as declare i int = 0; declare main_doc_prodid int; declare main_doc_lineid int; declare main_doc_position varchar(1000); declare doc_related varchar(1000); begin doc_related=(select "Sxetika" from "pvlhseis" pvlin where "Aa"=:aa); while (i < 150) do begin if ((select count(ppl."Aa") from "pvlhseis" ppl,"grammes" ggr,"eidhpar" eid where ggr."Aapar"=ppl."Aa" and eid."Aa"=ppl."Parastatiko" and (ppl."Sxetiko"=:aa or doc_abbreviation(eid."Parastatiko",coalesce( ppl."Seira",'')||'#'||ppl."Ariumospar")=:doc_related) )>:i) then begin main_doc_prodid=(select first 1 skip (:i) ggr."Eidos" from "pvlhseis" ppl,"grammes" ggr,"eidhpar" eid, "kinhseis" kin where kin."Grammh"=ggr."Aa" and ggr."Aapar"=ppl."Aa" and eid."Aa"=ppl."Parastatiko" and (ppl."Sxetiko"=:aa or doc_abbreviation(eid."Parastatiko",coalesce( ppl."Seira",'')||'#'||ppl."Ariumospar")=:doc_related) ); main_doc_lineid=(select first 1 skip (:i) ggr."Aa" from "pvlhseis" ppl,"grammes" ggr,"eidhpar" eid, "kinhseis" kin where kin."Grammh"=ggr."Aa" and ggr."Aapar"=ppl."Aa" and eid."Aa"=ppl."Parastatiko" and (ppl."Sxetiko"=:aa or doc_abbreviation(eid."Parastatiko",coalesce( ppl."Seira",'')||'#'||ppl."Ariumospar")=:doc_related) ); main_doc_position=(select first 1 skip (:i) kin."Uesh" from "pvlhseis" ppl,"grammes" ggr,"eidhpar" eid, "kinhseis" kin where kin."Grammh"=ggr."Aa" and ggr."Aapar"=ppl."Aa" and eid."Aa"=ppl."Parastatiko" and (ppl."Sxetiko"=:aa or doc_abbreviation(eid."Parastatiko",coalesce( ppl."Seira",'')||'#'||ppl."Ariumospar")=:doc_related) ); if (:main_doc_prodid in (select ggr."Eidos" from "grammes" ggr where ggr."Aapar"=:aa)) then begin update "stockperdocline" stdl set stdl."Quantity"= (select grg."Posothta" from "grammes" grg where grg."Aa"=stdl."RelID") - (select sum(ggr."Posothta") from "grammes" ggr,"kinhseis" kks where ggr."Aa"=kks."Grammh" and ggr."Aapar"=:aa and ggr."Eidos"=:main_doc_prodid and kks."Uesh"=:main_doc_position ) where stdl."RelID"=:main_doc_lineid; end end else suspend; i = i + 1; end end -- doc-eof -- -- client -- select "pelates"."custom2" im_cust1, "pelates"."custom3" im_cust2, "pelates"."custom4" im_cust3, "pelates"."custom5" im_cust4 from "pelates" where "pelates"."Aa"=:cl -- client-eof -- |