Thursday, June 7, 2018

LS NAV - Modify the Statement-Post routine to pass Salesperson Code to the Customer Ledger Entry when posting Sales Transactions

By default, the salesperson from the Transaction Register does not get passed to the Customer Ledger entry when statements are posted.

To modify this:

  • Objects
    • C99001457 Statement-Post
      • Function PostToCustomer
  • Create new Function
    • GetPOSTrxSR
      • Parameters - Store(code) Terminal(code), Trx (int)
      • Variables - TSE (rec, Trans. Sales Entry)
      • Return - SR (text)
GetPOSTrxFirstSR(Store : Code[10];Terminal : Code[10];Trx : Integer) SR : Text
// Uses FIRST Sales Staff - SR code if exists(comes from SALESP POS Command). Otherwise, defaults to customer SR
TSE.SETRANGE("Store No.",Store);
TSE.SETRANGE("POS Terminal No.",Terminal);
TSE.SETRANGE("Transaction No.",Trx);
IF TSE.FIND('-') THEN BEGIN
  REPEAT
    IF TSE."Sales Staff" > '' THEN BEGIN
      Staff.SETRANGE(ID,TSE."Sales Staff");
        IF Staff.FIND('-') THEN BEGIN
          IF (SR = '') AND (Staff."Sales Person" > '') THEN BEGIN
            SR := Staff."Sales Person";
          END;
        END;
    END;
  UNTIL TSE.NEXT <=0;
//If SR blank, use customer default
  IF SR = '' THEN BEGIN
    TH.SETRANGE("Store No.",Store);
    TH.SETRANGE("POS Terminal No.",Terminal);
    TH.SETRANGE("Transaction No.",Trx);
    IF TH.FIND('-') THEN BEGIN
      Cus.SETRANGE("No.",TH."Customer No.");
      IF Cus.FIND('-') THEN BEGIN;
      SR := Cus."Salesperson Code";
      END;
    END;
  END;
END;
  • Modify Statement-Post
    •    GenJnlLine.VALIDATE("Salespers./Purch. Code",DT.GetPOSTrxFirstSR(Transaction."Store No.",Transaction."POS Terminal No.",Transaction."Transaction No."));
    •  

No comments:

Post a Comment