1
votes

I want to pick the balance (flowfield)record from customer table to the Bill Table. I have a Customer table and a BillPros table. The balance in the customer table is a flowfield.

//Customer on Variable Band Billing
Customers.RESET;
Customers.SETCURRENTKEY(Customers."No.");
Customers.SETFILTER(Customers."No.",'%1',MeterR."Customer Number");
Customers.SETFILTER(Customers."Customer Posting 
         Group",'%1',Surcharge."Customer Posting Group");
Customers.CALCFIELDS("Balance (LCY)");
Bal := Customers."Balance (LCY)";

IF Customers.FIND('-')THEN 

   //Post Metre Reading;
      PostReading.RESET;
      PostReading.Date := MeterR.Period;
      PostReading.MetreID :=MeterR."Metre ID";
      PostReading."Last Reading" := MeterR."Metre Reading";
      PostReading.INSERT;



      //Bill Info Process
      TotalAmount:=0;
        BillPros.INIT;
        BillPros."Customer No." := MeterR."Customer Number";
        BillPros.Consumption := TotalReading;
        BillPros.Rate := Bands."Rate Amount";
        BillPros."Invoice No." := MeterR."Invoice Number";
        BillPros.Amount := TotalReading*Bands."Rate Amount";


        BillPros.Balance := Bal;
1

1 Answers

0
votes

Your code is wrong. You should call the CALCFIELDS after the FIND('-'). Before that you "don't have" the actual Customer Record. And you don't need the Bal variable. You can write BillPros.Balance := Customer."Balance (LCY)";