Wednesday, November 27, 2019

LS NAV - Get Retail Item Price with discounts and promos

PROCEDURE GetItemPOSPrice@1000000004(Itm@1000000023 : Text[30]) : Decimal;
    VAR
      PT@1000000000 : Record 99008980;
      PosTerminal@1000000022 : Record 99001471;
      StoreSetup@1000000021 : Record 99001470;
      Item@1000000020 : Record 27;
      ItemVariant@1000000019 : Record 5401;
      TransLine@1000000018 : Record 99008981;
      Customer@1000000017 : Record 18;
      Staff@1000000016 : Record 99001461;
      PosFunc@1000000015 : Codeunit 99008900;
      PosPrice@1000000014 : Codeunit 99008906;
      Globals@1000000013 : Codeunit 99008919;
      gStoreNo@1000000012 : Code[10];
      gPosTerminalNo@1000000011 : Code[10];
      gReceiptNo@1000000010 : Code[20];
      gItemNo@1000000009 : Code[20];
      gQuantity@1000000008 : Decimal;
      gDescription@1000000007 : Text[100];
      gCustomerName@1000000006 : Text[50];
      gPriceInBarcode@1000000005 : Decimal;
      gCalcQty@1000000004 : Decimal;
      gStaffID@1000000003 : Code[20];
      SalesTypeBoxVisible@1000000002 : Boolean INDATASET;
      PriceGrBoxVisible@1000000001 : Boolean INDATASET;
      FinalPrice@1000000024 : Decimal;
    BEGIN
      TransLine.VALIDATE(TransLine.Number,TransLine.Number);
      gQuantity := 1;
      TransLine.VALIDATE(TransLine.Number,Itm);
      TransLine.InsertLine;

      TransLine.GET(TransLine."Receipt No.",TransLine."Line No.");

      Item.GET(TransLine.Number);
      IF Item."Qty. Becomes Negative" THEN BEGIN
        TransLine."Item/Dept. Negative" := TRUE;
        TransLine.VALIDATE(TransLine.Quantity,-gQuantity)
      END
      ELSE
        TransLine.VALIDATE(TransLine.Quantity,gQuantity);
      IF TransLine."Price in Barcode" AND (gQuantity = gCalcQty) THEN
        TransLine.VALIDATE(TransLine.Amount,gPriceInBarcode);


      PosFunc.ChangeVATBusOnLine(PT);
      PosFunc.RecalcSlip(PT);

      EXIT(FinalPrice);
    END;

No comments:

Post a Comment