Options

customer new balance - old balance

gdeivekisgdeivekis Member Posts: 5
guys hello

i try to show the new balance and old balance of the customer in a sales invoice.

for the new balance i tried 1 option were i put on the trigger( on get after record) in customer dataitem (someone told me that) the functions customer.CALCFIELDS("BALANCE(LCY)"); but i get 0.00

do you hane any clues?

also about old balance what formula i can use. I think i will be like BALANCE(LCY) - INVOICE AMOUNT but i do not know how

thanks in advance

george

Comments

  • Options
    kinekine Member Posts: 12,562
    Have you something like Customer.GET("Sales Invoice Header"."Sell-to Customer No."); somewhere???
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    ShenpenShenpen Member Posts: 386
    Use CALCFIELDS, that' a flowfield.

    But dont' put that to the report: two months later you get a furious call from the client, because they reprinted an old invoice and the balance was totally wrong.

    Instead, put that into fields to the posted sales invoce header. Create the two new fields. Go to codeunit 80, search for INSERT and you will find where a posted sales invoice is inserted. Then, you can fill these fields there with code like this (just an example):

    IF Cust.GET(SalesHeader."Sell-to Customer No.") THEN BEGIN
    Cust.CALCFIELDS("Balance (LCY)");
    SalesInvHeader.VALIDATE("Old Balance", Cust."Balance (LCY)-SalesInvHeader.Amount");
    SalesInvHeader.VALIDATE("New Balance",Cust."Balance (LCY)");

    END;

    (posting the balance happened earlier thant inserting the invoice header)

    Do It Yourself is they key. Standard code might work - your code surely works.
  • Options
    ShenpenShenpen Member Posts: 386
    Did that work?

    Do It Yourself is they key. Standard code might work - your code surely works.
Sign In or Register to comment.