on 01-11-2021 10:22 AM
Hey,
I have found a method which trying to find the material id in the quick service mode before add the item as sales item.
The method is this one
@PluginAt(method="findMaterialById",pluginClass=MaterialPosService.class,where=POSITION.BEFORE)
But I noticed a strange behaviour.
Correctly it gets inside the method, get the code that I have input and split it into the material item and the other half I put it as additional field as price with the following code
MaterialPosService mst = (MaterialPosService) proxy ;
MaterialEntity mat= mst.getMaterialByKey(item);
mat.addAdditionalField(new AdditionalFieldEntity("FORCE_PRICE","",Double.toString(price)));
The system does not give me an error message and it find the correct material id in the debug mode, but I get the error message "material not found" in the checkout sales screens and never gets in the method addSalesItem.
@PluginAt(pluginClass=ReceiptPosService.class, method="addSalesItem", where=POSITION.BEFORE)
Can you please tell me what I am doing wrong?
Hello antonell
I think you are on the right way. But try it like the following code.Please let me know if this helped you out...
Best Regards
Klaus
@PluginAt(pluginClass=MaterialPosService.class, method="findMaterialById", where=POSITION.AFTER)
public Object MaterialPosService_findMaterialById_After(Object proxy, Object args[], Object ret, StackTraceElement stack){
String pItem = (String) args[0];
if (pItem.contentEquals("ARTICLEPART/PRICEPART")) {
pItem="ARTICLEPART";
String pPrice = "PRICEPART";
MaterialPosService matpos = (MaterialPosService) proxy;
MaterialEntity mat= matpos.findMaterialById(pItem);
mat.addAdditionalField(new AdditionalFieldEntity("FORCE_PRICE","",pPrice));
Pair<MaterialEntity, String> retN = new Pair<>(mat,"-1");
ret=retN;
}
return ret;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Klaus,
Can you please explain to me what is the purpose of the number "-1" in the Pair function?
Pair<MaterialEntity,String> retN =new Pair<>(mat,"-1");
Because I used it exactly as per your example, and I faced an issue with the retrieved material.
I changed it into 10 and then the system was recognize my material but all the other value such as prices was recognized it as manual entries and if I had two pricelists synchronized in my POS, was giving me a price from a different pricelist and not from the default one.
Pair<MaterialEntity,String> retN =new Pair<>(mat,"10");
Finally I changed this value into 1 and it seems to works properly, but i would like to know what is the purpose of that number.
Pair<MaterialEntity,String> retN =new Pair<>(mat,"1");
Hello Klaus Frick
Thank you very much for you answer.
It was very helpful for me and I manage to complete my plugin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.