Sales Price - Import::OnBeforeInsertRecord() nRecNum += 1; dlgProgress.UPDATE(3, nRecNum); "Sales Price".RESET; "Sales Price".SETRANGE("Sales Price"."Item No.",PRODUTO); "Sales Price".SETRANGE("Sales Price"."Sales Type",1); "Sales Price".SETRANGE("Sales Price"."Sales Code",'ALL'); "Sales Price".SETRANGE("Sales Price"."VAT Bus. Posting Gr. (Price)",'NAC'); "Sales Price".SETRANGE("Ending Date",0D); "Sales Price".SETRANGE("Currency Code",''); "Sales Price".SETRANGE("Variant Code",''); "Sales Price".SETRANGE("Unit of Measure Code",''); //"Sales Price".SETRANGE("Minimum Quantity",QT) DataInicioText:=COPYSTR(DATAINI,1,8); dia := COPYSTR(DataInicioText,1,2); mes := COPYSTR(DataInicioText,4,2); ano:= COPYSTR(DataInicioText,7,4); MESSAGE('ano %1',ano); MESSAGE('data %1',DataInicioText); EVALUATE(DataInicio,dia+mes+ano); "Sales Price".SETRANGE("Starting Date",DataInicio); "Sales Price"."Starting Date":=DataInicio; "Sales Price"."Item No.":=PRODUTO; "Sales Price"."Allow Invoice Disc." :=TRUE; "Sales Price"."VAT Bus. Posting Gr. (Price)":='NAC'; "Sales Price"."Allow Invoice Disc.":=TRUE; "Sales Price"."Sales Code":='ALL'; "Sales Price"."Sales Type":=1; "Sales Price"."Currency Code":=''; "Sales Price"."Variant Code":=''; "Sales Price"."Ending Date":=0D; "Sales Price".VALIDATE("Sales Price"."Sales Code",'ALL'); "Sales Price".VALIDATE("VAT Bus. Posting Gr. (Price)",'NAC'); Item.GET(PRODUTO); "Sales Price"."Unit of Measure Code":=Item."Base Unit of Measure"; //Quantity Quantity:=FORMAT(QT); EVALUATE("Sales Price"."Minimum Quantity",Quantity); //Unit Price Price:=FORMAT(PVP); EVALUATE("Sales Price"."Unit Price",Price); //Unit Price with vat VATPercentageProd:=Item."VAT Prod. Posting Group"; VATPercentageBus:=Item."VAT Bus. Posting Gr. (Price)"; VATPostingSetup.GET(VATPercentageBus,VATPercentageProd); VATPerCent:=VATPostingSetup."VAT %"; EVALUATE(PriceVAT,PVP); "Sales Price"."Unit Price Including VAT":=ConvertPriceToVAT(VATPerCent,PriceVAT); IF NOT "Sales Price".INSERT(TRUE) THEN BEGIN "Sales Price".NEXT(-1); "Sales Price"."VAT Bus. Posting Gr. (Price)":='NAC'; "Sales Price"."Ending Date":=DataInicio-1; "Sales Price".MODIFY(TRUE); END;
Answers
If you want get the date from a day, moth and year you must use this:
This will actually not work like this because DMY4Date expects integers, not strings, as parameters. But anyway, it is the right function if you need to reassemble your date.
Alternatively add in your local separator in the string you EVALUATE, or better, still, make it locale independent by doing i.e. creating a date string in the ISO format and evaluating it using the XML option. You need the 4-digit version of the year for this to work.
But my problem now is I tried this code
But the previous record is not being modified... And the message shows the a wrong previous record like the image below...
I need to fill the field Ending Date right next to the date 08-11-2018 to close the last product price.
My idea is when inserting a new record I always need to fill the Ending Date of my previous record. If I'm modifyng a record already inserted in the system, the idea is to modify the existing record understand?