ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

Code refactoring codeunit 99000830 function SignFactor

Open NikolayVityuk opened this issue 7 years ago • 5 comments

From my point of view it would be better if in SignFactor function (codeunit 99000830 ) instead of EXIT we use Sign := 1 ot Sign = -1

It allowes us to change returning value by OnAfterSignFactor event for existing tables (depending on additional condition, new type of document for example)

Now it's impossible. Please take a look.

[External] SignFactor(VAR ReservEntry : Record "Reservation Entry") : Integer // Demand is regarded as negative, supply is regarded as positive. CASE ReservEntry."Source Type" OF DATABASE::"Sales Line": IF ReservEntry."Source Subtype" IN [3,5] THEN // Credit memo, Return Order = supply SIGN := 1 ELSE SIGN := -1; DATABASE::"Requisition Line": IF ReservEntry."Source Subtype" = 1 THEN SIGN := -1 ELSE SIGN := 1; DATABASE::"Purchase Line": IF ReservEntry."Source Subtype" IN [3,5] THEN // Credit memo, Return Order = demand SIGN := -1 ELSE SIGN := 1; DATABASE::"Item Journal Line": IF (ReservEntry."Source Subtype" = 4) AND Inbound THEN SIGN := 1 ELSE IF ReservEntry."Source Subtype" IN [1,3,4,5] THEN // Sale, Negative Adjmt., Transfer, Consumption SIGN := -1 ELSE SIGN := 1; DATABASE::"Job Journal Line": SIGN := -1; DATABASE::"Item Ledger Entry": SIGN := 1; DATABASE::"Prod. Order Line": SIGN := 1; DATABASE::"Prod. Order Component": SIGN := -1; DATABASE::"Assembly Header": SIGN := 1; DATABASE::"Assembly Line": SIGN := -1; DATABASE::"Planning Component": SIGN := -1; DATABASE::"Transfer Line": IF ReservEntry."Source Subtype" = 0 THEN // Outbound SIGN := -1 ELSE SIGN := 1; DATABASE::"Service Line": IF ReservEntry."Source Subtype" IN [3] THEN // Credit memo SIGN := 1 ELSE SIGN := -1; DATABASE::"Job Planning Line": SIGN := -1; DATABASE::"Item Document Line": IF ReservEntry."Source Subtype" = 0 THEN // Receipt SIGN := 1 ELSE SIGN := -1; END;

OnAfterSignFactor(ReservEntry,Sign); EXIT(Sign);

NikolayVityuk avatar Feb 22 '19 12:02 NikolayVityuk

Why would you want that change. It basically means that you would override our logic, which seems to be correct logic ;-) In which scenario would you like to override our values?

JesperSchulz avatar Feb 27 '19 10:02 JesperSchulz

@JesperSchulz For example I want to add new document type to Assembly Header. (to do disassembly or for instance credit-memo for this document. In this case I have to change sign in Assembly Header and Lines in 337 table) But I can't do it using extension.

The only way is to copy 99% of code from Assembly to new tables, codeunites etc.

NikolayVityuk avatar Feb 27 '19 12:02 NikolayVityuk

Hello @jobulsin ,

Was it included in the April release? If not, when can we see expected realization? We are really waiting for this opportunity!

Thank you!

AliiaSalikhova avatar Apr 12 '19 14:04 AliiaSalikhova

The change is in the April release :-)

JesperSchulz avatar Apr 15 '19 07:04 JesperSchulz

@JesperSchulz thank you very much!

AliiaSalikhova avatar Apr 15 '19 08:04 AliiaSalikhova