ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

Event requests/function refactoring - CU7600 Calendar Management, P7605 Customized Cal. Entries Subfm

Open TKapitan opened this issue 8 years ago • 5 comments

Hello, Could you please create new publishers in the CU7600 (Calendar Management) / refactor the function?

Reason: We need to propagate new fields from the calendar changes to the base calendar

CU7600 The functions CheckDateStatus AND CheckCustomizedDateStatus (current state, both functions contains the same code except the first line in the CheckCustomizedDateStatus, I attach only one of them, but we need to refactor both of them)

[External] CheckDateStatus(CalendarCode : Code[10];TargetDate : Date;VAR Description : Text[50]) : Boolean
BaseCalChange.RESET;
BaseCalChange.SETRANGE("Base Calendar Code",CalendarCode);
IF BaseCalChange.FINDSET THEN
  REPEAT
    CASE BaseCalChange."Recurring System" OF
      BaseCalChange."Recurring System"::" ":
        IF TargetDate = BaseCalChange.Date THEN BEGIN
          Description := BaseCalChange.Description;
          EXIT(BaseCalChange.Nonworking);
        END;
      BaseCalChange."Recurring System"::"Weekly Recurring":
        IF DATE2DWY(TargetDate,1) = BaseCalChange.Day THEN BEGIN
          Description := BaseCalChange.Description;
          EXIT(BaseCalChange.Nonworking);
        END;
      BaseCalChange."Recurring System"::"Annual Recurring":
        IF (DATE2DMY(TargetDate,2) = DATE2DMY(BaseCalChange.Date,2)) AND
           (DATE2DMY(TargetDate,1) = DATE2DMY(BaseCalChange.Date,1))
        THEN BEGIN
          Description := BaseCalChange.Description;
          EXIT(BaseCalChange.Nonworking);
        END;
    END;
  UNTIL BaseCalChange.NEXT = 0;
Description := '';

Future state (new var parameter)

[External] CheckDateStatus(CalendarCode : Code[10];TargetDate : Date;VAR Description : Text[50]; VAR BaseCalChange) : Boolean
BaseCalChange.RESET;
BaseCalChange.SETRANGE("Base Calendar Code",CalendarCode);
IF BaseCalChange.FINDSET THEN
  REPEAT
    CASE BaseCalChange."Recurring System" OF
      BaseCalChange."Recurring System"::" ":
        IF TargetDate = BaseCalChange.Date THEN BEGIN
          Description := BaseCalChange.Description;
          EXIT(BaseCalChange.Nonworking);
        END;
      BaseCalChange."Recurring System"::"Weekly Recurring":
        IF DATE2DWY(TargetDate,1) = BaseCalChange.Day THEN BEGIN
          Description := BaseCalChange.Description;
          EXIT(BaseCalChange.Nonworking);
        END;
      BaseCalChange."Recurring System"::"Annual Recurring":
        IF (DATE2DMY(TargetDate,2) = DATE2DMY(BaseCalChange.Date,2)) AND
           (DATE2DMY(TargetDate,1) = DATE2DMY(BaseCalChange.Date,1))
        THEN BEGIN
          Description := BaseCalChange.Description;
          EXIT(BaseCalChange.Nonworking);
        END;
    END;
  UNTIL BaseCalChange.NEXT = 0;
Description := '';

CU7600 The function CombineChanges (current state)

...
    TempCustChange."Recurring System" := CustCalChange."Recurring System";
    TempCustChange."Entry No." := TempCounter;
    TempCustChange.INSERT;
  UNTIL CustCalChange.NEXT = 0;
...
    TempCustChange.Nonworking := BaseCalChange.Nonworking;
    TempCustChange."Recurring System" := BaseCalChange."Recurring System";
    TempCustChange.INSERT;
  UNTIL BaseCalChange.NEXT = 0;
...

Future state

...
    TempCustChange."Recurring System" := CustCalChange."Recurring System";
    TempCustChange."Entry No." := TempCounter;
    OnCombineChangesCustCalendar(var TempCustChange, CustCalChange, TempCounter);
    TempCustChange.INSERT;
  UNTIL CustCalChange.NEXT = 0;
...
    TempCustChange.Nonworking := BaseCalChange.Nonworking;
    TempCustChange."Recurring System" := BaseCalChange."Recurring System";
    OnCombineChangesBaseCalendar(var TempCustChange, BaseCalChange, TempCounter);
    TempCustChange.INSERT;
  UNTIL BaseCalChange.NEXT = 0;
...

CU7600 The function CreateWhereUsedEntries(current state)

...
    WhereUsedBaseCalendar.INSERT;
  END;

COMMIT;

Future state

...
    WhereUsedBaseCalendar.INSERT;
  END;

  OnCreateWhereUsedEntries(var WhereUsedBaseCalendar, BaseCalendarCode );
COMMIT;

P7605 The function UpdateBaseCalendarChanges(current state)

...
  CustomizedCalendarChange.Nonworking := Nonworking;
  CustomizedCalendarChange.INSERT;
END;

Future state

...
  CustomizedCalendarChange.Nonworking := Nonworking;
  CustomizedCalendarChange.INSERT;

  OnUpdateBaseCalendarChanges(var CustomizedCalendarChange, Rec, Nonworking);
END;

P7604/P7605 Please create a new functions. This is the most important thing, without this function, it is impossible to do any change on this page...

[External] GetCalendarCode(VAR CalendarCode : Code[10];VAR LocNonworking : Boolean;VAR LocDescription : Text[30])
[External] GetCalendarCode(VAR SourceType : 'Company,Customer,Vendor,Location,Shipping Agent';VAR SourceCode : Code[20];VAR AdditionalSourceCode : Code[20];VAR CalendarCode : Code[10];VAR LocNonworking : Boolean;VAR LocDescription : Text[30])

TKapitan avatar Jun 16 '18 20:06 TKapitan

We cannot change signature for External procedures. Can you suggest another solution without adding parameter in existing procedure?

AlexanderYakunin avatar Jun 19 '18 12:06 AlexanderYakunin

I think that all pages based on Date table have to be refactored... They are all based on the Date record and all other information is calculated using global variables which are inaccessible.

It is impossible to do any change in these pages without changing the standard functionality...

My request could be circumvented by making variable BaseCalChange from CheckDateStatus global (if it's not yet) and expose it using getter function... Then the programmer could call

CheckDateStatus(...); GetBaseCalChangeVar(...);

But I don't think that it's the right solution, there are other pages with the same problem (like resource capacity, matrix pages...).

TKapitan avatar Jul 04 '18 10:07 TKapitan

Thank you for your input. We will investigate this request further and may get back to you with further questions.

JesperSchulz avatar Nov 07 '18 10:11 JesperSchulz

@TKapitan, what fields do you want to add? Will it makes sense to add them to the standard product?

AndreiPanko avatar Nov 07 '18 16:11 AndreiPanko

Assuming a solution was found due to lack of response on old issue. Closing issue. If problem still exists, please open a new issue.

JesperSchulz avatar Dec 05 '18 13:12 JesperSchulz