How to Split amounts into Different Months

kolaboykolaboy Member Posts: 446
Hi
I have created a form where employee post contribution amounts every months and it writes to a table called contributions. They basically use start and end Date to post these contributions. They use the begining of the month as start date and end of month as end date, this writes it into the table.

I have also developed a report that is picking these contributions and place them in their respective months and year.

Now employee have to post contributions arrears of more than one month. Say there is an arrears of 3000 and this is for three months and each month is 1000. They select the start date for the first months of the arrears and the end date of the last month and them enter the whole 3000. The report picks this amount but it place it on the first month. I need this to be place 1000 on each of the months for the arrears months.

Can someone help me split these contribution(3000) into the different months in arrears 1000 for each. It should be for any amount of months in arrears.
Here is the report:
OBJECT Report 75022 Employee Profile
{
  OBJECT-PROPERTIES
  {
    Date=20/04/08;
    Time=23:42:55;
    Modified=Yes;
    Version List=SSMS1.5.4;
  }
  PROPERTIES
  {
    OnPreReport=BEGIN
                  IF (Empid = '')
                  THEN ERROR(EmpidNull);
                  //IF (FromDate = 0D) OR (ToDate = 0D) THEN
                     // ERROR(DateBlank);
                  //IF (FromDate > ToDate) THEN
                     // ERROR(DateError);

                  //IF (BenefitsPayable = 0.00)
                  //THEN MESSAGE(bepaynull);

                  CompanyInfo.GET;
                  CompanyInfo.CALCFIELDS(Picture);
                END;

    Orientation=Portrait;
  }
  DATAITEMS
  {
    { PROPERTIES
      {
        DataItemTable=Table2000000007;
        DataItemTableView=SORTING(Period Type,Period Start)
                          ORDER(Ascending);
        OnPreDataItem=BEGIN

                        y := 0;
                        Months := 0;
                         monthCount := 0;
                      END;

        OnAfterGetRecord=BEGIN

                           User.GET(USERID);
                           UserName := User.Name;


                           Employee.GET(Empid);
                           EmployeeName := Employee."First Name" + Space + Employee."Middle Name" + Space + Employee."Last Name";

                             BirthDate := Employee."Birth Date";


                           IF EVALUATE(NewBirthDate,BirthDate) THEN BEGIN
                           RetireDate1 := CALCDATE('<60Y>',NewBirthDate);
                           RetireDate := FORMAT(RetireDate1,0,'<Day>/<Month>/<Year4>');
                           END ELSE BEGIN
                           RetireDate := 'N/A';
                           END;
                           AdmissionDate := Employee."Admission Date";
                           EmployerCode := Employee."Employer No.";
                           Address := Employee.Address + Employee."Address 2";
                           Customer.GET(EmployerCode);
                           EmployerName := Customer.Name;



                           Date.RESET;
                           Date.SETRANGE("Period Type",Calendar."Period Type"::Month);
                           Date.SETRANGE("Period Start",StartDate,FinalDate);


                           FOR i := 1  TO 12 DO
                           BEGIN
                             contrArr[i] := 0;
                           END;

                           i := 1;
                           REPEAT


                           IF (y = 0 ) OR (i > 1) THEN
                           Date.NEXT;

                           MonthContAmount := 0;

                           Cont.SETCURRENTKEY("Employee No.","From Date");
                           Cont.SETRANGE("Employee No.",Empid);
                           Cont.SETRANGE("From Date",Date."Period Start",Date."Period Start");

                           DisplayYear := FORMAT(Date."Period Start",0,'<Year4>');
                           CurrentMonth := FORMAT(Date."Period Start",0,'<Month Text>');
                           currentDate[i] := FORMAT(Date."Period Start",0,'<month><year>');


                           IF Cont.FIND('-') THEN REPEAT
                             MonthContAmount := MonthContAmount + Cont.Quantity;
                           UNTIL Cont.NEXT = 0;

                           IF MonthContAmount > 0 THEN
                             monthCount := monthCount + 1;

                           CASE CurrentMonth OF
                           'January': contrArr[1] := MonthContAmount;
                           'February': contrArr[2] := MonthContAmount;
                           'March': contrArr[3] := MonthContAmount;
                           'April': contrArr[4] := MonthContAmount;
                           'May': contrArr[5] := MonthContAmount;
                           'June': contrArr[6] := MonthContAmount;
                           'July': contrArr[7] := MonthContAmount;
                           'August': contrArr[8] := MonthContAmount;
                           'September': contrArr[9] := MonthContAmount;
                           'October': contrArr[10] := MonthContAmount;
                           'November': contrArr[11] := MonthContAmount;
                           'December': contrArr[12] := MonthContAmount;
                           END;

                           i := i + 1;
                           y := y + 1;

                           UNTIL (i > 12) OR (CurrentMonth = 'December');


                           // Code added by akjallow to skip year "0000".
                           IF FORMAT("Period Start",0,'<Year4>') = '0000'
                           THEN CurrReport.SKIP;
                         END;

      }
      SECTIONS
      {
        { PROPERTIES
          {
            SectionType=Header;
            SectionWidth=19500;
            SectionHeight=9386;
          }
          CONTROLS
          {
            { 1000000003;TextBox;2400 ;423  ;1800 ;423  ;HorzAlign=Left;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         SourceExpr=TODAY }
            { 1000000004;PictureBox;5550;0  ;8550 ;3384 ;Border=Yes;
                                                         SourceExpr=CompanyInfo.Picture }
            { 1000000005;Label  ;5700 ;3807 ;8250 ;423  ;HorzAlign=Center;
                                                         VertAlign=Center;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         MultiLine=Yes;
                                                         CaptionML=ENU=SOCIAL SECURITY AND HOUSING FINANCE CORPORATION }
            { 1000000006;Label  ;6300 ;4230 ;5850 ;423  ;HorzAlign=Center;
                                                         VertAlign=Center;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         MultiLine=Yes;
                                                         CaptionML=ENU=NATIONAL PROVIDENT FUND SCHEME }
            { 1000000007;Label  ;6300 ;4653 ;6450 ;423  ;HorzAlign=Center;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=EMPLOYEE MEMBERSHIP PROFILE }
            { 1000000008;Label  ;0    ;5922 ;4050 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=SOCIAL SECURITY NUMBER: }
            { 1000000009;Label  ;0    ;6768 ;4050 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=CURRENT EMPLOYER           : }
            { 1000000010;TextBox;4050 ;5922 ;4500 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         SourceExpr=Empid }
            { 1000000011;Label  ;0    ;7614 ;4050 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=EMPLOYEE NAME                 : }
            { 1000000012;TextBox;4050 ;7614 ;8700 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         SourceExpr=EmployeeName }
            { 1000000013;Label  ;13050;6768 ;3450 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=DATE OF BIRTH            : }
            { 1000000014;TextBox;16650;6768 ;2100 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         SourceExpr=BirthDate }
            { 1000000016;Label  ;13050;5922 ;3450 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=DATE OF ADMISSION  : }
            { 1000000033;TextBox;16650;5922 ;2100 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         SourceExpr=AdmissionDate }
            { 1000000034;Label  ;13050;7614 ;3450 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=DATE OF RETIREMENT: }
            { 1000000035;TextBox;16650;7614 ;2100 ;423  ;HorzAlign=Left;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         SourceExpr=RetireDate }
            { 1000000036;TextBox;4050 ;6768 ;8700 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         SourceExpr=EmployerName }
            { 1000000038;Label  ;750  ;8883 ;1500 ;423  ;HorzAlign=Right;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         FontUnderline=Yes;
                                                         CaptionML=ENU="     Jan     " }
            { 1000000048;Label  ;2250 ;8883 ;1500 ;423  ;HorzAlign=Right;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         FontUnderline=Yes;
                                                         CaptionML=ENU="     Feb     " }
            { 1000000049;Label  ;3750 ;8883 ;1500 ;423  ;HorzAlign=Right;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         FontUnderline=Yes;
                                                         CaptionML=ENU="     Mar     " }
            { 1000000050;Label  ;8250 ;8883 ;1500 ;423  ;HorzAlign=Right;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         FontUnderline=Yes;
                                                         CaptionML=ENU="     Jun     " }
            { 1000000051;Label  ;6750 ;8883 ;1500 ;423  ;HorzAlign=Right;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         FontUnderline=Yes;
                                                         CaptionML=ENU="     May     " }
            { 1000000052;Label  ;5250 ;8883 ;1500 ;423  ;HorzAlign=Right;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         FontUnderline=Yes;
                                                         CaptionML=ENU="     Apr     " }
            { 1000000053;Label  ;15750;8883 ;1500 ;423  ;HorzAlign=Right;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         FontUnderline=Yes;
                                                         CaptionML=ENU="     Nov     " }
            { 1000000054;Label  ;14250;8883 ;1500 ;423  ;HorzAlign=Right;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         FontUnderline=Yes;
                                                         CaptionML=ENU="     Oct     " }
            { 1000000055;Label  ;12750;8883 ;1500 ;423  ;HorzAlign=Right;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         FontUnderline=Yes;
                                                         CaptionML=ENU="     Sep     " }
            { 1000000056;Label  ;11250;8883 ;1500 ;423  ;HorzAlign=Right;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         FontUnderline=Yes;
                                                         CaptionML=ENU="     Aug     " }
            { 1000000057;Label  ;9750 ;8883 ;1500 ;423  ;HorzAlign=Right;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         FontUnderline=Yes;
                                                         CaptionML=ENU="     Jul     " }
            { 1000000058;Label  ;17250;8883 ;1500 ;423  ;HorzAlign=Right;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         FontUnderline=Yes;
                                                         CaptionML=ENU="     Dec     " }
            { 1000000061;Label  ;300  ;423  ;2100 ;423  ;FontSize=9;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=PRINTED ON: }
            { 1000000063;TextBox;1050 ;846  ;4075 ;1269 ;VertAlign=Top;
                                                         FontSize=9;
                                                         FontBold=Yes;
                                                         MultiLine=Yes;
                                                         SourceExpr=UserName }
            { 1000000064;Label  ;300  ;846  ;750  ;423  ;FontSize=9;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=BY: }
          }
           }
        { PROPERTIES
          {
            SectionType=Body;
            SectionWidth=19500;
            SectionHeight=500;
          }
          CONTROLS
          {
            { 1000000001;TextBox;0    ;0    ;750  ;423  ;HorzAlign=Left;
                                                         VertAlign=Bottom;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         SourceExpr=DisplayYear }
            { 1000000000;TextBox;750  ;0    ;1500 ;423  ;HorzAlign=Right;
                                                         VertAlign=Bottom;
                                                         FontSize=8;
                                                         FontBold=No;
                                                         SourceExpr=contrArr[1] }
            { 1000000002;TextBox;2250 ;0    ;1500 ;423  ;HorzAlign=Right;
                                                         VertAlign=Bottom;
                                                         FontSize=8;
                                                         FontBold=No;
                                                         SourceExpr=contrArr[2] }
            { 1000000037;TextBox;3750 ;0    ;1500 ;423  ;HorzAlign=Right;
                                                         VertAlign=Bottom;
                                                         FontSize=8;
                                                         FontBold=No;
                                                         SourceExpr=contrArr[3] }
            { 1000000039;TextBox;8250 ;0    ;1500 ;423  ;HorzAlign=Right;
                                                         VertAlign=Bottom;
                                                         FontSize=8;
                                                         FontBold=No;
                                                         SourceExpr=contrArr[6] }
            { 1000000040;TextBox;6750 ;0    ;1500 ;423  ;HorzAlign=Right;
                                                         VertAlign=Bottom;
                                                         FontSize=8;
                                                         FontBold=No;
                                                         SourceExpr=contrArr[5] }
            { 1000000041;TextBox;5250 ;0    ;1500 ;423  ;HorzAlign=Right;
                                                         VertAlign=Bottom;
                                                         FontSize=8;
                                                         FontBold=No;
                                                         SourceExpr=contrArr[4] }
            { 1000000042;TextBox;12750;0    ;1500 ;423  ;HorzAlign=Right;
                                                         VertAlign=Bottom;
                                                         FontSize=8;
                                                         FontBold=No;
                                                         SourceExpr=contrArr[9] }
            { 1000000043;TextBox;11250;0    ;1500 ;423  ;HorzAlign=Right;
                                                         VertAlign=Bottom;
                                                         FontSize=8;
                                                         FontBold=No;
                                                         SourceExpr=contrArr[8] }
            { 1000000044;TextBox;9750 ;0    ;1500 ;423  ;HorzAlign=Right;
                                                         VertAlign=Bottom;
                                                         FontSize=8;
                                                         FontBold=No;
                                                         SourceExpr=contrArr[7] }
            { 1000000045;TextBox;17250;0    ;1500 ;423  ;HorzAlign=Right;
                                                         VertAlign=Bottom;
                                                         FontSize=8;
                                                         FontBold=No;
                                                         SourceExpr=contrArr[12] }
            { 1000000046;TextBox;15750;0    ;1500 ;423  ;HorzAlign=Right;
                                                         VertAlign=Bottom;
                                                         FontSize=8;
                                                         FontBold=No;
                                                         SourceExpr=contrArr[11] }
            { 1000000047;TextBox;14250;0    ;1500 ;423  ;HorzAlign=Right;
                                                         VertAlign=Bottom;
                                                         FontSize=8;
                                                         FontBold=No;
                                                         SourceExpr=contrArr[10] }
          }
           }
      }
       }
    { PROPERTIES
      {
        DataItemIndent=0;
        DataItemTable=Table5207;
        DataItemTableView=SORTING(From Date,To Date)
                          ORDER(Ascending);
        PrintOnlyIfDetail=No;
        OnAfterGetRecord=BEGIN


                           // Check if balances exist or not.
                           IF (Balances.GET(Empid) = TRUE) THEN BEGIN
                           BalBrFwd := Balances.BalBrFwd;
                           END ELSE BEGIN
                           BalBrFwd := 0.00;
                           END;
                           // Balance checking ends here.

                           // Get Name ends above.


                           // Initialize variables
                           FromDate :=ApplicationDate;
                           ToDate :=TODAY;
                           Amount := 0; TotalAmount := 0; CurrAccTotal := 0;
                           ContMonth := '';
                           MonthContAmount := 0;
                           // Variable initialization ends above.

                           // Code to get Rate from Benefits
                           BenefitsKey.SETRANGE("Period Start",FromDate,ToDate);
                           BenefitsKey.SETFILTER("Period Start",'<=%1',FromDate);
                           BenefitsKey.SETFILTER("Period End",'>=%1',ToDate);
                           // Code Ends above.


                           IF BenefitsKey.FIND('-')
                           THEN BEGIN
                           Rate := BenefitsKey.Rate;
                           END;


                           //First Code brought down here
                           Contributions.SETCURRENTKEY("Employee No.");
                           Contributions.SETRANGE("Employee No.",Empid);
                           Contributions.SETRANGE("From Date",FromDate,ToDate);
                           Contributions.SETFILTER("From Date",'>=%1',FromDate);
                           Contributions.SETFILTER("To Date",'<=%1',ToDate);


                           //Code to Count Months
                           //IF (Contributions."From Date" <> 0D) AND (Contributions."To Date" > Contributions."From Date") THEN BEGIN
                             //  Calendar.RESET;
                            //   Calendar.SETRANGE("Period Type",Calendar."Period Type"::Month);
                           //    Calendar.SETRANGE("Period Start",Cont."From Date",Cont."To Date");
                           //   Months := Calendar.COUNT;
                           //END ELSE
                           //     Months := 0;
                           //Code Ends above.

                           //First Code brought down here
                           Cont.SETCURRENTKEY("Employee No.");
                           Cont.SETRANGE("Employee No.",Empid);
                           Cont.SETRANGE("From Date",FromDate,ToDate);
                           Cont.SETFILTER("From Date",'>=%1',FromDate);
                           Cont.SETFILTER("To Date",'<=%1',ToDate);

                           IF Cont.FIND('-')
                           THEN  BEGIN
                           TotalAmount := Cont.Quantity;
                           //Months := Cont.COUNT;
                           IF Cont.NEXT <> 0
                           THEN REPEAT
                           TotalAmount := TotalAmount + Cont.Quantity;
                           UNTIL Cont.NEXT = 0;
                           END;


                           Amount := (TotalAmount * Rate * Months)/24;
                           CurrAccTotal := Amount + TotalAmount;


                           CompanyInfo.GET;
                           CompanyInfo.CALCFIELDS(Picture);

                           //Formatting Months Below
                           ContMonth := FORMAT(FromDate,20,'<Month Text>, <Year4>');
                           MonthContAmount := Quantity;
                           EndDate := FORMAT(ToDate,0,'<Day> <Month Text>,  <Year4>');
                           BeginDate := FORMAT(StartDate,0,'<Day> <Month Text>,  <Year4>');
                           // Formatting Ends above line.


                            RateDisplay := Rate * 100;
                            AmountPayable := (BenefitsPayable * GrandTotal)/100;
                         END;

      }
      SECTIONS
      {
        { PROPERTIES
          {
            SectionType=Footer;
            SectionWidth=19500;
            SectionHeight=3303;
          }
          CONTROLS
          {
            { 1000000027;Label  ;0    ;846  ;7950 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=ACCUMULATED MONTHS OF CONTRIBUTIONS BETWEEN [ }
            { 1000000018;TextBox;7950 ;846  ;1350 ;423  ;HorzAlign=Left;
                                                         FontSize=9;
                                                         FontBold=Yes;
                                                         SourceExpr=StartDate }
            { 1000000020;Label  ;11850;846  ;450  ;423  ;HorzAlign=Left;
                                                         FontSize=9;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=] : }
            { 1000000024;TextBox;12300;846  ;2400 ;423  ;HorzAlign=Left;
                                                         FontSize=9;
                                                         FontBold=Yes;
                                                         SourceExpr=monthCount }
            { 1000000021;Label  ;0    ;1692 ;2700 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=BALANCE  B/FWD [ }
            { 1000000022;TextBox;2700 ;1692 ;2700 ;423  ;FontSize=8;
                                                         FontBold=Yes;
                                                         SourceExpr=BeginDate }
            { 1000000025;Label  ;5400 ;1692 ;450  ;423  ;HorzAlign=Left;
                                                         FontSize=9;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=] : }
            { 1000000023;TextBox;5850 ;1692 ;2550 ;423  ;HorzAlign=Left;
                                                         FontSize=8;
                                                         FontBold=Yes;
                                                         SourceExpr=BalBrFwd }
            { 1000000015;Label  ;0    ;2538 ;8850 ;423  ;FontSize=9;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=PREVIOUS EMPLOYER (S) : }
            { 1000000030;Label  ;11700;2538 ;2250 ;423  ;HorzAlign=Right;
                                                         FontSize=9;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=From Date }
            { 1000000032;Label  ;14700;2538 ;2100 ;423  ;HorzAlign=Right;
                                                         FontSize=9;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=To Date }
            { 1000000059;TextBox;10500;846  ;1350 ;423  ;HorzAlign=Left;
                                                         FontSize=9;
                                                         FontBold=Yes;
                                                         SourceExpr=FinalDate }
            { 1000000060;Label  ;9300 ;846  ;1200 ;423  ;HorzAlign=Left;
                                                         FontSize=9;
                                                         FontBold=Yes;
                                                         CaptionML=ENU=]  AND [ }
          }
           }
      }
       }
    { PROPERTIES
      {
        DataItemIndent=0;
        DataItemTable=Table5214;
        DataItemTableView=SORTING(Employee No.,Line No.)
                          ORDER(Ascending);
        OnAfterGetRecord=BEGIN
                           "Misc. Article Information".SETRANGE("Employee No.",Empid);
                           "Misc. Article Information".SETFILTER("Employee No.",Empid);
                         END;

        DataItemLinkReference=Contributions;
        DataItemLink=Employee No.=FIELD(Employee No.);
      }
      SECTIONS
      {
        { PROPERTIES
          {
            SectionType=Body;
            SectionWidth=19500;
            SectionHeight=846;
          }
          CONTROLS
          {
            { 1000000026;TextBox;0    ;0    ;2400 ;423  ;FontSize=9;
                                                         FontBold=Yes;
                                                         SourceExpr="Employer No." }
            { 1000000029;TextBox;2400 ;0    ;9150 ;423  ;HorzAlign=Left;
                                                         FontSize=9;
                                                         FontBold=Yes;
                                                         SourceExpr=Employer }
            { 1000000028;TextBox;11550;0    ;2400 ;423  ;FontSize=9;
                                                         FontBold=Yes;
                                                         SourceExpr="From Date" }
            { 1000000031;TextBox;14700;0    ;2250 ;423  ;FontSize=9;
                                                         FontBold=Yes;
                                                         SourceExpr="To Date" }
          }
           }
        { PROPERTIES
          {
            SectionType=Footer;
            SectionWidth=19500;
            SectionHeight=846;
          }
          CONTROLS
          {
          }
           }
      }
       }
  }
  REQUESTFORM
  {
    PROPERTIES
    {
      Width=9900;
      Height=6490;
    }
    CONTROLS
    {
      { 1000000000;Label  ;550  ;880  ;3300 ;440  ;FontBold=Yes;
                                                   CaptionML=ENU=Employee ID }
      { 1000000001;Label  ;440  ;3080 ;3300 ;440  ;Visible=No;
                                                   FontBold=Yes;
                                                   CaptionML=ENU=Total Benefit Payable }
      { 1000000002;TextBox;5060 ;880  ;1810 ;440  ;SourceExpr=Empid;
                                                   TableRelation=Employee }
      { 1000000003;TextBox;5060 ;3080 ;1700 ;440  ;Visible=No;
                                                   SourceExpr=BenefitsPayable }
      { 1000000004;Label  ;550  ;1650 ;3300 ;440  ;Visible=Yes;
                                                   FontBold=Yes;
                                                   CaptionML=ENU=Begin Date: }
      { 1000000005;Label  ;550  ;2310 ;3300 ;440  ;Visible=Yes;
                                                   FontBold=Yes;
                                                   CaptionML=ENU=End Date: }
      { 1000000006;TextBox;5060 ;1650 ;1700 ;440  ;Visible=Yes;
                                                   SourceExpr=StartDate }
      { 1000000007;TextBox;5060 ;2420 ;1700 ;440  ;Visible=Yes;
                                                   SourceExpr=FinalDate }
    }
  }
  CODE
  {
    VAR
      Empid@1000000000 : Code[20];
      BenefitsPayable@1000000001 : Decimal;
      TotalAmount@1000000003 : Decimal;
      Amount@1000000004 : Decimal;
      Calendar@1000000006 : Record 2000000007;
      Months@1000000007 : Integer;
      CurrAccTotal@1000000009 : Decimal;
      BenefitsKey@1000000010 : Record 75012;
      FromDate@1000000022 : Date;
      ToDate@1000000023 : Date;
      CompanyInfo@1000000011 : Record 79;
      BalBrFwd@1000000012 : Decimal;
      Employee@1000000014 : Record 5200;
      EmployeeName@1000000015 : Text[250];
      EmployerCode@1000000016 : Code[20];
      EmployerName@1000000017 : Text[250];
      Customer@1000000018 : Record 18;
      Space@1000000020 : TextConst 'ENU=" "';
      BirthDate@1000000019 : Text[30];
      AdmissionDate@1000000021 : Text[30];
      OldAmount@1000000025 : Decimal;
      GrandTotal@1000000026 : Decimal;
      ContMonth@1000000027 : Text[30];
      MonthContAmount@1000000028 : Decimal;
      Rate@1000000029 : Decimal;
      Cont@1000000024 : Record 5207;
      EmpidNull@1000000030 : TextConst 'ENU=You must enter Employee #';
      DateBlank@1000000031 : TextConst 'ENU=You must enter Date From and Date To';
      DateError@1000000032 : TextConst 'ENU=Date From must be earlier than Date To';
      msg@1000000033 : TextConst 'ENU=You did not enter Bal. B/FWD. % System will automatically calculate it if contributions exist prior to specified date.';
      BeginDate@1000000035 : Text[30];
      EndDate@1000000034 : Text[30];
      Balances@1000000036 : Record 75020;
      RateDisplay@1000000037 : Decimal;
      AmountPayable@1000000038 : Decimal;
      bepaynull@1000000039 : TextConst 'ENU=You did not provide percentage of  Benefits payable';
      Address@1000000040 : Text[250];
      User@1000000041 : Record 2000000002;
      UserName@1000000042 : Text[100];
      RetireDate@1000000043 : Text[30];
      NewBirthDate@1000000044 : Date;
      BirthText@1000000045 : Text[30];
      RetireDate1@1000000046 : Date;
      AdmissionDate1@1000000047 : Date;
      EmploymentDate@1000000048 : Date;
      ApplicationDate@1000000049 : Date;
      StartDate@1000000005 : Date;
      FinalDate@1000000002 : Date;
      DisplayYear@1000000008 : Text[30];
      Current@1000000013 : Integer;
      contrArr@1000000050 : ARRAY [12] OF Decimal;
      i@1000000051 : Integer;
      currentDate@1000000053 : ARRAY [12] OF Text[30];
      CurrentMonth@1000000052 : Text[30];
      y@1000000054 : Integer;
      monthCount@1000000055 : Integer;

    PROCEDURE @1000000000();
    BEGIN
    END;

    BEGIN
    END.
  }
}


