This repository has been archived by the owner on Oct 23, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Undo Item Charges.txt
154 lines (135 loc) · 4.85 KB
/
Undo Item Charges.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
OBJECT Codeunit 50003 Undo Item Charges
{
OBJECT-PROPERTIES
{
Date=03/10/17;
Time=16:05:26;
Modified=Yes;
Version List=;
}
PROPERTIES
{
TableNo=111;
OnRun=BEGIN
SETRANGE(Type,Type::"Charge (Item)");
SETFILTER(Quantity,'<>0');
IF NOT FIND('-') THEN
EXIT;
IF NOT HideDialog THEN
IF NOT CONFIRM(Text000) THEN
EXIT;
SalesShptLine.COPY(Rec);
Code;
Rec := SalesShptLine;
END;
}
CODE
{
VAR
Text000@2029616 : TextConst 'ENU=Do you really want to undo the selected Shipment lines?';
Text001@2029615 : TextConst 'ENU=Undo quantity posting...';
Text002@2029614 : TextConst 'ENU=There is not enough space to insert correction lines.';
Text003@2029613 : TextConst 'ENU=Checking lines...';
Text004@2029610 : TextConst 'ENU=This function only works for item charges. Please use the original function for items.';
Text005@2029612 : TextConst 'ENU=This shipment has already been invoiced. Undo Shipment can be applied only to posted, but not invoiced shipments.';
SalesShptLine@2029634 : Record 111;
ItemJnlPostLine@2029628 : Codeunit 22;
HideDialog@2029621 : Boolean;
LineSpacing@2029619 : Integer;
PROCEDURE SetHideDialog@8(NewHideDialog@1000 : Boolean);
BEGIN
HideDialog := NewHideDialog;
END;
LOCAL PROCEDURE Code@2();
VAR
PostedWhseShptLine@1006 : Record 7323;
SalesLine@1007 : Record 37;
ServItem@1003 : Record 5940;
Window@1001 : Dialog;
ItemShptEntryNo@1002 : Integer;
DocLineNo@1004 : Integer;
DeleteServItems@1000 : Boolean;
PostedWhseShptLineFound@1005 : Boolean;
BEGIN
WITH SalesShptLine DO BEGIN
CLEAR(ItemJnlPostLine);
SETCURRENTKEY("Item Shpt. Entry No.");
SETRANGE(Correction,FALSE);
REPEAT
IF NOT HideDialog THEN
Window.OPEN(Text003);
CheckSalesShptLine(SalesShptLine);
UNTIL NEXT = 0;
FIND('-');
REPEAT
IF NOT HideDialog THEN
Window.OPEN(Text001);
InsertNewShipmentLine(SalesShptLine,ItemShptEntryNo,DocLineNo);
UpdateSalesOrderLine(SalesShptLine);
"Quantity Invoiced" := Quantity;
"Qty. Invoiced (Base)" := "Quantity (Base)";
"Qty. Shipped Not Invoiced" := 0;
Correction := TRUE;
MODIFY;
UNTIL NEXT = 0;
END;
END;
LOCAL PROCEDURE CheckSalesShptLine@3(SalesShptLine@1001 : Record 111);
VAR
TempItemLedgEntry@1015 : TEMPORARY Record 32;
BEGIN
WITH SalesShptLine DO BEGIN
TESTFIELD(Type,Type::"Charge (Item)");
IF "Qty. Shipped Not Invoiced" <> Quantity THEN
ERROR(Text005);
TESTFIELD("Drop Shipment",FALSE);
IF Type = Type::Item THEN
FIELDERROR(Type,Text004);
END;
END;
LOCAL PROCEDURE InsertNewShipmentLine@1(OldSalesShptLine@1000 : Record 111;ItemShptEntryNo@1001 : Integer;DocLineNo@1004 : Integer);
VAR
NewSalesShptLine@1002 : Record 111;
BEGIN
WITH OldSalesShptLine DO BEGIN
NewSalesShptLine.SETRANGE("Document No.","Document No.");
NewSalesShptLine."Document No." := "Document No.";
NewSalesShptLine."Line No." := "Line No.";
NewSalesShptLine.FIND('=');
IF NewSalesShptLine.FIND('>') THEN BEGIN
LineSpacing := (NewSalesShptLine."Line No." - "Line No.") DIV 2;
IF LineSpacing = 0 THEN
ERROR(Text002);
END ELSE
LineSpacing := 10000;
NewSalesShptLine.RESET;
NewSalesShptLine.INIT;
NewSalesShptLine.COPY(OldSalesShptLine);
NewSalesShptLine."Line No." := "Line No." + LineSpacing;
NewSalesShptLine."Appl.-from Item Entry" := "Item Shpt. Entry No.";
NewSalesShptLine.Quantity := -Quantity;
NewSalesShptLine."Qty. Shipped Not Invoiced" := 0;
NewSalesShptLine."Quantity (Base)" := -"Quantity (Base)";
NewSalesShptLine."Quantity Invoiced" := NewSalesShptLine.Quantity;
NewSalesShptLine."Qty. Invoiced (Base)" := NewSalesShptLine."Quantity (Base)";
NewSalesShptLine.Correction := TRUE;
NewSalesShptLine.INSERT;
END;
END;
LOCAL PROCEDURE UpdateSalesOrderLine@4(SalesShptLine@1000 : Record 111);
VAR
SalesLine@1001 : Record 37;
BEGIN
WITH SalesShptLine DO BEGIN
SalesLine.GET(SalesLine."Document Type"::Order,"Order No.",SalesShptLine."Order Line No.");
SalesLine."Quantity Shipped" := SalesLine."Quantity Shipped" - Quantity;
SalesLine."Qty. Shipped (Base)" := SalesLine."Qty. Shipped (Base)" - "Quantity (Base)";
SalesLine.InitOutstanding;
SalesLine.InitQtyToShip;
SalesLine.MODIFY;
END;
END;
BEGIN
END.
}
}