Can someone help me with this please.
Thanks

Comments

  • tinoruijstinoruijs Member Posts: 1,226
    kolaboy wrote:
    Can someone help me split these contribution(3000) into the different months in arrears 1000 for each. It should be for any amount of months in arrears.

    I personally think your post would be much clearer if you don't post the whole report here. :wink:

    If you just post the piece of code where you are trying to split the contribution into months, your post will be easier to read.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • kolaboykolaboy Member Posts: 446
    I actually did not have any idea of how to implement this with the report that is why i decided to post it so that experts can import it and help me to solve this.
    I am sorry for posting the whole report because i think it can give the experts some clue, but offcourse some will be bothered to read it.

    can someone help me out with it. Any suggestion or code sample that can do this for me?
    Thanks
  • tinoruijstinoruijs Member Posts: 1,226
    So they enter: startdate, enddate and amount.
    You could use DATE2DMY to retrieve both months and years of the dates.
    If years are equal you could just calculate as follows:
    intNoOfMonths := Month2 - Month1 + 1;
    decPartAmount := Amount / intNoOfMonths;
    repeat 
      intMonthNo += 1;
      decAmount[month] := decPartAmount;
    until intMonthNo = intNoOfMonths;
    

    Something like this?

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • kolaboykolaboy Member Posts: 446
    can you define you datatypes for me?
    Thanks
  • tinoruijstinoruijs Member Posts: 1,226
    kolaboy wrote:
    can you define you datatypes for me?
    Thanks

    Isn't that clear? :?:

    int = Integer
    dec = Decimal
    Month1 and 2 are integers. You can calculate them by:
    Month1 := DATE2DMY(startdate, 2);
    Amounts are decimal.

    And you need to use intYear1 and intYear2 too for dates in different years.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • kolaboykolaboy Member Posts: 446
    tinoruijs, i am trying to test your suggestion, i get error on this:
    decAmount[month] := decPartAmount;
    

    What is the Datatype of decAmount[month] ?
    Thanks
  • tinoruijstinoruijs Member Posts: 1,226
    kolaboy wrote:
    tinoruijs, i am trying to test your suggestion, i get error on this:
    decAmount[month] := decPartAmount;
    

    What is the Datatype of decAmount[month] ?
    Thanks

    dec = decimal.
    [] is use of dimensions (property on global or local).

    Dimensions
    Use this property to enter the dimensions of a variable, that is to create a multi-dimensional variable - an array.

    Applies to
    Variables

    Settings
    Enter the dimensions as a semicolon-separated list of integers, where each number defines the number of elements in that dimension. The maximum number of dimensions is 10 and the total number of elements in all dimensions is 1,000,000.

    Example
    To define an integer array with dimensions 3 x 3 x 4, start by creating an integer variable (for example called A.) Then, in the property sheet, set the Dimensions property to 3;3;4.

    To access the elements in the array, use a syntax like this:

    A[2][3][2]

    Note that indexing starts from 1 (not 0 as in some programming languages).

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • kolaboykolaboy Member Posts: 446
    Thanks Tino Ruijs for your ideas. I solved it. I used INSERT function and it works.
    Thanks onces again.
  • tinoruijstinoruijs Member Posts: 1,226
    Great!
    You're welcome!

    Tino Ruijs
    Microsoft Dynamics NAV specialist
Sign In or Register to comment.