diff --git a/src/Apps/W1/Subcontracting/App/ExtensionLogo.png b/src/Apps/W1/Subcontracting/App/ExtensionLogo.png new file mode 100644 index 0000000000..8cce2b2fd0 Binary files /dev/null and b/src/Apps/W1/Subcontracting/App/ExtensionLogo.png differ diff --git a/src/Apps/W1/Subcontracting/App/app.json b/src/Apps/W1/Subcontracting/App/app.json new file mode 100644 index 0000000000..b8e06f388f --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/app.json @@ -0,0 +1,40 @@ +{ + "id": "1f32a50d-0057-4b95-b5df-cc04d7e89470", + "name": "Subcontracting", + "publisher": "Microsoft", + "brief": "Manage subcontracting operations in your manufacturing process.", + "description": "Streamline your subcontracting workflow by managing production orders, routing operations, and component transfers to subcontractors. Create purchase orders for subcontracted work, track components sent to and returned from subcontractors, and maintain accurate costing for outsourced manufacturing operations.", + "version": "28.3.0.0", + "contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2345592", + "privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724009", + "EULA": "https://go.microsoft.com/fwlink/?linkid=2182906", + "help": "https://go.microsoft.com/fwlink/?linkid=2345593", + "url": "https://go.microsoft.com/fwlink/?linkid=2345594", + "logo": "ExtensionLogo.png", + "screenshots": [], + "dependencies": [], + "platform": "28.0.0.0", + "application": "28.3.0.0", + "idRanges": [ + { + "from": 99001500, + "to": 99001600 + } + ], + "features": [ + "NoImplicitWith", + "TranslationFile" + ], + "resourceExposurePolicy": { + "allowDebugging": true, + "includeSourceInSymbolFile": true, + "allowDownloadingSource": true + }, + "internalsVisibleTo": [ + { + "id": "32b0d4d1-eee6-4a42-9d76-86a026cd2a71", + "name": "Subcontracting Test", + "publisher": "Microsoft" + } + ] +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/General/SubcFeatureFlagHandler.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/General/SubcFeatureFlagHandler.Codeunit.al new file mode 100644 index 0000000000..c40a473bc0 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/General/SubcFeatureFlagHandler.Codeunit.al @@ -0,0 +1,27 @@ +#if not CLEAN28 +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Setup; + +codeunit 99001569 "Subc. Feature Flag Handler" +{ + ObsoleteState = Pending; + ObsoleteTag = '28.0'; + ObsoleteReason = 'Legacy Subcontracting will be discontinued, environments should move to the Subcontracting App so this codeunit will be removed in a future release.'; + + [Obsolete('Legacy Subcontracting will be discontinued, environments should move to the Subcontracting App so this codeunit will be removed in a future release.', '28.0')] + procedure IsSubcontractingEnabled(): Boolean + var + ManufacturingSetup: Record "Manufacturing Setup"; + begin + ManufacturingSetup.SetLoadFields("Legacy Subcontracting"); + if not ManufacturingSetup.Get() then + exit(false); + exit(not ManufacturingSetup."Legacy Subcontracting"); + end; +} +#endif \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/General/SubcILEntries.PageExt.al b/src/Apps/W1/Subcontracting/App/src/General/SubcILEntries.PageExt.al new file mode 100644 index 0000000000..c7565cda6f --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/General/SubcILEntries.PageExt.al @@ -0,0 +1,122 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Ledger; + +pageextension 99001501 "Subc. ILEntries" extends "Item Ledger Entries" +{ + layout + { + addlast(Control1) + { + field("Subc. Purch. Order No."; Rec."Subc. Purch. Order No.") + { + ApplicationArea = Subcontracting; + ToolTip = 'Specifies the number of the related purchase order.'; + Visible = false; + } + field("Subc. Purch. Order Line No."; Rec."Subc. Purch. Order Line No.") + { + ApplicationArea = Subcontracting; + ToolTip = 'Specifies the number of the related purchase order line.'; + Visible = false; + } + field("Prod. Order No."; Rec."Subc. Prod. Order No.") + { + ApplicationArea = Subcontracting; + ToolTip = 'Specifies the number of the related production order.'; + Visible = false; + } + field("Prod. Order Line No."; Rec."Subc. Prod. Order Line No.") + { + ApplicationArea = Subcontracting; + ToolTip = 'Specifies the number of the related production order line.'; + Visible = false; + } + } + } + actions + { + addafter("&Application") + { + group(Production) + { + Caption = 'Production'; + action("Production Order") + { + ApplicationArea = Subcontracting; + Caption = 'Production Order'; + Enabled = Rec."Subc. Prod. Order No." <> ''; + Image = Production; + ToolTip = 'View the related production order.'; + trigger OnAction() + begin + ShowProductionOrder(Rec); + end; + } + action("Production Order Routing") + { + ApplicationArea = Subcontracting; + Caption = 'Production Order Routing'; + Enabled = Rec."Subc. Prod. Order No." <> ''; + Image = Route; + ToolTip = 'View the related production order routing.'; + trigger OnAction() + begin + ShowProductionOrderRouting(Rec); + end; + } + action("Production Order Components") + { + ApplicationArea = Subcontracting; + Caption = 'Production Order Components'; + Enabled = Rec."Subc. Prod. Order No." <> ''; + Image = Components; + ToolTip = 'View the related production order components.'; + trigger OnAction() + begin + ShowProductionOrderComponents(Rec); + end; + } + action("Purchase Order") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Purchase Order'; + Enabled = Rec."Subc. Purch. Order No." <> ''; + Image = Order; + ToolTip = 'View the related subcontracting purchase order.'; + trigger OnAction() + begin + ShowPurchaseOrder(Rec); + end; + } + } + } + } + var + SubcProdOrderFactboxMgmt: Codeunit "Subc. ProdO. Factbox Mgmt."; + SubcPurchFactboxMgmt: Codeunit "Subc. Purch. Factbox Mgmt."; + + local procedure ShowProductionOrder(RecRelatedVariant: Variant) + begin + SubcProdOrderFactboxMgmt.ShowProductionOrder(RecRelatedVariant); + end; + + local procedure ShowProductionOrderRouting(RecRelatedVariant: Variant) + begin + SubcProdOrderFactboxMgmt.ShowProductionOrderRouting(RecRelatedVariant); + end; + + local procedure ShowProductionOrderComponents(RecRelatedVariant: Variant) + begin + SubcProdOrderFactboxMgmt.ShowProductionOrderComponents(RecRelatedVariant); + end; + + local procedure ShowPurchaseOrder(RecRelatedVariant: Variant) + begin + SubcPurchFactboxMgmt.ShowPurchaseOrder(RecRelatedVariant); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/General/SubcItemJnlPostLineExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/General/SubcItemJnlPostLineExt.Codeunit.al new file mode 100644 index 0000000000..0e99a2df5a --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/General/SubcItemJnlPostLineExt.Codeunit.al @@ -0,0 +1,136 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Costing; +using Microsoft.Inventory.Journal; +using Microsoft.Inventory.Ledger; +using Microsoft.Inventory.Posting; +using Microsoft.Manufacturing.Capacity; +using Microsoft.Manufacturing.Document; + +codeunit 99001515 "Subc. ItemJnlPostLine Ext" +{ +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Line", OnAfterInitItemLedgEntry, '', false, false)] + local procedure OnAfterInitItemLedgEntry(var NewItemLedgEntry: Record "Item Ledger Entry"; ItemJournalLine: Record "Item Journal Line"; var ItemLedgEntryNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + + UpdateNewItemLedgerEntry(NewItemLedgEntry, ItemJournalLine); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Line", OnBeforeInsertCapLedgEntry, '', false, false)] + local procedure OnBeforeInsertCapLedgEntry(var CapLedgEntry: Record "Capacity Ledger Entry"; ItemJournalLine: Record "Item Journal Line") + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + + UpdateCapLedgerEntry(CapLedgEntry, ItemJournalLine); + end; + +#if not CLEAN27 +#pragma warning disable AL0432 + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Line", OnAfterPostOutput, '', false, false)] +#pragma warning restore AL0432 +#else + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Mfg. Item Jnl.-Post Line", OnAfterPostOutput, '', false, false)] +#endif + local procedure OnAfterPostOutput(var ItemLedgerEntry: Record "Item Ledger Entry"; var ProdOrderLine: Record "Prod. Order Line"; var ItemJournalLine: Record "Item Journal Line") + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + + UpdateProdOrderRoutingLine(ProdOrderLine, ItemJournalLine); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Line", OnBeforeInsertCapValueEntry, '', false, false)] + local procedure "Item Jnl.-Post Line_OnBeforeInsertCapValueEntry"(var ValueEntry: Record "Value Entry"; ItemJnlLine: Record "Item Journal Line") + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + + ClearInvoicedQuantityForItemChargeSubAssign(ValueEntry, ItemJnlLine); + CopyItemChargeNoForItemChargeSubAssign(ValueEntry, ItemJnlLine); + end; + + local procedure UpdateProdOrderRoutingLine(var ProdOrderLine: Record "Prod. Order Line"; var ItemJournalLine: Record "Item Journal Line") + var + CapacityLedgerEntry: Record "Capacity Ledger Entry"; + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + ProductionOrder: Record "Production Order"; + begin + if not ItemJournalLine.Subcontracting then + exit; + + if not ProductionOrder.Get(ProdOrderLine.Status, ProdOrderLine."Prod. Order No.") then + exit; + + if not ProdOrderRoutingLine.Get(ProdOrderLine.Status, ProdOrderLine."Prod. Order No.", ProdOrderLine."Line No.", ProdOrderLine."Routing No.", ItemJournalLine."Operation No.") then + exit; + + CapacityLedgerEntry.SetRange("Routing No.", ProdOrderRoutingLine."Routing No."); + CapacityLedgerEntry.SetRange("Routing Reference No.", ProdOrderRoutingLine."Routing Reference No."); + CapacityLedgerEntry.SetRange("Operation No.", ProdOrderRoutingLine."Operation No."); + CapacityLedgerEntry.SetRange("Order No.", ProdOrderRoutingLine."Prod. Order No."); + CapacityLedgerEntry.CalcSums("Output Quantity"); + + if CapacityLedgerEntry."Output Quantity" >= ProdOrderLine."Quantity (Base)" then begin + ProdOrderRoutingLine."Routing Status" := "Prod. Order Routing Status"::Finished; + ProdOrderRoutingLine.Modify(); + end; + end; + + local procedure UpdateNewItemLedgerEntry(var NewItemLedgerEntry: Record "Item Ledger Entry"; var ItemJournalLine: Record "Item Journal Line") + begin + NewItemLedgerEntry."Subc. Prod. Order No." := ItemJournalLine."Subc. Prod. Order No."; + NewItemLedgerEntry."Subc. Prod. Order Line No." := ItemJournalLine."Subc. Prod. Order Line No."; + NewItemLedgerEntry."Subc. Purch. Order No." := ItemJournalLine."Subc. Purch. Order No."; + NewItemLedgerEntry."Subc. Purch. Order Line No." := ItemJournalLine."Subc. Purch. Order Line No."; + NewItemLedgerEntry."Subc. Operation No." := ItemJournalLine."Subc. Operation No."; + end; + + local procedure UpdateCapLedgerEntry(var CapacityLedgerEntry: Record "Capacity Ledger Entry"; var ItemJournalLine: Record "Item Journal Line") + begin + CapacityLedgerEntry."Subc. Subcontractor No." := ItemJournalLine."Source No."; + CapacityLedgerEntry."Subc. Purch. Order No." := ItemJournalLine."Subc. Purch. Order No."; + CapacityLedgerEntry."Subc. Purch. Order Line No." := ItemJournalLine."Subc. Purch. Order Line No."; + end; + + local procedure ClearInvoicedQuantityForItemChargeSubAssign(var ValueEntry: Record "Value Entry"; var ItemJournalLine: Record "Item Journal Line") + begin + if ItemJournalLine."Subc. Item Charge Assign." and (ValueEntry."Entry Type" = "Cost Entry Type"::"Direct Cost") then + ValueEntry."Invoiced Quantity" := 0; + end; + + local procedure CopyItemChargeNoForItemChargeSubAssign(var ValueEntry: Record "Value Entry"; ItemJournalLine: Record "Item Journal Line") + begin + if ItemJournalLine."Subc. Item Charge Assign." and (ItemJournalLine."Item Charge No." <> '') then + ValueEntry."Item Charge No." := ItemJournalLine."Item Charge No."; + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/General/SubcItemLedgerEntry.TableExt.al b/src/Apps/W1/Subcontracting/App/src/General/SubcItemLedgerEntry.TableExt.al new file mode 100644 index 0000000000..852f0a8820 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/General/SubcItemLedgerEntry.TableExt.al @@ -0,0 +1,48 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Ledger; +using Microsoft.Purchases.Document; + +tableextension 99001500 "Subc. Item Ledger Entry" extends "Item Ledger Entry" +{ + AllowInCustomizations = AsReadOnly; + fields + { + field(99001510; "Subc. Prod. Order No."; Code[20]) + { + Caption = 'Prod. Order No.'; + DataClassification = CustomerContent; + } + field(99001511; "Subc. Prod. Order Line No."; Integer) + { + Caption = 'Prod. Order Line No.'; + DataClassification = CustomerContent; + } + field(99001512; "Subc. Purch. Order No."; Code[20]) + { + Caption = 'Subc. Purch. Order No.'; + DataClassification = CustomerContent; + TableRelation = "Purchase Header"."No." where("Document Type" = const(Order)); + } + field(99001513; "Subc. Purch. Order Line No."; Integer) + { + Caption = 'Subc. Purch. Order Line No.'; + DataClassification = CustomerContent; + TableRelation = "Purchase Line"."Line No." where("Document Type" = const(Order), + "Document No." = field("Subc. Purch. Order No.")); + } + field(99001514; "Subc. Operation No."; Code[10]) + { + Caption = 'Subc. Operation No.'; + DataClassification = CustomerContent; + } + } + keys + { + key(Key99001500; "Subc. Prod. Order No.", "Subc. Prod. Order Line No.", "Subc. Purch. Order No.", "Subc. Purch. Order Line No.") { } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/General/SubcNotificationMgmt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/General/SubcNotificationMgmt.Codeunit.al new file mode 100644 index 0000000000..89f7e46cf2 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/General/SubcNotificationMgmt.Codeunit.al @@ -0,0 +1,117 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using System.Environment.Configuration; + +codeunit 99001506 "Subc. Notification Mgmt." +{ + var +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + ProdOrdNotificationDescriptionTxt: Label 'Show a notification if Production Orders were created for Subcontracting.'; + ProdOrdNotificationNameLbl: Label 'Show Created Production Orders'; + SubcOrdNotificationDescriptionTxt: Label 'Show a notification if Subcontracting Orders were created for Subcontracting.'; + SubcOrdNotificationNameLbl: Label 'Show Created Subcontracting Orders'; + + procedure ShowCreatedProductionOrderConfirmationMessageCode(): Code[50] + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(''); +#endif + exit(UpperCase(GetShowCreatedProductionOrderCode())); + end; + + procedure ShowCreatedSubcontractingOrderConfirmationMessageCode(): Code[50] + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(''); +#endif + exit(UpperCase(GetShowCreatedSubContPurchOrderCode())); + end; + + procedure GetShowCreatedProductionOrderCode(): Code[50] + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(''); +#endif + exit('Show Created Production Orders'); + end; + + procedure GetShowCreatedSubContPurchOrderCode(): Code[50] + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(''); +#endif + exit('Show Created Subcontracting Orders'); + end; + + [EventSubscriber(ObjectType::Page, Page::"My Notifications", OnInitializingNotificationWithDefaultState, '', false, false)] + local procedure InitializeSubcontractingNotifications() + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + RegisterSubcontrProductionOrderCreatedNotification(); + RegisterSubcontrPurchOrderCreatedNotification(); + end; + + local procedure RegisterSubcontrProductionOrderCreatedNotification() + var + MyNotifications: Record "My Notifications"; + begin + MyNotifications.InsertDefault(GetGuidProductionOrderCreatedNotification(), ProdOrdNotificationNameLbl, ProdOrdNotificationDescriptionTxt, true); + end; + + local procedure RegisterSubcontrPurchOrderCreatedNotification() + var + MyNotifications: Record "My Notifications"; + begin + MyNotifications.InsertDefault(GetGuidSubcontractingPOCreatedNotification(), SubcOrdNotificationNameLbl, SubcOrdNotificationDescriptionTxt, true); + end; + + procedure DisableNotification(var NotificationVar: Notification) + var + MyNotifications: Record "My Notifications"; + PageMyNotifications: Page "My Notifications"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + PageMyNotifications.InitializeNotificationsWithDefaultState(); + MyNotifications.Disable(NotificationVar.Id()); + end; + + procedure GetGuidProductionOrderCreatedNotification(): Guid + begin + exit('{5d564aca-ce60-4345-ba68-e1e50976a346}'); + end; + + procedure GetGuidSubcontractingPOCreatedNotification(): Guid + begin + exit('{f7b10c9e-071a-4455-a048-d17b29ef764c}'); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/General/SubcReportingTriggersExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/General/SubcReportingTriggersExt.Codeunit.al new file mode 100644 index 0000000000..218317c77d --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/General/SubcReportingTriggersExt.Codeunit.al @@ -0,0 +1,30 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Reports; +using System.Environment; + +codeunit 99001512 "Subc. Reporting Triggers Ext" +{ + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Reporting Triggers", SubstituteReport, '', false, false)] + local procedure SubstituteDetailedCalculation(ReportId: Integer; var NewReportId: Integer) +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if ReportId = Report::"Detailed Calculation" then + NewReportId := Report::"Subc. Detailed Calculation"; + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/General/SubcSessionState.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/General/SubcSessionState.Codeunit.al new file mode 100644 index 0000000000..d8c5f3b96a --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/General/SubcSessionState.Codeunit.al @@ -0,0 +1,117 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +codeunit 99001500 "Subc. Session State" +{ + SingleInstance = true; + + var +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + CodeDictionary: Dictionary of [Text, Code[1024]]; + DateDictionary: Dictionary of [Text, Date]; + RecordIDDictionary: Dictionary of [Text, RecordId]; + + procedure ClearAllDictionariesForKey(StoredKey: Text) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if CodeDictionary.ContainsKey(StoredKey) then + CodeDictionary.Remove(StoredKey); + + if DateDictionary.ContainsKey(StoredKey) then + DateDictionary.Remove(StoredKey); + + if RecordIDDictionary.ContainsKey(StoredKey) then + RecordIDDictionary.Remove(StoredKey); + end; + + procedure SetCode(KeyToStore: Text; CodeToStore: Code[1024]) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if CodeDictionary.ContainsKey(KeyToStore) then + CodeDictionary.Set(KeyToStore, CodeToStore) + else + CodeDictionary.Add(KeyToStore, CodeToStore); + end; + + procedure SetDate(KeyToStore: Text; DateToStore: Date) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if DateDictionary.ContainsKey(KeyToStore) then + DateDictionary.Set(KeyToStore, DateToStore) + else + DateDictionary.Add(KeyToStore, DateToStore); + end; + + procedure SetRecordID(KeyToStore: Text; RecordIDToStore: RecordId) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if RecordIDDictionary.ContainsKey(KeyToStore) then + RecordIDDictionary.Set(KeyToStore, RecordIDToStore) + else + RecordIDDictionary.Add(KeyToStore, RecordIDToStore); + end; + + procedure GetCode(StoredKey: Text): Code[1024] + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if CodeDictionary.ContainsKey(StoredKey) then + exit(CodeDictionary.Get(StoredKey)); + end; + + procedure GetDate(StoredKey: Text): Date + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if DateDictionary.ContainsKey(StoredKey) then + exit(DateDictionary.Get(StoredKey)); + end; + + procedure GetRecordID(StoredKey: Text; var ReturnRecordID: RecordId) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + Clear(ReturnRecordID); + if RecordIDDictionary.ContainsKey(StoredKey) then + ReturnRecordID := RecordIDDictionary.Get(StoredKey); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/General/SubcSynchronizeManagement.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/General/SubcSynchronizeManagement.Codeunit.al new file mode 100644 index 0000000000..4699420854 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/General/SubcSynchronizeManagement.Codeunit.al @@ -0,0 +1,281 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Foundation.Enums; +using Microsoft.Foundation.UOM; +using Microsoft.Inventory.Item; +using Microsoft.Inventory.Ledger; +using Microsoft.Inventory.Transfer; +using Microsoft.Manufacturing.Capacity; +using Microsoft.Manufacturing.Document; +using Microsoft.Purchases.Document; + +codeunit 99001511 "Subc. Synchronize Management" +{ + var +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + CannotDeleteSubcOrderTitleLbl: Label 'Transfer Order Exists'; + CannotDeleteSubcOrderWithTransferOrderErr: Label 'You cannot delete Subcontracting Order %1 because Transfer Order %2 is associated with it. Delete or receive the Transfer Order first.', Comment = '%1=Subcontracting Order No., %2=Transfer Order No.'; + CannotDeleteSubcOrderWithTransferOrdersErr: Label 'You cannot delete Subcontracting Order %1 because Transfer Orders are associated with it. Delete or receive all Transfer Orders first.', Comment = '%1=Subcontracting Order No.'; + OpenTransferOrderLbl: Label 'Open Transfer Order'; + + procedure SynchronizeExpectedReceiptDate(var PurchaseLine: Record "Purchase Line"; xRecPurchaseLine: Record "Purchase Line") + var + ProductionOrder: Record "Production Order"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if not IsSubcontractingLine(PurchaseLine) then + exit; + + if PurchaseLine."Expected Receipt Date" = xRecPurchaseLine."Expected Receipt Date" then + exit; + if PurchaseLine."Qty. Received (Base)" <> 0 then + exit; + + if not ProductionOrder.Get("Production Order Status"::Released, PurchaseLine."Prod. Order No.") then + exit; + + if not ProductionOrder."Created from Purch. Order" then + exit; + + if ProductionOrder."Due Date" <> PurchaseLine."Expected Receipt Date" then begin + ProductionOrder.SetUpdateEndDate(); + ProductionOrder.Validate("Due Date", PurchaseLine."Expected Receipt Date"); + ProductionOrder.Modify(); + end; + end; + + procedure SynchronizeQuantity(var PurchaseLine: Record "Purchase Line"; xRecPurchaseLine: Record "Purchase Line") + var + ItemUnitofMeasure: Record "Item Unit of Measure"; + ProdOrderComponent: Record "Prod. Order Component"; + ProdOrderLine: Record "Prod. Order Line"; + ProductionOrder: Record "Production Order"; + UnitofMeasureManagement: Codeunit "Unit of Measure Management"; + PurchLineBaseQuantity: Decimal; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if not IsSubcontractingLine(PurchaseLine) then + exit; + + if (PurchaseLine.Quantity = xRecPurchaseLine.Quantity) and (PurchaseLine."Unit of Measure Code" = xRecPurchaseLine."Unit of Measure Code") then + exit; + + if PurchaseLine."Qty. Received (Base)" <> 0 then + exit; + + if not ProductionOrder.Get("Production Order Status"::Released, PurchaseLine."Prod. Order No.") then + exit; + + if not ProductionOrder."Created from Purch. Order" then + exit; + + ItemUnitofMeasure.Get(PurchaseLine."No.", PurchaseLine."Unit of Measure Code"); + PurchLineBaseQuantity := + UnitofMeasureManagement.CalcBaseQty(PurchaseLine."No.", PurchaseLine."Variant Code", PurchaseLine."Unit of Measure Code", PurchaseLine.Quantity, ItemUnitofMeasure."Qty. per Unit of Measure", ItemUnitofMeasure."Qty. Rounding Precision", PurchaseLine.FieldCaption("Qty. Rounding Precision"), PurchaseLine.FieldCaption(Quantity), PurchaseLine.FieldCaption("Quantity (Base)")); + + if ProductionOrder.Quantity <> PurchLineBaseQuantity then begin + ProductionOrder.Quantity := PurchLineBaseQuantity; + ProductionOrder.Modify(); + end; + + if not ProdOrderLine.Get("Production Order Status"::Released, PurchaseLine."Prod. Order No.", PurchaseLine."Prod. Order Line No.") then + exit; + + if ProdOrderLine.Quantity = PurchLineBaseQuantity then + exit; + + ProdOrderLine.Validate(Quantity, PurchLineBaseQuantity); + ProdOrderLine.Modify(); + + ProdOrderComponent.SetRange("Prod. Order No.", PurchaseLine."Prod. Order No."); + ProdOrderComponent.SetRange("Prod. Order Line No.", ProdOrderLine."Line No."); + ProdOrderComponent.SetRange(Status, "Production Order Status"::Released); + if ProdOrderComponent.IsEmpty() then + exit; + + ProdOrderComponent.FindSet(); + repeat + ProdOrderComponent.Validate("Quantity per"); + ProdOrderComponent.Modify(); + until ProdOrderComponent.Next() = 0; + end; + + procedure DeleteEnhancedDocumentsByChangeOfVendorNo(var PurchaseHeader: Record "Purchase Header"; var xPurchaseHeader: Record "Purchase Header") + var + CapacityLedgerEntry: Record "Capacity Ledger Entry"; + ItemLedgerEntry, ItemLedgerEntry2 : Record "Item Ledger Entry"; + ProductionOrder: Record "Production Order"; + PurchaseLine, PurchaseLine2, PurchaseLineModify : Record "Purchase Line"; + TransferHeader: Record "Transfer Header"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + PurchaseLine.SetRange("Document Type", PurchaseHeader."Document Type"); + PurchaseLine.SetRange("Document No.", PurchaseHeader."No."); + PurchaseLine.SetRange(Type, "Purchase Line Type"::Item); + PurchaseLine.SetFilter("No.", '<>%1', ''); + PurchaseLine.SetFilter("Prod. Order No.", '<>%1', ''); + PurchaseLine.SetRange("Qty. Received (Base)", 0); + + PurchaseLine2.SetRange("Document Type", PurchaseHeader."Document Type"); + PurchaseLine2.SetRange("Document No.", PurchaseHeader."No."); + PurchaseLine2.SetRange(Type, "Purchase Line Type"::Item); + PurchaseLine2.SetFilter("No.", '<>%1', ''); + PurchaseLine2.SetRange("Prod. Order No.", ''); + PurchaseLine2.SetRange("Qty. Received (Base)", 0); + + if not PurchaseLine.IsEmpty() then begin + PurchaseLine.FindSet(); + repeat + if ProductionOrder.Get("Production Order Status"::Released, PurchaseLine."Prod. Order No.") then + if ProductionOrder."Created from Purch. Order" then begin + ItemLedgerEntry.SetRange("Order Type", "Inventory Order Type"::Production); + ItemLedgerEntry.SetRange("Order No.", ProductionOrder."No."); + if ItemLedgerEntry.IsEmpty() then begin + CapacityLedgerEntry.SetRange("Order Type", "Inventory Order Type"::Production); + CapacityLedgerEntry.SetRange("Order No.", ProductionOrder."No."); + if CapacityLedgerEntry.IsEmpty() then begin + ProductionOrder.DeleteProdOrderRelations(); + + // Delete References to Production Order to delete + PurchaseLineModify.SetRange("Document Type", PurchaseHeader."Document Type"); + PurchaseLineModify.SetRange("Document No.", PurchaseHeader."No."); + PurchaseLineModify.SetRange(Type, "Purchase Line Type"::Item); + PurchaseLineModify.SetFilter("No.", '<>%1', ''); + PurchaseLineModify.SetRange("Prod. Order No.", ProductionOrder."No."); + if not PurchaseLineModify.IsEmpty() then begin + PurchaseLineModify.ModifyAll("Prod. Order Line No.", 0); + PurchaseLineModify.ModifyAll("Operation No.", ''); + PurchaseLineModify.ModifyAll("Routing No.", ''); + PurchaseLineModify.ModifyAll("Routing Reference No.", 0); + PurchaseLineModify.ModifyAll("Prod. Order No.", ''); + end; + + // Delete Subcontracting dependent Purchase Lines + PurchaseLine2.SetRange("Subc. Prod. Order No.", ProductionOrder."No."); + if not PurchaseLine2.IsEmpty() then + PurchaseLine2.DeleteAll(true); + + TransferHeader.SetCurrentKey("Source ID", "Subc. Source Type", "Source Subtype"); + TransferHeader.SetRange("Source ID", xPurchaseHeader."Buy-from Vendor No."); + TransferHeader.SetRange("Subc. Source Type", "Transfer Source Type"::Subcontracting); + TransferHeader.SetRange("Source Subtype", TransferHeader."Source Subtype"::"2"); + TransferHeader.SetRange("Subcontr. Purch. Order No.", PurchaseHeader."No."); + if not TransferHeader.IsEmpty() then begin + TransferHeader.FindFirst(); + ItemLedgerEntry2.SetRange("Order Type", "Inventory Order Type"::Production); + ItemLedgerEntry2.SetRange("Order No.", ProductionOrder."No."); + if ItemLedgerEntry2.IsEmpty() then + TransferHeader.Delete(true); + end; + ProductionOrder.Delete(); + end; + end; + end; + until PurchaseLine.Next() = 0; + end; + end; + + procedure CheckTransferOrderExistsForPurchaseHeader(var PurchaseHeader: Record "Purchase Header") + var + TransferHeader: Record "Transfer Header"; + TransferOrderErrorInfo: ErrorInfo; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + TransferHeader.SetRange("Subcontr. Purch. Order No.", PurchaseHeader."No."); + if TransferHeader.IsEmpty() then + exit; + + TransferOrderErrorInfo.Title := CannotDeleteSubcOrderTitleLbl; + TransferOrderErrorInfo.RecordId := PurchaseHeader.RecordId; + if TransferHeader.Count() = 1 then begin + TransferHeader.FindFirst(); + TransferOrderErrorInfo.Message := StrSubstNo(CannotDeleteSubcOrderWithTransferOrderErr, PurchaseHeader."No.", TransferHeader."No."); + end else + TransferOrderErrorInfo.Message := StrSubstNo(CannotDeleteSubcOrderWithTransferOrdersErr, PurchaseHeader."No."); + TransferOrderErrorInfo.AddAction(OpenTransferOrderLbl, Codeunit::"Subc. Purchase Header Ext", 'ShowTransferOrdersForPurchHeader'); + Error(TransferOrderErrorInfo); + end; + + procedure DeleteEnhancedDocumentsByDeletePurchLine(var PurchaseLine: Record "Purchase Line") + var + CapacityLedgerEntry: Record "Capacity Ledger Entry"; + ItemLedgerEntry: Record "Item Ledger Entry"; + ProductionOrder: Record "Production Order"; + PurchaseLine2: Record "Purchase Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if not IsSubcontractingLine(PurchaseLine) then + exit; + + if PurchaseLine."Qty. Received (Base)" <> 0 then + exit; + + if ProductionOrder.Get("Production Order Status"::Released, PurchaseLine."Prod. Order No.") then begin + ItemLedgerEntry.SetRange("Order Type", "Inventory Order Type"::Production); + ItemLedgerEntry.SetRange("Order No.", ProductionOrder."No."); + if ItemLedgerEntry.IsEmpty() then begin + CapacityLedgerEntry.SetRange("Order Type", "Inventory Order Type"::Production); + CapacityLedgerEntry.SetRange("Order No.", ProductionOrder."No."); + if CapacityLedgerEntry.IsEmpty() then + if ProductionOrder."Created from Purch. Order" then begin + ProductionOrder.DeleteProdOrderRelations(); + + // Delete Subcontracting dependent Purchase Lines + PurchaseLine2.SetRange("Subc. Prod. Order No.", ProductionOrder."No."); + if PurchaseLine2.FindSet() then + PurchaseLine2.DeleteAll(true); + + ProductionOrder.Delete(); + end; + end; + end; + end; + + local procedure IsSubcontractingLine(var PurchaseLine: Record "Purchase Line") IsSubcontracting: Boolean + begin + if PurchaseLine.Type <> "Purchase Line Type"::Item then + exit(IsSubcontracting); + + if PurchaseLine."No." = '' then + exit(IsSubcontracting); + + if PurchaseLine."Prod. Order No." = '' then + exit(IsSubcontracting); + + IsSubcontracting := true; + exit(IsSubcontracting); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/General/SubcontractingManagement.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/General/SubcontractingManagement.Codeunit.al new file mode 100644 index 0000000000..95709ae407 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/General/SubcontractingManagement.Codeunit.al @@ -0,0 +1,428 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Foundation.Company; +using Microsoft.Inventory.Location; +using Microsoft.Inventory.Planning; +using Microsoft.Inventory.Requisition; +using Microsoft.Manufacturing.Capacity; +using Microsoft.Manufacturing.Document; +using Microsoft.Manufacturing.Routing; +using Microsoft.Manufacturing.Setup; +using Microsoft.Manufacturing.WorkCenter; +using Microsoft.Purchases.Document; +using Microsoft.Purchases.Vendor; +using System.Utilities; + +codeunit 99001505 "Subcontracting Management" +{ + var + ManufacturingSetup: Record "Manufacturing Setup"; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + RoutingLinkUpdConfQst: Label 'If you change the Work Center, you will also change the default location for components with Routing Link Code=%1.\Do you want to continue anyway?', Comment = '%1=Routing Link Code'; + SuccessfullyUpdatedMsg: Label 'Successfully updated.'; + UpdateIsCancelledErr: Label 'The update is cancelled.'; + WorkCenterVendorDoesntExistErr: Label 'Subcontractor %1 on Work Center %2 does not exist.', Comment = 'Parameter %1 - subcontractor/vendor number, %2 - work center number.'; + PurchOrderExistErr: Label 'The currently selected component %1 is already used in Purchase Order %2. Therefore, it is not permitted to change the %3 field.', Comment = '%1=Item No, %2=Purchase Order No, %3=Field Caption'; + HasManufacturingSetup: Boolean; + + procedure ChangeLocationOnProdOrderComponent(var ProdOrderComponent: Record "Prod. Order Component"; VendorSubcontrLocation: Code[10]; OriginalLocationCode: Code[10]; OriginalBinCode: Code[20]) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + case ProdOrderComponent."Component Supply Method" of + "Component Supply Method"::"Consignment at Vendor", + "Component Supply Method"::"Vendor-Supplied": + if (VendorSubcontrLocation <> '') and (ProdOrderComponent."Location Code" <> VendorSubcontrLocation) then + ProdOrderComponent.Validate("Location Code", VendorSubcontrLocation); + + "Component Supply Method"::"Transfer to Vendor", + "Component Supply Method"::Empty: + begin + if (ProdOrderComponent."Location Code" <> OriginalLocationCode) and (OriginalLocationCode <> '') then begin + ProdOrderComponent.Validate("Location Code", OriginalLocationCode); + ProdOrderComponent."Subc. Original Location Code" := ''; + end; + if (ProdOrderComponent."Bin Code" <> OriginalBinCode) and (OriginalBinCode <> '') then begin + ProdOrderComponent.Validate("Bin Code", OriginalBinCode); + ProdOrderComponent."Subc. Orig. Bin Code" := ''; + end; + end; + end; + end; + + procedure ChangeLocationOnPlanningComponent(var PlanningComponent: Record "Planning Component"; VendorSubcontrLocation: Code[10]; OriginalLocationCode: Code[10]; OriginalBinCode: Code[20]) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + case PlanningComponent."Component Supply Method" of + "Component Supply Method"::"Consignment at Vendor", + "Component Supply Method"::"Vendor-Supplied": + if (VendorSubcontrLocation <> '') and (PlanningComponent."Location Code" <> VendorSubcontrLocation) then + PlanningComponent.Validate("Location Code", VendorSubcontrLocation); + + "Component Supply Method"::"Transfer to Vendor", + "Component Supply Method"::Empty: + begin + if (PlanningComponent."Location Code" <> OriginalLocationCode) and (OriginalLocationCode <> '') then begin + PlanningComponent.Validate("Location Code", OriginalLocationCode); + PlanningComponent."Orig. Location Code" := ''; + end; + if (PlanningComponent."Bin Code" <> OriginalBinCode) and (OriginalBinCode <> '') then begin + PlanningComponent.Validate("Bin Code", OriginalBinCode); + PlanningComponent."Orig. Bin Code" := ''; + end; + end; + end; + end; + + procedure DelLocationLinkedComponents(ProdOrderRoutingLine: Record "Prod. Order Routing Line"; ShowMsg: Boolean) + var + ProdOrderComponent: Record "Prod. Order Component"; + ProdOrderLine: Record "Prod. Order Line"; + StockkeepingUnit: Record "Stockkeeping Unit"; + ConfirmManagement: Codeunit "Confirm Management"; + PlanningGetParameters: Codeunit "Planning-Get Parameters"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + ProdOrderComponent.SetRange(Status, ProdOrderRoutingLine.Status); + ProdOrderComponent.SetRange("Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + ProdOrderComponent.SetRange("Prod. Order Line No.", ProdOrderRoutingLine."Routing Reference No."); + ProdOrderComponent.SetRange("Routing Link Code", ProdOrderRoutingLine."Routing Link Code"); + if not ProdOrderComponent.IsEmpty() then begin + ProdOrderComponent.FindSet(); + if ShowMsg then + if not ConfirmManagement.GetResponseOrDefault(StrSubstNo(RoutingLinkUpdConfQst, ProdOrderRoutingLine."Routing Link Code"), true) then + Error(UpdateIsCancelledErr); + + ProdOrderLine.SetLoadFields("Item No.", "Variant Code", "Location Code"); + ProdOrderLine.Get(ProdOrderRoutingLine.Status, ProdOrderComponent."Prod. Order No.", ProdOrderComponent."Prod. Order Line No."); + PlanningGetParameters.AtSKU( + StockkeepingUnit, + ProdOrderLine."Item No.", + ProdOrderLine."Variant Code", + ProdOrderLine."Location Code"); + repeat + ProdOrderComponent.Validate("Location Code", StockkeepingUnit."Components at Location"); + ProdOrderComponent.Modify(); + until ProdOrderComponent.Next() = 0; + + if ShowMsg then + Message(SuccessfullyUpdatedMsg); + end; + end; + + procedure GetSubcontractor(WorkCenterNo: Code[20]; var Vendor: Record Vendor): Boolean + var + WorkCenter: Record "Work Center"; + HasSubcontractor, IsHandled : Boolean; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(false); + +#endif + OnBeforeGetSubcontractor(WorkCenterNo, Vendor, HasSubcontractor, IsHandled);//DO NOT DELETE + if IsHandled then + exit(HasSubcontractor); + + WorkCenter.SetLoadFields("Subcontractor No."); + WorkCenter.Get(WorkCenterNo); + if WorkCenter."Subcontractor No." <> '' then begin + Vendor.SetLoadFields("Subc. Location Code"); + if not Vendor.Get(WorkCenter."Subcontractor No.") then + Error(WorkCenterVendorDoesntExistErr, WorkCenter."Subcontractor No.", WorkCenter."No."); + Vendor.TestField("Subc. Location Code"); + exit(true); + end; + exit(false); + end; + + procedure UpdateSubcontractorPriceForRequisitionLine(var RequisitionLine: Record "Requisition Line") + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if IsSubcontracting(RequisitionLine."Work Center No.") then + RequisitionLine.UpdateSubcontractorPrice(); + end; + + procedure UpdateLinkedComponentsAfterRoutingTransfer(var ProdOrderLine: Record "Prod. Order Line"; var RoutingLine: Record "Routing Line"; var ProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + WorkCenter: Record "Work Center"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if ProdOrderRoutingLine.Type <> "Capacity Type"::"Work Center" then + exit; + + if ProdOrderRoutingLine."Routing Link Code" = '' then + exit; + + WorkCenter.SetLoadFields("Subcontractor No."); + WorkCenter.Get(RoutingLine."Work Center No."); + if WorkCenter."Subcontractor No." = '' then + exit; + + UpdLinkedComponents(ProdOrderRoutingLine, false); + end; + + procedure UpdateComponentSupplyMethodForPlanningComponent(var PlanningComponent: Record "Planning Component") + var + PlanningRoutingLine: Record "Planning Routing Line"; + Vendor: Record Vendor; + OrigLocationCode, VendorSubcontractingLocationCode : Code[10]; + OrigBinCode: Code[20]; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if PlanningComponent."Routing Link Code" = '' then + exit; + + PlanningRoutingLine.SetRange("Worksheet Template Name", PlanningComponent."Worksheet Template Name"); + PlanningRoutingLine.SetRange("Worksheet Batch Name", PlanningComponent."Worksheet Batch Name"); + PlanningRoutingLine.SetRange("Worksheet Line No.", PlanningComponent."Worksheet Line No."); + PlanningRoutingLine.SetRange("Routing Link Code", PlanningComponent."Routing Link Code"); + PlanningRoutingLine.SetRange(Type, "Capacity Type"::"Work Center"); + if not PlanningRoutingLine.IsEmpty() then begin + PlanningRoutingLine.SetLoadFields("No."); + PlanningRoutingLine.FindFirst(); + + if not GetSubcontractor(PlanningRoutingLine."No.", Vendor) then + Clear(Vendor); + if PlanningComponent."Component Supply Method" in ["Component Supply Method"::"Consignment at Vendor", "Component Supply Method"::"Vendor-Supplied"] then + VendorSubcontractingLocationCode := Vendor."Subc. Location Code"; + OrigLocationCode := PlanningComponent."Orig. Location Code"; + OrigBinCode := PlanningComponent."Orig. Bin Code"; + + ChangeLocationOnPlanningComponent(PlanningComponent, VendorSubcontractingLocationCode, OrigLocationCode, OrigBinCode); + + PlanningComponent.Modify(); + end; + end; + + procedure UpdateComponentSupplyMethodForProdOrderComponent(var ProdOrderComponent: Record "Prod. Order Component") + var + ProdOrderLine: Record "Prod. Order Line"; + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + PurchaseLine: Record "Purchase Line"; + PurchaseLine2: Record "Purchase Line"; + Vendor: Record Vendor; + ProdOrderCompFound: Boolean; + OrigLocationCode, VendorSubcontractingLocationCode : Code[10]; + OrigBinCode: Code[20]; + PurchOrderNo: Code[20]; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if ProdOrderComponent."Routing Link Code" = '' then + exit; + + ProdOrderLine.SetLoadFields("Routing Reference No.", "Routing No."); + ProdOrderLine.Get(ProdOrderComponent.Status, ProdOrderComponent."Prod. Order No.", ProdOrderComponent."Prod. Order Line No."); + + ProdOrderRoutingLine.SetRange(Status, ProdOrderComponent.Status); + ProdOrderRoutingLine.SetRange("Prod. Order No.", ProdOrderComponent."Prod. Order No."); + ProdOrderRoutingLine.SetRange("Routing No.", ProdOrderLine."Routing No."); + ProdOrderRoutingLine.SetRange("Routing Reference No.", ProdOrderLine."Routing Reference No."); + ProdOrderRoutingLine.SetRange("Routing Link Code", ProdOrderComponent."Routing Link Code"); + ProdOrderRoutingLine.SetLoadFields("Prod. Order No.", Type, "No."); + if ProdOrderRoutingLine.FindFirst() then begin + PurchaseLine.SetRange("Document Type", "Purchase Document Type"::Order); + PurchaseLine.SetRange("Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + PurchaseLine.SetLoadFields(SystemId); + if PurchaseLine.FindSet() then + repeat + if PurchOrderNo <> PurchaseLine."Document No." then begin + PurchOrderNo := PurchaseLine."Document No."; + PurchaseLine2.SetRange("Document Type", PurchaseLine."Document Type"); + PurchaseLine2.SetRange("Document No.", PurchaseLine."Document No."); + PurchaseLine2.SetRange(Type, "Purchase Line Type"::Item); + PurchaseLine2.SetRange("No.", ProdOrderComponent."Item No."); + ProdOrderCompFound := not PurchaseLine2.IsEmpty(); + end; + until (PurchaseLine.Next() = 0) or ProdOrderCompFound; + if ProdOrderCompFound then + Error(PurchOrderExistErr, ProdOrderComponent."Item No.", PurchOrderNo, ProdOrderComponent.FieldCaption(ProdOrderComponent."Component Supply Method")); + + if ProdOrderRoutingLine.Type = "Capacity Type"::"Work Center" then begin + if not GetSubcontractor(ProdOrderRoutingLine."No.", Vendor) then + Clear(Vendor); + + VendorSubcontractingLocationCode := Vendor."Subc. Location Code"; + if not (ProdOrderComponent."Component Supply Method" in ["Component Supply Method"::"Consignment at Vendor", "Component Supply Method"::"Vendor-Supplied"]) then + Clear(VendorSubcontractingLocationCode); + OrigLocationCode := ProdOrderComponent."Subc. Original Location Code"; + OrigBinCode := ProdOrderComponent."Subc. Orig. Bin Code"; + + ChangeLocationOnProdOrderComponent(ProdOrderComponent, VendorSubcontractingLocationCode, OrigLocationCode, OrigBinCode); + + ProdOrderComponent.Modify(); + end; + end; + end; + + procedure UpdLinkedComponents(ProdOrderRoutingLine: Record "Prod. Order Routing Line"; ShowMsg: Boolean) + var + ProdOrderComponent: Record "Prod. Order Component"; + Vendor: Record Vendor; + ConfirmManagement: Codeunit "Confirm Management"; + Subcontracting: Boolean; + OrigLocationCode, VendorSubcontractingLocationCode : Code[10]; + OrigBinCode: Code[20]; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + ProdOrderComponent.SetRange(Status, ProdOrderRoutingLine.Status); + ProdOrderComponent.SetRange("Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + ProdOrderComponent.SetRange("Prod. Order Line No.", ProdOrderRoutingLine."Routing Reference No."); + ProdOrderComponent.SetRange("Routing Link Code", ProdOrderRoutingLine."Routing Link Code"); + if ProdOrderComponent.FindSet() then begin + if ProdOrderRoutingLine.Type = "Capacity Type"::"Work Center" then + Subcontracting := GetSubcontractor(ProdOrderRoutingLine."No.", Vendor); + + if Subcontracting then begin + VendorSubcontractingLocationCode := Vendor."Subc. Location Code"; + if ShowMsg then + if not ConfirmManagement.GetResponseOrDefault(StrSubstNo(RoutingLinkUpdConfQst, ProdOrderRoutingLine."Routing Link Code"), true) then + Error(UpdateIsCancelledErr); + repeat + if not (ProdOrderComponent."Component Supply Method" in ["Component Supply Method"::"Consignment at Vendor", "Component Supply Method"::"Vendor-Supplied"]) then + Clear(VendorSubcontractingLocationCode); + OrigLocationCode := ProdOrderComponent."Subc. Original Location Code"; + OrigBinCode := ProdOrderComponent."Subc. Orig. Bin Code"; + + ChangeLocationOnProdOrderComponent(ProdOrderComponent, VendorSubcontractingLocationCode, OrigLocationCode, OrigBinCode); + + ProdOrderComponent.Modify(); + until ProdOrderComponent.Next() = 0; + + if ShowMsg then + Message(SuccessfullyUpdatedMsg); + end; + end; + end; + + /// + /// Gets the location code for production order components based on the setup field "Subc. Default Comp. Location". + /// The location code is retrieved from the purchase line, company information, or manufacturing setup. + /// + /// The components location code. + procedure GetComponentsLocationCode(PurchaseLine: Record "Purchase Line"): Code[10] + var + CompanyInformation: Record "Company Information"; + ComponentsLocationCode: Code[10]; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(''); + +#endif + GetManufacturingSetup(); + ManufacturingSetup.TestField("Subc. Default Comp. Location"); + + case ManufacturingSetup."Subc. Default Comp. Location" of + "Components at Location"::Purchase: + begin + PurchaseLine.TestField("Location Code"); + ComponentsLocationCode := PurchaseLine."Location Code"; + end; + "Components at Location"::Company: + begin + CompanyInformation.SetLoadFields("Location Code"); + CompanyInformation.Get(); + CompanyInformation.TestField("Location Code"); + ComponentsLocationCode := CompanyInformation."Location Code"; + end; + "Components at Location"::Manufacturing: + begin + ManufacturingSetup.SetLoadFields("Components at Location"); + ManufacturingSetup.Get(); + ManufacturingSetup.TestField("Components at Location"); + ComponentsLocationCode := ManufacturingSetup."Components at Location"; + end; + end; + + exit(ComponentsLocationCode); + end; + + internal procedure IsSubcontractingPurchaseDocument(PurchaseHeader: Record "Purchase Header"): Boolean + var + PurchaseLine: Record "Purchase Line"; + begin + PurchaseLine.SetRange("Document Type", PurchaseHeader."Document Type"); + PurchaseLine.SetRange("Document No.", PurchaseHeader."No."); + PurchaseLine.SetFilter("Prod. Order No.", '<>%1', ''); + PurchaseLine.SetFilter("Prod. Order Line No.", '<>%1', 0); + exit(not PurchaseLine.IsEmpty()); + end; + + internal procedure IsSubcontractingPurchaseLine(PurchaseLine: Record "Purchase Line"): Boolean + begin + exit((PurchaseLine."Prod. Order No." <> '') and (PurchaseLine."Prod. Order Line No." <> 0)); + end; + + local procedure GetManufacturingSetup() + begin + if HasManufacturingSetup then + exit; + HasManufacturingSetup := ManufacturingSetup.Get(); + end; + + local procedure IsSubcontracting(WorkCenterNo: Code[20]): Boolean + var + WorkCenter: Record "Work Center"; + begin + WorkCenter.SetLoadFields("Subcontractor No."); + if WorkCenter.Get(WorkCenterNo) then + exit(WorkCenter."Subcontractor No." <> '') + end; + + [InternalEvent(false, false)] + local procedure OnBeforeGetSubcontractor(WorkCenterNo: Code[20]; var Vendor: Record Vendor; var HasSubcontractor: Boolean; var IsHandled: Boolean) + begin + end; +} diff --git a/src/Apps/W1/Subcontracting/App/src/Install/SubcBusinessSetupExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Install/SubcBusinessSetupExt.Codeunit.al new file mode 100644 index 0000000000..a0bb8e73f4 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Install/SubcBusinessSetupExt.Codeunit.al @@ -0,0 +1,33 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Foundation.Company; +using Microsoft.Manufacturing.Setup; +using System.Environment.Configuration; + +codeunit 99001502 "Subc. Business Setup Ext." +{ + var + SubcontractingDescriptionLbl: Label 'Make manual Subcontracting Setup'; + SubcontractingKeyWordsLbl: Label 'Subcontracting, Management'; + SubcontractingLbl: Label 'Subcontracting App'; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Guided Experience", OnRegisterManualSetup, '', false, false)] + local procedure OnRegisterManualSetup(sender: Codeunit "Guided Experience") + var + ManualSetupCategory: Enum "Manual Setup Category"; + begin + sender.InsertManualSetup(SubcontractingLbl, SubcontractingLbl, SubcontractingDescriptionLbl, 0, ObjectType::Page, Page::"Manufacturing Setup", ManualSetupCategory::Uncategorized, SubcontractingKeyWordsLbl); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Company-Initialize", OnCompanyInitialize, '', false, false)] + local procedure OnCompanyInitialize() + var + SubcontractingCompInit: Codeunit "Subcontracting Comp. Init."; + begin + SubcontractingCompInit.CreateBasicSubcontractingMgtSetup(); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Install/SubcUpgradeTagDefExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Install/SubcUpgradeTagDefExt.Codeunit.al new file mode 100644 index 0000000000..1fcfc5431b --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Install/SubcUpgradeTagDefExt.Codeunit.al @@ -0,0 +1,21 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using System.Upgrade; + +codeunit 99001570 "Subc. Upgrade Tag Def. Ext." +{ + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Upgrade Tag", 'OnGetPerCompanyUpgradeTags', '', false, false)] + local procedure RegisterPerCompanyTags(var PerCompanyUpgradeTags: List of [Code[250]]) + begin + PerCompanyUpgradeTags.Add(GetSubcontractingUpgradeTag()); + end; + + internal procedure GetSubcontractingUpgradeTag(): Code[250] + begin + exit('MS-406123-Subcontracting-20260601'); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Install/SubcontractingCompInit.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Install/SubcontractingCompInit.Codeunit.al new file mode 100644 index 0000000000..c95d697575 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Install/SubcontractingCompInit.Codeunit.al @@ -0,0 +1,88 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Requisition; +using Microsoft.Manufacturing.Setup; + +codeunit 99001503 "Subcontracting Comp. Init." +{ + var + ReqWkshTempDescLbl: Label 'Subcontracting', MaxLength = 80; + ReqWkshTempNameLbl: Label 'SUBCONTR', MaxLength = 10; + ReqWkshDescLbl: Label 'Subcontracting', MaxLength = 100; + ReqWkshNameLbl: Label 'SUBCONTR', MaxLength = 10; + DefaultCompTransferLeadTimeLbl: Label '<1D>', Locked = true; + + procedure CreateBasicSubcontractingMgtSetup() + begin + InitializeManufacturingSetupDefaults(); + end; + + local procedure InitializeManufacturingSetupDefaults() + var + ManufacturingSetup: Record "Manufacturing Setup"; + begin + if not ManufacturingSetup.Get() then begin + ManufacturingSetup.Init(); + ManufacturingSetup.Insert(true); + end; + + if not CreateSubcontractingReqWkshTemplateAndNameAndUpdateSetup(ManufacturingSetup) then + exit; + + ManufacturingSetup."Create Prod. Order Info Line" := true; + Evaluate(ManufacturingSetup."Subc. Comp. Transfer Lead Time", GetDefaultCompTransferLeadTime()); + ManufacturingSetup.Modify(true); + end; + + procedure CreateSubcontractingReqWkshTemplateAndNameAndUpdateSetup(var ManufacturingSetup: Record "Manufacturing Setup"): Boolean + var + ReqWkshTemplate: Record "Req. Wksh. Template"; + RequisitionWkshName: Record "Requisition Wksh. Name"; + begin + if not CreateReqWkshTemplate(ReqWkshTemplate, false) then + exit(false); + + CreateRequisitionWkshName(RequisitionWkshName, ReqWkshTemplate.Name); + ManufacturingSetup."Subcontracting Template Name" := ReqWkshTemplate.Name; + ManufacturingSetup."Subcontracting Batch Name" := RequisitionWkshName.Name; + exit(true); + end; + + procedure CreateReqWkshTemplate(var ReqWkshTemplate: Record "Req. Wksh. Template"; Recurring: Boolean): Boolean + begin + ReqWkshTemplate.SetRange(Type, ReqWkshTemplate.Type::Subcontracting); + if ReqWkshTemplate.FindFirst() then + exit(false); + + ReqWkshTemplate.Init(); + ReqWkshTemplate.Validate(Name, ReqWkshTempNameLbl); + ReqWkshTemplate.Validate(Description, ReqWkshTempDescLbl); + ReqWkshTemplate.Recurring := Recurring; + ReqWkshTemplate.Validate(Type, ReqWkshTemplate.Type::Subcontracting); + ReqWkshTemplate.Validate("Page ID", Page::"Subc. Subcontracting Worksheet"); + ReqWkshTemplate.Insert(true); + exit(true); + end; + + procedure CreateRequisitionWkshName(var RequisitionWkshName: Record "Requisition Wksh. Name"; WorksheetTemplateName: Text) + begin + RequisitionWkshName.SetRange("Worksheet Template Name", WorksheetTemplateName); + if RequisitionWkshName.FindFirst() then + exit; + + RequisitionWkshName.Init(); + RequisitionWkshName.Validate("Worksheet Template Name", CopyStr(WorksheetTemplateName, 1, MaxStrLen(RequisitionWkshName."Worksheet Template Name"))); + RequisitionWkshName.Validate(Name, ReqWkshNameLbl); + RequisitionWkshName.Description := ReqWkshDescLbl; + RequisitionWkshName.Insert(true); + end; + + local procedure GetDefaultCompTransferLeadTime(): Text + begin + exit(DefaultCompTransferLeadTimeLbl); + end; +} diff --git a/src/Apps/W1/Subcontracting/App/src/Install/SubcontractingInstall.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Install/SubcontractingInstall.Codeunit.al new file mode 100644 index 0000000000..8af3d51e41 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Install/SubcontractingInstall.Codeunit.al @@ -0,0 +1,73 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using System.Upgrade; + +codeunit 99001501 "Subcontracting Install" +{ + Subtype = Install; + + trigger OnInstallAppPerCompany() + var + CurrentAppInfo: ModuleInfo; + begin + NavApp.GetCurrentModuleInfo(CurrentAppInfo); + + if CurrentAppInfo.DataVersion() = Version.Create(0, 0, 0, 0) then + HandleFreshInstallPerCompany() + else + HandleReinstallPerCompany(); + end; + + trigger OnInstallAppPerDatabase() + var + CurrentAppInfo: ModuleInfo; + begin + NavApp.GetCurrentModuleInfo(CurrentAppInfo); + if CurrentAppInfo.DataVersion() = Version.Create(0, 0, 0, 0) then + HandleFreshInstallPerDatabase() + else + HandleReinstallPerDatabase(); + end; + + local procedure HandleFreshInstallPerCompany() + var + SubcontractingCompInit: Codeunit "Subcontracting Comp. Init."; + begin + SubcontractingCompInit.CreateBasicSubcontractingMgtSetup(); + SetSubcontractingFeatureOnInstall(); + end; + + local procedure HandleReinstallPerCompany() + var + SubcontractingCompInit: Codeunit "Subcontracting Comp. Init."; + begin + SubcontractingCompInit.CreateBasicSubcontractingMgtSetup(); + SetSubcontractingFeatureOnInstall(); + end; + + local procedure HandleFreshInstallPerDatabase() + begin + end; + + local procedure HandleReinstallPerDatabase() + begin + end; + + local procedure SetSubcontractingFeatureOnInstall() + var + UpgradeTag: Codeunit "Upgrade Tag"; + SubcApplicationAreaMgmt: Codeunit "Subc. Application Area Mgmt."; + SubcUpgradeTagDefExt: Codeunit "Subc. Upgrade Tag Def. Ext."; + begin + if UpgradeTag.HasUpgradeTag(SubcUpgradeTagDefExt.GetSubcontractingUpgradeTag()) then + exit; + + SubcApplicationAreaMgmt.RefreshExperienceTierCurrentCompany(); + + UpgradeTag.SetUpgradeTag(SubcUpgradeTagDefExt.GetSubcontractingUpgradeTag()); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/ComponentSupplyMethod.Enum.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/ComponentSupplyMethod.Enum.al new file mode 100644 index 0000000000..fed94caf9e --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/ComponentSupplyMethod.Enum.al @@ -0,0 +1,30 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +enum 99001500 "Component Supply Method" +{ + Extensible = true; + // No supply method is selected. + value(0; Empty) + { + Caption = ' ', Locked = true; + } + // The subcontractor provides the required component materials. + value(1; "Vendor-Supplied") + { + Caption = 'Vendor-Supplied'; + } + // Your company owns the components and stores them at the subcontractor location (consignment stock). + value(2; "Consignment at Vendor") + { + Caption = 'Consignment at Vendor'; + } + // Components are sent to the subcontractor through a transfer order. + value(3; "Transfer to Vendor") + { + Caption = 'Transfer to Vendor'; + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/ComponentsatLocation.Enum.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/ComponentsatLocation.Enum.al new file mode 100644 index 0000000000..48e008184f --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/ComponentsatLocation.Enum.al @@ -0,0 +1,26 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +enum 99001503 "Components at Location" +{ + Extensible = true; + value(0; Empty) + { + Caption = ' ', Locked = true; + } + value(1; Purchase) + { + Caption = 'Purchase Line'; + } + value(2; Company) + { + Caption = 'Company Info'; + } + value(3; Manufacturing) + { + Caption = 'Manufacturing Setup'; + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCalcBOMTreeExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCalcBOMTreeExt.Codeunit.al new file mode 100644 index 0000000000..071b7f2f3e --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCalcBOMTreeExt.Codeunit.al @@ -0,0 +1,37 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.BOM.Tree; +using Microsoft.Inventory.Item; +using Microsoft.Manufacturing.Routing; + +codeunit 99001521 "Subc. Calc BOM Tree Ext." +{ +#if not CLEAN27 +#pragma warning disable AL0432 + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Calculate BOM Tree", OnBeforeCalcRoutingLineCosts, '', false, false)] +#pragma warning restore AL0432 +#else + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Mfg. Calculate BOM Tree", OnBeforeCalcRoutingLineCosts, '', false, false)] +#endif + local procedure OnBeforeCalcRoutingLineCosts(var RoutingLine: Record "Routing Line"; var LotSize: Decimal; var ScrapPct: Decimal; ParentItem: Record Item) + var + SubcSessionState: Codeunit "Subc. Session State"; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + SubcSessionState.SetRecordID('OnBeforeCalcRoutingLineCosts', ParentItem.RecordId()); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCalcProdOrderExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCalcProdOrderExt.Codeunit.al new file mode 100644 index 0000000000..8c61e6dee4 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCalcProdOrderExt.Codeunit.al @@ -0,0 +1,68 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Document; +using Microsoft.Manufacturing.ProductionBOM; +using Microsoft.Manufacturing.Routing; + +codeunit 99001517 "Subc. Calc. Prod. Order Ext." +{ +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 + +#endif + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Calculate Prod. Order", OnAfterTransferRoutingLine, '', false, false)] + local procedure OnAfterTransferRoutingLine(var ProdOrderLine: Record "Prod. Order Line"; var RoutingLine: Record "Routing Line"; var ProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + SubcPriceManagement: Codeunit "Subc. Price Management"; + SubcontractingManagement: Codeunit "Subcontracting Management"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + SubcontractingManagement.UpdateLinkedComponentsAfterRoutingTransfer(ProdOrderLine, RoutingLine, ProdOrderRoutingLine); + + SubcPriceManagement.ApplySubcontractorPricingToProdOrderRouting(ProdOrderLine, RoutingLine, ProdOrderRoutingLine); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Calculate Prod. Order", OnAfterTransferBOMComponent, '', false, false)] + local procedure OnAfterTransferBOMComponent(var ProdOrderLine: Record "Prod. Order Line"; var ProductionBOMLine: Record "Production BOM Line"; var ProdOrderComponent: Record "Prod. Order Component"; LineQtyPerUOM: Decimal; ItemQtyPerUOM: Decimal) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + TransferSubcontractingFieldsBOMComponent(ProductionBOMLine, ProdOrderComponent); + end; + + local procedure TransferSubcontractingFieldsBOMComponent(var ProductionBOMLine: Record "Production BOM Line"; var ProdOrderComponent: Record "Prod. Order Component") + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + ProdOrderComponent."Subc. Original Location Code" := ProdOrderComponent."Location Code"; + ProdOrderComponent."Subc. Orig. Bin Code" := ProdOrderComponent."Bin Code"; + ProdOrderComponent."Component Supply Method" := ProductionBOMLine."Component Supply Method"; + + OnAfterTransferSubcontractingFieldsBOMComponent(ProductionBOMLine, ProdOrderComponent); + end; + + [InternalEvent(false, false)] + local procedure OnAfterTransferSubcontractingFieldsBOMComponent(var ProductionBOMLine: Record "Production BOM Line"; var ProdOrderComponent: Record "Prod. Order Component") + begin + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCalcStandardCostExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCalcStandardCostExt.Codeunit.al new file mode 100644 index 0000000000..7645b42d83 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCalcStandardCostExt.Codeunit.al @@ -0,0 +1,61 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Item; +using Microsoft.Manufacturing.Routing; +using Microsoft.Manufacturing.StandardCost; + +codeunit 99001514 "Subc. Calc.StandardCost Ext." +{ +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 + +#endif + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Calculate Standard Cost", OnAfterCalcRtngLineCost, '', false, false)] + local procedure OnAfterCalcRtngLineCost(RoutingLine: Record "Routing Line"; MfgItemQtyBase: Decimal; var SLSub: Decimal) + var + SubcPriceManagement: Codeunit "Subc. Price Management"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + SubcPriceManagement.CalcStandardCostOnAfterCalcRtngLineCost(RoutingLine, MfgItemQtyBase, SLSub); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Calculate Standard Cost", OnCalcMfgItemOnBeforeCalcRtngCost, '', false, false)] + local procedure OnCalcMfgItemOnBeforeCalcRtngCost(var Item: Record Item; Level: Integer; var LotSize: Decimal; var MfgItemQtyBase: Decimal) + var + SubcSessionState: Codeunit "Subc. Session State"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + SubcSessionState.SetRecordID('OnCalcMfgItemOnBeforeCalcRtngCost', Item.RecordId()); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Calculate Standard Cost", OnAfterSetProperties, '', false, false)] + local procedure OnAfterSetProperties(var NewCalculationDate: Date; var NewCalcMultiLevel: Boolean; var NewUseAssemblyList: Boolean; var NewLogErrors: Boolean; var NewStdCostWkshName: Text[50]; var NewShowDialog: Boolean) + var + SubcSessionState: Codeunit "Subc. Session State"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + SubcSessionState.SetDate('OnAfterSetProperties', NewCalculationDate); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCalcSubcontractsExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCalcSubcontractsExt.Codeunit.al new file mode 100644 index 0000000000..4dc2501a0b --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCalcSubcontractsExt.Codeunit.al @@ -0,0 +1,37 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Requisition; +using Microsoft.Manufacturing.Document; +using Microsoft.Manufacturing.WorkCenter; + +codeunit 99001529 "Subc. Calc Subcontracts Ext." +{ + [EventSubscriber(ObjectType::Report, Report::"Subc. Calculate Subcontracts", OnAfterTransferProdOrderRoutingLine, '', false, false)] + local procedure OnAfterTransferProdOrderRoutingLine(var RequisitionLine: Record "Requisition Line"; ProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + WorkCenter: Record "Work Center"; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if RequisitionLine."Description 2" = '' then begin + WorkCenter.SetLoadFields("Name 2"); + if WorkCenter.Get(ProdOrderRoutingLine."Work Center No.") then + RequisitionLine."Description 2" := WorkCenter."Name 2"; + end; + + RequisitionLine.Validate("Subc. Standard Task Code", ProdOrderRoutingLine."Standard Task Code"); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCapLEntries.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCapLEntries.PageExt.al new file mode 100644 index 0000000000..e9f796b6da --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCapLEntries.PageExt.al @@ -0,0 +1,90 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Capacity; +using Microsoft.Purchases.Document; +using Microsoft.Purchases.History; +using Microsoft.Utilities; + +pageextension 99001502 "Subc. CapLEntries" extends "Capacity Ledger Entries" +{ + layout + { + addlast(Control1) + { + field("Subc. Purch. Order No."; Rec."Subc. Purch. Order No.") + { + ApplicationArea = Subcontracting; + ToolTip = 'Specifies the number of the related purchase order.'; + Visible = false; + } + field("Subc. Purch. Order Line No."; Rec."Subc. Purch. Order Line No.") + { + ApplicationArea = Subcontracting; + ToolTip = 'Specifies the number of the related purchase order line.'; + Visible = false; + } + field("Subc. Subcontractor No."; Rec."Subc. Subcontractor No.") + { + ApplicationArea = Subcontracting; + ToolTip = 'Specifies the number of the related subcontractor.'; + Visible = false; + } + } + } + actions + { + addafter("Ent&ry") + { + group(Production) + { + Caption = 'Production'; + + action(ShowDocument) + { + ApplicationArea = Subcontracting; + Caption = 'Show Document'; + Image = Document; + ToolTip = 'View the document related to this capacity ledger entry. Shows the posted purchase receipt or invoice if available, otherwise shows the purchase order.'; + trigger OnAction() + begin + ShowRelatedDocument(Rec); + end; + } + } + } + } + local procedure ShowRelatedDocument(CapacityLedgerEntry: Record "Capacity Ledger Entry") + var + PurchRcptHeader: Record "Purch. Rcpt. Header"; + PurchInvHeader: Record "Purch. Inv. Header"; + PurchaseHeader: Record "Purchase Header"; + PageManagement: Codeunit "Page Management"; + begin + if CapacityLedgerEntry."Document No." <> '' then begin + if PurchRcptHeader.Get(CapacityLedgerEntry."Document No.") then begin + PageManagement.PageRun(PurchRcptHeader); + exit; + end; + + if PurchInvHeader.Get(CapacityLedgerEntry."Document No.") then begin + PageManagement.PageRun(PurchInvHeader); + exit; + end; + end; + + if CapacityLedgerEntry."Subc. Purch. Order No." <> '' then + if PurchaseHeader.Get(PurchaseHeader."Document Type"::Order, CapacityLedgerEntry."Subc. Purch. Order No.") then begin + PageManagement.PageRun(PurchaseHeader); + exit; + end; + // No document found + Message(NoDocumentFoundMsg); + end; + + var + NoDocumentFoundMsg: Label 'No related document could be found for this entry.'; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCapLedgerEntryExt.TableExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCapLedgerEntryExt.TableExt.al new file mode 100644 index 0000000000..3aeba5d4f1 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCapLedgerEntryExt.TableExt.al @@ -0,0 +1,34 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Capacity; +using Microsoft.Purchases.Document; + +tableextension 99001504 "Subc. Cap Ledger Entry Ext." extends "Capacity Ledger Entry" +{ + AllowInCustomizations = AsReadOnly; + fields + { + field(99001500; "Subc. Subcontractor No."; Code[20]) + { + Caption = 'Subcontractor No.'; + DataClassification = CustomerContent; + } + field(99001512; "Subc. Purch. Order No."; Code[20]) + { + Caption = 'Subc. Purch. Order No.'; + DataClassification = CustomerContent; + TableRelation = "Purchase Header"."No." where("Document Type" = const(Order)); + } + field(99001513; "Subc. Purch. Order Line No."; Integer) + { + Caption = 'Subc. Purch. Order Line No.'; + DataClassification = CustomerContent; + TableRelation = "Purchase Line"."Line No." where("Document Type" = const(Order), + "Document No." = field("Subc. Purch. Order No.")); + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCarryOutActionExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCarryOutActionExt.Codeunit.al new file mode 100644 index 0000000000..e7813b6919 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCarryOutActionExt.Codeunit.al @@ -0,0 +1,38 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Planning; +using Microsoft.Inventory.Requisition; +using Microsoft.Manufacturing.Document; + +codeunit 99001523 "Subc. Carry Out Action Ext." +{ +#if not CLEAN27 +#pragma warning disable AL0432 + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Carry Out Action", OnAfterTransferPlanningComp, '', false, false)] +#pragma warning restore AL0432 +#else + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Mfg. Carry Out Action", OnAfterTransferPlanningComp, '', false, false)] +#endif + local procedure OnAfterTransferPlanningComp(var PlanningComponent: Record "Planning Component"; var ProdOrderComponent: Record "Prod. Order Component") +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + ProdOrderComponent."Component Supply Method" := PlanningComponent."Component Supply Method"; + ProdOrderComponent."Subc. Original Location Code" := PlanningComponent."Orig. Location Code"; + ProdOrderComponent."Subc. Orig. Bin Code" := PlanningComponent."Orig. Bin Code"; + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCompFactboxMgmt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCompFactboxMgmt.Codeunit.al new file mode 100644 index 0000000000..df2dfe4123 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcCompFactboxMgmt.Codeunit.al @@ -0,0 +1,227 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Ledger; +using Microsoft.Manufacturing.Document; +using Microsoft.Purchases.Document; + +codeunit 99001562 "Subc. Comp. Factbox Mgmt." +{ +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + + /// + /// Returns the total consumption quantity posted for the given production order component via its linked routing operation. + /// + /// The production order component to sum consumption entries for. + /// The absolute sum of consumption item ledger entry quantities for the component. + procedure GetConsumptionQtyFromProdOrderComponent(ProdOrderComponent: Record "Prod. Order Component"): Decimal + var + ItemLedgerEntry: Record "Item Ledger Entry"; + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(0); + +#endif + GetProdOrderRtngLineFromProdOrderComp(ProdOrderRoutingLine, ProdOrderComponent); + + ItemLedgerEntry.SetCurrentKey(ItemLedgerEntry."Order Type", ItemLedgerEntry."Order No.", ItemLedgerEntry."Order Line No.", ItemLedgerEntry."Entry Type", ItemLedgerEntry."Prod. Order Comp. Line No."); + ItemLedgerEntry.SetRange(ItemLedgerEntry."Order Type", ItemLedgerEntry."Order Type"::Production); + ItemLedgerEntry.SetRange(ItemLedgerEntry."Order No.", ProdOrderComponent."Prod. Order No."); + ItemLedgerEntry.SetRange(ItemLedgerEntry."Order Line No.", ProdOrderComponent."Prod. Order Line No."); + ItemLedgerEntry.SetRange(ItemLedgerEntry."Entry Type", ItemLedgerEntry."Entry Type"::Consumption); + ItemLedgerEntry.SetRange(ItemLedgerEntry."Prod. Order Comp. Line No.", ProdOrderComponent."Line No."); + ItemLedgerEntry.SetRange(ItemLedgerEntry."Subc. Operation No.", ProdOrderRoutingLine."Operation No."); + ItemLedgerEntry.CalcSums(ItemLedgerEntry.Quantity); + + exit(Abs(ItemLedgerEntry.Quantity)); + end; + + /// + /// Opens the Item Ledger Entries page filtered to consumption entries for the given production order component. + /// + /// The production order component to show consumption entries for. + procedure ShowConsumptionQtyFromProdOrderComponent(ProdOrderComponent: Record "Prod. Order Component") + var + ItemLedgerEntry: Record "Item Ledger Entry"; + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + GetProdOrderRtngLineFromProdOrderComp(ProdOrderRoutingLine, ProdOrderComponent); + + ItemLedgerEntry.SetCurrentKey(ItemLedgerEntry."Order Type", ItemLedgerEntry."Order No.", ItemLedgerEntry."Order Line No.", ItemLedgerEntry."Entry Type", ItemLedgerEntry."Prod. Order Comp. Line No."); + ItemLedgerEntry.SetRange(ItemLedgerEntry."Order Type", ItemLedgerEntry."Order Type"::Production); + ItemLedgerEntry.SetRange(ItemLedgerEntry."Order No.", ProdOrderComponent."Prod. Order No."); + ItemLedgerEntry.SetRange(ItemLedgerEntry."Order Line No.", ProdOrderComponent."Prod. Order Line No."); + ItemLedgerEntry.SetRange(ItemLedgerEntry."Entry Type", ItemLedgerEntry."Entry Type"::Consumption); + ItemLedgerEntry.SetRange(ItemLedgerEntry."Prod. Order Comp. Line No.", ProdOrderComponent."Line No."); + ItemLedgerEntry.SetRange(ItemLedgerEntry."Subc. Operation No.", ProdOrderRoutingLine."Operation No."); + Page.Run(Page::"Item Ledger Entries", ItemLedgerEntry); + end; + + /// + /// Returns the total outstanding base quantity on subcontracting purchase lines for the given production order component. + /// + /// The production order component to calculate outstanding quantity for. + /// The sum of Outstanding Qty. (Base) on matching purchase lines, or 0 if not a purchase subcontracting component. + procedure GetPurchOrderOutstandingQtyBaseFromProdOrderComp(ProdOrderComponent: Record "Prod. Order Component"): Decimal + var + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + PurchaseLine: Record "Purchase Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(0); + +#endif + if ProdOrderComponent."Routing Link Code" = '' then + exit(0); + if ProdOrderComponent."Component Supply Method" <> ProdOrderComponent."Component Supply Method"::"Vendor-Supplied" then + exit(0); + + GetProdOrderRtngLineFromProdOrderComp(ProdOrderRoutingLine, ProdOrderComponent); + + PurchaseLine.SetRange(PurchaseLine."Document Type", PurchaseLine."Document Type"::Order); + PurchaseLine.SetRange(PurchaseLine."Subc. Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Prod. Order Line No.", ProdOrderRoutingLine."Routing Reference No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Routing No.", ProdOrderRoutingLine."Routing No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Operation No.", ProdOrderRoutingLine."Operation No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Work Center No.", ProdOrderRoutingLine."Work Center No."); + PurchaseLine.SetRange(PurchaseLine."No.", ProdOrderComponent."Item No."); + PurchaseLine.CalcSums(PurchaseLine."Outstanding Qty. (Base)"); + exit(PurchaseLine."Outstanding Qty. (Base)"); + end; + + /// + /// Opens the Purchase Lines page filtered to outstanding subcontracting purchase lines for the given production order component. + /// + /// The production order component to filter purchase lines by. + procedure ShowPurchOrderOutstandingQtyBaseFromProdOrderComp(ProdOrderComponent: Record "Prod. Order Component") + var + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + PurchaseLine: Record "Purchase Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if ProdOrderComponent."Routing Link Code" = '' then + exit; + if ProdOrderComponent."Component Supply Method" <> ProdOrderComponent."Component Supply Method"::"Vendor-Supplied" then + exit; + + GetProdOrderRtngLineFromProdOrderComp(ProdOrderRoutingLine, ProdOrderComponent); + + PurchaseLine.SetRange(PurchaseLine."Document Type", PurchaseLine."Document Type"::Order); + PurchaseLine.SetRange(PurchaseLine."Subc. Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Prod. Order Line No.", ProdOrderRoutingLine."Routing Reference No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Routing No.", ProdOrderRoutingLine."Routing No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Operation No.", ProdOrderRoutingLine."Operation No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Work Center No.", ProdOrderRoutingLine."Work Center No."); + PurchaseLine.SetRange(PurchaseLine."No.", ProdOrderComponent."Item No."); + Page.Run(Page::"Purchase Lines", PurchaseLine); + end; + + /// + /// Returns the total received base quantity on subcontracting purchase lines for the given production order component. + /// + /// The production order component to calculate received quantity for. + /// The sum of Qty. Received (Base) on matching purchase lines, or 0 if not a purchase subcontracting component. + procedure GetPurchOrderQtyReceivedBaseFromProdOrderComp(ProdOrderComponent: Record "Prod. Order Component"): Decimal + var + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + PurchaseLine: Record "Purchase Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(0); + +#endif + if ProdOrderComponent."Routing Link Code" = '' then + exit(0); + if ProdOrderComponent."Component Supply Method" <> ProdOrderComponent."Component Supply Method"::"Vendor-Supplied" then + exit(0); + + GetProdOrderRtngLineFromProdOrderComp(ProdOrderRoutingLine, ProdOrderComponent); + + PurchaseLine.SetRange(PurchaseLine."Document Type", PurchaseLine."Document Type"::Order); + PurchaseLine.SetRange(PurchaseLine."Subc. Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Prod. Order Line No.", ProdOrderRoutingLine."Routing Reference No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Routing No.", ProdOrderRoutingLine."Routing No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Operation No.", ProdOrderRoutingLine."Operation No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Work Center No.", ProdOrderRoutingLine."Work Center No."); + PurchaseLine.SetRange(PurchaseLine."No.", ProdOrderComponent."Item No."); + PurchaseLine.CalcSums(PurchaseLine."Qty. Received (Base)"); + exit(PurchaseLine."Qty. Received (Base)"); + end; + + /// + /// Opens the Purchase Lines page filtered to subcontracting purchase lines for the given production order component to show received quantities. + /// + /// The production order component to filter purchase lines by. + procedure ShowPurchOrderQtyReceivedBaseFromProdOrderComp(ProdOrderComponent: Record "Prod. Order Component") + var + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + PurchaseLine: Record "Purchase Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if ProdOrderComponent."Routing Link Code" = '' then + exit; + if ProdOrderComponent."Component Supply Method" <> ProdOrderComponent."Component Supply Method"::"Vendor-Supplied" then + exit; + GetProdOrderRtngLineFromProdOrderComp(ProdOrderRoutingLine, ProdOrderComponent); + + PurchaseLine.SetRange(PurchaseLine."Document Type", PurchaseLine."Document Type"::Order); + PurchaseLine.SetRange(PurchaseLine."Subc. Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Prod. Order Line No.", ProdOrderRoutingLine."Routing Reference No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Routing No.", ProdOrderRoutingLine."Routing No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Operation No.", ProdOrderRoutingLine."Operation No."); + PurchaseLine.SetRange(PurchaseLine."Subc. Work Center No.", ProdOrderRoutingLine."Work Center No."); + PurchaseLine.SetRange(PurchaseLine."No.", ProdOrderComponent."Item No."); + Page.Run(Page::"Purchase Lines", PurchaseLine); + end; + + local procedure GetProdOrderRtngLineFromProdOrderComp(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; ProdOrderComponent: Record "Prod. Order Component") + var + ProdOrderLine: Record "Prod. Order Line"; + begin + if not ProdOrderLine.Get(ProdOrderComponent.Status, ProdOrderComponent."Prod. Order No.", ProdOrderComponent."Prod. Order Line No.") then + exit; + + ProdOrderRoutingLine.SetRange(Status, ProdOrderLine.Status); + ProdOrderRoutingLine.SetRange("Prod. Order No.", ProdOrderLine."Prod. Order No."); + ProdOrderRoutingLine.SetRange("Routing Reference No.", ProdOrderLine."Routing Reference No."); + ProdOrderRoutingLine.SetRange("Routing Link Code", ProdOrderComponent."Routing Link Code"); + if ProdOrderRoutingLine.IsEmpty() then + exit; + + ProdOrderRoutingLine.FindFirst(); + end; +} diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcDispatchingList.Report.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcDispatchingList.Report.al new file mode 100644 index 0000000000..98e422586b --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcDispatchingList.Report.al @@ -0,0 +1,2024 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.CRM.Contact; +using Microsoft.CRM.Interaction; +using Microsoft.CRM.Segment; +using Microsoft.CRM.Team; +using Microsoft.Finance.Currency; +using Microsoft.Finance.GeneralLedger.Setup; +using Microsoft.Finance.ReceivablesPayables; +using Microsoft.Finance.VAT.Calculation; +using Microsoft.Finance.VAT.Clause; +using Microsoft.Foundation.Address; +using Microsoft.Foundation.Company; +using Microsoft.Foundation.PaymentTerms; +using Microsoft.Foundation.Shipping; +using Microsoft.Inventory.Location; +using Microsoft.Manufacturing.Document; +using Microsoft.Purchases.Document; +using Microsoft.Purchases.Posting; +using Microsoft.Purchases.Setup; +using Microsoft.Purchases.Vendor; +using Microsoft.Sales.Customer; +using Microsoft.Sales.Setup; +using Microsoft.Utilities; +using System.Email; +using System.Globalization; +using System.Utilities; + +report 99001504 "Subc. Dispatching List" +{ + ApplicationArea = Subcontracting; + Caption = 'Subcontractor - Dispatch List'; + DefaultLayout = Word; + PreviewMode = PrintLayout; + UsageCategory = Administration; + WordLayout = '.\src\Manufacturing\SubcDispatchingList.docx'; + WordMergeDataItem = "Purchase Header"; + + dataset + { + dataitem("Purchase Header"; "Purchase Header") + { + DataItemTableView = sorting("Document Type", "Buy-from Vendor No.", "No.") where("Subc. Order" = const(true)); + RequestFilterFields = "No.", "Buy-from Vendor No.", "No. Printed"; + RequestFilterHeading = 'Subcontractor - Dispatch List'; + column(AllowInvoiceDisc_Lbl; AllowInvoiceDiscCaptionLbl) + { + } + column(Amount_Lbl; AmountCaptionLbl) + { + } + column(Buyer_Lbl; BuyerCaptionLbl) + { + } + column(BuyFrmVendNo_PurchHeader; "Buy-from Vendor No.") + { + } + column(BuyFrmVendNo_PurchHeader_Lbl; FieldCaption("Buy-from Vendor No.")) + { + } + column(BuyFromAddr1; BuyFromAddr[1]) + { + } + column(BuyFromAddr2; BuyFromAddr[2]) + { + } + column(BuyFromAddr3; BuyFromAddr[3]) + { + } + column(BuyFromAddr4; BuyFromAddr[4]) + { + } + column(BuyFromAddr5; BuyFromAddr[5]) + { + } + column(BuyFromAddr6; BuyFromAddr[6]) + { + } + column(BuyFromAddr7; BuyFromAddr[7]) + { + } + column(BuyFromAddr8; BuyFromAddr[8]) + { + } + column(BuyFromContactEmail; BuyFromContact."E-Mail") + { + } + column(BuyFromContactEmailLbl; BuyFromContactEmailLbl) + { + } + column(BuyFromContactMobilePhoneNo; BuyFromContact."Mobile Phone No.") + { + } + column(BuyFromContactMobilePhoneNoLbl; BuyFromContactMobilePhoneNoLbl) + { + } + column(BuyFromContactPhoneNo; BuyFromContact."Phone No.") + { + } + column(BuyFromContactPhoneNoLbl; BuyFromContactPhoneNoLbl) + { + } + column(CompanyAddress1; CompanyAddr[1]) + { + } + column(CompanyAddress2; CompanyAddr[2]) + { + } + column(CompanyAddress3; CompanyAddr[3]) + { + } + column(CompanyAddress4; CompanyAddr[4]) + { + } + column(CompanyAddress5; CompanyAddr[5]) + { + } + column(CompanyAddress6; CompanyAddr[6]) + { + } + column(CompanyBankAccountNo; CompanyInformation."Bank Account No.") + { + } + column(CompanyBankAccountNo_Lbl; CompanyInfoBankAccNoCaptionLbl) + { + } + column(CompanyBankBranchNo; CompanyInformation."Bank Branch No.") + { + } + column(CompanyBankBranchNo_Lbl; CompanyInformation.FieldCaption("Bank Branch No.")) + { + } + column(CompanyBankName; CompanyInformation."Bank Name") + { + } + column(CompanyBankName_Lbl; CompanyInfoBankNameCaptionLbl) + { + } + column(CompanyCustomGiro; CustomGiroTxt) + { + } + column(CompanyCustomGiro_Lbl; CustomGiroLbl) + { + } + column(CompanyEMail; CompanyInformation."E-Mail") + { + } + column(CompanyEmail_Lbl; EmailIDCaptionLbl) + { + } + column(CompanyGiroNo; CompanyInformation."Giro No.") + { + } + column(CompanyGiroNo_Lbl; CompanyInfoGiroNoCaptionLbl) + { + } + column(CompanyHomePage; CompanyInformation."Home Page") + { + } + column(CompanyHomePage_Lbl; HomePageCaptionLbl) + { + } + column(CompanyIBAN; CompanyInformation.IBAN) + { + } + column(CompanyIBAN_Lbl; CompanyInformation.FieldCaption(IBAN)) + { + } + column(CompanyLegalOffice; LegalOfficeTxt) + { + } + column(CompanyLegalOffice_Lbl; LegalOfficeLbl) + { + } + column(CompanyLogoPosition; CompanyLogoPosition) + { + } + column(CompanyPhoneNo; CompanyInformation."Phone No.") + { + } + column(CompanyPhoneNo_Lbl; CompanyInfoPhoneNoCaptionLbl) + { + } + column(CompanyPicture; CompanyInformation.Picture) + { + } + column(CompanyRegistrationNumber; CompanyInformation.GetRegistrationNumber()) + { + } + column(CompanyRegistrationNumber_Lbl; CompanyInformation.GetRegistrationNumberLbl()) + { + } + column(CompanySWIFT; CompanyInformation."SWIFT Code") + { + } + column(CompanySWIFT_Lbl; CompanyInformation.FieldCaption("SWIFT Code")) + { + } + column(CompanyVATRegistrationNo; CompanyInformation.GetVATRegistrationNumber()) + { + } + column(CompanyVATRegistrationNo_Lbl; CompanyInformation.GetVATRegistrationNumberLbl()) + { + } + column(CompanyVATRegNo; CompanyInformation.GetVATRegistrationNumber()) + { + } + column(CompanyVATRegNo_Lbl; CompanyInformation.GetVATRegistrationNumberLbl()) + { + } + column(ConfirmToCaption_Lbl; ConfirmToCaptionLbl) + { + } + column(ContinuedCaptionLbl; ContinuedCaptionLbl) + { } + column(DimText; DimText) + { + } + column(DocType_PurchHeader; "Document Type") + { + } + column(DocumentDate; Format("Document Date", 0, 4)) + { + } + column(DocumentDate_Lbl; DocumentDateCaptionLbl) + { + } + column(DocumentTitle_Lbl; DocumentTitleLbl) + { + } + column(DueDate; Format("Due Date", 0, 4)) + { + } + column(EmailID_Lbl; EmailIDCaptionLbl) + { + } + column(ExptRecptDt_PurchaseHeader; Format("Expected Receipt Date", 0, 4)) + { + } + column(SubcAddrInfoLine; AddrInfoLine) + { + } + column(SubcAmountCaptionLbl; SubAmountCaptionLbl) + { + } + column(SubcBarcodeBase; TempCompanyInformation.Picture) + { + } + column(SubcCompanyAddress1; CompanyAddress1Footer) + { + } + column(SubcCompanyAddress2; CompanyAddress2Footer) + { + } + column(SubcCompanyAddress3; CompanyAddress3Footer) + { + } + column(SubcCompanyAddress4; CompanyAddress4Footer) + { + } + column(SubcCompanyBankName; CompanyInfoBankNameFooter) + { + } + column(SubcCompanyBankName_Lbl; CompanyInfoBankNameLblFooter) + { + } + column(SubcCompanyEMail; CompanyInfoEmailFooter) + { + } + column(SubcCompanyHomePage; CompanyInfoHomepageFooter) + { + } + column(SubcCompanyIBAN; CompanyInfoIBANFooter) + { + } + column(SubcCompanyIBAN_Lbl; CompanyInfoIBANLblFooter) + { + } + column(SubcCompanyInfo1Picture; CompanyInformation1.Picture) + { + } + column(SubcCompanyInfo2Picture; CompanyInformation2.Picture) + { + } + column(SubcCompanyInfoCourtLocation; CompanyInfoCourtLocationFooter) + { + } + column(SubcCompanyInfoExecutiveDirector1; CompanyInfoExecutiveDirector1Footer) + { + } + column(SubcCompanyInfoExecutiveDirector2; CompanyInfoExecutiveDirector2Footer) + { + } + column(SubcCompanyInfoExecutiveDirector3; CompanyInfoExecutiveDirector3Footer) + { + } + column(SubcCompanyInfoExecutiveDirector4; CompanyInfoExecutiveDirector4Footer) + { + } + column(SubcCompanyInfoFaxLbl; CompanyInfoFaxNoLblFooter) + { + } + column(SubcCompanyInfoFaxNo; CompanyInfoFaxNoFooter) + { + } + column(SubcCompanyInfoPhoneNoLbl; CompanyInfoPhoneNoLblFooter) + { + } + column(SubcCompanyInfoPicture; SubCompanyInformation.Picture) + { + } + column(SubcCompanyInfoRegisterCourtNo; CompanyInfoRegisterCourtNoFooter) + { + } + column(SubcCompanyPhoneNo; CompanyInfoPhoneNoFooter) + { + } + column(SubcCompanyPhoneNo_Lbl; CompanyInfoPhoneNoLblFooter) + { + } + column(SubcCompanySWIFT; CompanyInfoSWIFTFooter) + { + } + column(SubcCompanySWIFT_Lbl; CompanyInfoSWIFTLblFooter) + { + } + column(SubcCompanyVATRegistrationNo; CompanyVATRegNoFooter) + { + } + column(SubcCompanyVATRegistrationNo_Lbl; CompanyVATRegNoLblFooter) + { + } + column(SubcCompanyVATRegNo_Lbl; CompanyVATRegNoLblFooter) + { + } + column(SubcCourtLocationLbl; CourtLocationLblFooter) + { + } + column(SubcDocCaptionLbl; DocCaptionLbl) + { + } + column(SubcDocumentDate; Format("Document Date", 0, HeaderDateFormatExpression)) + { + } + column(SubcDocumentDateLbl; DocumentDateLbl) + { + } + column(SubcDueDate; Format("Due Date", 0, HeaderDateFormatExpression)) + { + } + column(SubcEMail_Lbl; CompanyInfoEMailAddressLblFooter) + { + } + column(SubcExecutiveDirectorsLbl; ExecutiveDirectorsLblFooter) + { + } + column(SubcExternalDocumentNoCaptionLbl; ExternalDocumentNoCaptionLbl) + { + } + column(SubcFooterMark; FooterMark) + { + } + column(SubcHeaderMark; HeaderMark) + { + } + column(SubcHeaderPhoneNo; HeaderPhoneNo) + { + } + column(SubcHeaderPhoneNoLbl; CompanyInfoPhoneNoCaptionLbl) + { + } + column(SubcHomePage_Lbl; CompanyInfoHomepageLblFooter) + { + } + column(SubcInvDiscAmount; InvDiscAmount) + { + } + column(SubcInvDiscAmtCaptionLbl; InvDiscAmtCaptionLbl) + { + } + column(SubcOfForPageLbl; OfForPageLbl) + { + } + column(SubcOrder_Date; Format("Order Date", 0, HeaderDateFormatExpression)) + { + } + column(SubcOrderNoCaptionLbl; SubOrderNoCaptionLbl) + { + } + column(SubcPageLbl; SubcPageLbl) + { + } + column(SubcPaymentTermsDescriptionLbl; PaymentTermsDescriptionTxt) + { + } + column(SubcPrintAddressLine; PrintAddressLine) + { + } + column(SubcPrintBarCode; PrintBarCode) + { + } + column(SubcPrintFooterLine; PrintFooterLine) + { + } + column(SubcPromisedDeliveryDateLbl; PromisedDeliveryDateLbl) + { + } + column(SubcPurchDocNum; "No.") + { + } + column(SubcPurchDocNumLbl; PurchOrderNumCaptionLbl) + { + } + column(SubcRegisterCourtNoLbl; RegisterCourtLblFooter) + { + } + column(SubcSalesLineLineDiscountLbl; SalesLineLineDiscountLbl) + { + } + column(SubcSalesperson; SalespersonPurchaser.Name) + { + } + column(SubcSalesPersonEmail; SalespersonPurchaser."E-Mail") + { + } + column(SubcSalespersonLbl; SalespersonLbl) + { + } + column(SubcSalesPersonPurchaserEmailLbl; SalesPersonPurchaserEmailLbl) + { + } + column(SubcSellToCustomerNoCaptionLbl; SellToCustomerNoCaption) + { + } + column(SubcSellToCustomerNoShipToAddr; SellToCustomerNoShipToAddr) + { + } + column(SubcSeperator2Lbl; Seperator2Lbl) + { + } + column(SubcSeperator3Lbl; Seperator3Lbl) + { + } + column(SubcSeperatorLbl; SeperatorLbl) + { + } + column(SubcShipToAddressCaptionLbl; ShipToAddressCaption) + { + } + column(SubcShptMethodDesc; ShipmentMethod.Description) + { + } + column(SubcShptMethodDescLbl; ShptMethodDescTxt) + { + } + column(SubcTotalAmountInclVAT; Format(TotalAmountInclVAT, 0, DecimalAmountFormatExpression)) + { + } + column(SubcTotalText; SubTotalText) + { + } + column(SubcUnit_PriceCaptionLbl; Unit_PriceCaptionLbl) + { + } + column(SubcUnitOfMeasureLbl; UnitOfMeasureLbl) + { + } + column(SubcVATAmount; Format(SubVATAmount, 0, DecimalAmountFormatExpression)) + { + } + column(SubcVATAmountSpecificationCaptionLbl; VATAmountSpecificationCaptionLbl) + { + } + column(SubcVATBaseAmount; Format(SubVATBaseAmount, 0, DecimalAmountFormatExpression)) + { + } + column(SubcVATClauseCaptionLbl; VATClauseCaptionLbl) + { + } + column(SubcVATDiscountAmount; Format(SubVATDiscountAmount, 0, DecimalAmountFormatExpression)) + { + } + column(SubcVATNo; "VAT Registration No.") + { + } + column(SubcVATNoLbl; VATNoLbl) + { + } + column(SubcVendorNo; "Buy-from Vendor No.") + { + } + column(SubcVendorNoLbl; VendorNoLbl) + { + } + column(SubcYourReferenceLbl; YourReferenceLbl) + { + } + column(HomePage_Lbl; HomePageCaptionLbl) + { + } + column(ItemDescription_Lbl; ItemDescriptionCaptionLbl) + { + } + column(ItemLineAmount_Lbl; ItemLineAmountCaptionLbl) + { + } + column(ItemNumber_Lbl; ItemNumberCaptionLbl) + { + } + column(ItemQuantity_Lbl; ItemQuantityCaptionLbl) + { + } + column(ItemUnit_Lbl; ItemUnitCaptionLbl) + { + } + column(ItemUnitPrice_Lbl; ItemUnitPriceCaptionLbl) + { + } + column(No_PurchHeader; "No.") + { + } + column(OrderDate_Lbl; OrderDateLbl) + { + } + column(OrderDate_PurchaseHeader; Format("Order Date", 0, 4)) + { + } + column(OrderDatenLbl; OrderDatenLbl) + { } + column(OrderNo_Lbl; OrderNoCaptionLbl) + { + } + column(OutputNo; OutputNo) + { + } + column(OutstandingLbl; OutstandingLbl) + { } + column(Page_Lbl; PageCaptionLbl) + { + } + column(PageLbl; PageLbl) + { } + column(PaymentDetails_Lbl; PaymentDetailsCaptionLbl) + { + } + column(PaymentTermsDesc_Lbl; PaymentTermsDescCaptionLbl) + { + } + column(PayToContactEmail; PayToContact."E-Mail") + { + } + column(PayToContactEmailLbl; PayToContactEmailLbl) + { + } + column(PayToContactMobilePhoneNo; PayToContact."Mobile Phone No.") + { + } + column(PayToContactMobilePhoneNoLbl; PayToContactMobilePhoneNoLbl) + { + } + column(PayToContactPhoneNo; PayToContact."Phone No.") + { + } + column(PayToContactPhoneNoLbl; PayToContactPhoneNoLbl) + { + } + column(PayToVendNo_PurchHeader; "Pay-to Vendor No.") + { + } + column(PrepmtPaymentTermsDesc; PrepmtPaymentTerms.Description) + { + } + column(PrepymtTermsDesc_Lbl; PrepymtTermsDescCaptionLbl) + { + } + column(PricesIncludingVAT_Lbl; PricesIncludingVATCaptionLbl) + { + } + column(PricesInclVAT_PurchHeader; "Prices Including VAT") + { + } + column(PricesInclVAT_PurchHeader_Lbl; FieldCaption("Prices Including VAT")) + { + } + column(PricesInclVATtxt; PricesInclVATtxtLbl) + { + } + column(PurchaserText; PurchaserText) + { + } + column(PurchLineInvDiscAmt_Lbl; PurchLineInvDiscAmtCaptionLbl) + { + } + column(PurchOrderCaption_Lbl; PurchOrderCaptionLbl) + { + } + column(PurchOrderDateCaption_Lbl; PurchOrderDateCaptionLbl) + { + } + column(PurchOrderNumCaption_Lbl; PurchOrderNumCaptionLbl) + { + } + column(Receiveby_Lbl; ReceivebyCaptionLbl) + { + } + column(ReferenceText; ReferenceText) + { + } + column(SalesPurchPersonName; SalespersonPurchaser.Name) + { + } + column(SellToCustNo_PurchHeader; "Sell-to Customer No.") + { + } + column(SellToCustNo_PurchHeader_Lbl; FieldCaption("Sell-to Customer No.")) + { + } + column(ShipmentMethodDesc; ShipmentMethod.Description) + { + } + column(ShipmentMethodDesc_Lbl; ShipmentMethodDescCaptionLbl) + { + } + column(ShipToAddr1; ShipToAddr[1]) + { + } + column(ShipToAddr2; ShipToAddr[2]) + { + } + column(ShipToAddr3; ShipToAddr[3]) + { + } + column(ShipToAddr4; ShipToAddr[4]) + { + } + column(ShipToAddr5; ShipToAddr[5]) + { + } + column(ShipToAddr6; ShipToAddr[6]) + { + } + column(ShipToAddr7; ShipToAddr[7]) + { + } + column(ShipToAddr8; ShipToAddr[8]) + { + } + column(ShiptoAddress_Lbl; ShiptoAddressCaptionLbl) + { + } + column(SubcontractorDispatchListLbl; SubcontractorDispatchListLbl) + { } + column(SubcontractorLbl; SubcontractorLbl) + { } + column(SubcOrdNoLbl; SubcOrdNoLbl) + { } + column(Subtotal_Lbl; SubtotalCaptionLbl) + { + } + column(TaxIdentTypeCaption_Lbl; TaxIdentTypeCaptionLbl) + { + } + column(ToCaption_Lbl; ToCaptionLbl) + { + } + column(Total_Lbl; TotalCaptionLbl) + { + } + column(VALVATBaseLCY_Lbl; VALVATBaseLCYCaptionLbl) + { + } + column(VATAmtLineInvDiscBaseAmt_Lbl; VATAmtLineInvDiscBaseAmtCaptionLbl) + { + } + column(VATAmtLineLineAmt_Lbl; VATAmtLineLineAmtCaptionLbl) + { + } + column(VATAmtLineVAT_Lbl; VATAmtLineVATCaptionLbl) + { + } + column(VATAmtLineVATAmt_Lbl; VATAmtLineVATAmtCaptionLbl) + { + } + column(VATAmtSpec_Lbl; VATAmtSpecCaptionLbl) + { + } + column(VATBaseDisc_PurchHeader; "VAT Base Discount %") + { + } + column(VATIdentifier_Lbl; VATIdentifierCaptionLbl) + { + } + column(VATNoText; VATNoText) + { + } + column(VATRegNo_PurchHeader; "VAT Registration No.") + { + } + column(VendAddr1; VendAddr[1]) + { + } + column(VendAddr2; VendAddr[2]) + { + } + column(VendAddr3; VendAddr[3]) + { + } + column(VendAddr4; VendAddr[4]) + { + } + column(VendAddr5; VendAddr[5]) + { + } + column(VendAddr6; VendAddr[6]) + { + } + column(VendAddr7; VendAddr[7]) + { + } + column(VendAddr8; VendAddr[8]) + { + } + column(VendNo_Lbl; VendNoCaptionLbl) + { + } + column(Vendor__Subcontracting_Location_Code_; Vendor."Subc. Location Code") + { + } + column(Vendor__Subcontracting_Location_Code_Caption; Vendor.FieldCaption("Subc. Location Code")) + { + } + column(VendorIDCaption_Lbl; VendorIDCaptionLbl) + { + } + column(VendorInvoiceNo; "Vendor Invoice No.") + { + } + column(VendorInvoiceNo_Lbl; VendorInvoiceNoLbl) + { + } + column(VendorOrderNo; "Vendor Order No.") + { + } + column(VendorOrderNo_Lbl; VendorOrderNoLbl) + { + } + column(YourRef_PurchHeader; "Your Reference") + { + } + dataitem("Purchase Line"; "Purchase Line") + { + DataItemLink = "Document Type" = field("Document Type"), "Document No." = field("No."); + DataItemTableView = sorting("Document Type", "Document No.", "Line No.") where("Prod. Order No." = filter(<> '')); + column(AllowInvDisc_PurchLine; "Allow Invoice Disc.") + { + } + column(AllowInvDisctxt; AllowInvDisctxt) + { + } + column(AmountIncludingVAT; "Amount Including VAT") + { + } + column(Desc_PurchLine; Description) + { + } + column(Desc_PurchLine_Lbl; FieldCaption(Description)) + { + } + column(DirectUniCost_Lbl; DirectUniCostCaptionLbl) + { + } + column(DirUnitCost_PurchLine; FormattedDirectUnitCost) + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 2; + } + column(ExpectedReceiptDate; Format("Expected Receipt Date", 0, 4)) + { + } + column(ExpectedReceiptDateLbl; ExpectedReceiptDateLbl) + { + } + column(SubcDescriptionCaption; "Purchase Line".FieldCaption(Description)) + { + } + column(SubcExpectedReceiptDate; Format("Expected Receipt Date", 0, LineDateFormatExpression)) + { + } + column(SubcLineDescription2; "Purchase Line"."Description 2") + { + } + column(SubcLineDisc; LineDiscountPctText) + { + } + column(SubcLineMark; LineMark) + { + } + column(SubcNoCaption; "Purchase Line".FieldCaption("No.")) + { + } + column(SubcPosNoText; PosNoText) + { + } + column(SubcPUoM; PricingUoMCode) + { + } + column(SubcPurchQty; "Purchase Line".Quantity) + { + } + column(SubcPUS; PriceUnit) + { + } + column(SubcQuantityCaption; "Purchase Line".FieldCaption(Quantity)) + { + } + column(SubcSalesLineLineAmount; LineAmount) + { + } + column(SubcUnitCost; UnitCost) + { + } + column(InvDiscAmt_PurchLine; -"Inv. Discount Amount") + { + AutoFormatExpression = "Currency Code"; + AutoFormatType = 1; + } + column(InvDiscCaption_Lbl; InvDiscCaptionLbl) + { + } + column(ItemNo_PurchLine; "No.") + { + } + column(ItemReferenceNo_PurchLine; "Item Reference No.") + { + } + column(JobNo_PurchLine; "Job No.") + { + } + column(JobNo_PurchLine_Lbl; JobNoLbl) + { + } + column(JobTaskNo_PurchLine; "Job Task No.") + { + } + column(JobTaskNo_PurchLine_Lbl; JobTaskNoLbl) + { + } + column(LineAmt_PurchLine; FormattedLineAmount) + { + } + column(LineDisc_PurchLine; "Line Discount %") + { + } + column(LineNo_PurchLine; "Line No.") + { + } + column(No_PurchLine; ItemNo) + { + } + column(No_PurchLine_Lbl; FieldCaption("No.")) + { + } + column(PlannedReceiptDate; Format("Planned Receipt Date", 0, 4)) + { + } + column(PlannedReceiptDateLbl; PlannedReceiptDateLbl) + { + } + column(PromisedReceiptDate; Format("Promised Receipt Date", 0, 4)) + { + } + column(PromisedReceiptDateLbl; PromisedReceiptDateLbl) + { + } + column(Purchase_Line_Operation_No_; "Purchase Line"."Subc. Operation No.") + { + } + column(Purchase_Line_Outstanding_Qty; "Purchase Line"."Outstanding Quantity") + { } + column(Purchase_Line_Prod__Order_Line_No_; "Purchase Line"."Subc. Prod. Order Line No.") + { + } + column(Purchase_Line_Prod__Order_No_; "Purchase Line"."Subc. Prod. Order No.") + { + } + column(Purchase_Line_Routing_No_; "Purchase Line"."Subc. Routing No.") + { + } + column(Purchase_Line_Routing_Reference_No_; "Purchase Line"."Subc. Rtng Reference No.") + { + } + column(PurchLineLineDisc_Lbl; PurchLineLineDiscCaptionLbl) + { + } + column(Qty_PurchLine; FormattedQuanitity) + { + } + column(Qty_PurchLine_Lbl; FieldCaption(Quantity)) + { + } + column(RequestedReceiptDate; Format("Requested Receipt Date", 0, 4)) + { + } + column(RequestedReceiptDateLbl; RequestedReceiptDateLbl) + { + } + column(TotalInclVAT; "Line Amount" - "Inv. Discount Amount") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(TotalPriceCaption_Lbl; TotalPriceCaptionLbl) + { + } + column(Type_PurchLine; Format(Type, 0, 2)) + { + } + column(UnitPrice_PurchLine; "Unit Price (LCY)") + { + } + column(UnitPrice_PurchLine_Lbl; UnitPriceLbl) + { + } + column(UOM_PurchLine; "Unit of Measure") + { + } + column(UOM_PurchLine_Lbl; ItemUnitOfMeasureCaptionLbl) + { + } + column(VATDiscountAmount_Lbl; VATDiscountAmountCaptionLbl) + { + } + column(VATIdentifier_PurchLine; "VAT Identifier") + { + } + column(VATIdentifier_PurchLine_Lbl; FieldCaption("VAT Identifier")) + { + } + column(VendorItemNo_PurchLine; "Vendor Item No.") + { + } + dataitem("Prod. Order Line"; "Prod. Order Line") + { + DataItemLink = "Prod. Order No." = field("Prod. Order No."), "Line No." = field("Prod. Order Line No."); + DataItemTableView = sorting(Status, "Prod. Order No.", "Line No.") where(Status = const(Released)); + } + dataitem("Prod. Order Routing Line"; "Prod. Order Routing Line") + { + DataItemLink = "Prod. Order No." = field("Prod. Order No."), "Routing No." = field("Routing No."), "Routing Reference No." = field("Routing Reference No."), "Operation No." = field("Operation No."); + DataItemTableView = sorting(Status, "Prod. Order No.", "Routing Reference No.", "Routing No.", "Operation No.") where(Status = const(Released)); + column(ComponentsToShipLbl; ComponentsToShipLbl) + { } + column(EndingDateLbl; EndingDateLbl) + { } + column(ItemLbl; ItemLbl) + { } + column(Prod__Order_Line___Item_No__; "Prod. Order Line"."Item No.") + { + } + column(Prod__Order_Line___Quantity__Base__; "Prod. Order Line"."Quantity (Base)") + { + } + column(Prod__Order_Line___Remaining_Quantity_; Format("Prod. Order Line"."Remaining Quantity")) + { + } + column(Prod__Order_Line___Unit_of_Measure_Code_; "Prod. Order Line"."Unit of Measure Code") + { + } + column(Prod__Order_Line__Quantity; Format("Prod. Order Line".Quantity)) + { + } + column(Prod__Order_Routing_Line__Ending_Date_; Format("Ending Date", 0, 4)) + { + } + column(Prod__Order_Routing_Line__Operation_No__; "Operation No.") + { + } + column(Prod__Order_Routing_Line__Operation_No__Caption; FieldCaption("Operation No.")) + { + } + column(Prod__Order_Routing_Line__Prod__Order_No__; "Prod. Order No.") + { + } + column(Prod__Order_Routing_Line__Starting_Date_; Format("Starting Date", 0, 4)) + { + } + column(Prod__Order_Routing_Line_Description; Description) + { + } + column(Prod__Order_Routing_Line_Description_Control1130538; Description) + { + } + column(Prod__Order_Routing_Line_Routing_Link_Code; "Routing Link Code") + { + } + column(Prod__Order_Routing_Line_Routing_No_; "Routing No.") + { + } + column(Prod__Order_Routing_Line_Routing_Reference_No_; "Routing Reference No.") + { + } + column(Prod__Order_Routing_Line_Status; Status) + { + } + column(ProdOrderLbl; ProdOrderLbl) + { } + column(QtyToShipLbl; QtyToShipLbl) + { } + column(QuantityBaseLbl; QuantityBaseLbl) + { } + column(QuantityLbl; QuantityLbl) + { } + column(RemainingQuantityLbl; RemainingQuantityLbl) + { } + column(StartingDateLbl; StartingDateLbl) + { } + column(UoMLbl; UoMLbl) + { } + dataitem("Prod. Order Component"; "Prod. Order Component") + { + DataItemLink = Status = field(Status), "Prod. Order No." = field("Prod. Order No."), "Prod. Order Line No." = field("Routing Reference No."), "Routing Link Code" = field("Routing Link Code"); + DataItemTableView = sorting(Status, "Prod. Order No.", "Prod. Order Line No.", "Line No."); + column(Expected_Qty___Base______Qty__transf__to_Subcontractor______Qty__in_Transit__Base__; "Expected Qty. (Base)" - "Subc. Qty. transf. to Subcontr" - "Subc. Qty. in Transit (Base)") + { + DecimalPlaces = 0 : 5; + } + column(Prod__Order_Component__Expected_Qty___Base__; "Expected Qty. (Base)") + { + } + column(Prod__Order_Component__Expected_Qty___Base__Caption; FieldCaption("Expected Qty. (Base)")) + { + } + column(Prod__Order_Component__Item_No__; "Item No.") + { + } + column(Prod__Order_Component__Qty__in_Transit__Base__; "Subc. Qty. in Transit (Base)") + { + } + column(Prod__Order_Component__Qty__in_Transit__Base__Caption; FieldCaption("Subc. Qty. in Transit (Base)")) + { + } + column(Prod__Order_Component__Qty__transf__to_Subcontractor_; "Subc. Qty. transf. to Subcontr") + { + } + column(Prod__Order_Component__Qty__transf__to_Subcontractor_Caption; FieldCaption("Subc. Qty. transf. to Subcontr")) + { + } + column(Prod__Order_Component_Description; Description) + { + } + column(Prod__Order_Component_Line_No_; "Line No.") + { + } + column(Prod__Order_Component_Prod__Order_Line_No_; "Prod. Order Line No.") + { + } + column(Prod__Order_Component_Prod__Order_No_; "Prod. Order No.") + { + } + column(Prod__Order_Component_Routing_Link_Code; "Routing Link Code") + { + } + column(Prod__Order_Component_Status; Status) + { + } + trigger OnPreDataItem() + begin + SetRange("Subc. Purchase Order Filter", "Purchase Header"."No."); + end; + } + } + trigger OnAfterGetRecord() + begin + AllowInvDisctxt := Format("Allow Invoice Disc."); + TotalSubTotal += "Line Amount"; + TotalInvoiceDiscountAmount -= "Inv. Discount Amount"; + TotalAmount += Amount; + + ItemNo := "No."; + + if "Vendor Item No." <> '' then + ItemNo := "Vendor Item No."; + + if "Item Reference No." <> '' then + ItemNo := "Item Reference No."; + + FormatDocument.SetPurchaseLine("Purchase Line", FormattedQuanitity, FormattedDirectUnitCost, FormattedVATPct, FormattedLineAmount); + + BlankZero("Purchase Line"); + end; + } + dataitem(Totals; "Integer") + { + DataItemTableView = sorting(Number) where(Number = const(1)); + column(SubcTotalAmountIncludingVAT; TotalAmountIncludingVATTxt) + { + } + column(SubcTotalInvoiceDiscountAmount; Format(VATDiscountAmount, 0, DecimalAmountFormatExpression)) + { + } + column(SubcTotalNetAmount; Format(TotalAmount, 0, DecimalAmountFormatExpression)) + { + } + column(SubcTotalSubTotal; Format(TotalSubTotal, 0, DecimalAmountFormatExpression)) + { + } + column(SubcTotalVATAmount; Format(VATAmount, 0, DecimalAmountFormatExpression)) + { + } + column(SubcTotalVATBaseLCY; Format(VATBaseAmount, 0, DecimalAmountFormatExpression)) + { + } + column(TotalAmount; TotalAmount) + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(TotalAmountInclVAT; TotalAmountInclVAT) + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(TotalExclVATText; TotalExclVATText) + { + } + column(TotalInclVATText; TotalInclVATText) + { + } + column(TotalInvoiceDiscountAmount; TotalInvoiceDiscountAmount) + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(TotalSubTotal; TotalSubTotal) + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(TotalText; TotalText) + { + } + column(TotalVATAmount; VATAmount) + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(TotalVATBaseAmount; VATBaseAmount) + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(TotalVATDiscountAmount; -VATDiscountAmount) + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(VATAmountText; TempVATAmountLine.VATAmountText()) + { + } + trigger OnAfterGetRecord() + var + TempPrepmtPurchaseLine: Record "Purchase Line" temporary; + begin + Clear(TempPurchaseLine); + Clear(PurchPost); + if not TempPurchaseLine.IsEmpty() then + TempPurchaseLine.DeleteAll(); + if not TempVATAmountLine.IsEmpty() then + TempVATAmountLine.DeleteAll(); + PurchPost.GetPurchLines("Purchase Header", TempPurchaseLine, 0); + TempPurchaseLine.CalcVATAmountLines(0, "Purchase Header", TempPurchaseLine, TempVATAmountLine); + TempPurchaseLine.UpdateVATOnLines(0, "Purchase Header", TempPurchaseLine, TempVATAmountLine); + VATAmount := TempVATAmountLine.GetTotalVATAmount(); + VATBaseAmount := TempVATAmountLine.GetTotalVATBase(); + VATDiscountAmount := + TempVATAmountLine.GetTotalVATDiscount("Purchase Header"."Currency Code", "Purchase Header"."Prices Including VAT"); + TotalAmountInclVAT := TempVATAmountLine.GetTotalAmountInclVAT(); + + if not TempPrepaymentInvLineBuffer.IsEmpty() then + TempPrepaymentInvLineBuffer.DeleteAll(); + PurchasePostPrepayments.GetPurchLines("Purchase Header", 0, TempPurchaseLine); + if not TempPrepmtPurchaseLine.IsEmpty() then begin + PurchasePostPrepayments.GetPurchLinesToDeduct("Purchase Header", TempPurchaseLine); + if not TempPurchaseLine.IsEmpty() then + PurchasePostPrepayments.CalcVATAmountLines("Purchase Header", TempPurchaseLine, TempPrePmtVATAmountLineDeduct, 1); + end; + PurchasePostPrepayments.CalcVATAmountLines("Purchase Header", TempPrepmtPurchaseLine, TempPrepmtVATAmountLine, 0); + TempPrepmtVATAmountLine.DeductVATAmountLine(TempPrePmtVATAmountLineDeduct); + PurchasePostPrepayments.UpdateVATOnLines("Purchase Header", TempPrepmtPurchaseLine, TempPrepmtVATAmountLine, 0); + PurchasePostPrepayments.BuildInvLineBuffer("Purchase Header", TempPrepmtPurchaseLine, 0, TempPrepaymentInvLineBuffer); + PrepmtVATAmount := TempPrepmtVATAmountLine.GetTotalVATAmount(); + PrepmtVATBaseAmount := TempPrepmtVATAmountLine.GetTotalVATBase(); + PrepmtTotalAmountInclVAT := TempPrepmtVATAmountLine.GetTotalAmountInclVAT(); + + if TotalAmount <> TotalAmountInclVAT then begin + TotalAmountIncludingVATTxt := Format(TotalAmountInclVAT, 0, DecimalAmountFormatExpression); + SubFormatDocument.SetTotalLabels("Purchase Header"."Currency Code", TotalText, TotalInclVATText, TotalExclVATText); + end else begin + TotalAmountIncludingVATTxt := ''; + TotalInclVATText := ''; + end; + end; + } + dataitem(VATCounter; "Integer") + { + DataItemTableView = sorting(Number); + column(VATAmtLineInvDiscAmt; TempVATAmountLine."Invoice Discount Amount") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(VATAmtLineInvDiscBaseAmt; TempVATAmountLine."Inv. Disc. Base Amount") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(VATAmtLineLineAmt; TempVATAmountLine."Line Amount") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(VATAmtLineVAT; TempVATAmountLine."VAT %") + { + DecimalPlaces = 0 : 5; + } + column(VATAmtLineVATAmt; TempVATAmountLine."VAT Amount") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(VATAmtLineVATBase; TempVATAmountLine."VAT Base") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(VATAmtLineVATIdentifier; TempVATAmountLine."VAT Identifier") + { + } + trigger OnAfterGetRecord() + begin + TempVATAmountLine.GetLine(Number); + end; + + trigger OnPreDataItem() + begin + if VATAmount = 0 then + CurrReport.Break(); + SetRange(Number, 1, TempVATAmountLine.Count); + end; + } + dataitem(VATCounterLCY; "Integer") + { + DataItemTableView = sorting(Number); + column(VALExchRate; VALExchRate) + { + } + column(VALSpecLCYHeader; VALSpecLCYHeader) + { + } + column(VALVATAmountLCY; VALVATAmountLCY) + { + AutoFormatType = 1; + } + column(VALVATBaseLCY; VALVATBaseLCY) + { + AutoFormatType = 1; + } + trigger OnAfterGetRecord() + begin + TempVATAmountLine.GetLine(Number); + VALVATBaseLCY := + TempVATAmountLine.GetBaseLCY( + "Purchase Header"."Posting Date", "Purchase Header"."Currency Code", "Purchase Header"."Currency Factor"); + VALVATAmountLCY := + TempVATAmountLine.GetAmountLCY( + "Purchase Header"."Posting Date", "Purchase Header"."Currency Code", "Purchase Header"."Currency Factor"); + end; + + trigger OnPreDataItem() + begin + if (not GLSetup."Print VAT specification in LCY") or + ("Purchase Header"."Currency Code" = '') or + (TempVATAmountLine.GetTotalVATAmount() = 0) + then + CurrReport.Break(); + + SetRange(Number, 1, TempVATAmountLine.Count); + + if GLSetup."LCY Code" = '' then + VALSpecLCYHeader := VATAmountSpecificationLbl + LocalCurrencyLbl + else + VALSpecLCYHeader := VATAmountSpecificationLbl + Format(GLSetup."LCY Code"); + + CurrencyExchangeRate.FindCurrency("Purchase Header"."Posting Date", "Purchase Header"."Currency Code", 1); + VALExchRate := StrSubstNo(ExchangeRateLbl, CurrencyExchangeRate."Relational Exch. Rate Amount", CurrencyExchangeRate."Exchange Rate Amount"); + end; + } + dataitem(PrepmtLoop; "Integer") + { + DataItemTableView = sorting(Number) where(Number = filter(1 ..)); + column(PrepaymentSpecCaption; PrepaymentSpecCaptionLbl) + { + } + column(PrepmtInvBuDescCaption; PrepmtInvBuDescCaptionLbl) + { + } + column(PrepmtInvBufAmt; TempPrepaymentInvLineBuffer.Amount) + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(PrepmtInvBufDesc; TempPrepaymentInvLineBuffer.Description) + { + } + column(PrepmtInvBufGLAccNo; TempPrepaymentInvLineBuffer."G/L Account No.") + { + } + column(PrepmtInvBufGLAccNoCaption; PrepmtInvBufGLAccNoCaptionLbl) + { + } + column(PrepmtLineAmount; PrepmtLineAmount) + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(PrepmtTotalAmountInclVAT; PrepmtTotalAmountInclVAT) + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(PrepmtVATAmount; PrepmtVATAmount) + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(PrepmtVATAmountText; TempPrepmtVATAmountLine.VATAmountText()) + { + } + column(PrepmtVATBaseAmount; PrepmtVATBaseAmount) + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(TotalExclVATText2; TotalExclVATText) + { + } + column(TotalInclVATText2; TotalInclVATText) + { + } + trigger OnAfterGetRecord() + begin + if Number = 1 then begin + if not TempPrepaymentInvLineBuffer.Find('-') then + CurrReport.Break(); + end else + if TempPrepaymentInvLineBuffer.Next() = 0 then + CurrReport.Break(); + + if "Purchase Header"."Prices Including VAT" then + PrepmtLineAmount := TempPrepaymentInvLineBuffer."Amount Incl. VAT" + else + PrepmtLineAmount := TempPrepaymentInvLineBuffer.Amount; + end; + } + dataitem(PrepmtVATCounter; "Integer") + { + DataItemTableView = sorting(Number); + column(PrepmtVATAmtLineLineAmt; TempPrepmtVATAmountLine."Line Amount") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(PrepmtVATAmtLineVAT; TempPrepmtVATAmountLine."VAT %") + { + DecimalPlaces = 0 : 5; + } + column(PrepmtVATAmtLineVATAmt; TempPrepmtVATAmountLine."VAT Amount") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(PrepmtVATAmtLineVATBase; TempPrepmtVATAmountLine."VAT Base") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(PrepmtVATAmtLineVATId; TempPrepmtVATAmountLine."VAT Identifier") + { + } + column(PrepymtVATAmtSpecCaption; PrepymtVATAmtSpecCaptionLbl) + { + } + trigger OnAfterGetRecord() + begin + TempPrepmtVATAmountLine.GetLine(Number); + end; + + trigger OnPreDataItem() + begin + SetRange(Number, 1, TempPrepmtVATAmountLine.Count); + end; + } + dataitem(LetterText; "Integer") + { + DataItemTableView = sorting(Number) where(Number = const(1)); + column(BodyText; BodyLbl) + { + } + column(ClosingText; ClosingLbl) + { + } + column(GreetingText; GreetingLbl) + { + } + } + dataitem(SubcVATAmountLine; "VAT Amount Line") + { + DataItemTableView = sorting("VAT Identifier", "VAT Calculation Type", "Tax Group Code", "Use Tax", Positive); + UseTemporary = true; + column(SubcInvoiceDiscountAmount_VATAmountLine; "Invoice Discount Amount") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(SubcInvoiceDiscountAmount_VATAmountLine_Lbl; FieldCaption("Invoice Discount Amount")) + { + } + column(SubcInvoiceDiscountBaseAmount_VATAmountLine; "Inv. Disc. Base Amount") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(SubcInvoiceDiscountBaseAmount_VATAmountLine_Lbl; FieldCaption("Inv. Disc. Base Amount")) + { + } + column(SubcLineAmount_VatAmountLine; "Line Amount") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(SubcLineAmount_VatAmountLine_Lbl; FieldCaption("Line Amount")) + { + } + column(SubcNoOfVATIdentifiers; Count) + { + } + column(SubcOfLbl; OfLbl) + { + } + column(SubcTotalExclVATText; SubTotalExclVATText) + { + } + column(SubcTotalInclVATText; SubTotalInclVATText) + { + } + column(SubcVATAmount_VatAmountLine; "VAT Amount") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(SubcVATAmount_VatAmountLine_Lbl; FieldCaption("VAT Amount")) + { + } + column(SubcVATBase_VatAmountLine; "VAT Base") + { + AutoFormatExpression = "Purchase Header"."Currency Code"; + AutoFormatType = 1; + } + column(SubcVATBase_VatAmountLine_Lbl; FieldCaption("VAT Base")) + { + } + column(SubcVATClause2Description; VATClause2.Description) + { + } + column(SubcVATClause2Description2; VATClause2."Description 2") + { + } + column(SubcVATIdentifier_VatAmountLine; "VAT Identifier") + { + } + column(SubcVATIdentifier_VatAmountLine_Lbl; FieldCaption("VAT Identifier")) + { + } + column(SubcVATPct_VatAmountLine; "VAT %") + { + DecimalPlaces = 0 : 5; + } + column(SubcVATPct_VatAmountLine_Lbl; FieldCaption("VAT %")) + { + } + column(SubcVATPercentCaptionLbl; VATPercentCaptionLbl) + { + } + } + trigger OnAfterGetRecord() + begin + TotalAmount := 0; + CurrReport.Language := LanguageMgt.GetLanguageIdOrDefault("Language Code"); + FormatAddress.SetLanguageCode("Language Code"); + + FormatAddressFields("Purchase Header"); + FormatDocumentFields("Purchase Header"); + if BuyFromContact.Get("Buy-from Contact No.") then; + if PayToContact.Get("Pay-to Contact No.") then; + + if not IsReportInPreviewMode() then begin + Codeunit.Run(Codeunit::"Purch.Header-Printed", "Purchase Header"); + if ShouldArchiveDocument then + ArchiveManagement.StorePurchDocument("Purchase Header", ShouldLogInteraction); + end; + + SubFormatAddress.PurchHeaderShipTo(ShipToAddr, "Purchase Header"); + + if not SubcVATAmountLine.IsEmpty() then + SubcVATAmountLine.DeleteAll(); + "Purchase Line".CalcVATAmountLines(0, "Purchase Header", "Purchase Line", SubcVATAmountLine); + "Purchase Line".UpdateVATOnLines(0, "Purchase Header", "Purchase Line", SubcVATAmountLine); + ShowShippingAddr := ("Purchase Header"."Buy-from Vendor No." <> "Purchase Header"."Sell-to Customer No."); + if not ShowShippingAddr then + Clear(ShipToAddr); + + SetTotalLabels("Currency Code", SubTotalText); + SetInvDisAmountLbl("Currency Code", InvDiscAmtCaptionLbl); + + FormatFooter(); + + SubVATAmount := SubcVATAmountLine.GetTotalVATAmount(); + SubVATBaseAmount := SubcVATAmountLine.GetTotalVATBase(); + SubVATDiscountAmount := SubcVATAmountLine.GetTotalVATDiscount("Purchase Header"."Currency Code", "Purchase Header"."Prices Including VAT"); + + SetLabels(); + + Vendor.Get("Purchase Header"."Buy-from Vendor No."); + end; + } + dataitem(SubcShipToAddr; Integer) + { + DataItemTableView = sorting(Number); + column(TempSUBShipToAddr__Address; TempShiptoAddress.Address) + { + } + trigger OnPreDataItem() + begin + SetRange(Number, 1, TempShiptoAddress.Count); + end; + + trigger OnAfterGetRecord() + begin + if Number = 1 then + TempShiptoAddress.Find('-') + else + TempShiptoAddress.Next(); + end; + } + } + requestpage + { + SaveValues = true; + + layout + { + area(Content) + { + group(Options) + { + Caption = 'Options'; + field(ArchiveDocument; ShouldArchiveDocument) + { + ApplicationArea = Subcontracting; + Caption = 'Archive Document'; + ToolTip = 'Specifies whether to archive the order.'; + Visible = false; + } + field(LogInteraction; ShouldLogInteraction) + { + ApplicationArea = Subcontracting; + Caption = 'Log Interaction'; + Enabled = LogInteractionEnable; + ToolTip = 'Specifies if you want to log this interaction.'; + } + field(SubcPrintAddressLine; PrintAddressLine) + { + ApplicationArea = Subcontracting; + Caption = 'Show Address Line'; + ToolTip = 'Specifies if the address line is shown.'; + } + field(SubcPrintFooterLine; PrintFooterLine) + { + ApplicationArea = Subcontracting; + Caption = 'Show Footer Line'; + ToolTip = 'Specifies if the footer line is shown.'; + } + field(SubcPrintBarCode; PrintBarCode) + { + ApplicationArea = Subcontracting; + Caption = 'Show Bar Code'; + ToolTip = 'Specifies if the Barcode is shown.'; + } + } + } + } + trigger OnInit() + begin + LogInteractionEnable := true; + ShouldArchiveDocument := PurchasesPayablesSetup."Archive Orders"; + end; + + trigger OnOpenPage() + begin + LogInteractionEnable := ShouldLogInteraction; + end; + } + trigger OnInitReport() +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + CurrReport.Quit(); +#endif + GLSetup.Get(); + CompanyInformation.Get(); + PurchasesPayablesSetup.Get(); + CompanyInformation.CalcFields(Picture); + + SalesReceivablesSetup.Get(); + SubFormatDocument.SetLogoPosition(SalesReceivablesSetup."Logo Position on Documents", CompanyInformation1, CompanyInformation2, SubCompanyInformation); + end; + + trigger OnPostReport() + begin + if ShouldLogInteraction and not IsReportInPreviewMode() then + if "Purchase Header".FindSet() then + repeat + SegManagement.LogDocument( + 13, "Purchase Header"."No.", 0, 0, Database::Vendor, "Purchase Header"."Buy-from Vendor No.", + "Purchase Header"."Purchaser Code", '', "Purchase Header"."Posting Description", ''); + until "Purchase Header".Next() = 0; + end; + + trigger OnPreReport() + begin + if not CurrReport.UseRequestPage then + InitLogInteraction(); + end; + + var + CompanyInformation: Record "Company Information"; + SubCompanyInformation: Record "Company Information"; + CompanyInformation1: Record "Company Information"; + CompanyInformation2: Record "Company Information"; + TempCompanyInformation: Record "Company Information" temporary; + BuyFromContact: Record Contact; + PayToContact: Record Contact; + CurrencyExchangeRate: Record "Currency Exchange Rate"; + GLSetup: Record "General Ledger Setup"; + PaymentTerms: Record "Payment Terms"; + PrepmtPaymentTerms: Record "Payment Terms"; + TempPrepaymentInvLineBuffer: Record "Prepayment Inv. Line Buffer" temporary; + TempPurchaseLine: Record "Purchase Line" temporary; + PurchasesPayablesSetup: Record "Purchases & Payables Setup"; + ResponsibilityCenter: Record "Responsibility Center"; + SalesReceivablesSetup: Record "Sales & Receivables Setup"; + SalespersonPurchaser: Record "Salesperson/Purchaser"; + TempShiptoAddress: Record "Ship-to Address" temporary; + ShipmentMethod: Record "Shipment Method"; + TempPrepmtVATAmountLine: Record "VAT Amount Line" temporary; + TempPrePmtVATAmountLineDeduct: Record "VAT Amount Line" temporary; + TempVATAmountLine: Record "VAT Amount Line" temporary; + VATClause2: Record "VAT Clause"; + Vendor: Record Vendor; + ArchiveManagement: Codeunit ArchiveManagement; + SubFormatAddress: Codeunit "Format Address"; + FormatAddress: Codeunit "Format Address"; + SubFormatDocument: Codeunit "Format Document"; + FormatDocument: Codeunit "Format Document"; + LanguageMgt: Codeunit Language; + PurchPost: Codeunit "Purch.-Post"; + PurchasePostPrepayments: Codeunit "Purchase-Post Prepayments"; + SegManagement: Codeunit SegManagement; + ShouldArchiveDocument: Boolean; + PrintAddressLine: Boolean; + PrintBarCode: Boolean; + PrintFooterLine: Boolean; + PrintPaymentTerms: Boolean; + ShowShippingAddr: Boolean; + ShouldLogInteraction: Boolean; + LogInteractionEnable: Boolean; + VATAmount, VATBaseAmount, VATDiscountAmount : Decimal; + PrepmtLineAmount: Decimal; + PrepmtTotalAmountInclVAT: Decimal; + PrepmtVATAmount: Decimal; + PrepmtVATBaseAmount: Decimal; + TotalAmount: Decimal; + TotalAmountInclVAT: Decimal; + TotalInvoiceDiscountAmount: Decimal; + TotalSubTotal: Decimal; + VALVATAmountLCY: Decimal; + VALVATBaseLCY: Decimal; + SubVATAmount: Decimal; + SubVATBaseAmount: Decimal; + SubVATDiscountAmount: Decimal; + CompanyLogoPosition: Integer; + OutputNo: Integer; + AllowInvoiceDiscCaptionLbl: Label 'Allow Invoice Discount'; + AmountCaptionLbl: Label 'Amount'; + BodyLbl: Label 'The purchase order is attached to this message.'; + BuyerCaptionLbl: Label 'Buyer'; + BuyFromContactEmailLbl: Label 'Buy-from Contact E-Mail'; + BuyFromContactMobilePhoneNoLbl: Label 'Buy-from Contact Mobile Phone No.'; + BuyFromContactPhoneNoLbl: Label 'Buy-from Contact Phone No.'; + ClosingLbl: Label 'Sincerely'; + CompanyInfoBankAccNoCaptionLbl: Label 'Account No.'; + CompanyInfoBankNameCaptionLbl: Label 'Bank'; + CompanyInfoGiroNoCaptionLbl: Label 'Giro No.'; + CompanyInfoPhoneNoCaptionLbl: Label 'Phone No.'; + ComponentsToShipLbl: Label 'Components to ship'; + ConfirmToCaptionLbl: Label 'Confirm To'; + ContinuedCaptionLbl: Label 'Continued'; + DirectUniCostCaptionLbl: Label 'Direct Unit Cost'; + DocumentDateCaptionLbl: Label 'Document Date'; + DocumentTitleLbl: Label 'Purchase Order'; + EmailIDCaptionLbl: Label 'Email'; + EndingDateLbl: Label 'Ending Date'; + ExchangeRateLbl: Label 'Exchange rate: %1/%2', Comment = '%1=Currency Code, %2=Currency Code'; + ExpectedReceiptDateLbl: Label 'Expected Receipt Date'; + SubAmountCaptionLbl: Label 'Amount'; + CompanyInfoBankNameLbl: Label 'Bank'; + CompanyInfoFaxLbl: Label 'Fax No.'; + CompanyInfoPhoneNoLbl: Label 'Phone No.'; + CourtLocationLbl: Label 'Court Location: '; + DocCaptionLbl: Label 'Subcontractor - Dispatch List'; + DocumentDateLbl: Label 'Document Date'; + EMailLbl: Label 'Email'; + ExternalDocumentNoCaptionLbl: Label 'Ext. Doc. No.'; + HomePageLbl: Label 'Home Page'; + OfForPageLbl: Label 'of'; + OfLbl: Label 'of'; + SubOrderNoCaptionLbl: Label 'Order No.'; + PageLbl: Label 'Page'; + PaymentTermsDescriptionLbl: Label 'Payment Terms:'; + PromisedDeliveryDateLbl: Label 'Deliv. Date'; + RegisterCourtNoLbl: Label 'Register Court: '; + SalesLineLineDiscountLbl: Label 'Discount %'; + SalespersonLbl: Label 'Purchaser'; + SalesPersonPurchaserEmailLbl: Label 'E-Mail'; + ShptMethodDescLbl: Label 'Shipment Method:'; + Unit_PriceCaptionLbl: Label 'Unit Price'; + UnitOfMeasureLbl: Label 'Unit of Measure'; + VATAmountSpecificationCaptionLbl: Label 'VAT Amount Specification'; + VATClauseCaptionLbl: Label 'VAT Clause'; + VATNoLbl: Label 'VAT Registration No.'; + VATPercentCaptionLbl: Label '% VAT'; + VendorNoLbl: Label 'Vendor No.'; + YourReferenceLbl: Label 'Your Reference'; + GreetingLbl: Label 'Hello'; + HomePageCaptionLbl: Label 'Home Page'; + InvDiscCaptionLbl: Label 'Invoice Discount:'; + ItemDescriptionCaptionLbl: Label 'Description'; + ItemLbl: Label 'Item'; + ItemLineAmountCaptionLbl: Label 'Line Amount'; + ItemNumberCaptionLbl: Label 'Item No.'; + ItemQuantityCaptionLbl: Label 'Quantity'; + ItemUnitCaptionLbl: Label 'Unit'; + ItemUnitOfMeasureCaptionLbl: Label 'Unit'; + ItemUnitPriceCaptionLbl: Label 'Unit Price'; + JobNoLbl: Label 'Job No.'; + JobTaskNoLbl: Label 'Job Task No.'; + LocalCurrencyLbl: Label 'Local Currency'; + OrderDateLbl: Label 'Order Date'; + OrderDatenLbl: Label 'Order Date'; + OrderNoCaptionLbl: Label 'Order No.'; + OutstandingLbl: Label 'Outstanding'; + PageCaptionLbl: Label 'Page'; + SubcPageLbl: Label 'Page'; + PaymentDetailsCaptionLbl: Label 'Payment Details'; + PaymentTermsDescCaptionLbl: Label 'Payment Terms'; + PayToContactEmailLbl: Label 'Pay-to Contact E-Mail'; + PayToContactMobilePhoneNoLbl: Label 'Pay-to Contact Mobile Phone No.'; + PayToContactPhoneNoLbl: Label 'Pay-to Contact Phone No.'; + PlannedReceiptDateLbl: Label 'Planned Receipt Date'; + PrepaymentSpecCaptionLbl: Label 'Prepayment Specification'; + PrepmtInvBuDescCaptionLbl: Label 'Description'; + PrepmtInvBufGLAccNoCaptionLbl: Label 'G/L Account No.'; + PrepymtTermsDescCaptionLbl: Label 'Prepmt. Payment Terms'; + PrepymtVATAmtSpecCaptionLbl: Label 'Prepayment VAT Amount Specification'; + PricesIncludingVATCaptionLbl: Label 'Prices Including VAT'; + PricesInclVATtxtLbl: Label 'Prices Including VAT'; + ProdOrderLbl: Label 'Prod. Order:'; + PromisedReceiptDateLbl: Label 'Promised Receipt Date'; + PurchLineInvDiscAmtCaptionLbl: Label 'Invoice Discount Amount'; + PurchLineLineDiscCaptionLbl: Label 'Discount %'; + PurchOrderCaptionLbl: Label 'PURCHASE ORDER'; + PurchOrderDateCaptionLbl: Label 'Purchase Order Date:'; + PurchOrderNumCaptionLbl: Label 'Order No.'; + QtyToShipLbl: Label 'Qty to ship'; + QuantityBaseLbl: Label 'Quantity (Base)'; + QuantityLbl: Label 'Quantity'; + ReceivebyCaptionLbl: Label 'Receive By'; + RemainingQuantityLbl: Label 'Remaining Qty'; + RequestedReceiptDateLbl: Label 'Requested Receipt Date'; + ShipmentMethodDescCaptionLbl: Label 'Shipment Method'; + ShiptoAddressCaptionLbl: Label 'Ship-to Address'; + StartingDateLbl: Label 'Starting Date'; + SubcontractorDispatchListLbl: Label 'Subcontractor Dispatch List'; + SubcontractorLbl: Label 'Subcontractor'; + SubcOrdNoLbl: Label 'Subc. Ord. No.'; + SubtotalCaptionLbl: Label 'Subtotal'; + TaxIdentTypeCaptionLbl: Label 'Tax Ident. Type'; + ToCaptionLbl: Label 'To:'; + TotalCaptionLbl: Label 'Total'; + TotalPriceCaptionLbl: Label 'Total Price'; + UnitPriceLbl: Label 'Unit Price (LCY)'; + UoMLbl: Label 'UoM'; + VALVATBaseLCYCaptionLbl: Label 'VAT Base'; + VATAmountSpecificationLbl: Label 'VAT Amount Specification in '; + VATAmtLineInvDiscBaseAmtCaptionLbl: Label 'Invoice Discount Base Amount'; + VATAmtLineLineAmtCaptionLbl: Label 'Line Amount'; + VATAmtLineVATAmtCaptionLbl: Label 'VAT Amount'; + VATAmtLineVATCaptionLbl: Label 'VAT %'; + VATAmtSpecCaptionLbl: Label 'VAT Amount Specification'; + VATDiscountAmountCaptionLbl: Label 'Payment Discount on VAT'; + VATIdentifierCaptionLbl: Label 'VAT Identifier'; + VendNoCaptionLbl: Label 'Vendor No.'; + VendorIDCaptionLbl: Label 'Vendor ID'; + VendorInvoiceNoLbl: Label 'Vendor Invoice No.'; + VendorOrderNoLbl: Label 'Vendor Order No.'; + LineDiscountPctPlaceholderLbl: Label '%1%', Locked = true; + InvDiscAmtCapLbl: Label 'Invoice Discount Amount %1', Comment = '%1=Currency Code'; + TotalTxt: Label 'Net Amount %1', Comment = '%1=Currency Code'; + CustomGiroLbl, CustomGiroTxt, LegalOfficeLbl, LegalOfficeTxt : Text; + FormattedDirectUnitCost: Text; + FormattedLineAmount: Text; + FormattedQuanitity: Text; + FormattedVATPct: Text; + AddrInfoLine: Text; + CompanyInfoBankNameLblFooter, CompanyInfoIBANLblFooter, CompanyInfoSWIFTLblFooter : Text; + CompanyInfoEMailAddressLblFooter, CompanyInfoFaxNoLblFooter, CompanyInfoHomepageLblFooter, CompanyInfoPhoneNoLblFooter : Text; + CompanyVATRegNoFooter, CompanyVATRegNoLblFooter, SellToCustomerNoCaption, SellToCustomerNoShipToAddr, ShipToAddressCaption : Text; + CourtLocationLblFooter, ExecutiveDirectorsLblFooter, RegisterCourtLblFooter : Text; + DecimalAmountFormatExpression: Text; + FooterMark: Text; + HeaderDateFormatExpression: Text; + HeaderMark: Text; + InvDiscAmount: Text; + LineAmount, PosNoText, UnitCost : Text; + LineDateFormatExpression: Text; + LineDiscountPctText: Text; + LineMark: Text; + PaymentTermsDescriptionTxt: Text; + PriceUnit: Text; + PricingUoMCode: Text; + Seperator2Lbl, Seperator3Lbl, SeperatorLbl : Text; + ShptMethodDescTxt: Text; + TotalAmountIncludingVATTxt: Text; + ItemNo: Text; + CompanyInfoSWIFTFooter: Text[20]; + AllowInvDisctxt: Text[30]; + CompanyInfoCourtLocationFooter, CompanyInfoFaxNoFooter, CompanyInfoPhoneNoFooter, CompanyInfoRegisterCourtNoFooter : Text[30]; + HeaderPhoneNo: Text[30]; + + CompanyInfoIBANFooter: Text[50]; + InvDiscAmtCaptionLbl: Text[50]; + SubTotalExclVATText, SubTotalInclVATText, SubTotalText : Text[50]; + PurchaserText: Text[50]; + TotalExclVATText: Text[50]; + TotalInclVATText: Text[50]; + TotalText: Text[50]; + VALExchRate: Text[50]; + CompanyInfoEmailFooter: Text[80]; + CompanyInfoExecutiveDirector1Footer, CompanyInfoExecutiveDirector2Footer, CompanyInfoExecutiveDirector3Footer, CompanyInfoExecutiveDirector4Footer : Text[80]; + ReferenceText: Text[80]; + VALSpecLCYHeader: Text[80]; + VATNoText: Text[80]; + BuyFromAddr: array[8] of Text[100]; + CompanyAddr: array[8] of Text[100]; + CompanyAddress1Footer, CompanyAddress2Footer, CompanyAddress3Footer, CompanyAddress4Footer : Text[100]; + CompanyInfoBankNameFooter: Text[100]; + ShipToAddr: array[8] of Text[100]; + VendAddr: array[8] of Text[100]; + DimText: Text[120]; + CompanyInfoHomepageFooter: Text[255]; + + procedure InitializeRequest(LogInteractionParam: Boolean) + begin + ShouldLogInteraction := LogInteractionParam; + end; + + local procedure IsReportInPreviewMode(): Boolean + var + MailManagement: Codeunit "Mail Management"; + begin + exit(CurrReport.Preview or MailManagement.IsHandlingGetEmailBody()); + end; + + local procedure FormatAddressFields(var PurchaseHeader: Record "Purchase Header") + begin + FormatAddress.GetCompanyAddr(PurchaseHeader."Responsibility Center", ResponsibilityCenter, CompanyInformation, CompanyAddr); + FormatAddress.PurchHeaderBuyFrom(BuyFromAddr, PurchaseHeader); + if PurchaseHeader."Buy-from Vendor No." <> PurchaseHeader."Pay-to Vendor No." then + FormatAddress.PurchHeaderPayTo(VendAddr, PurchaseHeader); + FormatAddress.PurchHeaderShipTo(ShipToAddr, PurchaseHeader); + end; + + local procedure FormatDocumentFields(PurchaseHeader: Record "Purchase Header") + begin + FormatDocument.SetTotalLabels(PurchaseHeader."Currency Code", TotalText, TotalInclVATText, TotalExclVATText); + FormatDocument.SetPurchaser(SalespersonPurchaser, PurchaseHeader."Purchaser Code", PurchaserText); + FormatDocument.SetPaymentTerms(PaymentTerms, PurchaseHeader."Payment Terms Code", PurchaseHeader."Language Code"); + FormatDocument.SetPaymentTerms(PrepmtPaymentTerms, PurchaseHeader."Prepmt. Payment Terms Code", PurchaseHeader."Language Code"); + FormatDocument.SetShipmentMethod(ShipmentMethod, PurchaseHeader."Shipment Method Code", PurchaseHeader."Language Code"); + + ReferenceText := CopyStr(FormatDocument.SetText(PurchaseHeader."Your Reference" <> '', CopyStr(PurchaseHeader.FieldCaption("Your Reference"), 1, 80)), 1, MaxStrLen(ReferenceText)); + VATNoText := CopyStr(FormatDocument.SetText(PurchaseHeader."VAT Registration No." <> '', CopyStr(PurchaseHeader.FieldCaption("VAT Registration No."), 1, 80)), 1, MaxStrLen(VATNoText)); + end; + + local procedure InitLogInteraction() + begin + ShouldLogInteraction := SegManagement.FindInteractionTemplateCode("Interaction Log Entry Document Type"::"Purch. Ord.") <> ''; + end; + + local procedure BlankZero(PurchaseLine: Record "Purchase Line") + begin + if PurchaseLine."Line Discount %" = 0 then + LineDiscountPctText := '' + else + LineDiscountPctText := StrSubstNo(LineDiscountPctPlaceholderLbl, Round(PurchaseLine."Line Discount %", 0.1)); + + if PurchaseLine."Line Amount" = 0 then + LineAmount := '' + else + LineAmount := Format(PurchaseLine."Line Amount", 0, DecimalAmountFormatExpression); + + if PurchaseLine."Unit Cost" = 0 then + UnitCost := '' + else + UnitCost := FormattedDirectUnitCost; + end; + + local procedure FormatFooter() + begin + if PrintFooterLine then begin + CompanyAddress1Footer := CompanyAddr[1]; + CompanyAddress2Footer := CompanyAddr[2]; + CompanyAddress3Footer := CompanyAddr[3]; + CompanyAddress4Footer := CompanyAddr[4]; + + CompanyInfoPhoneNoLblFooter := CompanyInfoPhoneNoLbl; + CompanyInfoFaxNoLblFooter := CompanyInfoFaxLbl; + CompanyInfoEMailAddressLblFooter := EMailLbl; + CompanyInfoHomepageLblFooter := HomePageLbl; + CompanyVATRegNoLblFooter := CompanyInformation.GetVATRegistrationNumberLbl(); + + CompanyInfoPhoneNoFooter := CompanyInformation."Phone No."; + CompanyInfoFaxNoFooter := CompanyInformation."Fax No."; + CompanyInfoEmailFooter := CompanyInformation."E-Mail"; + CompanyVATRegNoFooter := CompanyInformation.GetVATRegistrationNumber(); + + CourtLocationLblFooter := CourtLocationLbl; + RegisterCourtLblFooter := RegisterCourtNoLbl; + + CompanyInfoBankNameLblFooter := CompanyInfoBankNameLbl; + CompanyInfoIBANLblFooter := CompanyInformation.FieldCaption(IBAN); + CompanyInfoSWIFTLblFooter := CompanyInformation.FieldCaption("SWIFT Code"); + + CompanyInfoBankNameFooter := CompanyInformation."Bank Name"; + CompanyInfoIBANFooter := CompanyInformation.IBAN; + CompanyInfoSWIFTFooter := CompanyInformation."SWIFT Code"; + end; + end; + + local procedure SetInvDisAmountLbl(CurrencyCode: Code[10]; var SubInvDiscAmtCaptionLbl: Text[50]) + var + GeneralLedgerSetup: Record "General Ledger Setup"; + begin + if CurrencyCode = '' then begin + GeneralLedgerSetup.Get(); + GeneralLedgerSetup.TestField("LCY Code"); + SubInvDiscAmtCaptionLbl := StrSubstNo(InvDiscAmtCapLbl, GeneralLedgerSetup."LCY Code"); + end else + SubInvDiscAmtCaptionLbl := StrSubstNo(InvDiscAmtCapLbl, CurrencyCode); + end; + + local procedure SetTotalLabels(CurrencyCode: Code[10]; var TotalAsText: Text[50]) + var + GeneralLedgerSetup: Record "General Ledger Setup"; + begin + if CurrencyCode = '' then begin + GeneralLedgerSetup.Get(); + GeneralLedgerSetup.TestField("LCY Code"); + TotalAsText := StrSubstNo(TotalTxt, GeneralLedgerSetup."LCY Code"); + end else + TotalAsText := StrSubstNo(TotalTxt, CurrencyCode); + end; + + local procedure SetLabels() + begin + if "Purchase Header"."Invoice Discount Value" = 0 then begin + InvDiscAmount := ''; + InvDiscAmtCaptionLbl := ''; + end else + InvDiscAmount := Format("Purchase Header"."Invoice Discount Value", 0, DecimalAmountFormatExpression); + + if ("Purchase Header"."Payment Terms Code" = '') or (not PrintPaymentTerms) then + PaymentTermsDescriptionTxt := '' + else + PaymentTermsDescriptionTxt := PaymentTermsDescriptionLbl; + + if "Purchase Header"."Shipment Method Code" = '' then + ShptMethodDescTxt := '' + else + ShptMethodDescTxt := ShptMethodDescLbl; + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcDispatchingList.docx b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcDispatchingList.docx new file mode 100644 index 0000000000..0d99e66bbb Binary files /dev/null and b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcDispatchingList.docx differ diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcFinishedProdOrder.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcFinishedProdOrder.PageExt.al new file mode 100644 index 0000000000..9305138f0c --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcFinishedProdOrder.PageExt.al @@ -0,0 +1,69 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Ledger; +using Microsoft.Manufacturing.Document; +using Microsoft.Purchases.Document; + +pageextension 99001548 "Subc. Finished Prod. Order" extends "Finished Production Order" +{ + actions + { + addafter("Registered Put-away Lines") + { + action("Subcontracting Purchase Lines") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Order Lines'; + Image = SubcontractingWorksheet; + RunObject = page "Purchase Lines"; + RunPageLink = "Document Type" = const(Order), "Prod. Order No." = field("No."); + ToolTip = 'Show purchase order lines for subcontracting.'; + } + } + addafter("&Warehouse Entries") + { + action("Subc. Transfer Orders") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Transfer Orders'; + Image = TransferOrder; + ToolTip = 'View the subcontracting transfer orders related to this production order.'; + + trigger OnAction() + var + SubcPurchFactboxMgmt: Codeunit "Subc. Purch. Factbox Mgmt."; + begin + SubcPurchFactboxMgmt.ShowTransferOrdersFromProductionOrder(Rec); + end; + } + action("Subc. Transfer Entries") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Transfer Entries'; + Image = ItemLedger; + RunObject = page "Item Ledger Entries"; + RunPageLink = "Entry Type" = const(Transfer), "Subc. Prod. Order No." = field("No."); + RunPageView = sorting("Order Type", "Order No."); + ToolTip = 'View the list of subcontracting transfers.'; + } + action("WIP Ledger Entries") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting WIP Entries'; + Image = LedgerEntries; + RunObject = page "Subc. WIP Ledger Entries"; + RunPageLink = "Prod. Order Status" = field(Status), "Prod. Order No." = field("No."); + ToolTip = 'View the Subcontracting WIP Entries for this production order.'; + } + } + addlast(Category_Entries) + { + actionref("Subc. Transfer Entries_Promoted"; "Subc. Transfer Entries") { } + actionref("WIP Ledger Entries_Promoted"; "WIP Ledger Entries") { } + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcFinishedProdOrders.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcFinishedProdOrders.PageExt.al new file mode 100644 index 0000000000..ff954e609e --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcFinishedProdOrders.PageExt.al @@ -0,0 +1,64 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Ledger; +using Microsoft.Manufacturing.Document; +using Microsoft.Purchases.Document; + +pageextension 99001543 "Subc. Finished Prod. Orders" extends "Finished Production Orders" +{ + actions + { + addafter("E&ntries") + { + action("Subcontracting Purchase Lines") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Order Lines'; + Image = SubcontractingWorksheet; + RunObject = page "Purchase Lines"; + RunPageLink = "Document Type" = const(Order), "Prod. Order No." = field("No."); + ToolTip = 'Show purchase order lines for subcontracting.'; + } + } + addafter("&Warehouse Entries") + { + action("Subc. Transfer Orders") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Transfer Orders'; + Image = TransferOrder; + ToolTip = 'View the subcontracting transfer orders related to this production order.'; + + trigger OnAction() + var + SubcPurchFactboxMgmt: Codeunit "Subc. Purch. Factbox Mgmt."; + begin + SubcPurchFactboxMgmt.ShowTransferOrdersFromProductionOrder(Rec); + end; + } + action("Subc. Transfer Entries") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Transfer Entries'; + Image = ItemLedger; + RunObject = page "Item Ledger Entries"; + RunPageLink = "Entry Type" = const(Transfer), "Subc. Prod. Order No." = field("No."); + RunPageView = sorting("Order Type", "Order No."); + ToolTip = 'View the list of subcontracting transfers.'; + } + action("WIP Ledger Entries") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting WIP Entries'; + Image = LedgerEntries; + RunObject = page "Subc. WIP Ledger Entries"; + RunPageLink = "Prod. Order Status" = field(Status), "Prod. Order No." = field("No."); + ToolTip = 'View the Subcontracting WIP Entries for this production order.'; + } + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcPlanningComp.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcPlanningComp.PageExt.al new file mode 100644 index 0000000000..0d33f17d31 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcPlanningComp.PageExt.al @@ -0,0 +1,21 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Planning; + +pageextension 99001511 "Subc. Planning Comp" extends "Planning Components" +{ + layout + { + addlast(Control1) + { + field("Component Supply Method"; Rec."Component Supply Method") + { + ApplicationArea = Subcontracting; + } + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcPlanningCompExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcPlanningCompExt.Codeunit.al new file mode 100644 index 0000000000..9a8f1e299b --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcPlanningCompExt.Codeunit.al @@ -0,0 +1,120 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Location; +using Microsoft.Inventory.Planning; +using Microsoft.Manufacturing.Document; +using Microsoft.Manufacturing.Routing; +using Microsoft.Purchases.Vendor; + +codeunit 99001522 "Subc. Planning Comp. Ext." +{ +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 + +#endif + [EventSubscriber(ObjectType::Table, Database::"Planning Component", OnAfterValidateEvent, "Routing Link Code", false, false)] + local procedure OnAfterValidateRoutingLinkCode(var Rec: Record "Planning Component"; var xRec: Record "Planning Component"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + HandleRoutingLinkCodeValidation(Rec, xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Planning Component", OnAfterTransferFromComponent, '', false, false)] + local procedure OnAfterTransferFromComponent(var PlanningComponent: Record "Planning Component"; var ProdOrderComp: Record "Prod. Order Component") + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + PlanningComponent."Component Supply Method" := ProdOrderComp."Component Supply Method"; + PlanningComponent."Orig. Location Code" := ProdOrderComp."Subc. Original Location Code"; + PlanningComponent."Orig. Bin Code" := ProdOrderComp."Subc. Orig. Bin Code"; + end; + + [EventSubscriber(ObjectType::Table, Database::"Planning Component", OnAfterValidateEvent, "Location Code", false, false)] + local procedure OnAfterValidateLocationCode(var Rec: Record "Planning Component"; var xRec: Record "Planning Component"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + if Rec."Location Code" <> xRec."Location Code" then + Rec."Orig. Location Code" := xRec."Location Code"; + end; + + [EventSubscriber(ObjectType::Table, Database::"Planning Component", OnAfterValidateEvent, "Bin Code", false, false)] + local procedure OnAfterValidateBinCode(var Rec: Record "Planning Component"; var xRec: Record "Planning Component"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + if Rec."Bin Code" <> xRec."Bin Code" then + Rec."Orig. Bin Code" := xRec."Bin Code"; + end; + + local procedure HandleRoutingLinkCodeValidation(var PlanningComponent: Record "Planning Component"; var xPlanningComponent: Record "Planning Component") + var + PlanningRoutingLine: Record "Planning Routing Line"; + StockkeepingUnit: Record "Stockkeeping Unit"; + Vendor: Record Vendor; + PlanningGetParameters: Codeunit "Planning-Get Parameters"; + SubcontractingManagement: Codeunit "Subcontracting Management"; + begin + if PlanningComponent."Component Supply Method" = PlanningComponent."Component Supply Method"::"Transfer to Vendor" then + exit; + + if PlanningComponent."Routing Link Code" <> '' then begin + PlanningRoutingLine.SetRange("Worksheet Template Name", PlanningComponent."Worksheet Template Name"); + PlanningRoutingLine.SetRange("Worksheet Batch Name", PlanningComponent."Worksheet Batch Name"); + PlanningRoutingLine.SetRange("Worksheet Line No.", PlanningComponent."Worksheet Line No."); + PlanningRoutingLine.SetRange("Routing Link Code", PlanningComponent."Routing Link Code"); + PlanningRoutingLine.SetRange(Type, PlanningRoutingLine.Type::"Work Center"); + PlanningRoutingLine.SetLoadFields("No."); + if PlanningRoutingLine.FindFirst() then + if SubcontractingManagement.GetSubcontractor(PlanningRoutingLine."No.", Vendor) then + SubcontractingManagement.ChangeLocationOnPlanningComponent(PlanningComponent, Vendor."Subc. Location Code", PlanningComponent."Orig. Location Code", PlanningComponent."Orig. Bin Code"); + end else + if xPlanningComponent."Routing Link Code" <> '' then + if PlanningComponent."Orig. Location Code" <> '' then begin + PlanningComponent.Validate("Location Code", PlanningComponent."Orig. Location Code"); + PlanningComponent."Orig. Location Code" := ''; + if PlanningComponent."Orig. Bin Code" <> '' then begin + PlanningComponent.Validate("Bin Code", PlanningComponent."Orig. Bin Code"); + PlanningComponent."Orig. Bin Code" := ''; + end; + end else begin + PlanningGetParameters.AtSKU( + StockkeepingUnit, + PlanningComponent."Item No.", + PlanningComponent."Variant Code", + PlanningComponent."Location Code"); + PlanningComponent.Validate(PlanningComponent."Location Code", StockkeepingUnit."Components at Location"); + end; + end; + +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcPlanningCompExt.TableExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcPlanningCompExt.TableExt.al new file mode 100644 index 0000000000..176bbf0b92 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcPlanningCompExt.TableExt.al @@ -0,0 +1,59 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Item; +using Microsoft.Inventory.Location; +using Microsoft.Inventory.Planning; +using Microsoft.Warehouse.Structure; + +tableextension 99001503 "Subc. Planning Comp Ext." extends "Planning Component" +{ + AllowInCustomizations = AsReadOnly; + fields + { + field(99001524; "Component Supply Method"; Enum "Component Supply Method") + { + Caption = 'Component Supply Method'; + DataClassification = CustomerContent; + ToolTip = 'Specifies how components are supplied to the subcontractor for the planning component. Vendor-supplied - components are provided by the subcontractor. Consignment at Vendor - components are owned by your company but stored at the subcontractor location. Transfer to Vendor - components are sent to the subcontractor through a transfer order.'; + trigger OnValidate() + var + Item: Record Item; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + SubcontractingManagement: Codeunit "Subcontracting Management"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if "Component Supply Method" = "Component Supply Method"::"Transfer to Vendor" then + if "Item No." <> '' then begin + Item.Get("Item No."); + Item.TestField(Type, Item.Type::Inventory); + end; + SubcontractingManagement.UpdateComponentSupplyMethodForPlanningComponent(Rec); + end; + } + field(99001525; "Orig. Location Code"; Code[10]) + { + Caption = 'Original Location Code'; + DataClassification = CustomerContent; + TableRelation = Location; + } + field(99001526; "Orig. Bin Code"; Code[20]) + { + Caption = 'Original Bin Code'; + DataClassification = CustomerContent; + TableRelation = Bin; + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcPlanningLineMgmtExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcPlanningLineMgmtExt.Codeunit.al new file mode 100644 index 0000000000..7b8f8a706f --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcPlanningLineMgmtExt.Codeunit.al @@ -0,0 +1,91 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Item; +using Microsoft.Inventory.Planning; +using Microsoft.Inventory.Requisition; +using Microsoft.Inventory.Transfer; +using Microsoft.Manufacturing.Document; +using Microsoft.Manufacturing.ProductionBOM; +using Microsoft.Manufacturing.Routing; + +codeunit 99001518 "Subc. Planning Line Mgmt Ext." +{ +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif +#if not CLEAN27 +#pragma warning disable AL0432 + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Planning Line Management", OnAfterTransferRtngLine, '', false, false)] +#pragma warning restore AL0432 +#else + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Mfg. Planning Line Management", OnAfterTransferRtngLine, '', false, false)] +#endif + local procedure OnAfterTransferRtngLine(var ReqLine: Record "Requisition Line"; var RoutingLine: Record "Routing Line"; var PlanningRoutingLine: Record "Planning Routing Line") + var + SubcPriceManagement: Codeunit "Subc. Price Management"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + SubcPriceManagement.ApplySubcontractorPricingToPlanningRouting(ReqLine, RoutingLine, PlanningRoutingLine); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Mfg. Planning Line Management", OnCreatePlanningComponentFromProdBOMOnBeforeGetPlanningParameters, '', false, false)] + local procedure TransferComponentSupplyMethod_OnCreatePlanningComponentFromProdBOMOnBeforeGetPlanningParameters(var PlanningComponent: Record "Planning Component"; ProductionBOMLine: Record "Production BOM Line") + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + PlanningComponent."Component Supply Method" := ProductionBOMLine."Component Supply Method"; + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Mfg. Planning Line Management", OnTransferBOMOnBeforeUpdatePlanningComp, '', false, false)] + local procedure IgnorePurchaseComponentsFromSubcontracting_OnTransferBOMOnBeforeUpdatePlanningComp(var ProductionBOMLine: Record "Production BOM Line"; var UpdateCondition: Boolean; var IsHandled: Boolean; var ReqQty: Decimal) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if ProductionBOMLine."Component Supply Method" = "Component Supply Method"::"Vendor-Supplied" then + IsHandled := true; + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Component", OnAfterFilterLinesWithItemToPlan, '', false, false)] + local procedure ProdOrderComponent_OnAfterFilterLinesWithItemToPlan(var ProdOrderComponent: Record "Prod. Order Component"; var Item: Record Item; IncludeFirmPlanned: Boolean) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + ProdOrderComponent.SetFilter("Component Supply Method", '<>%1', "Component Supply Method"::"Vendor-Supplied"); + end; + + [EventSubscriber(ObjectType::Table, Database::"Transfer Line", OnAfterFilterLinesWithItemToPlan, '', false, false)] + local procedure TransferLine_OnAfterFilterLinesWithItemToPlan(var Sender: Record "Transfer Line"; var Item: Record Item; IsReceipt: Boolean; IsSupplyForPlanning: Boolean; var TransferLine: Record "Transfer Line") + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + TransferLine.SetRange("Transfer WIP Item", false); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdBOMLineExt.TableExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdBOMLineExt.TableExt.al new file mode 100644 index 0000000000..2a543c74c3 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdBOMLineExt.TableExt.al @@ -0,0 +1,43 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Item; +using Microsoft.Manufacturing.ProductionBOM; + +tableextension 99001531 "Subc. Prod BOM Line Ext." extends "Production BOM Line" +{ + AllowInCustomizations = AsReadOnly; + fields + { + field(99001522; "Component Supply Method"; Enum "Component Supply Method") + { + Caption = 'Component Supply Method'; + DataClassification = CustomerContent; + ToolTip = 'Specifies how components are supplied to the subcontractor for the production BOM line. Vendor-supplied - components are provided by the subcontractor. Consignment at Vendor - components are owned by your company but stored at the subcontractor location. Transfer to Vendor - components are sent to the subcontractor through a transfer order.'; + trigger OnValidate() + var + Item: Record Item; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if "Component Supply Method" = "Component Supply Method"::"Transfer to Vendor" then + if (Type = Type::Item) and ("No." <> '') then begin + Item.Get("No."); + Item.TestField(Type, Item.Type::Inventory); + end; + end; + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdBOMLines.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdBOMLines.PageExt.al new file mode 100644 index 0000000000..bca0cf31e7 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdBOMLines.PageExt.al @@ -0,0 +1,21 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.ProductionBOM; + +pageextension 99001510 "Subc. Prod BOM Lines" extends "Production BOM Lines" +{ + layout + { + addlast(Control1) + { + field("Component Supply Method"; Rec."Component Supply Method") + { + ApplicationArea = Subcontracting; + } + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdBOMVersionLines.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdBOMVersionLines.PageExt.al new file mode 100644 index 0000000000..ae14805545 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdBOMVersionLines.PageExt.al @@ -0,0 +1,22 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.ProductionBOM; + +pageextension 99001514 "Subc. ProdBOMVersionLines" extends "Production BOM Version Lines" +{ + layout + { + addlast(Control1) + { + field("Component Supply Method"; Rec."Component Supply Method") + { + ApplicationArea = Subcontracting; + ToolTip = 'Specifies how components are supplied to the subcontractor for the production BOM line.'; + } + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOFactboxMgmt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOFactboxMgmt.Codeunit.al new file mode 100644 index 0000000000..d081e2e9b8 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOFactboxMgmt.Codeunit.al @@ -0,0 +1,295 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Ledger; +using Microsoft.Inventory.Transfer; +using Microsoft.Manufacturing.Document; +using Microsoft.Purchases.Document; +using Microsoft.Purchases.History; +using Microsoft.Utilities; +using System.Reflection; + +codeunit 99001559 "Subc. ProdO. Factbox Mgmt." +{ +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 + +#endif + /// + /// Opens the appropriate Production Order page (Released or Finished) for the production order linked to the given variant record. + /// + /// A record variant of a purchase or transfer document line. + procedure ShowProductionOrder(RecRelatedVariant: Variant) + var + ProductionOrder: Record "Production Order"; + FinishedProductionOrder: Page "Finished Production Order"; + ReleasedProductionOrder: Page "Released Production Order"; + OperationNo: Code[10]; + ProdOrderNo: Code[20]; + RoutingNo: Code[20]; + ProdOrderLineNo: Integer; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if not SetProdOrderInformationByVariant(RecRelatedVariant, ProdOrderNo, ProdOrderLineNo, RoutingNo, OperationNo) then + exit; + ProductionOrder.SetFilter(Status, '>=%1', ProductionOrder.Status::Released); + ProductionOrder.SetRange("No.", ProdOrderNo); + if not ProductionOrder.FindFirst() then + exit; + case ProductionOrder.Status of + ProductionOrder.Status::Released: + begin + ProductionOrder.SetRange(Status, ProductionOrder.Status::Released); + ReleasedProductionOrder.SetTableView(ProductionOrder); + ReleasedProductionOrder.Editable := false; + ReleasedProductionOrder.Run(); + end; + ProductionOrder.Status::Finished: + begin + ProductionOrder.SetRange(Status, ProductionOrder.Status::Finished); + FinishedProductionOrder.SetTableView(ProductionOrder); + FinishedProductionOrder.Editable := false; + FinishedProductionOrder.Run(); + end; + end; + end; + + /// + /// Opens the Production Order Routing page for the routing line linked to the given variant record. + /// + /// A record variant of a purchase or transfer document line. + procedure ShowProductionOrderRouting(RecRelatedVariant: Variant) + var + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + ProdOrderRouting: Page "Prod. Order Routing"; + OperationNo: Code[10]; + ProdOrderNo: Code[20]; + RoutingNo: Code[20]; + ProdOrderLineNo: Integer; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if not SetProdOrderInformationByVariant(RecRelatedVariant, ProdOrderNo, ProdOrderLineNo, RoutingNo, OperationNo) then + exit; + SetFilterProductionOrderRouting(ProdOrderRoutingLine, ProdOrderNo, ProdOrderLineNo, RoutingNo, OperationNo); + ProdOrderRoutingLine.FindFirst(); + ProdOrderRouting.SetTableView(ProdOrderRoutingLine); + ProdOrderRouting.Editable := false; + ProdOrderRouting.Run(); + end; + + /// + /// Returns the number of production order routing lines linked to the given variant record. + /// + /// A record variant of a purchase or transfer document line. + /// The count of matching production order routing lines, or 0 if no production order is found. + procedure CalcNoOfProductionOrderRoutings(RecRelatedVariant: Variant): Integer + var + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + OperationNo: Code[10]; + ProdOrderNo: Code[20]; + RoutingNo: Code[20]; + ProdOrderLineNo: Integer; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(0); + +#endif + if not SetProdOrderInformationByVariant(RecRelatedVariant, ProdOrderNo, ProdOrderLineNo, RoutingNo, OperationNo) then + exit; + SetFilterProductionOrderRouting(ProdOrderRoutingLine, ProdOrderNo, ProdOrderLineNo, RoutingNo, OperationNo); + exit(ProdOrderRoutingLine.Count()); + end; + + local procedure SetFilterProductionOrderRouting(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; ProdOrderNo: Code[20]; ProdOrderLineNo: Integer; RoutingNo: Code[20]; OperationNo: Code[10]) + begin + ProdOrderRoutingLine.SetFilter(Status, '>=%1', ProdOrderRoutingLine.Status::Released); + ProdOrderRoutingLine.SetRange("Prod. Order No.", ProdOrderNo); + ProdOrderRoutingLine.SetRange("Routing Reference No.", ProdOrderLineNo); + ProdOrderRoutingLine.SetRange("Routing No.", RoutingNo); + ProdOrderRoutingLine.SetRange("Operation No.", OperationNo); + end; + + /// + /// Opens the Production Order Components page filtered to the production order linked to the given variant record. + /// + /// A record variant of a purchase or transfer document line. + procedure ShowProductionOrderComponents(RecRelatedVariant: Variant) + var + ProdOrderComponent: Record "Prod. Order Component"; + PageManagement: Codeunit "Page Management"; + OperationNo: Code[10]; + ProdOrderNo: Code[20]; + RoutingNo: Code[20]; + ProdOrderLineNo: Integer; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if not SetProdOrderInformationByVariant(RecRelatedVariant, ProdOrderNo, ProdOrderLineNo, RoutingNo, OperationNo) then + exit; + SetFilterProductionOrderComponents(ProdOrderComponent, ProdOrderNo, ProdOrderLineNo, RoutingNo, OperationNo); + PageManagement.PageRun(ProdOrderComponent); + end; + + /// + /// Returns the number of production order components linked to the given variant record. + /// + /// A record variant of a purchase or transfer document line. + /// The count of matching production order components, or 0 if no production order is found. + procedure CalcNoOfProductionOrderComponents(RecRelatedVariant: Variant): Integer + var + ProdOrderComponent: Record "Prod. Order Component"; + OperationNo: Code[10]; + ProdOrderNo: Code[20]; + RoutingNo: Code[20]; + ProdOrderLineNo: Integer; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(0); + +#endif + if not SetProdOrderInformationByVariant(RecRelatedVariant, ProdOrderNo, ProdOrderLineNo, RoutingNo, OperationNo) then + exit(0); + + SetFilterProductionOrderComponents(ProdOrderComponent, ProdOrderNo, ProdOrderLineNo, RoutingNo, OperationNo); + exit(ProdOrderComponent.Count()); + end; + + local procedure SetFilterProductionOrderComponents(var ProdOrderComponent: Record "Prod. Order Component"; ProdOrderNo: Code[20]; ProdOrderLineNo: Integer; RoutingNo: Code[20]; OperationNo: Code[10]) + var + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + begin + ProdOrderRoutingLine.SetLoadFields("Routing Link Code"); + ProdOrderRoutingLine.SetFilter(Status, '>=%1', ProdOrderRoutingLine.Status::Released); + ProdOrderRoutingLine.SetRange("Prod. Order No.", ProdOrderNo); + ProdOrderRoutingLine.SetRange("Routing Reference No.", ProdOrderLineNo); + ProdOrderRoutingLine.SetRange("Routing No.", RoutingNo); + ProdOrderRoutingLine.SetRange("Operation No.", OperationNo); + if ProdOrderRoutingLine.FindFirst() then + ProdOrderComponent.SetRange("Routing Link Code", ProdOrderRoutingLine."Routing Link Code"); + + ProdOrderComponent.SetFilter(Status, '>=%1', ProdOrderComponent.Status::Released); + ProdOrderComponent.SetRange("Prod. Order No.", ProdOrderNo); + ProdOrderComponent.SetRange("Prod. Order Line No.", ProdOrderLineNo); + end; + + local procedure SetProdOrderInformationByVariant(RecRelatedVariant: Variant; var ProdOrderNo: Code[20]; var ProdOrderLineNo: Integer; var RoutingNo: Code[20]; var OperationNo: Code[10]): Boolean + var + ItemLedgerEntry: Record "Item Ledger Entry"; + PurchaseLine: Record "Purchase Line"; + PurchInvLine: Record "Purch. Inv. Line"; + PurchRcptLine: Record "Purch. Rcpt. Line"; + TransferLine: Record "Transfer Line"; + TransferReceiptLine: Record "Transfer Receipt Line"; + TransferShipmentLine: Record "Transfer Shipment Line"; + DataTypeManagement: Codeunit "Data Type Management"; + ResultRecordRef: RecordRef; + RecId: RecordId; + begin + if not RecRelatedVariant.IsRecord() then + exit(false); + + DataTypeManagement.GetRecordRef(RecRelatedVariant, ResultRecordRef); + + RecId := ResultRecordRef.RecordId(); + + if RecId.TableNo() = 0 then + exit(false); + + case RecId.TableNo() of + Database::"Purchase Line": + begin + ResultRecordRef.SetTable(PurchaseLine); + ProdOrderNo := PurchaseLine."Prod. Order No."; + ProdOrderLineNo := PurchaseLine."Prod. Order Line No."; + RoutingNo := PurchaseLine."Routing No."; + OperationNo := PurchaseLine."Operation No."; + end; + Database::"Purch. Rcpt. Line": + begin + ResultRecordRef.SetTable(PurchRcptLine); + ProdOrderNo := PurchRcptLine."Prod. Order No."; + ProdOrderLineNo := PurchRcptLine."Prod. Order Line No."; + RoutingNo := PurchRcptLine."Routing No."; + OperationNo := PurchRcptLine."Operation No."; + end; + Database::"Purch. Inv. Line": + begin + ResultRecordRef.SetTable(PurchInvLine); + ProdOrderNo := PurchInvLine."Prod. Order No."; + ProdOrderLineNo := PurchInvLine."Prod. Order Line No."; + RoutingNo := PurchInvLine."Routing No."; + OperationNo := PurchInvLine."Operation No."; + end; + Database::"Transfer Line": + begin + ResultRecordRef.SetTable(TransferLine); + ProdOrderNo := TransferLine."Subc. Prod. Order No."; + ProdOrderLineNo := TransferLine."Subc. Prod. Order Line No."; + RoutingNo := TransferLine."Subc. Routing No."; + OperationNo := TransferLine."Subc. Operation No."; + end; + Database::"Transfer Shipment Line": + begin + ResultRecordRef.SetTable(TransferShipmentLine); + ProdOrderNo := TransferShipmentLine."Subc. Prod. Order No."; + ProdOrderLineNo := TransferShipmentLine."Subc. Prod. Order Line No."; + RoutingNo := TransferShipmentLine."Subc. Routing No."; + OperationNo := TransferShipmentLine."Subc. Operation No."; + end; + Database::"Transfer Receipt Line": + begin + ResultRecordRef.SetTable(TransferReceiptLine); + ProdOrderNo := TransferReceiptLine."Subc. Prod. Order No."; + ProdOrderLineNo := TransferReceiptLine."Subc. Prod. Order Line No."; + RoutingNo := TransferReceiptLine."Subc. Routing No."; + OperationNo := TransferReceiptLine."Subc. Operation No."; + end; + Database::"Item Ledger Entry": + begin + ResultRecordRef.SetTable(ItemLedgerEntry); + ProdOrderNo := ItemLedgerEntry."Order No."; + ProdOrderLineNo := ItemLedgerEntry."Order Line No."; + OperationNo := ItemLedgerEntry."Subc. Operation No."; + RoutingNo := GetRoutingNoFromProdOrderRoutingLine(ProdOrderNo, ProdOrderLineNo, OperationNo); + end; + end; + exit((ProdOrderNo <> '') and (ProdOrderLineNo <> 0)); + end; + + local procedure GetRoutingNoFromProdOrderRoutingLine(ProdOrderNo: Code[20]; ProdOrderLineNo: Integer; OperationNo: Code[10]): Code[20] + var + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + begin + ProdOrderRoutingLine.SetRange("Prod. Order No.", ProdOrderNo); + ProdOrderRoutingLine.SetRange("Routing Reference No.", ProdOrderLineNo); + ProdOrderRoutingLine.SetRange("Operation No.", OperationNo); + if ProdOrderRoutingLine.FindFirst() then + exit(ProdOrderRoutingLine."Routing No."); + end; +} diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrdCompRes.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrdCompRes.Codeunit.al new file mode 100644 index 0000000000..8d3269e9e2 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrdCompRes.Codeunit.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Document; + +codeunit 99001530 "Subc. Prod. Ord. Comp. Res." +{ + EventSubscriberInstance = Manual; + + /// + /// When a transfer is created, the storage location in the production component is swapped and thus triggers the verification.\ + /// The verification attempts to perform an auto tracking if the order tracking policy of the item is not equal to None, but this is not possible.\ + /// Therefore the verification is overwritten and set to false. + /// + /// + /// + /// + /// + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Prod. Order Comp.-Reserve", OnVerifyChangeOnBeforeHasError, '', false, false)] + local procedure "Prod. Order Comp.-Reserve_OnVerifyChangeOnBeforeHasError"(NewProdOrderComp: Record "Prod. Order Component"; OldProdOrderComp: Record "Prod. Order Component"; var HasError: Boolean; var ShowError: Boolean) +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + HasError := false; + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderComp.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderComp.PageExt.al new file mode 100644 index 0000000000..bcecc24cef --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderComp.PageExt.al @@ -0,0 +1,38 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Document; + +pageextension 99001512 "Subc. Prod Order Comp" extends "Prod. Order Components" +{ + layout + { + addafter("Remaining Quantity") + { + field("Subc. Qty.on TransOrder (Base)"; Rec."Subc. Qty.on TransOrder (Base)") + { + ApplicationArea = Subcontracting; + } + field("Subc. Qty. in Transit (Base)"; Rec."Subc. Qty. in Transit (Base)") + { + ApplicationArea = Subcontracting; + Visible = false; + } + field("Subc. Qty. transf. to Subcontractor"; Rec."Subc. Qty. transf. to Subcontr") + { + ApplicationArea = Subcontracting; + } + } + addlast(Control1) + { + field("Component Supply Method"; Rec."Component Supply Method") + { + ApplicationArea = Subcontracting; + ToolTip = 'Specifies how components are supplied to the subcontractor for the production component.'; + } + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderCompExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderCompExt.Codeunit.al new file mode 100644 index 0000000000..858cbba555 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderCompExt.Codeunit.al @@ -0,0 +1,549 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Location; +using Microsoft.Inventory.Planning; +using Microsoft.Inventory.Tracking; +using Microsoft.Inventory.Transfer; +using Microsoft.Manufacturing.Document; +using Microsoft.Purchases.Document; +using Microsoft.Purchases.Vendor; +using System.Utilities; + +codeunit 99001524 "Subc. Prod. Order Comp. Ext." +{ + var +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + ExistingPostedTransferLineQst: Label 'The component has already been assigned to the posted subcontracting transfer order %1.\\Do you want to continue?', Comment = '%1=Transfer Order No'; + ExistingPurchLineErr: Label 'You cannot change this field because the component is already assigned to subcontracting purchase order %1.\\Updating the quantity is only allowed through the purchase order.', Comment = '%1=Document No'; + LocationCodeChangeNotAllowedErr: Label 'The component has already been assigned to the subcontracting transfer order %1.\\The location code may only be updated via the purchase order and processing of the stock transfer.', Comment = '%1=Transfer Order No'; + ExistingTransferLineErr: Label 'You cannot open Tracking Specification because this component is already specified in Transfer Order %1.', Comment = '%1=Document No.'; + CannotModifyCompTransferExistsErr: Label 'You cannot change this component because transfer orders exist for the linked production order %1, purchase order %2.', Comment = '%1=Production Order No., %2=Purchase Order No.'; + CannotModifyCompStockAtSubcErr: Label 'You cannot change this component because there are remaining components or WIP items transferred to the subcontractor for production order %1, purchase order %2.', Comment = '%1=Production Order No., %2=Purchase Order No.'; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Prod. Order Comp.-Reserve", OnAfterInitFromProdOrderComp, '', false, false)] + local procedure OnAfterInitFromProdOrderComp(ProdOrderComponent: Record "Prod. Order Component") + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + ValidateSubcontractingReservationConstraints(ProdOrderComponent); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Component", OnAfterValidateEvent, "Bin Code", false, false)] + local procedure OnAfterValidateBinCode(var Rec: Record "Prod. Order Component"; var xRec: Record "Prod. Order Component"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + SetOriginalBinCode(Rec, xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Component", OnAfterValidateEvent, "Location Code", false, false)] + local procedure OnAfterValidateLocationCode(var Rec: Record "Prod. Order Component"; var xRec: Record "Prod. Order Component"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + SetOriginalLocationCode(Rec, xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Component", OnAfterValidateEvent, "Routing Link Code", false, false)] + local procedure OnAfterValidateRoutingLinkCode(var Rec: Record "Prod. Order Component"; var xRec: Record "Prod. Order Component"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + HandleRoutingLinkCodeValidation(Rec, xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Component", OnBeforeValidateEvent, "Location Code", false, false)] + local procedure OnBeforeValidateLocationCode(var Rec: Record "Prod. Order Component"; var xRec: Record "Prod. Order Component"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + CheckExistingSubcontractingTransferOrder(Rec, xRec, CurrFieldNo); + + if CurrFieldNo <> 0 then + if Rec."Location Code" <> xRec."Location Code" then + if xRec."Component Supply Method" = Rec."Component Supply Method"::"Transfer to Vendor" then + CheckUncompletedSubcontractingDocumentsExist(xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Component", OnBeforeValidateEvent, "Bin Code", false, false)] + local procedure OnBeforeValidateBinCode(var Rec: Record "Prod. Order Component"; var xRec: Record "Prod. Order Component"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + + if CurrFieldNo <> 0 then + if Rec."Bin Code" <> xRec."Bin Code" then + if xRec."Component Supply Method" = Rec."Component Supply Method"::"Transfer to Vendor" then + CheckUncompletedSubcontractingDocumentsExist(xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Component", OnBeforeValidateEvent, "Item No.", false, false)] + local procedure OnBeforeValidateItemNo(var Rec: Record "Prod. Order Component"; var xRec: Record "Prod. Order Component"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + + if CurrFieldNo <> 0 then + if Rec."Item No." <> xRec."Item No." then + if xRec."Component Supply Method" = Rec."Component Supply Method"::"Transfer to Vendor" then + CheckUncompletedSubcontractingDocumentsExist(xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Component", OnBeforeValidateEvent, "Variant Code", false, false)] + local procedure OnBeforeValidateVariantCode(var Rec: Record "Prod. Order Component"; var xRec: Record "Prod. Order Component"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + + if CurrFieldNo <> 0 then + if Rec."Variant Code" <> xRec."Variant Code" then + if xRec."Component Supply Method" = Rec."Component Supply Method"::"Transfer to Vendor" then + CheckUncompletedSubcontractingDocumentsExist(xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Component", OnBeforeValidateEvent, "Quantity per", false, false)] + local procedure OnBeforeValidateQuantityPer(var Rec: Record "Prod. Order Component"; var xRec: Record "Prod. Order Component"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + CheckExistingDocumentsForSubcontracting(Rec, xRec, CurrFieldNo); + + if CurrFieldNo <> 0 then + if Rec."Quantity per" <> xRec."Quantity per" then + if xRec."Component Supply Method" = Rec."Component Supply Method"::"Transfer to Vendor" then + CheckUncompletedSubcontractingDocumentsExist(xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Component", OnBeforeValidateEvent, "Expected Quantity", false, false)] + local procedure OnBeforeValidateExpectedQuantity(var Rec: Record "Prod. Order Component"; var xRec: Record "Prod. Order Component"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + + if CurrFieldNo <> 0 then + if Rec."Expected Quantity" <> xRec."Expected Quantity" then + if xRec."Component Supply Method" = Rec."Component Supply Method"::"Transfer to Vendor" then + CheckUncompletedSubcontractingDocumentsExist(xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Component", OnBeforeValidateEvent, "Component Supply Method", false, false)] + local procedure OnBeforeValidateComponentSupplyMethod(var Rec: Record "Prod. Order Component"; var xRec: Record "Prod. Order Component"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + + if CurrFieldNo <> 0 then + if Rec."Component Supply Method" <> xRec."Component Supply Method" then + if xRec."Component Supply Method" = Rec."Component Supply Method"::"Transfer to Vendor" then + CheckUncompletedSubcontractingDocumentsExist(xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Component", OnBeforeDeleteEvent, '', false, false)] + local procedure OnBeforeDeleteProdOrderComponent(var Rec: Record "Prod. Order Component"; RunTrigger: Boolean) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + if not RunTrigger then + exit; + + if Rec."Component Supply Method" = Rec."Component Supply Method"::"Transfer to Vendor" then + CheckUncompletedSubcontractingDocumentsExist(Rec); + end; + + local procedure CheckExistingPostedSubcontractingTransferOrder(ProdOrderComponent: Record "Prod. Order Component"): Boolean + var + TransferShipmentLine: Record "Transfer Shipment Line"; + ConfirmManagement: Codeunit "Confirm Management"; + begin + if ProdOrderComponent."Component Supply Method" <> "Component Supply Method"::"Transfer to Vendor" then + exit; + + TransferShipmentLine.SetRange("Subc. Prod. Order No.", ProdOrderComponent."Prod. Order No."); + TransferShipmentLine.SetRange("Subc. Prod. Order Line No.", ProdOrderComponent."Prod. Order Line No."); + TransferShipmentLine.SetRange("Subc. Prod. Ord. Comp Line No.", ProdOrderComponent."Line No."); + TransferShipmentLine.SetRange("Item No.", ProdOrderComponent."Item No."); + TransferShipmentLine.SetLoadFields(SystemId); + if not TransferShipmentLine.IsEmpty() then begin + TransferShipmentLine.FindFirst(); + if not ConfirmManagement.GetResponse(StrSubstNo(ExistingPostedTransferLineQst, TransferShipmentLine."Document No.")) then + Error(''); + end; + end; + + local procedure CheckExistingReservationOnTransferLine(ProdOrderComponent: Record "Prod. Order Component"; TransferLine: Record "Transfer Line") Result: Boolean + var + ReservationEntry: Record "Reservation Entry"; + begin + ReservationEntry.SetCurrentKey("Source Type", "Source Subtype", "Source ID", "Source Ref. No.", "Reservation Status"); + ReservationEntry.SetRange("Source Type", Database::"Transfer Line"); + ReservationEntry.SetRange("Source ID", TransferLine."Document No."); + ReservationEntry.SetRange("Source Ref. No.", TransferLine."Line No."); + ReservationEntry.SetRange("Item No.", ProdOrderComponent."Item No."); + ReservationEntry.SetRange("Variant Code", ProdOrderComponent."Variant Code"); + + Result := not ReservationEntry.IsEmpty(); + exit(Result); + end; + + local procedure CheckExistingSubcontractingPurchaseOrder(ProdOrderComponent: Record "Prod. Order Component"): Boolean + var + PurchaseLine: Record "Purchase Line"; + TempPurchaseLine: Record "Purchase Line" temporary; + begin + if ProdOrderComponent."Component Supply Method" <> ProdOrderComponent."Component Supply Method"::"Vendor-Supplied" then + exit; + + PurchaseLine.SetCurrentKey("Prod. Order No.", "Prod. Order Line No.", "Routing No.", "Operation No."); + PurchaseLine.SetRange("Prod. Order No.", ProdOrderComponent."Prod. Order No."); + PurchaseLine.SetRange("Prod. Order Line No.", ProdOrderComponent."Prod. Order Line No."); + PurchaseLine.SetLoadFields("Document Type", "Document No.", "Line No."); + if PurchaseLine.FindSet() then + repeat + TempPurchaseLine.Init(); + TempPurchaseLine."Document Type" := PurchaseLine."Document Type"; + TempPurchaseLine."Document No." := PurchaseLine."Document No."; + TempPurchaseLine."Line No." := PurchaseLine."Line No."; + TempPurchaseLine.Insert(); + until PurchaseLine.Next() = 0; + + if TempPurchaseLine.FindSet() then + repeat + PurchaseLine.Reset(); + PurchaseLine.SetRange("Document Type", TempPurchaseLine."Document Type"); + PurchaseLine.SetRange("Document No.", TempPurchaseLine."Document No."); + PurchaseLine.SetRange(Type, "Purchase Line Type"::Item); + PurchaseLine.SetRange("No.", ProdOrderComponent."Item No."); + PurchaseLine.SetRange("Prod. Order No.", ''); + PurchaseLine.SetLoadFields("Document No."); + if PurchaseLine.FindFirst() then + Error(ExistingPurchLineErr, PurchaseLine."Document No."); + until TempPurchaseLine.Next() = 0; + end; + + local procedure CheckExistingSubcontractingTransferOrder(var ProdOrderComponent: Record "Prod. Order Component"; var xProdOrderComponent: Record "Prod. Order Component"; CurrFieldNo: Integer) + var + TransferLine: Record "Transfer Line"; + begin + if CurrFieldNo = 0 then + exit; + + if ProdOrderComponent."Location Code" = xProdOrderComponent."Location Code" then + exit; + + if ProdOrderComponent."Component Supply Method" <> "Component Supply Method"::"Transfer to Vendor" then + exit; + + TransferLine.SetCurrentKey("Subc. Prod. Order No.", "Subc. Routing No.", "Subc. Routing Reference No.", "Subc. Operation No.", "Subc. Purch. Order No."); + TransferLine.SetRange("Subc. Prod. Order No.", ProdOrderComponent."Prod. Order No."); + TransferLine.SetRange("Subc. Prod. Order Line No.", ProdOrderComponent."Prod. Order Line No."); + TransferLine.SetRange("Subc. Prod. Ord. Comp Line No.", ProdOrderComponent."Line No."); + TransferLine.SetRange("Item No.", ProdOrderComponent."Item No."); + TransferLine.SetLoadFields(SystemId); + if TransferLine.FindFirst() then + Error(LocationCodeChangeNotAllowedErr, TransferLine."Document No."); + end; + + local procedure CheckIfProdOrderCompIsInSubcontractingOrder(ProdOrderComponent: Record "Prod. Order Component") Result: Boolean + var + PurchOrderNo: Code[20]; + PurchOrderLineNo: Integer; + begin + GetPurchOrderFromProdOrderComp(ProdOrderComponent, PurchOrderNo, PurchOrderLineNo); + + Result := PurchOrderNo <> ''; + exit(Result); + end; + + local procedure CheckIfTransferLineOnProdOrderCompLineExists(ProdOrderComponent: Record "Prod. Order Component"; var TransferLine: Record "Transfer Line"): Boolean + var + ProdOrderLine: Record "Prod. Order Line"; + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + begin + ProdOrderLine.SetLoadFields("Routing Reference No."); + if not ProdOrderLine.Get(ProdOrderComponent.Status, ProdOrderComponent."Prod. Order No.", ProdOrderComponent."Prod. Order Line No.") then + exit(false); + + GetProdOrderRtngLineFromProdOrderComp(ProdOrderRoutingLine, ProdOrderComponent); + + TransferLine.SetCurrentKey("Subc. Prod. Order No.", "Subc. Prod. Order Line No.", "Subc. Routing Reference No.", "Subc. Routing No.", "Subc. Operation No."); + TransferLine.SetRange("Subc. Prod. Order No.", ProdOrderLine."Prod. Order No."); + TransferLine.SetRange("Subc. Prod. Order Line No.", ProdOrderLine."Line No."); + TransferLine.SetRange("Subc. Routing Reference No.", ProdOrderLine."Routing Reference No."); + TransferLine.SetRange("Subc. Routing No.", ProdOrderRoutingLine."Routing No."); + TransferLine.SetRange("Subc. Operation No.", ProdOrderRoutingLine."Operation No."); + TransferLine.SetRange("Item No.", ProdOrderComponent."Item No."); + TransferLine.SetRange("Variant Code", ProdOrderComponent."Variant Code"); + if TransferLine.IsEmpty() then + exit(false); + + TransferLine.SetLoadFields(SystemId); + TransferLine.FindFirst(); + exit(true); + end; + + local procedure GetProdOrderRtngLineFromProdOrderComp(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; ProdOrderComponent: Record "Prod. Order Component") + var + ProdOrderLine: Record "Prod. Order Line"; + begin + ProdOrderLine.SetLoadFields("Routing Reference No."); + if not ProdOrderLine.Get(ProdOrderComponent.Status, ProdOrderComponent."Prod. Order No.", ProdOrderComponent."Prod. Order Line No.") then + exit; + + ProdOrderRoutingLine.SetRange(Status, ProdOrderLine.Status); + ProdOrderRoutingLine.SetRange("Prod. Order No.", ProdOrderLine."Prod. Order No."); + ProdOrderRoutingLine.SetRange("Routing Reference No.", ProdOrderLine."Routing Reference No."); + ProdOrderRoutingLine.SetRange("Routing Link Code", ProdOrderComponent."Routing Link Code"); + if ProdOrderRoutingLine.IsEmpty() then + exit; + + ProdOrderRoutingLine.SetLoadFields(SystemId); + ProdOrderRoutingLine.FindFirst(); + end; + + local procedure GetPurchOrderFromProdOrderComp(ProdOrderComponent: Record "Prod. Order Component"; var PurchOrderNo: Code[20]; var PurchOrderLineNo: Integer) + var + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + PurchaseLine: Record "Purchase Line"; + begin + GetProdOrderRtngLineFromProdOrderComp(ProdOrderRoutingLine, ProdOrderComponent); + + PurchaseLine.SetCurrentKey("Document Type", Type, "Prod. Order No.", "Prod. Order Line No."); + PurchaseLine.SetRange("Document Type", PurchaseLine."Document Type"::Order); + PurchaseLine.SetRange("Prod. Order No.", ProdOrderComponent."Prod. Order No."); + PurchaseLine.SetRange("Prod. Order Line No.", ProdOrderComponent."Prod. Order Line No."); + PurchaseLine.SetRange("Operation No.", ProdOrderRoutingLine."Operation No."); + if PurchaseLine.IsEmpty() then + exit; + + PurchaseLine.FindFirst(); + PurchOrderNo := PurchaseLine."Document No."; + PurchOrderLineNo := PurchaseLine."Line No."; + end; + + local procedure ValidateSubcontractingReservationConstraints(var ProdOrderComponent: Record "Prod. Order Component") + var + TransferLine: Record "Transfer Line"; + begin + if not CheckIfProdOrderCompIsInSubcontractingOrder(ProdOrderComponent) then + exit; + + if not CheckIfTransferLineOnProdOrderCompLineExists(ProdOrderComponent, TransferLine) then + exit; + + if not CheckExistingReservationOnTransferLine(ProdOrderComponent, TransferLine) then + exit; + + Error(ExistingTransferLineErr, TransferLine."Document No."); + end; + + local procedure HandleRoutingLinkCodeValidation(var ProdOrderComponent: Record "Prod. Order Component"; var xProdOrderComponent: Record "Prod. Order Component") + var + ProdOrderLine: Record "Prod. Order Line"; + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + StockkeepingUnit: Record "Stockkeeping Unit"; + Vendor: Record Vendor; + PlanningGetParameters: Codeunit "Planning-Get Parameters"; + SubcontractingManagement: Codeunit "Subcontracting Management"; + begin + if ProdOrderComponent."Component Supply Method" = ProdOrderComponent."Component Supply Method"::"Transfer to Vendor" then + exit; + + ProdOrderLine.SetLoadFields("Routing No.", "Routing Reference No.", "Item No.", "Variant Code", "Location Code"); + ProdOrderLine.Get(ProdOrderComponent.Status, ProdOrderComponent."Prod. Order No.", ProdOrderComponent."Prod. Order Line No."); + if ProdOrderComponent."Routing Link Code" <> '' then begin + ProdOrderRoutingLine.SetRange(Status, ProdOrderComponent.Status); + ProdOrderRoutingLine.SetRange("Prod. Order No.", ProdOrderComponent."Prod. Order No."); + ProdOrderRoutingLine.SetRange("Routing No.", ProdOrderLine."Routing No."); + ProdOrderRoutingLine.SetRange("Routing Reference No.", ProdOrderLine."Routing Reference No."); + ProdOrderRoutingLine.SetRange("Routing Link Code", ProdOrderComponent."Routing Link Code"); + ProdOrderRoutingLine.SetLoadFields("Starting Date", "Starting Time", Type, "No."); + if ProdOrderRoutingLine.FindFirst() then begin + ProdOrderComponent."Due Date" := ProdOrderRoutingLine."Starting Date"; + ProdOrderComponent."Due Time" := ProdOrderRoutingLine."Starting Time"; + if (ProdOrderRoutingLine.Type = ProdOrderRoutingLine.Type::"Work Center") then + if SubcontractingManagement.GetSubcontractor(ProdOrderRoutingLine."No.", Vendor) then + SubcontractingManagement.ChangeLocationOnProdOrderComponent(ProdOrderComponent, Vendor."Subc. Location Code", ProdOrderComponent."Subc. Original Location Code", ProdOrderComponent."Subc. Orig. Bin Code"); + end; + end else + if xProdOrderComponent."Routing Link Code" <> '' then + if ProdOrderComponent."Subc. Original Location Code" <> '' then begin + ProdOrderComponent.Validate("Location Code", ProdOrderComponent."Subc. Original Location Code"); + ProdOrderComponent."Subc. Original Location Code" := ''; + if ProdOrderComponent."Subc. Orig. Bin Code" <> '' then begin + ProdOrderComponent.Validate("Bin Code", ProdOrderComponent."Subc. Orig. Bin Code"); + ProdOrderComponent."Subc. Orig. Bin Code" := ''; + end; + end else begin + PlanningGetParameters.AtSKU( + StockkeepingUnit, + ProdOrderLine."Item No.", + ProdOrderLine."Variant Code", + ProdOrderLine."Location Code"); + ProdOrderComponent.Validate("Location Code", StockkeepingUnit."Components at Location"); + end; + end; + + local procedure SetOriginalBinCode(var ProdOrderComponent: Record "Prod. Order Component"; var xProdOrderComponent: Record "Prod. Order Component") + begin + if ProdOrderComponent."Bin Code" <> xProdOrderComponent."Bin Code" then + ProdOrderComponent."Subc. Orig. Bin Code" := xProdOrderComponent."Bin Code"; + end; + + local procedure SetOriginalLocationCode(var ProdOrderComponent: Record "Prod. Order Component"; var xProdOrderComponent: Record "Prod. Order Component") + begin + if (ProdOrderComponent."Location Code" <> xProdOrderComponent."Location Code") then + ProdOrderComponent."Subc. Original Location Code" := xProdOrderComponent."Location Code"; + end; + + local procedure CheckExistingDocumentsForSubcontracting(var ProdOrderComponent: Record "Prod. Order Component"; var xProdOrderComponent: Record "Prod. Order Component"; CurrFieldNo: Integer) + begin + if CurrFieldNo = 0 then + exit; + + if ProdOrderComponent."Quantity per" <> xProdOrderComponent."Quantity per" then begin + CheckExistingSubcontractingTransferOrder(ProdOrderComponent, xProdOrderComponent, CurrFieldNo); + CheckExistingPostedSubcontractingTransferOrder(ProdOrderComponent); + CheckExistingSubcontractingPurchaseOrder(ProdOrderComponent); + end; + end; + + local procedure CheckUncompletedSubcontractingDocumentsExist(ProdOrderComponent: Record "Prod. Order Component") + var + ProdOrderLine: Record "Prod. Order Line"; + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + PurchaseLine: Record "Purchase Line"; + begin + ProdOrderLine.SetLoadFields("Routing Reference No.", "Routing No."); + if not ProdOrderLine.Get(ProdOrderComponent.Status, ProdOrderComponent."Prod. Order No.", ProdOrderComponent."Prod. Order Line No.") then + exit; + + PurchaseLine.SetCurrentKey("Document Type", Type, "Prod. Order No.", "Prod. Order Line No."); + PurchaseLine.SetRange("Document Type", PurchaseLine."Document Type"::Order); + PurchaseLine.SetRange("Prod. Order No.", ProdOrderComponent."Prod. Order No."); + PurchaseLine.SetRange("Prod. Order Line No.", ProdOrderComponent."Prod. Order Line No."); + + if ProdOrderComponent."Routing Link Code" <> '' then begin + ProdOrderRoutingLine.SetRange(Status, ProdOrderLine.Status); + ProdOrderRoutingLine.SetRange("Prod. Order No.", ProdOrderLine."Prod. Order No."); + ProdOrderRoutingLine.SetRange("Routing Reference No.", ProdOrderLine."Routing Reference No."); + ProdOrderRoutingLine.SetRange("Routing Link Code", ProdOrderComponent."Routing Link Code"); + ProdOrderRoutingLine.SetLoadFields("Operation No."); + if ProdOrderRoutingLine.FindFirst() then + PurchaseLine.SetRange("Operation No.", ProdOrderRoutingLine."Operation No."); + end; + + if PurchaseLine.FindSet() then + repeat + if HasSubcTransferForPurchLine(PurchaseLine, ProdOrderComponent) then + Error(CannotModifyCompTransferExistsErr, PurchaseLine."Prod. Order No.", PurchaseLine."Document No."); + + ProdOrderComponent.SetRange("Subc. Purchase Order Filter", PurchaseLine."Document No."); + if HasStockAtSubcLocationForComponentForPurchLine(ProdOrderComponent) then + Error(CannotModifyCompStockAtSubcErr, PurchaseLine."Prod. Order No.", PurchaseLine."Document No."); + until PurchaseLine.Next() = 0; + end; + + local procedure HasSubcTransferForPurchLine(PurchaseLine: Record "Purchase Line"; ProdOrderComponent: Record "Prod. Order Component"): Boolean + var + TransferLine: Record "Transfer Line"; + begin + TransferLine.SetCurrentKey("Subc. Purch. Order No.", "Subc. Prod. Order No.", "Subc. Prod. Order Line No.", "Subc. Operation No."); + TransferLine.SetRange("Subc. Purch. Order No.", PurchaseLine."Document No."); + TransferLine.SetRange("Subc. Prod. Order No.", ProdOrderComponent."Prod. Order No."); + TransferLine.SetRange("Subc. Prod. Order Line No.", ProdOrderComponent."Prod. Order Line No."); + TransferLine.SetRange("Subc. Prod. Ord. Comp Line No.", ProdOrderComponent."Line No."); + exit(not TransferLine.IsEmpty()); + end; + + local procedure HasStockAtSubcLocationForComponentForPurchLine(ProdOrderComponent: Record "Prod. Order Component"): Boolean + var + SubcTransferManagement: Codeunit "Subc. Transfer Management"; + NetStockAtSubcLocation: Decimal; + begin + ProdOrderComponent.CalcFields("Subc. Qty. transf. to Subcontr"); + if ProdOrderComponent."Subc. Qty. transf. to Subcontr" = 0 then + exit(false); + + NetStockAtSubcLocation := ProdOrderComponent."Subc. Qty. transf. to Subcontr"; + NetStockAtSubcLocation -= SubcTransferManagement.CalcConsumedQtyAtSubcLocation(ProdOrderComponent); + exit(NetStockAtSubcLocation > 0); + end; +} diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderCompExt.TableExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderCompExt.TableExt.al new file mode 100644 index 0000000000..ce85c33c98 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderCompExt.TableExt.al @@ -0,0 +1,144 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Item; +using Microsoft.Inventory.Ledger; +using Microsoft.Inventory.Location; +using Microsoft.Inventory.Transfer; +using Microsoft.Manufacturing.Document; +using Microsoft.Purchases.Document; +using Microsoft.Warehouse.Structure; + +tableextension 99001502 "Subc. Prod Order Comp Ext." extends "Prod. Order Component" +{ + AllowInCustomizations = AsReadOnly; + fields + { + field(99001522; "Component Supply Method"; Enum "Component Supply Method") + { + Caption = 'Component Supply Method'; + DataClassification = CustomerContent; + ToolTip = 'Specifies how components are supplied to the subcontractor for the production order component. Vendor-supplied - components are provided by the subcontractor. Consignment at Vendor - components are owned by your company but stored at the subcontractor location. Transfer to Vendor - components are sent to the subcontractor through a transfer order.'; + trigger OnValidate() + var + Item: Record Item; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + SubcontractingManagement: Codeunit "Subcontracting Management"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if "Component Supply Method" = "Component Supply Method"::"Transfer to Vendor" then + if "Item No." <> '' then begin + Item.Get("Item No."); + Item.TestField(Type, Item.Type::Inventory); + end; + SubcontractingManagement.UpdateComponentSupplyMethodForProdOrderComponent(Rec); + end; + } + field(99001523; "Subc. Original Location Code"; Code[10]) + { + Caption = 'Original Location Code'; + DataClassification = CustomerContent; + TableRelation = Location; + } + field(99001524; "Subc. Qty. transf. to Subcontr"; Decimal) + { + AutoFormatType = 0; + CalcFormula = sum("Item Ledger Entry".Quantity where("Entry Type" = const(Transfer), + "Subc. Prod. Order No." = field("Prod. Order No."), + "Subc. Prod. Order Line No." = field("Prod. Order Line No."), + "Prod. Order Comp. Line No." = field("Line No."), + "Subc. Purch. Order No." = field("Subc. Purchase Order Filter"), + "Location Code" = field("Location Code")) + + ); + Caption = 'Qty. transf. to Subcontractor'; + DecimalPlaces = 0 : 5; + Editable = false; + FieldClass = FlowField; + ToolTip = 'Specifies the item amount transferred to the subcontractor.'; + } + field(99001525; "Subc. Qty. in Transit (Base)"; Decimal) + { + AutoFormatType = 0; + CalcFormula = sum("Transfer Line"."Qty. in Transit (Base)" where("Subc. Prod. Order No." = field("Prod. Order No."), + "Subc. Prod. Order Line No." = field("Prod. Order Line No."), + "Subc. Prod. Ord. Comp Line No." = field("Line No."), + "Subc. Purch. Order No." = field("Subc. Purchase Order Filter"), + "Subc. Return Order" = const(false), + "Derived From Line No." = const(0))); + Caption = 'Qty. in Transit (Base)'; + DecimalPlaces = 0 : 5; + Editable = false; + FieldClass = FlowField; + ToolTip = 'Specifies the items that are in transit.'; + } + field(99001526; "Subc. Qty.on TransOrder (Base)"; Decimal) + { + AutoFormatType = 0; + CalcFormula = sum("Transfer Line"."Outstanding Qty. (Base)" where("Subc. Prod. Order No." = field("Prod. Order No."), + "Subc. Prod. Order Line No." = field("Prod. Order Line No."), + "Subc. Prod. Ord. Comp Line No." = field("Line No."), + "Subc. Purch. Order No." = field("Subc. Purchase Order Filter"), + "Subc. Return Order" = const(false), + "Derived From Line No." = const(0))); + Caption = 'Qty. on Transfer Order (Base)'; + DecimalPlaces = 0 : 5; + Editable = false; + FieldClass = FlowField; + ToolTip = 'Specifies the item amount that is on the transfer order.'; + } + field(99001527; "Subc. Purchase Order Filter"; Code[20]) + { + Caption = 'Subc. Purchase Order Filter'; + FieldClass = FlowFilter; + TableRelation = "Purchase Header"."No." where("Document Type" = const(Order), + "Subc. Order" = const(true)); + } + field(99001528; "Subc. Orig. Bin Code"; Code[20]) + { + Caption = 'Original Bin Code'; + DataClassification = CustomerContent; + TableRelation = Bin; + } + field(99001530; "RetQtyInTransit (Base)"; Decimal) + { + AutoFormatType = 0; + CalcFormula = sum("Transfer Line"."Qty. in Transit (Base)" where("Subc. Prod. Order No." = field("Prod. Order No."), + "Subc. Prod. Order Line No." = field("Prod. Order Line No."), + "Subc. Prod. Ord. Comp Line No." = field("Line No."), + "Subc. Purch. Order No." = field("Subc. Purchase Order Filter"), + "Subc. Return Order" = const(true), + "Derived From Line No." = const(0))); + Caption = 'Return Qty. in Transit (Base)'; + DecimalPlaces = 0 : 5; + Editable = false; + FieldClass = FlowField; + } + field(99001531; "RetQtyOnTransOrder (Base)"; Decimal) + { + AutoFormatType = 0; + CalcFormula = sum("Transfer Line"."Outstanding Qty. (Base)" where("Subc. Prod. Order No." = field("Prod. Order No."), + "Subc. Prod. Order Line No." = field("Prod. Order Line No."), + "Subc. Prod. Ord. Comp Line No." = field("Line No."), + "Subc. Purch. Order No." = field("Subc. Purchase Order Filter"), + "Subc. Return Order" = const(true), + "Derived From Line No." = const(0))); + Caption = 'Return Qty. on Transfer Order (Base)'; + DecimalPlaces = 0 : 5; + Editable = false; + FieldClass = FlowField; + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderCompLine.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderCompLine.PageExt.al new file mode 100644 index 0000000000..29df1f0de7 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderCompLine.PageExt.al @@ -0,0 +1,22 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Document; + +pageextension 99001513 "Subc. ProdOrderCompLine" extends "Prod. Order Comp. Line List" +{ + layout + { + addlast(Control1) + { + field("Component Supply Method"; Rec."Component Supply Method") + { + ApplicationArea = Subcontracting; + ToolTip = 'Specifies how components are supplied to the subcontractor for the production component.'; + } + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderComponents.Page.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderComponents.Page.al new file mode 100644 index 0000000000..f7482c07c6 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderComponents.Page.al @@ -0,0 +1,183 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Document; + +page 99001503 "Subc. Prod. Order Components" +{ + ApplicationArea = Subcontracting; + Caption = 'Prod. Order Comp. Line List'; + Editable = false; + PageType = List; + SourceTable = "Prod. Order Component"; + UsageCategory = None; + + layout + { + area(Content) + { + repeater(Components) + { + ShowCaption = false; + field("Component Supply Method"; Rec."Component Supply Method") + { + ToolTip = 'Specifies how components are supplied to the subcontractor for the production order component.'; + } + field("Item No."; Rec."Item No.") + { + ToolTip = 'Specifies the number of the item that is a component in the production order component list.'; + } + field("Variant Code"; Rec."Variant Code") + { + ToolTip = 'Specifies the variant of the item on the line.'; + Visible = false; + } + field(Description; Rec.Description) + { + ToolTip = 'Specifies a description of the item on the line.'; + } + field("Description 2"; Rec."Description 2") + { + ToolTip = 'Specifies a second description of the item on the line.'; + Visible = false; + } + field("Location Code"; Rec."Location Code") + { + ToolTip = 'Specifies the location where the component is stored. Copies the location code from the corresponding field on the production order line.'; + Visible = false; + } + field("Quantity per"; Rec."Quantity per") + { + AutoFormatType = 0; + ToolTip = 'Specifies how many units of the component are required to produce the parent item.'; + } + field("Expected Quantity"; Rec."Expected Quantity") + { + AutoFormatType = 0; + ToolTip = 'Specifies the quantity of the component expected to be consumed during the production of the quantity on this line.'; + } + field("Remaining Quantity"; Rec."Remaining Quantity") + { + AutoFormatType = 0; + ToolTip = 'Specifies the difference between the finished and planned quantities, or zero if the finished quantity is greater than the remaining quantity.'; + } + field("OutQtyOnPurch Order (Base)"; SubcCompFactboxMgmt.GetPurchOrderOutstandingQtyBaseFromProdOrderComp(Rec)) + { + AutoFormatType = 0; + Caption = 'Outstanding Qty (Base)'; + DecimalPlaces = 0 : 5; + Editable = false; + ToolTip = 'Specifies the outstanding item amount that is on the subcontracting order.'; + trigger OnDrillDown() + begin + SubcCompFactboxMgmt.ShowPurchOrderOutstandingQtyBaseFromProdOrderComp(Rec); + end; + } + field("ReceivedQtyOnPurch Order (Base)"; SubcCompFactboxMgmt.GetPurchOrderQtyReceivedBaseFromProdOrderComp(Rec)) + { + AutoFormatType = 0; + Caption = 'Qty. received (Base)'; + DecimalPlaces = 0 : 5; + Editable = false; + ToolTip = 'Specifies the received item amount that is on the subcontracting order.'; + trigger OnDrillDown() + begin + SubcCompFactboxMgmt.ShowPurchOrderQtyReceivedBaseFromProdOrderComp(Rec); + end; + } + field("Subc. Qty.on Transfer Order (Base)"; Rec."Subc. Qty.on TransOrder (Base)") + { + ToolTip = 'Specifies the item amount that is on the transfer order.'; + } + field("RetQtyOnTransOrder (Base)"; Rec."RetQtyOnTransOrder (Base)") + { + ToolTip = 'Specifies the item amount that is on the transfer order to be returned.'; + } + field("Subc.Qty. in Transit (Base)"; Rec."Subc. Qty. in Transit (Base)") + { + ToolTip = 'Specifies the items that are in transit.'; + Visible = false; + } + field("RetQtyInTransit (Base)"; Rec."RetQtyInTransit (Base)") + { + ToolTip = 'Specifies the items that are in transit for return.'; + Visible = false; + } + field("Qty. transf. to Subcontractor"; Rec."Subc. Qty. transf. to Subcontr") + { + ToolTip = 'Specifies the item amount transferred to the subcontractor.'; + } + field(ConsumedQty; SubcCompFactboxMgmt.GetConsumptionQtyFromProdOrderComponent(Rec)) + { + AutoFormatType = 0; + Caption = 'Consumed'; + DecimalPlaces = 0 : 5; + Editable = false; + ToolTip = 'Specifies the consumed Quantity from assigned Components.'; + trigger OnDrillDown() + begin + SubcCompFactboxMgmt.ShowConsumptionQtyFromProdOrderComponent(Rec); + end; + } + field("Due Date"; Rec."Due Date") + { + ToolTip = 'Specifies the date when the produced item must be available. The date is copied from the header of the production order.'; + } + field("Unit Cost"; Rec."Unit Cost") + { + AutoFormatExpression = ''; + AutoFormatType = 2; + ToolTip = 'Specifies the cost of one unit of the item or resource on the line.'; + Visible = false; + } + field("Cost Amount"; Rec."Cost Amount") + { + AutoFormatExpression = ''; + AutoFormatType = 2; + ToolTip = 'Specifies the total cost on the line by multiplying the unit cost by the quantity.'; + Visible = false; + } + } + } + area(FactBoxes) + { + systempart(LinksFactbox; Links) + { + Visible = false; + } + systempart(NotesFactbox; Notes) + { + Visible = false; + } + } + } + actions + { + area(Navigation) + { + group("Line") + { + Caption = 'Line'; + Image = Line; + action("Item Tracking Lines") + { + Caption = 'Item Tracking Lines'; + Image = ItemTrackingLines; + ShortcutKey = 'Shift+Ctrl+I'; + ToolTip = 'View or edit serial numbers and lot numbers that are assigned to the item on the document or journal line.'; + + trigger OnAction() + begin + Rec.OpenItemTrackingLines(); + end; + } + } + } + } + + var + SubcCompFactboxMgmt: Codeunit "Subc. Comp. Factbox Mgmt."; +} diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderRtng.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderRtng.PageExt.al new file mode 100644 index 0000000000..311eaf6d92 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderRtng.PageExt.al @@ -0,0 +1,229 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Document; +using Microsoft.Purchases.Document; + +pageextension 99001503 "Subc. Prod. Order Rtng." extends "Prod. Order Routing" +{ + layout + { + modify(Type) + { + trigger OnAfterValidate() + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; +#endif + UpdateWIPEnabled(); + end; + } + modify("No.") + { + trigger OnAfterValidate() + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; +#endif + UpdateWIPEnabled(); + end; + } + addafter(Description) + { + field(Subcontracting; Rec.Subcontracting) + { + ApplicationArea = Subcontracting; + } + field("Transfer WIP Item"; Rec."Transfer WIP Item") + { + ApplicationArea = Subcontracting; + Enabled = TransferWIPItemEnabled; + } + field("Transfer Description"; Rec."Transfer Description") + { + ApplicationArea = Subcontracting; + Enabled = Rec."Transfer WIP Item"; + } + field("Transfer Description 2"; Rec."Transfer Description 2") + { + ApplicationArea = Subcontracting; + Enabled = Rec."Transfer WIP Item"; + Visible = false; + } + field("WIP Qty. (Base) at Subc."; Rec."WIP Qty. (Base) at Subc.") + { + ApplicationArea = Subcontracting; + Visible = false; + } + field("WIP Qty. (Base) in Transit"; Rec."WIP Qty. (Base) in Transit") + { + ApplicationArea = Subcontracting; + Visible = false; + } + } + addbefore(Control1900383207) + { + part("Subc. Routing Info Factbox"; "Subc. Routing Info Factbox") + { + ApplicationArea = Subcontracting; + SubPageLink = "Prod. Order No." = field("Prod. Order No."), "Routing No." = field("Routing No."), "Routing Reference No." = field("Routing Reference No."), "Operation No." = field("Operation No."); + } + } + } + actions + { + addafter("Allocated Capacity") + { + action("Subcontracting Purchase Lines") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Purchase Order Lines'; + Image = SubcontractingWorksheet; + Enabled = SubcontractingActionsEnabled; + RunObject = page "Purchase Lines"; + RunPageLink = "Document Type" = const(Order), "Prod. Order No." = field("Prod. Order No."), "Routing No." = field("Routing No."), "Routing Reference No." = field("Routing Reference No."), "Operation No." = field("Operation No."); + ToolTip = 'Show purchase order lines for subcontracting.'; + } + action("WIP Ledger Entries") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting WIP Entries'; + Image = LedgerEntries; + Enabled = SubcontractingActionsEnabled; + RunObject = page "Subc. WIP Ledger Entries"; + RunPageLink = "Prod. Order Status" = field(Status), + "Prod. Order No." = field("Prod. Order No."), + "Routing Reference No." = field("Routing Reference No."), + "Routing No." = field("Routing No."), + "Operation No." = field("Operation No."); + ToolTip = 'View the Subcontracting WIP Entries for this routing line.'; + } + } + addlast("F&unctions") + { + action(CreateSubcontracting) + { + ApplicationArea = Subcontracting; + Caption = 'Create Subcontracting Order'; + Image = CreateDocument; + Enabled = SubcontractingActionsEnabled; + Visible = CreateSubcontractingVisible; + ToolTip = 'Create Purchase Orders for Subcontracting directly from the Production Routing Line.'; + trigger OnAction() + var + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + begin + CurrPage.SetSelectionFilter(ProdOrderRoutingLine); + CreateSubcontractingOrders(ProdOrderRoutingLine); + end; + } + action("WIP Adjustment") + { + ApplicationArea = Subcontracting; + Caption = 'WIP Adjustment'; + Image = AdjustEntries; + Enabled = SubcontractingActionsEnabled; + ToolTip = 'Manually adjust the WIP quantity for the selected prod. order routing line.'; + + trigger OnAction() + var + WIPLedgerEntry: Record "Subcontractor WIP Ledger Entry"; + WIPAdjustmentPage: Page "Subc. WIP Adjustment"; + begin + WIPLedgerEntry.SetProductionOrderRoutingFilter(Rec, true); + WIPAdjustmentPage.SetWIPLedgerEntry(WIPLedgerEntry); + WIPAdjustmentPage.SetDocumentNo(Rec."Prod. Order No."); + WIPAdjustmentPage.RunModal(); + end; + } + } + } + var +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 + SubcontractingEnabled: Boolean; +#endif + TransferWIPItemEnabled: Boolean; + SubcontractingActionsEnabled: Boolean; + CreateSubcontractingVisible: Boolean; + NoPurchOrderCreatedMsg: Label 'No subcontracting order was created for the selected operations in production order %1. Please check whether the operation or operations have already been completed.', Comment = '%1=Production Order No.'; + + trigger OnOpenPage() + var + StatusFilter: Text; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + SubcontractingEnabled := SubcFeatureFlagHandler.IsSubcontractingEnabled(); +#pragma warning restore AL0432 + if not SubcontractingEnabled then + exit; +#endif + StatusFilter := Rec.GetFilter(Rec.Status); + if StatusFilter.Contains(Format("Production Order Status"::Released)) then + CreateSubcontractingVisible := true + else + CreateSubcontractingVisible := false; + end; + + trigger OnAfterGetRecord() + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; +#endif + UpdateWIPEnabled(); + end; + + trigger OnAfterGetCurrRecord() + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; +#endif + UpdateWIPEnabled(); + SubcontractingActionsEnabled := Rec.Subcontracting and (Rec.Status = "Production Order Status"::Released); + end; + + local procedure UpdateWIPEnabled() + begin + Rec.Calcfields(Subcontracting); + TransferWIPItemEnabled := Rec.Subcontracting; + end; + + internal procedure CreateSubcontractingOrders(var ProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + PurchaseLine: Record "Purchase Line"; + SubcPurchaseOrderCreator: Codeunit "Subc. Purchase Order Creator"; + NoOfCreatedPurchOrder: Integer; + begin + NoOfCreatedPurchOrder := SubcPurchaseOrderCreator.CreateSubcontractingOrdersForRoutingLineSelection(ProdOrderRoutingLine); + + if NoOfCreatedPurchOrder = 0 then begin + PurchaseLine.SetCurrentKey("Document Type", Type, "Prod. Order No."); + PurchaseLine.SetRange("Document Type", PurchaseLine."Document Type"::Order); + PurchaseLine.SetRange(Type, PurchaseLine.Type::Item); + PurchaseLine.SetRange("Prod. Order No.", Rec."Prod. Order No."); + PurchaseLine.SetRange("Routing No.", Rec."Routing No."); + PurchaseLine.SetRange("Routing Reference No.", Rec."Routing Reference No."); + PurchaseLine.SetRange("Operation No.", Rec."Operation No."); + if PurchaseLine.IsEmpty() then + Message(NoPurchOrderCreatedMsg, ProdOrderRoutingLine."Prod. Order No.") + end else begin + if NoOfCreatedPurchOrder = 1 then begin + SubcPurchaseOrderCreator.ClearOperationNoForCreatedPurchaseOrder(); + SubcPurchaseOrderCreator.SetOperationNoForCreatedPurchaseOrder(Rec."Operation No."); + SubcPurchaseOrderCreator.ClearRoutingReferenceNoForCreatedPurchaseOrder(); + SubcPurchaseOrderCreator.SetRoutingReferenceNoForCreatedPurchaseOrder(Rec."Routing Reference No."); + end; + SubcPurchaseOrderCreator.ShowCreatedPurchaseOrder(Rec."Prod. Order No.", NoOfCreatedPurchOrder); + end; + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderRtngExt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderRtngExt.Codeunit.al new file mode 100644 index 0000000000..a0fd4dd15d --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderRtngExt.Codeunit.al @@ -0,0 +1,317 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Transfer; +using Microsoft.Manufacturing.Document; +using Microsoft.Manufacturing.Routing; +using Microsoft.Manufacturing.WorkCenter; +using Microsoft.Purchases.Document; + +codeunit 99001520 "Subc. Prod. Order Rtng. Ext." +{ + var +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + CannotModifyRtngLineTransferExistsErr: Label 'You cannot change this routing line because transfer orders exist for the linked production order %1, purchase order %2.', Comment = '%1=Production Order No., %2=Purchase Order No.'; + CannotModifyRtngLineStockAtSubcErr: Label 'You cannot change this routing line because there are remaining components or WIP items transferred to the subcontractor for production order %1, purchase order %2.', Comment = '%1=Production Order No., %2=Purchase Order No.'; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnBeforeDeleteEvent, '', false, false)] + local procedure OnBeforeDeleteProdOrderRtngLine(var Rec: Record "Prod. Order Routing Line"; RunTrigger: Boolean) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + + if not RunTrigger then + exit; + + if Rec."Transfer WIP Item" then + CheckSubcRtngLineDocumentsExist(Rec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnAfterDeleteEvent, '', false, false)] + local procedure OnAfterDeleteProdOrderRtngLine(var Rec: Record "Prod. Order Routing Line"; RunTrigger: Boolean) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + + if not RunTrigger then + exit; + + HandleSubcontractingAfterRoutingLineDelete(Rec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnBeforeValidateEvent, "No.", false, false)] + local procedure OnBeforeValidateNo(var Rec: Record "Prod. Order Routing Line"; var xRec: Record "Prod. Order Routing Line"; CurrFieldNo: Integer) + var + SubcontractingManagement: Codeunit "Subcontracting Management"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + + if CurrFieldNo <> 0 then + if (xRec."No." <> Rec."No.") and xRec."Transfer WIP Item" then + CheckSubcRtngLineDocumentsExist(xRec); + + if (xRec."No." <> Rec."No.") and (Rec."Routing Link Code" <> '') then + SubcontractingManagement.UpdLinkedComponents(Rec, true); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnBeforeValidateEvent, "Operation No.", false, false)] + local procedure OnBeforeValidateOperationNo(var Rec: Record "Prod. Order Routing Line"; var xRec: Record "Prod. Order Routing Line"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + + if CurrFieldNo <> 0 then + if (xRec."Operation No." <> Rec."Operation No.") and xRec."Transfer WIP Item" then + CheckSubcRtngLineDocumentsExist(xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnBeforeValidateEvent, "Routing Link Code", false, false)] + local procedure OnBeforeValidateRoutingLinkCode(var Rec: Record "Prod. Order Routing Line"; var xRec: Record "Prod. Order Routing Line"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + + if CurrFieldNo <> 0 then + if (xRec."Routing Link Code" <> Rec."Routing Link Code") and xRec."Transfer WIP Item" then + CheckSubcRtngLineDocumentsExist(xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnBeforeValidateEvent, "Type", false, false)] + local procedure OnBeforeValidateType(var Rec: Record "Prod. Order Routing Line"; var xRec: Record "Prod. Order Routing Line"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + + if CurrFieldNo <> 0 then + if (xRec.Type <> Rec.Type) and xRec."Transfer WIP Item" then + CheckSubcRtngLineDocumentsExist(xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnBeforeValidateEvent, "Transfer WIP Item", false, false)] + local procedure OnBeforeValidateTransferWIPItem(var Rec: Record "Prod. Order Routing Line"; var xRec: Record "Prod. Order Routing Line"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + + if CurrFieldNo <> 0 then + if (xRec."Transfer WIP Item" <> Rec."Transfer WIP Item") and xRec."Transfer WIP Item" then + CheckSubcRtngLineDocumentsExist(xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnAfterValidateEvent, "Routing Link Code", false, false)] + local procedure OnAfterValidateRoutingLinkCode(var Rec: Record "Prod. Order Routing Line"; var xRec: Record "Prod. Order Routing Line"; CurrFieldNo: Integer) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + HandleRoutingLinkCodeValidation(Rec, xRec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnAfterValidateEvent, "Standard Task Code", false, false)] + local procedure OnAfterValidateStandardTaskCode(var Rec: Record "Prod. Order Routing Line"; var xRec: Record "Prod. Order Routing Line"; CurrFieldNo: Integer) + var + SubcPriceManagement: Codeunit "Subc. Price Management"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary then + exit; + SubcPriceManagement.GetSubcPriceList(Rec); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnAfterWorkCenterTransferFields, '', false, false)] + local procedure OnAfterWorkCenterTransferFields(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; WorkCenter: Record "Work Center") + var + SubcPriceManagement: Codeunit "Subc. Price Management"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + SubcPriceManagement.GetSubcPriceList(ProdOrderRoutingLine); + end; + + [EventSubscriber(ObjectType::Table, Database::"Prod. Order Routing Line", OnAfterCopyFromRoutingLine, '', false, false)] + local procedure OnAfterCopyFromRoutingLine(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; RoutingLine: Record "Routing Line") + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + ProdOrderRoutingLine."Transfer WIP Item" := RoutingLine."Transfer WIP Item"; + ProdOrderRoutingLine."Transfer Description" := RoutingLine."Transfer Description"; + ProdOrderRoutingLine."Transfer Description 2" := RoutingLine."Transfer Description 2"; + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Prod. Order Route Management", OnCalculateOnBeforeProdOrderRtngLineLoopIteration, '', false, false)] + local procedure CheckSubcontractingOnCalculateOnBeforeProdOrderRtngLineLoopIteration(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; var ProdOrderLine: Record "Prod. Order Line"; var IsHandled: Boolean) + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + ProdOrderRoutingLine.CheckForSubcontractingPurchaseLineTypeMismatch(); + end; + + local procedure HandleRoutingLinkCodeValidation(var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; var xProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + SubcontractingManagement: Codeunit "Subcontracting Management"; + begin + if ProdOrderRoutingLine."Routing Link Code" <> xProdOrderRoutingLine."Routing Link Code" then + if xProdOrderRoutingLine."Routing Link Code" <> '' then begin + SubcontractingManagement.DelLocationLinkedComponents(xProdOrderRoutingLine, true); + if ProdOrderRoutingLine."Routing Link Code" <> '' then + SubcontractingManagement.UpdLinkedComponents(ProdOrderRoutingLine, false); + end else + if ProdOrderRoutingLine."Routing Link Code" <> '' then + SubcontractingManagement.UpdLinkedComponents(ProdOrderRoutingLine, true); + end; + + local procedure HandleSubcontractingAfterRoutingLineDelete(var ProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + WorkCenter: Record "Work Center"; + SubcontractingManagement: Codeunit "Subcontracting Management"; + begin + if ProdOrderRoutingLine.Status = ProdOrderRoutingLine.Status::Released then + if ProdOrderRoutingLine.Type = ProdOrderRoutingLine.Type::"Work Center" then begin + WorkCenter.SetLoadFields("Subcontractor No."); + if WorkCenter.Get(ProdOrderRoutingLine."No.") then + if (ProdOrderRoutingLine."Routing Link Code" <> '') and (WorkCenter."Subcontractor No." <> '') then + SubcontractingManagement.DelLocationLinkedComponents(ProdOrderRoutingLine, false); + end; + end; + + local procedure CheckSubcRtngLineDocumentsExist(ProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + PurchaseLine: Record "Purchase Line"; + begin + PurchaseLine.SetCurrentKey("Document Type", Type, "Prod. Order No.", "Prod. Order Line No."); + PurchaseLine.SetRange("Document Type", PurchaseLine."Document Type"::Order); + PurchaseLine.SetRange("Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + PurchaseLine.SetRange("Routing No.", ProdOrderRoutingLine."Routing No."); + PurchaseLine.SetRange("Routing Reference No.", ProdOrderRoutingLine."Routing Reference No."); + PurchaseLine.SetRange("Operation No.", ProdOrderRoutingLine."Operation No."); + if PurchaseLine.FindSet() then + repeat + if HasSubcTransferForPurchLine(PurchaseLine) then + Error(CannotModifyRtngLineTransferExistsErr, PurchaseLine."Prod. Order No.", PurchaseLine."Document No."); + if HasStockAtSubcLocation(PurchaseLine, ProdOrderRoutingLine) then + Error(CannotModifyRtngLineStockAtSubcErr, PurchaseLine."Prod. Order No.", PurchaseLine."Document No."); + until PurchaseLine.Next() = 0; + end; + + local procedure HasSubcTransferForPurchLine(PurchaseLine: Record "Purchase Line"): Boolean + var + TransferLine: Record "Transfer Line"; + begin + TransferLine.SetRange("Subc. Purch. Order No.", PurchaseLine."Document No."); + TransferLine.SetRange("Subc. Purch. Order Line No.", PurchaseLine."Line No."); + TransferLine.SetRange("Subc. Prod. Order No.", PurchaseLine."Prod. Order No."); + exit(not TransferLine.IsEmpty()); + end; + + local procedure HasStockAtSubcLocation(PurchaseLine: Record "Purchase Line"; ProdOrderRoutingLine: Record "Prod. Order Routing Line"): Boolean + var + ProdOrderComponent: Record "Prod. Order Component"; + SubcWIPLedgerEntry: Record "Subcontractor WIP Ledger Entry"; + SubcTransferManagement: Codeunit "Subc. Transfer Management"; + NetStockAtSubcLocation: Decimal; + begin + ProdOrderComponent.SetCurrentKey(Status, "Prod. Order No.", "Routing Link Code"); + ProdOrderComponent.SetRange(Status, "Production Order Status"::Released); + ProdOrderComponent.SetRange("Prod. Order No.", PurchaseLine."Prod. Order No."); + ProdOrderComponent.SetRange("Prod. Order Line No.", PurchaseLine."Prod. Order Line No."); + ProdOrderComponent.SetRange("Component Supply Method", ProdOrderComponent."Component Supply Method"::"Transfer to Vendor"); + ProdOrderComponent.SetRange("Subc. Purchase Order Filter", PurchaseLine."Document No."); + ProdOrderComponent.SetRange("Routing Link Code", ProdOrderRoutingLine."Routing Link Code"); + ProdOrderComponent.SetAutoCalcFields("Subc. Qty. transf. to Subcontr"); + if ProdOrderComponent.FindSet() then + repeat + if ProdOrderComponent."Subc. Qty. transf. to Subcontr" <> 0 then begin + NetStockAtSubcLocation := ProdOrderComponent."Subc. Qty. transf. to Subcontr"; + NetStockAtSubcLocation -= SubcTransferManagement.CalcConsumedQtyAtSubcLocation(ProdOrderComponent); + if NetStockAtSubcLocation > 0 then + exit(true); + end; + until ProdOrderComponent.Next() = 0; + + SubcWIPLedgerEntry.SetCurrentKey("Prod. Order No.", "Prod. Order Status", "Prod. Order Line No.", "Routing Reference No.", "Routing No.", "Operation No.", "Location Code"); + SubcWIPLedgerEntry.SetRange("Prod. Order No.", PurchaseLine."Prod. Order No."); + SubcWIPLedgerEntry.SetRange("Prod. Order Status", "Production Order Status"::Released); + SubcWIPLedgerEntry.SetRange("Prod. Order Line No.", PurchaseLine."Prod. Order Line No."); + SubcWIPLedgerEntry.SetRange("Routing Reference No.", ProdOrderRoutingLine."Routing Reference No."); + SubcWIPLedgerEntry.SetRange("Routing No.", ProdOrderRoutingLine."Routing No."); + SubcWIPLedgerEntry.SetRange("Operation No.", ProdOrderRoutingLine."Operation No."); + SubcWIPLedgerEntry.SetRange("In Transit", false); + SubcWIPLedgerEntry.CalcSums("Quantity (Base)"); + if SubcWIPLedgerEntry."Quantity (Base)" <> 0 then + exit(true); + + exit(false); + end; +} diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderRtngLineExt.TableExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderRtngLineExt.TableExt.al new file mode 100644 index 0000000000..138ca54f36 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProdOrderRtngLineExt.TableExt.al @@ -0,0 +1,277 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Location; +using Microsoft.Manufacturing.Capacity; + +using Microsoft.Manufacturing.Document; +using Microsoft.Manufacturing.WorkCenter; +using Microsoft.Purchases.Document; +using Microsoft.Purchases.Vendor; + +tableextension 99001506 "Subc. ProdOrderRtngLine Ext." extends "Prod. Order Routing Line" +{ + fields + { + modify(Type) + { + trigger OnAfterValidate() +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Type = xRec.Type then + exit; + + if Type <> "Capacity Type"::"Work Center" then + "Transfer WIP Item" := false; + end; + } + modify("No.") + { + trigger OnAfterValidate() + var + WorkCenter: Record "Work Center"; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if "No." = xRec."No." then + exit; + if Type <> "Capacity Type"::"Work Center" then begin + "Transfer WIP Item" := false; + exit; + end; + WorkCenter.SetLoadFields("Subcontractor No."); + WorkCenter.Get("No."); + if WorkCenter."Subcontractor No." = '' then + "Transfer WIP Item" := false; + end; + } + field(99001550; "Vendor No. Subc. Price"; Code[20]) + { + AllowInCustomizations = AsReadOnly; + Caption = 'Vendor No. Subcontracting Prices'; + DataClassification = CustomerContent; + Editable = false; + TableRelation = Vendor; + } + field(99001551; Subcontracting; Boolean) + { + AllowInCustomizations = AsReadOnly; + CalcFormula = exist("Work Center" where("No." = field("Work Center No."), + "Subcontractor No." = filter(<> ''))); + Caption = 'Subcontracting'; + Editable = false; + FieldClass = FlowField; + ToolTip = 'Specifies whether the Work Center Group is set up with a Vendor for Subcontracting.'; + } + field(99001560; "Transfer WIP Item"; Boolean) + { + AllowInCustomizations = AsReadWrite; + Caption = 'Transfer WIP Item'; + DataClassification = CustomerContent; + ToolTip = 'Specifies whether the production order parent item (WIP item) is transferred to the subcontractor for this operation.'; + + trigger OnValidate() + begin + if "Transfer WIP Item" then begin + CalcFields(Subcontracting); + TestField(Subcontracting, true); + end; + end; + } + field(99001561; "Transfer Description"; Text[100]) + { + AllowInCustomizations = AsReadWrite; + Caption = 'Transfer Description'; + DataClassification = CustomerContent; + ToolTip = 'Specifies the operation-specific description used on transfer orders for the semi-finished item as it is shipped to the subcontracting location. If empty, the standard description is used.'; + } + field(99001562; "Transfer Description 2"; Text[50]) + { + AllowInCustomizations = AsReadWrite; + Caption = 'Transfer Description 2'; + DataClassification = CustomerContent; + ToolTip = 'Specifies an additional operation-specific description line used on transfer orders for the semi-finished item as it is shipped to the subcontracting location.'; + } +#pragma warning disable AA0232 + field(99001563; "WIP Qty. (Base) at Subc."; Decimal) +#pragma warning restore AA0232 + { + AllowInCustomizations = AsReadOnly; + AutoFormatType = 0; + CalcFormula = sum("Subcontractor WIP Ledger Entry"."Quantity (Base)" where("Prod. Order Status" = field(Status), + "Prod. Order No." = field("Prod. Order No."), + "Prod. Order Line No." = field("Prod. Order Line Filter"), + "Routing Reference No." = field("Routing Reference No."), + "Routing No." = field("Routing No."), + "Operation No." = field("Operation No."), + "Location Code" = field("WIP Location Filter"), + "In Transit" = const(false))); + Caption = 'WIP Qty. (Base) at Subcontractor'; + DecimalPlaces = 0 : 5; + Editable = false; + FieldClass = FlowField; + ToolTip = 'Specifies the total work-in-progress quantity (base) of the production order parent item currently held at the subcontractor location for this operation, as tracked by Subcontracting WIP Entries.'; + } + field(99001564; "WIP Qty. (Base) in Transit"; Decimal) + { + AllowInCustomizations = AsReadOnly; + AutoFormatType = 0; + CalcFormula = sum("Subcontractor WIP Ledger Entry"."Quantity (Base)" where("Prod. Order Status" = field(Status), + "Prod. Order No." = field("Prod. Order No."), + "Prod. Order Line No." = field("Prod. Order Line Filter"), + "Routing Reference No." = field("Routing Reference No."), + "Routing No." = field("Routing No."), + "Operation No." = field("Operation No."), + "In Transit" = const(true))); + Caption = 'WIP Qty. (Base) in Transit'; + DecimalPlaces = 0 : 5; + Editable = false; + FieldClass = FlowField; + ToolTip = 'Specifies the outstanding quantity of the production order parent item on transfer orders that is currently in transit to the subcontractor for this operation.'; + } + field(99001534; "WIP Location Filter"; Code[10]) + { + Caption = 'WIP Location Filter'; + FieldClass = FlowFilter; + TableRelation = Location; + ToolTip = 'Specifies the location filter used for FlowField calculations.'; + } + field(99001535; "Prod. Order Line Filter"; Integer) + { + Caption = 'Prod. Order Line Filter'; + FieldClass = FlowFilter; + ToolTip = 'Specifies the production order line filter used for FlowField calculations.'; + } + } + + trigger OnBeforeDelete() + begin + CheckForSubcontractingPurchaseLineTypeMismatchOnDeleteLine(); + end; + + var + PurchaseLineTypeMismatchErr: Label 'There is at least one Purchase Line (%1) which is linked to Production Order Routing Line (%2). The Purchase Line cannot be of type %3 for this Production Order Routing Line. Please delete the Purchase line first before changing the Production Order Routing Line.', + Comment = '%1 = PurchaseLine Record Id, %2 = Production Order Routing Line Record Id, %3 = Purchase Line Type'; + PurchaseLineTypeMismatchNotLastOperationErr: Label 'There is at least one Purchase Line (%1) which is linked to Production Order Routing Line (%2). Because the Production Order Routing Line is the last operation after delete, the Purchase Line cannot be of type Not Last Operation. Please delete the Purchase line first before changing the Production Order Routing Line.', + Comment = '%1 = PurchaseLine Record Id, %2 = Previous Production Order Routing Line Record Id'; + + /// + /// Checks if the prod. order routing line has a linked purchase order line. In case of mismatching last operation or not last operation on changing + /// the prod. order routing line order an error will be thrown if the type does not match with purchase line + /// + internal procedure CheckForSubcontractingPurchaseLineTypeMismatch() + var + ProdOrderLine: Record "Prod. Order Line"; + PurchLine: Record "Purchase Line"; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Status <> "Production Order Status"::Released then + exit; + + ProdOrderLine.SetLoadFields(SystemId); + ProdOrderLine.SetRange(Status, Status); + ProdOrderLine.SetRange("Prod. Order No.", "Prod. Order No."); + ProdOrderLine.SetRange("Routing Reference No.", "Routing Reference No."); + ProdOrderLine.SetRange("Routing No.", "Routing No."); + if ProdOrderLine.Find('-') then + repeat + PurchLine.SetLoadFields(SystemId); + PurchLine.SetCurrentKey("Prod. Order No.", "Prod. Order Line No.", "Routing No.", "Operation No."); + PurchLine.SetRange("Prod. Order No.", "Prod. Order No."); + PurchLine.SetRange("Prod. Order Line No.", ProdOrderLine."Line No."); + PurchLine.SetRange("Operation No.", "Operation No."); + PurchLine.SetRange("Document Type", PurchLine."Document Type"::Order); + PurchLine.SetRange(Type, PurchLine.Type::Item); + if "Next Operation No." <> '' then begin + PurchLine.SetRange("Subc. Purchase Line Type", "Subc. Purchase Line Type"::LastOperation); + if PurchLine.FindFirst() then + Error(PurchaseLineTypeMismatchErr, PurchLine.RecordId(), RecordId(), Format("Subc. Purchase Line Type"::LastOperation)); + end else begin + PurchLine.SetRange("Subc. Purchase Line Type", "Subc. Purchase Line Type"::NotLastOperation); + if PurchLine.FindFirst() then + Error(PurchaseLineTypeMismatchErr, PurchLine.RecordId(), RecordId(), Format("Subc. Purchase Line Type"::NotLastOperation)); + end; + until ProdOrderLine.Next() = 0; + end; + + local procedure CheckForSubcontractingPurchaseLineTypeMismatchOnDeleteLine() + var + ProdOrderLine: Record "Prod. Order Line"; + PurchLine: Record "Purchase Line"; + PrevProdOrderRoutingLine: Record "Prod. Order Routing Line"; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Status <> "Production Order Status"::Released then + exit; + ProdOrderLine.SetLoadFields(SystemId); + ProdOrderLine.SetRange(Status, Status); + ProdOrderLine.SetRange("Prod. Order No.", "Prod. Order No."); + ProdOrderLine.SetRange("Routing Reference No.", "Routing Reference No."); + ProdOrderLine.SetRange("Routing No.", "Routing No."); + if ProdOrderLine.Find('-') then + repeat + PurchLine.SetLoadFields(SystemId); + PurchLine.SetCurrentKey("Prod. Order No.", "Prod. Order Line No.", "Routing No.", "Operation No."); + PurchLine.SetRange("Prod. Order No.", "Prod. Order No."); + PurchLine.SetRange("Prod. Order Line No.", ProdOrderLine."Line No."); + PurchLine.SetRange("Document Type", PurchLine."Document Type"::Order); + PurchLine.SetRange(Type, PurchLine.Type::Item); + if "Next Operation No." = '' then begin + PrevProdOrderRoutingLine := Rec; + PrevProdOrderRoutingLine.SetRecFilter(); + PrevProdOrderRoutingLine.SetFilter("Operation No.", "Previous Operation No."); + PrevProdOrderRoutingLine.SetLoadFields(SystemId); + if PrevProdOrderRoutingLine.FindSet() then + repeat + PurchLine.SetRange("Operation No.", PrevProdOrderRoutingLine."Operation No."); + PurchLine.SetRange("Subc. Purchase Line Type", "Subc. Purchase Line Type"::NotLastOperation); + if PurchLine.FindFirst() then + Error(PurchaseLineTypeMismatchNotLastOperationErr, PurchLine.RecordId(), PrevProdOrderRoutingLine.RecordId()); + until PrevProdOrderRoutingLine.Next() = 0; + end; + until ProdOrderLine.Next() = 0; + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProductionOrderExt.TableExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProductionOrderExt.TableExt.al new file mode 100644 index 0000000000..084227bf0a --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcProductionOrderExt.TableExt.al @@ -0,0 +1,21 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Document; + +tableextension 99001505 "Subc. Production Order Ext." extends "Production Order" +{ + AllowInCustomizations = AsReadOnly; + fields + { + field(99001552; "Created from Purch. Order"; Boolean) + { + Caption = 'Created from Purchase Order'; + DataClassification = CustomerContent; + Description = 'For internal use only'; + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRelProdOrder.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRelProdOrder.PageExt.al new file mode 100644 index 0000000000..7612fdcf78 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRelProdOrder.PageExt.al @@ -0,0 +1,85 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Ledger; +using Microsoft.Manufacturing.Document; +using Microsoft.Purchases.Document; +pageextension 99001504 "Subc. Rel. Prod. Order" extends "Released Production Order" +{ + actions + { + addafter("Registered Put-away Lines") + { + action("Subcontracting Purchase Lines") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Order Lines'; + Image = SubcontractingWorksheet; + RunObject = page "Purchase Lines"; + RunPageLink = "Document Type" = const(Order), "Prod. Order No." = field("No."); + ToolTip = 'Show purchase order lines for subcontracting.'; + } + } + addafter("&Warehouse Entries") + { + action("Subc. Transfer Orders") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Transfer Orders'; + Image = TransferOrder; + ToolTip = 'View the subcontracting transfer orders related to this production order.'; + + trigger OnAction() + var + SubcPurchFactboxMgmt: Codeunit "Subc. Purch. Factbox Mgmt."; + begin + SubcPurchFactboxMgmt.ShowTransferOrdersFromProductionOrder(Rec); + end; + } + action("Subc. Transfer Entries") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Transfer Entries'; + Image = ItemLedger; + RunObject = page "Item Ledger Entries"; + RunPageLink = "Entry Type" = const(Transfer), + "Subc. Prod. Order No." = field("No."); + RunPageView = sorting("Order Type", "Order No."); + ToolTip = 'View the list of subcontracting transfers.'; + } + action("WIP Ledger Entries") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting WIP Entries'; + Image = LedgerEntries; + RunObject = page "Subc. WIP Ledger Entries"; + RunPageLink = "Prod. Order Status" = field(Status), "Prod. Order No." = field("No."); + ToolTip = 'View the Subcontracting WIP Entries for this production order.'; + } + } + addlast("F&unctions") + { + action("WIP Adjustment") + { + ApplicationArea = Subcontracting; + Caption = 'WIP Adjustment'; + Image = AdjustEntries; + ToolTip = 'Manually adjust the WIP quantities for all routing operations of this production order.'; + + trigger OnAction() + var + WIPLedgerEntry: Record "Subcontractor WIP Ledger Entry"; + WIPAdjustmentPage: Page "Subc. WIP Adjustment"; + begin + WIPLedgerEntry.SetProductionOrderFilter(Rec, true); + WIPAdjustmentPage.SetWIPLedgerEntry(WIPLedgerEntry); + WIPAdjustmentPage.SetDocumentNo(Rec."No."); + WIPAdjustmentPage.RunModal(); + end; + } + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRelProdOrders.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRelProdOrders.PageExt.al new file mode 100644 index 0000000000..0446a28a16 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRelProdOrders.PageExt.al @@ -0,0 +1,63 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Ledger; +using Microsoft.Manufacturing.Document; +using Microsoft.Purchases.Document; +pageextension 99001505 "Subc. Rel. Prod. Orders" extends "Released Production Orders" +{ + actions + { + addafter("E&ntries") + { + action("Subcontracting Purchase Lines") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Order Lines'; + Image = SubcontractingWorksheet; + RunObject = page "Purchase Lines"; + RunPageLink = "Document Type" = const(Order), "Prod. Order No." = field("No."); + ToolTip = 'Show purchase order lines for subcontracting.'; + } + } + addafter("&Warehouse Entries") + { + action("Subc. Transfer Orders") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Transfer Orders'; + Image = TransferOrder; + ToolTip = 'View the subcontracting transfer orders related to this production order.'; + + trigger OnAction() + var + SubcPurchFactboxMgmt: Codeunit "Subc. Purch. Factbox Mgmt."; + begin + SubcPurchFactboxMgmt.ShowTransferOrdersFromProductionOrder(Rec); + end; + } + action("Subc. Transfer Entries") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Transfer Entries'; + Image = ItemLedger; + RunObject = page "Item Ledger Entries"; + RunPageLink = "Entry Type" = const(Transfer), "Subc. Prod. Order No." = field("No."); + RunPageView = sorting("Order Type", "Order No."); + ToolTip = 'View the list of subcontracting transfers.'; + } + action("WIP Ledger Entries") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting WIP Entries'; + Image = LedgerEntries; + RunObject = page "Subc. WIP Ledger Entries"; + RunPageLink = "Prod. Order Status" = field(Status), "Prod. Order No." = field("No."); + ToolTip = 'View the Subcontracting WIP Entries for this production order.'; + } + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcReqWkshMakeOrd.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcReqWkshMakeOrd.Codeunit.al new file mode 100644 index 0000000000..b4c0c324d5 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcReqWkshMakeOrd.Codeunit.al @@ -0,0 +1,124 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Requisition; +using Microsoft.Manufacturing.Document; +using Microsoft.Purchases.Document; + +codeunit 99001516 "Subc. Req. Wksh. Make Ord." +{ +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 + +#endif + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Req. Wksh.-Make Order", OnAfterInsertPurchOrderLine, '', false, false)] + local procedure OnAfterInsertPurchOrderLine(var PurchOrderLine: Record "Purchase Line"; var NextLineNo: Integer; var RequisitionLine: Record "Requisition Line") + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + HandleSubcontractingAfterPurchOrderLineInsert(PurchOrderLine, RequisitionLine); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Req. Wksh.-Make Order", OnInsertPurchOrderLineOnAfterCheckInsertFinalizePurchaseOrderHeader, '', false, false)] + local procedure OnInsertPurchOrderLineOnAfterCheckInsertFinalizePurchaseOrderHeader(var RequisitionLine: Record "Requisition Line"; var PurchaseHeader: Record "Purchase Header"; var NextLineNo: Integer) + var + PurchaseLineWithService: Record "Purchase Line"; + SubcPurchaseOrderCreator: Codeunit "Subc. Purchase Order Creator"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if RequisitionLine."Prod. Order No." = '' then + exit; + PurchaseLineWithService."Document Type" := PurchaseHeader."Document Type"; + PurchaseLineWithService."Document No." := PurchaseHeader."No."; + SubcPurchaseOrderCreator.TransferSubcontractingProdOrderComp(PurchaseLineWithService, RequisitionLine, NextLineNo); + end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"Carry Out Action", OnPurchOrderChgAndResheduleOnAfterGetPurchHeader, '', false, false)] + local procedure OnPurchOrderChgAndResheduleOnAfterGetPurchHeader(var PurchaseHeader: Record "Purchase Header"; var PurchaseLine: Record "Purchase Line"; var RequisitionLine: Record "Requisition Line") + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + UpdateSubcontractingComponentPurchLines(PurchaseLine, RequisitionLine); + end; + + local procedure HandleSubcontractingAfterPurchOrderLineInsert(var PurchaseLine: Record "Purchase Line"; var RequisitionLine: Record "Requisition Line") + var + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + SubcPurchaseOrderCreator: Codeunit "Subc. Purchase Order Creator"; + begin + SubcPurchaseOrderCreator.InsertProdDescriptionOnAfterInsertPurchOrderLine(PurchaseLine, RequisitionLine); + if (RequisitionLine."Prod. Order No." <> '') and (RequisitionLine."Operation No." <> '') then begin + ProdOrderRoutingLine.SetLoadFields("Transfer WIP Item"); + if ProdOrderRoutingLine.Get( + "Production Order Status"::Released, + RequisitionLine."Prod. Order No.", + RequisitionLine."Routing Reference No.", + RequisitionLine."Routing No.", + RequisitionLine."Operation No.") + then begin + PurchaseLine."Transfer WIP Item" := ProdOrderRoutingLine."Transfer WIP Item"; + PurchaseLine.Modify(); + end; + end; + end; + + local procedure UpdateSubcontractingComponentPurchLines(PurchaseLine: Record "Purchase Line"; RequisitionLine: Record "Requisition Line") + var + ProdOrderComponent: Record "Prod. Order Component"; + ProdOrderRoutingLine: Record "Prod. Order Routing Line"; + PurchaseLineComp: Record "Purchase Line"; + begin + if RequisitionLine."Prod. Order No." = '' then + exit; + if RequisitionLine."Operation No." = '' then + exit; + + ProdOrderRoutingLine.SetLoadFields("Routing Link Code"); + if not ProdOrderRoutingLine.Get( + "Production Order Status"::Released, RequisitionLine."Prod. Order No.", + RequisitionLine."Routing Reference No.", RequisitionLine."Routing No.", RequisitionLine."Operation No.") + then + exit; + + ProdOrderComponent.SetRange(Status, "Production Order Status"::Released); + ProdOrderComponent.SetRange("Prod. Order No.", RequisitionLine."Prod. Order No."); + ProdOrderComponent.SetRange("Prod. Order Line No.", RequisitionLine."Prod. Order Line No."); + ProdOrderComponent.SetRange("Routing Link Code", ProdOrderRoutingLine."Routing Link Code"); + ProdOrderComponent.SetRange("Component Supply Method", "Component Supply Method"::"Vendor-Supplied"); + ProdOrderComponent.SetLoadFields("Item No.", "Variant Code", "Remaining Quantity"); + if ProdOrderComponent.FindSet() then + repeat + PurchaseLineComp.SetRange("Document Type", PurchaseLine."Document Type"); + PurchaseLineComp.SetRange("Document No.", PurchaseLine."Document No."); + PurchaseLineComp.SetRange(Type, "Purchase Line Type"::Item); + PurchaseLineComp.SetRange("No.", ProdOrderComponent."Item No."); + PurchaseLineComp.SetRange("Variant Code", ProdOrderComponent."Variant Code"); + PurchaseLineComp.SetRange("Subc. Prod. Order No.", ProdOrderComponent."Prod. Order No."); + PurchaseLineComp.SetRange("Subc. Operation No.", RequisitionLine."Operation No."); + if PurchaseLineComp.FindFirst() then + if PurchaseLineComp.Quantity <> ProdOrderComponent."Remaining Quantity" then begin + PurchaseLineComp.Validate(Quantity, ProdOrderComponent."Remaining Quantity"); + PurchaseLineComp.Modify(true); + end; + until ProdOrderComponent.Next() = 0; + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingFactboxMgmt.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingFactboxMgmt.Codeunit.al new file mode 100644 index 0000000000..e2da280b94 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingFactboxMgmt.Codeunit.al @@ -0,0 +1,344 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Transfer; +using Microsoft.Manufacturing.Document; +using Microsoft.Manufacturing.WorkCenter; +using Microsoft.Purchases.Document; +using Microsoft.Purchases.History; +using Microsoft.Purchases.Vendor; + +codeunit 99001561 "Subc. Routing Factbox Mgmt." +{ +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 + +#endif + /// + /// Returns the subcontractor vendor number for the work center on the given production order routing line. + /// + /// The production order routing line to retrieve the subcontractor for. + /// The subcontractor vendor number, or an empty string if the line is a machine center type. + procedure GetSubcontractorNo(ProdOrderRoutingLine: Record "Prod. Order Routing Line"): Code[20] + var + WorkCenter: Record "Work Center"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(''); + +#endif + if ProdOrderRoutingLine.Type = ProdOrderRoutingLine.Type::"Machine Center" then + exit(''); + WorkCenter.SetLoadFields("Subcontractor No."); + if WorkCenter.Get(ProdOrderRoutingLine."Work Center No.") then + exit(WorkCenter."Subcontractor No."); + end; + + /// + /// Opens the Vendor Card for the subcontractor assigned to the work center on the given production order routing line. + /// + /// The production order routing line whose work center subcontractor to show. + procedure ShowSubcontractor(ProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + Vendor: Record Vendor; + WorkCenter: Record "Work Center"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if ProdOrderRoutingLine.Type = ProdOrderRoutingLine.Type::"Work Center" then begin + WorkCenter.Get(ProdOrderRoutingLine."Work Center No."); + if Vendor.Get(WorkCenter."Subcontractor No.") then + Page.Run(Page::"Vendor Card", Vendor); + end; + end; + + /// + /// Returns the total quantity on open purchase order lines linked to the given production order routing line. + /// + /// The production order routing line to sum purchase order quantities for. + /// The sum of Quantity on matching open purchase order lines. + procedure GetPurchOrderQtyFromRoutingLine(ProdOrderRoutingLine: Record "Prod. Order Routing Line"): Decimal + var + PurchaseLine: Record "Purchase Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(0); + +#endif + PurchaseLine.SetRange(PurchaseLine."Document Type", PurchaseLine."Document Type"::Order); + PurchaseLine.SetRange(PurchaseLine."Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + PurchaseLine.SetRange(PurchaseLine."Routing Reference No.", ProdOrderRoutingLine."Routing Reference No."); + PurchaseLine.SetRange(PurchaseLine."Operation No.", ProdOrderRoutingLine."Operation No."); + PurchaseLine.CalcSums(PurchaseLine.Quantity); + exit(PurchaseLine.Quantity); + end; + + /// + /// Opens the Purchase Lines page filtered to open purchase lines linked to the given production order routing line. + /// + /// The production order routing line to filter purchase lines by. + procedure ShowPurchaseOrderLinesFromRouting(ProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + PurchaseLine: Record "Purchase Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + PurchaseLine.SetRange(PurchaseLine."Document Type", PurchaseLine."Document Type"::Order); + PurchaseLine.SetRange(PurchaseLine."Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + PurchaseLine.SetRange(PurchaseLine."Routing Reference No.", ProdOrderRoutingLine."Routing Reference No."); + PurchaseLine.SetRange(PurchaseLine."Operation No.", ProdOrderRoutingLine."Operation No."); + + Page.Run(Page::"Purchase Lines", PurchaseLine); + end; + + /// + /// Returns the total received quantity on purchase receipt lines linked to the given production order routing line. + /// + /// The production order routing line to sum received quantities for. + /// The sum of Quantity on matching purchase receipt lines. + procedure GetPurchReceiptQtyFromRoutingLine(ProdOrderRoutingLine: Record "Prod. Order Routing Line"): Decimal + var + PurchRcptLine: Record "Purch. Rcpt. Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(0); + +#endif + PurchRcptLine.SetRange(PurchRcptLine."Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + PurchRcptLine.SetRange(PurchRcptLine."Routing Reference No.", ProdOrderRoutingLine."Routing Reference No."); + PurchRcptLine.SetRange(PurchRcptLine."Operation No.", ProdOrderRoutingLine."Operation No."); + PurchRcptLine.CalcSums(PurchRcptLine.Quantity); + exit(PurchRcptLine.Quantity); + end; + + /// + /// Opens the Purch. Receipt Lines page filtered to receipt lines linked to the given production order routing line. + /// + /// The production order routing line to filter receipt lines by. + procedure ShowPurchaseReceiptLinesFromRouting(ProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + PurchRcptLine: Record "Purch. Rcpt. Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + PurchRcptLine.SetRange(PurchRcptLine."Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + PurchRcptLine.SetRange(PurchRcptLine."Routing Reference No.", ProdOrderRoutingLine."Routing Reference No."); + PurchRcptLine.SetRange(PurchRcptLine."Operation No.", ProdOrderRoutingLine."Operation No."); + + Page.Run(Page::"Purch. Receipt Lines", PurchRcptLine); + end; + + /// + /// Returns the total invoiced quantity on purchase invoice lines linked to the given production order routing line. + /// + /// The production order routing line to sum invoiced quantities for. + /// The sum of Quantity on matching purchase invoice lines. + procedure GetPurchInvoicedQtyFromRoutingLine(ProdOrderRoutingLine: Record "Prod. Order Routing Line"): Decimal + var + PurchInvLine: Record "Purch. Inv. Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(0); + +#endif + PurchInvLine.SetRange(PurchInvLine."Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + PurchInvLine.SetRange(PurchInvLine."Routing Reference No.", ProdOrderRoutingLine."Routing Reference No."); + PurchInvLine.SetRange(PurchInvLine."Operation No.", ProdOrderRoutingLine."Operation No."); + PurchInvLine.CalcSums(PurchInvLine.Quantity); + exit(PurchInvLine.Quantity); + end; + + /// + /// Opens the Posted Purchase Invoice Lines page filtered to invoice lines linked to the given production order routing line. + /// + /// The production order routing line to filter invoice lines by. + procedure ShowPurchaseInvoiceLinesFromRouting(ProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + PurchInvLine: Record "Purch. Inv. Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + PurchInvLine.SetCurrentKey(PurchInvLine.Type, PurchInvLine."Prod. Order No.", PurchInvLine."Prod. Order Line No."); + PurchInvLine.SetRange(PurchInvLine."Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + PurchInvLine.SetRange(PurchInvLine."Routing Reference No.", ProdOrderRoutingLine."Routing Reference No."); + PurchInvLine.SetRange(PurchInvLine."Operation No.", ProdOrderRoutingLine."Operation No."); + + Page.Run(Page::"Posted Purchase Invoice Lines", PurchInvLine); + end; + + /// + /// Returns the number of outbound subcontracting transfer lines linked to the given production order routing line. + /// + /// The production order routing line to count transfer lines for. + /// The count of matching outbound transfer lines. + procedure GetNoOfTransferLinesFromRouting(ProdOrderRoutingLine: Record "Prod. Order Routing Line"): Decimal + var + TransferLine: Record "Transfer Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(0); + +#endif + TransferLine.SetCurrentKey(TransferLine."Subc. Prod. Order No.", TransferLine."Subc. Prod. Order Line No.", TransferLine."Subc. Routing Reference No.", TransferLine."Subc. Routing No.", TransferLine."Subc. Operation No."); + TransferLine.SetRange(TransferLine."Subc. Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + TransferLine.SetRange(TransferLine."Subc. Routing Reference No.", ProdOrderRoutingLine."Routing Reference No."); + TransferLine.SetRange(TransferLine."Subc. Routing No.", ProdOrderRoutingLine."Routing No."); + TransferLine.SetRange(TransferLine."Subc. Operation No.", ProdOrderRoutingLine."Operation No."); + TransferLine.SetRange("Subc. Return Order", false); + TransferLine.SetRange("Derived From Line No.", 0); + exit(TransferLine.Count()); + end; + + /// + /// Returns the number of return subcontracting transfer lines linked to the given production order routing line. + /// + /// The production order routing line to count return transfer lines for. + /// The count of matching return transfer lines. + procedure GetNoOfReturnTransferLinesFromRouting(ProdOrderRoutingLine: Record "Prod. Order Routing Line"): Decimal + var + TransferLine: Record "Transfer Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(0); + +#endif + TransferLine.SetCurrentKey(TransferLine."Subc. Prod. Order No.", TransferLine."Subc. Prod. Order Line No.", TransferLine."Subc. Routing Reference No.", TransferLine."Subc. Operation No."); + TransferLine.SetRange(TransferLine."Subc. Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + TransferLine.SetRange(TransferLine."Subc. Routing Reference No.", 0); + TransferLine.SetRange(TransferLine."Subc. Operation No.", ''); + TransferLine.SetRange("Derived From Line No.", 0); + TransferLine.SetRange("Subc. Return Order", true); + exit(TransferLine.Count()); + end; + + /// + /// Opens the Transfer Lines page filtered to outbound subcontracting transfer lines for the given production order routing line. + /// + /// The production order routing line to filter transfer lines by. + procedure ShowTransferLinesFromRouting(ProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + TransferLine: Record "Transfer Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + TransferLine.SetCurrentKey(TransferLine."Subc. Prod. Order No.", TransferLine."Subc. Prod. Order Line No.", TransferLine."Subc. Routing Reference No.", TransferLine."Subc. Routing No.", TransferLine."Subc. Operation No."); + TransferLine.SetRange(TransferLine."Subc. Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + TransferLine.SetRange(TransferLine."Subc. Routing Reference No.", ProdOrderRoutingLine."Routing Reference No."); + TransferLine.SetRange(TransferLine."Subc. Routing No.", ProdOrderRoutingLine."Routing No."); + TransferLine.SetRange(TransferLine."Subc. Operation No.", ProdOrderRoutingLine."Operation No."); + TransferLine.SetRange("Derived From Line No.", 0); + Page.Run(Page::"Transfer Lines", TransferLine); + end; + + /// + /// Opens the Transfer Lines page filtered to return subcontracting transfer lines for the given production order routing line. + /// + /// The production order routing line to filter return transfer lines by. + procedure ShowReturnTransferLinesFromRouting(ProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + TransferLine: Record "Transfer Line"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + TransferLine.SetCurrentKey(TransferLine."Subc. Prod. Order No.", TransferLine."Subc. Prod. Order Line No.", TransferLine."Subc. Routing Reference No.", TransferLine."Subc. Operation No."); + TransferLine.SetRange(TransferLine."Subc. Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + TransferLine.SetRange(TransferLine."Subc. Routing Reference No.", 0); + TransferLine.SetRange(TransferLine."Subc. Operation No.", ''); + TransferLine.SetRange("Derived From Line No.", 0); + Page.Run(Page::"Transfer Lines", TransferLine); + end; + + /// + /// Returns the number of production order components linked via routing link code to the given production order routing line. + /// + /// The production order routing line to count linked components for. + /// The count of matching production order components, or 0 if the routing link code is empty. + procedure GetNoOfLinkedComponentsFromRouting(ProdOrderRoutingLine: Record "Prod. Order Routing Line"): Integer + var + ProdOrderComponent: Record "Prod. Order Component"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit(0); + +#endif + if ProdOrderRoutingLine."Routing Link Code" = '' then + exit(0); + ProdOrderComponent.SetRange(ProdOrderComponent.Status, ProdOrderRoutingLine.Status); + ProdOrderComponent.SetRange(ProdOrderComponent."Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + ProdOrderComponent.SetRange(ProdOrderComponent."Prod. Order Line No.", ProdOrderRoutingLine."Routing Reference No."); + ProdOrderComponent.SetRange(ProdOrderComponent."Routing Link Code", ProdOrderRoutingLine."Routing Link Code"); + exit(ProdOrderComponent.Count()); + end; + + /// + /// Opens the Subc. Prod. Order Components page filtered to components linked to the given production order routing line. + /// + /// The production order routing line to filter production order components by. + procedure ShowProdOrderComponents(ProdOrderRoutingLine: Record "Prod. Order Routing Line") + var + ProdOrderComponent: Record "Prod. Order Component"; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + ProdOrderComponent.SetRange(ProdOrderComponent.Status, ProdOrderRoutingLine.Status); + ProdOrderComponent.SetRange(ProdOrderComponent."Prod. Order No.", ProdOrderRoutingLine."Prod. Order No."); + ProdOrderComponent.SetRange(ProdOrderComponent."Prod. Order Line No.", ProdOrderRoutingLine."Routing Reference No."); + ProdOrderComponent.SetRange(ProdOrderComponent."Routing Link Code", ProdOrderRoutingLine."Routing Link Code"); + Page.Run(Page::"Subc. Prod. Order Components", ProdOrderComponent); + end; +} diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingInfoFactbox.Page.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingInfoFactbox.Page.al new file mode 100644 index 0000000000..9b19c32709 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingInfoFactbox.Page.al @@ -0,0 +1,126 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Document; + +page 99001502 "Subc. Routing Info Factbox" +{ + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Routing Details'; + Editable = false; + PageType = CardPart; + RefreshOnActivate = true; + SourceTable = "Prod. Order Routing Line"; + layout + { + area(Content) + { + field(ShowSubcontractor; SubcRoutingFactboxMgmt.GetSubcontractorNo(Rec)) + { + Caption = 'Subcontractor'; + ToolTip = 'Specifies the assigned Subcontractor No. of this Prod. Order Routing Line.'; + trigger OnDrillDown() + begin + ShowSubcontractorFromRouting(); + end; + } + field(ShowQtyInSubcontractingOrder; SubcRoutingFactboxMgmt.GetPurchOrderQtyFromRoutingLine(Rec)) + { + AutoFormatType = 0; + Caption = 'Purch. Order Qty.'; + DecimalPlaces = 0 : 5; + ToolTip = 'Specifies the dependent Quantity in Subcontracting Orders of this Prod. Order Routing Line.'; + trigger OnDrillDown() + begin + ShowPurchaseOrders(); + end; + } + field(ShowQtyShippedRequest; SubcRoutingFactboxMgmt.GetPurchReceiptQtyFromRoutingLine(Rec)) + { + AutoFormatType = 0; + Caption = 'Quantity Received'; + DecimalPlaces = 0 : 5; + ToolTip = 'Specifies the dependent Quantity Received in Subcontracting Receipts of this Prod. Order Routing Line.'; + trigger OnDrillDown() + begin + ShowPurchaseReceipts(); + end; + } + field(ShowQtyInvoicedRequest; SubcRoutingFactboxMgmt.GetPurchInvoicedQtyFromRoutingLine(Rec)) + { + AutoFormatType = 0; + Caption = 'Quantity Invoiced'; + DecimalPlaces = 0 : 5; + ToolTip = 'Specifies the dependent Quantity Invoiced in Subcontracting Invoices of this Prod. Order Routing Line.'; + trigger OnDrillDown() + begin + ShowPurchaseInvoices(); + end; + } + field(ShowNoOfTransferOrdersFromProdOrderComp; SubcPurchFactboxMgmt.ShowTransferOrdersAndReturnOrder(Rec, false, false)) + { + Caption = 'Transfer Order Lines'; + ToolTip = 'Specifies the number of transfer order lines assigned to this routing line.'; + trigger OnDrillDown() + begin + SubcPurchFactboxMgmt.ShowTransferOrdersAndReturnOrder(Rec, true, false); + end; + } + field(ShowNoOfReturnTransferOrdersFromProdOrderComp; SubcPurchFactboxMgmt.ShowTransferOrdersAndReturnOrder(Rec, false, true)) + { + Caption = 'Return Transfer Order Lines'; + ToolTip = 'Specifies the number of Return transfer order lines assigned to this routing line.'; + trigger OnDrillDown() + begin + SubcPurchFactboxMgmt.ShowTransferOrdersAndReturnOrder(Rec, true, true); + end; + } + field(ShowNoOfLinkedComp; SubcRoutingFactboxMgmt.GetNoOfLinkedComponentsFromRouting(Rec)) + { + Caption = 'Components'; + ToolTip = 'Specifies the number of components linked to this routing line.'; + trigger OnDrillDown() + begin + ShowProdOrderComponents(); + end; + } + field("WIP Qty. (Base) at Subc."; Rec."WIP Qty. (Base) at Subc.") + { + } + field("WIP Qty. (Base) in Transit"; Rec."WIP Qty. (Base) in Transit") + { + } + } + } + local procedure ShowSubcontractorFromRouting() + begin + SubcRoutingFactboxMgmt.ShowSubcontractor(Rec); + end; + + local procedure ShowPurchaseOrders() + begin + SubcRoutingFactboxMgmt.ShowPurchaseOrderLinesFromRouting(Rec); + end; + + local procedure ShowPurchaseReceipts() + begin + SubcRoutingFactboxMgmt.ShowPurchaseReceiptLinesFromRouting(Rec); + end; + + local procedure ShowPurchaseInvoices() + begin + SubcRoutingFactboxMgmt.ShowPurchaseInvoiceLinesFromRouting(Rec); + end; + + local procedure ShowProdOrderComponents() + begin + SubcRoutingFactboxMgmt.ShowProdOrderComponents(Rec); + end; + + var + SubcRoutingFactboxMgmt: Codeunit "Subc. Routing Factbox Mgmt."; + SubcPurchFactboxMgmt: Codeunit "Subc. Purch. Factbox Mgmt."; +} diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingLine.TableExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingLine.TableExt.al new file mode 100644 index 0000000000..fd1d98d05d --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingLine.TableExt.al @@ -0,0 +1,118 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Capacity; +using Microsoft.Manufacturing.Routing; +using Microsoft.Manufacturing.WorkCenter; + +tableextension 99001560 "Subc. Routing Line" extends "Routing Line" +{ + AllowInCustomizations = AsReadWrite; + fields + { + modify(Type) + { + trigger OnAfterValidate() +#if not CLEAN28 + var +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; + +#endif + if Type = xRec.Type then + exit; + + if Type <> "Capacity Type"::"Work Center" then + "Transfer WIP Item" := false; + end; + } + modify("No.") + { + trigger OnAfterValidate() + var + WorkCenter: Record "Work Center"; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if "No." = xRec."No." then + exit; + if Type <> "Capacity Type"::"Work Center" then begin + "Transfer WIP Item" := false; + exit; + end; + WorkCenter.SetLoadFields("Subcontractor No."); + WorkCenter.Get("No."); + if WorkCenter."Subcontractor No." = '' then + "Transfer WIP Item" := false; + end; + } + field(99001551; Subcontracting; Boolean) + { + AllowInCustomizations = AsReadOnly; + CalcFormula = exist("Work Center" where("No." = field("Work Center No."), + "Subcontractor No." = filter(<> ''))); + Caption = 'Subcontracting'; + Editable = false; + FieldClass = FlowField; + ToolTip = 'Specifies whether the Work Center Group is set up with a Vendor for Subcontracting.'; + } + field(99001560; "Transfer WIP Item"; Boolean) + { + Caption = 'Transfer WIP Item'; + DataClassification = CustomerContent; + ToolTip = 'Specifies whether the production order parent item (WIP item) is transferred to the subcontractor for this operation.'; + + trigger OnValidate() + var +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if "Transfer WIP Item" then begin + CalcFields(Subcontracting); + TestField(Subcontracting, true); + end; + end; + } + field(99001561; "Transfer Description"; Text[100]) + { + Caption = 'Transfer Description'; + DataClassification = CustomerContent; + ToolTip = 'Specifies the operation-specific description used on transfer orders for the semi-finished item as it is shipped to the subcontracting location. If empty, the standard description is used.'; + } + field(99001562; "Transfer Description 2"; Text[50]) + { + Caption = 'Transfer Description 2'; + DataClassification = CustomerContent; + ToolTip = 'Specifies an additional operation-specific description line used on transfer orders for the semi-finished item as it is shipped to the subcontracting location.'; + } + } +} diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingLines.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingLines.PageExt.al new file mode 100644 index 0000000000..6e3bf00d92 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingLines.PageExt.al @@ -0,0 +1,136 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Routing; + +pageextension 99001508 "Subc. Routing Lines" extends "Routing Lines" +{ + layout + { + modify("No.") + { + trigger OnAfterValidate() + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; +#endif + UpdateWIPEnabled(); + end; + } + modify(Type) + { + trigger OnAfterValidate() + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; +#endif + UpdateWIPEnabled(); + end; + } + addafter("Send-Ahead Quantity") + { + field("Transfer WIP Item"; Rec."Transfer WIP Item") + { + ApplicationArea = Subcontracting; + Enabled = TransferWIPItemEnabled; + } + field("Transfer Description"; Rec."Transfer Description") + { + ApplicationArea = Subcontracting; + Enabled = Rec."Transfer WIP Item"; + } + field("Transfer Description 2"; Rec."Transfer Description 2") + { + ApplicationArea = Subcontracting; + Enabled = Rec."Transfer WIP Item"; + Visible = false; + } + } + } + actions + { + addafter("&Quality Measures") + { + action("Subc. Prices") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Prices'; + Image = Price; + ToolTip = 'View the related subcontracting prices.'; + + trigger OnAction() + begin + ShowRelatedSubcontractorPrices(); + end; + } + } + } + +#if not CLEAN28 + trigger OnOpenPage() + begin +#pragma warning disable AL0432 + SubcontractingEnabled := SubcFeatureFlagHandler.IsSubcontractingEnabled(); +#pragma warning restore AL0432 + end; +#endif + + trigger OnAfterGetRecord() + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; + +#endif + UpdateWIPEnabled(); + end; + + trigger OnAfterGetCurrRecord() + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; + +#endif + UpdateWIPEnabled(); + end; + + var +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 + SubcontractingEnabled: Boolean; +#endif + TransferWIPItemEnabled: Boolean; + + local procedure UpdateWIPEnabled() + begin + Rec.Calcfields(Subcontracting); + TransferWIPItemEnabled := Rec.Subcontracting; + end; + + procedure ShowRelatedSubcontractorPrices() + var + SubcontractorPrice: Record "Subcontractor Price"; + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; + +#endif + Rec.TestField(Type, Rec.Type::"Work Center"); + SubcontractorPrice.SetRange("Work Center No.", Rec."No."); + if Rec."Standard Task Code" <> '' then + SubcontractorPrice.SetRange("Standard Task Code", Rec."Standard Task Code") + else + SubcontractorPrice.SetRange("Standard Task Code"); + + Page.Run(Page::"Subcontractor Prices", SubcontractorPrice); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingVersionLines.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingVersionLines.PageExt.al new file mode 100644 index 0000000000..dcbbfff831 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcRoutingVersionLines.PageExt.al @@ -0,0 +1,129 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.Routing; + +pageextension 99001509 "Subc. Routing Version Lines" extends "Routing Version Lines" +{ + layout + { + modify("No.") + { + trigger OnAfterValidate() + begin + UpdateWIPEnabled(); + end; + } + modify(Type) + { + trigger OnAfterValidate() + begin + UpdateWIPEnabled(); + end; + } + addafter(Description) + { + field("Transfer WIP Item"; Rec."Transfer WIP Item") + { + ApplicationArea = Subcontracting; + Enabled = TransferWIPItemEnabled; + ToolTip = 'Specifies whether a WIP item should be transferred for this subcontracting routing line.'; + } + field("Transfer Description"; Rec."Transfer Description") + { + ApplicationArea = Subcontracting; + Enabled = Rec."Transfer WIP Item"; + ToolTip = 'Specifies the description of the WIP item to transfer.'; + } + field("Transfer Description 2"; Rec."Transfer Description 2") + { + ApplicationArea = Subcontracting; + Enabled = Rec."Transfer WIP Item"; + ToolTip = 'Specifies an additional description of the WIP item to transfer.'; + } + } + } + actions + { + addafter("Quality Measures") + { + action("Subc. Prices") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting Prices'; + Image = Price; + ToolTip = 'View the related subcontracting prices.'; + + trigger OnAction() + begin + ShowRelatedSubcontractorPrices(); + end; + } + } + } + +#if not CLEAN28 + trigger OnOpenPage() + begin +#pragma warning disable AL0432 + SubcontractingEnabled := SubcFeatureFlagHandler.IsSubcontractingEnabled(); +#pragma warning restore AL0432 + if not SubcontractingEnabled then + exit; + end; +#endif + + trigger OnAfterGetRecord() + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; +#endif + UpdateWIPEnabled(); + end; + + trigger OnAfterGetCurrRecord() + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; +#endif + UpdateWIPEnabled(); + end; + + var +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 + SubcontractingEnabled: Boolean; +#endif + TransferWIPItemEnabled: Boolean; + + local procedure UpdateWIPEnabled() + begin + Rec.Calcfields(Subcontracting); + TransferWIPItemEnabled := Rec.Subcontracting; + end; + + procedure ShowRelatedSubcontractorPrices() + var + SubcontractorPrice: Record "Subcontractor Price"; + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; +#endif + Rec.TestField(Type, Rec.Type::"Work Center"); + SubcontractorPrice.SetRange("Work Center No.", Rec."No."); + if Rec."Standard Task Code" <> '' then + SubcontractorPrice.SetRange("Standard Task Code", Rec."Standard Task Code") + else + SubcontractorPrice.SetRange("Standard Task Code"); + + Page.Run(Page::"Subcontractor Prices", SubcontractorPrice); + end; +} diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcWorkCenterCard.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcWorkCenterCard.PageExt.al new file mode 100644 index 0000000000..cfcd353b6c --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcWorkCenterCard.PageExt.al @@ -0,0 +1,86 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.WorkCenter; + +pageextension 99001506 "Subc. Work Center Card" extends "Work Center Card" +{ + layout + { + modify("Subcontractor No.") + { + trigger OnAfterValidate() + begin + CurrPage.Update(false); + end; + } + } + actions + { + addafter("Pla&nning") + { + group(Subcontracting) + { + Caption = 'Subcontracting'; + Image = SubcontractingWorksheet; + + action("Subcontractor Prices") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontractor Prices'; + Enabled = IsSubcontractingWorkCenter; + Image = Price; + RunObject = page "Subcontractor Prices"; + RunPageLink = "Work Center No." = field("No."); + RunPageView = sorting("Vendor No.", "Item No.", "Standard Task Code", "Work Center No.", "Variant Code", "Starting Date", "Unit of Measure Code", "Minimum Quantity", "Currency Code"); + ToolTip = 'Set up different prices for the work center and vendor in subcontracting.'; + } + action("WIP Ledger Entries") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting WIP Entries'; + Enabled = IsSubcontractingWorkCenter; + Image = LedgerEntries; + RunObject = page "Subc. WIP Ledger Entries"; + RunPageLink = "Work Center No." = field("No."); + ToolTip = 'View the Subcontracting WIP Entries that track work-in-progress quantities at this work center''s subcontracting location.'; + } + } + } + modify("Subcontractor - Dispatch List") + { + Enabled = IsSubcontractingWorkCenter; + } + } + + trigger OnOpenPage() + begin +#if not CLEAN28 +#pragma warning disable AL0432 + SubcontractingEnabled := SubcFeatureFlagHandler.IsSubcontractingEnabled(); +#pragma warning restore AL0432 +#endif + end; + + trigger OnAfterGetCurrRecord() + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; + +#endif + IsSubcontractingWorkCenter := Rec."Subcontractor No." <> ''; + end; + + var +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 + SubcontractingEnabled: Boolean; +#endif + IsSubcontractingWorkCenter: Boolean; +} diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcWorkCenterExtension.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcWorkCenterExtension.Codeunit.al new file mode 100644 index 0000000000..c252f3044a --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcWorkCenterExtension.Codeunit.al @@ -0,0 +1,35 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.WorkCenter; + +codeunit 99001519 "Subc. Work Center Extension" +{ + [EventSubscriber(ObjectType::Table, Database::"Work Center", OnAfterDeleteEvent, '', false, false)] + local procedure OnAfterDeleteWorkCenter(var Rec: Record "Work Center"; RunTrigger: Boolean) + var + SubcontractorPrice: Record "Subcontractor Price"; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary() then + exit; + + if not RunTrigger then + exit; + + SubcontractorPrice.DeletePricesForWorkCenter(Rec."No."); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcWorkCenterList.PageExt.al b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcWorkCenterList.PageExt.al new file mode 100644 index 0000000000..870e6efe6f --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Manufacturing/SubcWorkCenterList.PageExt.al @@ -0,0 +1,76 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Manufacturing.WorkCenter; + +pageextension 99001507 "Subc. Work Center List" extends "Work Center List" +{ + actions + { + addafter("Pla&nning") + { + group(Subcontracting) + { + Caption = 'Subcontracting'; + Image = SubcontractingWorksheet; + action("Subcontractor Prices") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontractor Prices'; + Enabled = IsSubcontractingWorkCenter; + Image = Price; + ToolTip = 'Set up different prices for the work center and vendor in subcontracting.'; + trigger OnAction() + var + SubcontractorPrice: Record "Subcontractor Price"; + SubcontractorPrices: Page "Subcontractor Prices"; + begin + SubcontractorPrice.SetRange("Work Center No.", Rec."No."); + SubcontractorPrices.SetTableView(SubcontractorPrice); + SubcontractorPrices.RunModal(); + end; + } + action("WIP Ledger Entries") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting WIP Entries'; + Image = LedgerEntries; + RunObject = page "Subc. WIP Ledger Entries"; + RunPageLink = "Work Center No." = field("No."); + ToolTip = 'View the Subcontracting WIP Entries that track work-in-progress quantities at this work center''s subcontracting location.'; + } + } + } + } + + trigger OnOpenPage() + begin +#if not CLEAN28 +#pragma warning disable AL0432 + SubcontractingEnabled := SubcFeatureFlagHandler.IsSubcontractingEnabled(); +#pragma warning restore AL0432 +#endif + end; + + trigger OnAfterGetCurrRecord() + begin +#if not CLEAN28 + if not SubcontractingEnabled then + exit; + +#endif + IsSubcontractingWorkCenter := Rec."Subcontractor No." <> ''; + end; + + var +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 + SubcontractingEnabled: Boolean; +#endif + IsSubcontractingWorkCenter: Boolean; +} diff --git a/src/Apps/W1/Subcontracting/App/src/MasterData/SubcItemCard.PageExt.al b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcItemCard.PageExt.al new file mode 100644 index 0000000000..5d99d33d23 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcItemCard.PageExt.al @@ -0,0 +1,27 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Item; + +pageextension 99001518 "Subc. Item Card" extends "Item Card" +{ + actions + { + addafter(PurchPriceLists) + { + action("Subcontractor Prices") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontractor Prices'; + Image = Price; + RunObject = page "Subcontractor Prices"; + RunPageLink = "Item No." = field("No."); + RunPageView = sorting("Vendor No.", "Item No.", "Standard Task Code", "Work Center No.", "Variant Code", "Starting Date", "Unit of Measure Code", "Minimum Quantity", "Currency Code"); + ToolTip = 'Set up different prices for the item in subcontracting.'; + } + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/MasterData/SubcItemExtension.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcItemExtension.Codeunit.al new file mode 100644 index 0000000000..a1b9ce4cfc --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcItemExtension.Codeunit.al @@ -0,0 +1,35 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Item; + +codeunit 99001532 "Subc. Item Extension" +{ + [EventSubscriber(ObjectType::Table, Database::Item, OnAfterDeleteEvent, '', false, false)] + local procedure OnAfterDeleteItem(var Rec: Record Item; RunTrigger: Boolean) + var + SubcontractorPrice: Record "Subcontractor Price"; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary() then + exit; + + if not RunTrigger then + exit; + + SubcontractorPrice.DeletePricesForItem(Rec."No."); + end; +} diff --git a/src/Apps/W1/Subcontracting/App/src/MasterData/SubcItemJournalLineExt.TableExt.al b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcItemJournalLineExt.TableExt.al new file mode 100644 index 0000000000..55d3d6ff29 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcItemJournalLineExt.TableExt.al @@ -0,0 +1,49 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Journal; +using Microsoft.Purchases.Document; + +tableextension 99001508 "Subc. Item Journal Line Ext." extends "Item Journal Line" +{ + AllowInCustomizations = AsReadOnly; + fields + { + field(99001510; "Subc. Prod. Order No."; Code[20]) + { + Caption = 'Subc. Prod. Order No.'; + DataClassification = CustomerContent; + } + field(99001511; "Subc. Prod. Order Line No."; Integer) + { + Caption = 'Subc. Prod. Order Line No.'; + DataClassification = CustomerContent; + } + field(99001512; "Subc. Purch. Order No."; Code[20]) + { + Caption = 'Subc. Purch. Order No.'; + DataClassification = CustomerContent; + TableRelation = "Purchase Header"."No." where("Document Type" = const(Order)); + } + field(99001513; "Subc. Purch. Order Line No."; Integer) + { + Caption = 'Subc. Purch. Order Line No.'; + DataClassification = CustomerContent; + TableRelation = "Purchase Line"."Line No." where("Document Type" = const(Order), + "Document No." = field("Subc. Purch. Order No.")); + } + field(99001514; "Subc. Operation No."; Code[10]) + { + Caption = 'Operation No.'; + DataClassification = CustomerContent; + } + field(99001542; "Subc. Item Charge Assign."; Boolean) + { + Caption = 'Subc. Item Charge Assignment'; + DataClassification = CustomerContent; + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/MasterData/SubcItemList.PageExt.al b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcItemList.PageExt.al new file mode 100644 index 0000000000..8e233b9ec0 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcItemList.PageExt.al @@ -0,0 +1,39 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Item; + +pageextension 99001519 "Subc. Item List" extends "Item List" +{ + actions + { + addafter(PurchPriceLists) + { + action("Subcontractor Prices") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontractor Prices'; + Image = Price; + RunObject = page "Subcontractor Prices"; + RunPageLink = "Item No." = field("No."); + RunPageView = sorting("Vendor No.", "Item No.", "Standard Task Code", "Work Center No.", "Variant Code", "Starting Date", "Unit of Measure Code", "Minimum Quantity", "Currency Code"); + ToolTip = 'Set up different prices for the item in subcontracting.'; + } + } + addlast(History) + { + action("WIP Ledger Entries") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontracting WIP Entries'; + Image = LedgerEntries; + RunObject = page "Subc. WIP Ledger Entries"; + RunPageLink = "Item No." = field("No."); + ToolTip = 'View the Subcontracting WIP Entries that track work-in-progress quantities for this item across subcontracting locations.'; + } + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/MasterData/SubcVendor.TableExt.al b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcVendor.TableExt.al new file mode 100644 index 0000000000..39122891f8 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcVendor.TableExt.al @@ -0,0 +1,75 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Inventory.Location; +using Microsoft.Manufacturing.WorkCenter; +using Microsoft.Purchases.Vendor; + +tableextension 99001507 "Subc. Vendor" extends Vendor +{ + AllowInCustomizations = AsReadOnly; + fields + { + field(99001515; "Subc. Location Code"; Code[10]) + { + Caption = 'Subcontracting Location Code'; + DataClassification = CustomerContent; + TableRelation = Location where("Use As In-Transit" = const(false)); + trigger OnValidate() + var + Location: Record Location; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + ErrorInfo: ErrorInfo; + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if "Subc. Location Code" = '' then + exit; + Location.Get("Subc. Location Code"); + if Location."Bin Mandatory" or Location."Require Pick" or Location."Require Put-away" or Location."Require Receive" or Location."Require Shipment" then begin + ErrorInfo.Title := CannotUseLocationLbl; + ErrorInfo.Message := StrSubstNo(BinWarehouseEnabledOnLocationErr, "Subc. Location Code"); + ErrorInfo.Verbosity := ErrorInfo.Verbosity::Error; + ErrorInfo.PageNo := Page::"Location Card"; + ErrorInfo.RecordId := Location.RecordId; + ErrorInfo.AddNavigationAction(ShowLocationCardLbl); + Error(ErrorInfo); + end; + end; + } + field(99001516; "Subc. Linked to Work Center"; Boolean) + { + CalcFormula = exist("Work Center" where("Subcontractor No." = field("No."))); + Caption = 'Linked to Work Center'; + Editable = false; + FieldClass = FlowField; + } + field(99001517; "Subc. Work Center No."; Code[20]) + { + Caption = 'Work Center No.'; + DataClassification = CustomerContent; + TableRelation = "Work Center" where("Subcontractor No." = field("No.")); + } + } + + keys + { + key(SubcLocationCode; "Subc. Location Code") { } + } + + var + CannotUseLocationLbl: Label 'Cannot use the location for subcontracting'; + ShowLocationCardLbl: Label 'Show Location Card'; + BinWarehouseEnabledOnLocationErr: Label 'Location %1 cannot be used as a subcontracting location because Bin Mandatory or warehouse handling is enabled on the location.', Comment = '%1 = Location Code'; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/MasterData/SubcVendorCard.PageExt.al b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcVendorCard.PageExt.al new file mode 100644 index 0000000000..9c6585a2a8 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcVendorCard.PageExt.al @@ -0,0 +1,43 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Purchases.Vendor; + +pageextension 99001516 "Subc. Vendor Card" extends "Vendor Card" +{ + layout + { + addafter("Location Code") + { + field("Subc. Location Code"; Rec."Subc. Location Code") + { + ApplicationArea = Subcontracting; + ToolTip = 'Specifies the subcontracting location where items from the vendor must be received by default after having performed an outside work.'; + } + field("Subc. Linked to Work Center"; Rec."Subc. Linked to Work Center") + { + ApplicationArea = Subcontracting; + ToolTip = 'Specifies if a work center is related to the vendor.'; + } + } + } + actions + { + addafter("Prepa&yment Percentages") + { + action("Subcontractor Prices") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontractor Prices'; + Image = Price; + RunObject = page "Subcontractor Prices"; + RunPageLink = "Vendor No." = field("No."); + RunPageView = sorting("Vendor No.", "Item No.", "Standard Task Code", "Work Center No.", "Variant Code", "Starting Date", "Unit of Measure Code", "Minimum Quantity", "Currency Code"); + ToolTip = 'Set up different prices for the vendor in subcontracting.'; + } + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/MasterData/SubcVendorExtension.Codeunit.al b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcVendorExtension.Codeunit.al new file mode 100644 index 0000000000..1108624a31 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcVendorExtension.Codeunit.al @@ -0,0 +1,35 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Purchases.Vendor; + +codeunit 99001531 "Subc. Vendor Extension" +{ + [EventSubscriber(ObjectType::Table, Database::Vendor, OnAfterDeleteEvent, '', false, false)] + local procedure OnAfterDeleteVendor(var Rec: Record Vendor; RunTrigger: Boolean) + var + SubcontractorPrice: Record "Subcontractor Price"; +#if not CLEAN28 +#pragma warning disable AL0432 + SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler"; +#pragma warning restore AL0432 +#endif + begin +#if not CLEAN28 +#pragma warning disable AL0432 + if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then +#pragma warning restore AL0432 + exit; +#endif + if Rec.IsTemporary() then + exit; + + if not RunTrigger then + exit; + + SubcontractorPrice.DeletePricesForVendor(Rec."No."); + end; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/MasterData/SubcVendorList.PageExt.al b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcVendorList.PageExt.al new file mode 100644 index 0000000000..00ac3b4e54 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/MasterData/SubcVendorList.PageExt.al @@ -0,0 +1,27 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using Microsoft.Purchases.Vendor; + +pageextension 99001517 "Subc. Vendor List" extends "Vendor List" +{ + actions + { + addafter("Prepa&yment Percentages") + { + action("Subcontractor Prices") + { + ApplicationArea = Subcontracting; + Caption = 'Subcontractor Prices'; + Image = Price; + RunObject = page "Subcontractor Prices"; + RunPageLink = "Vendor No." = field("No."); + RunPageView = sorting("Vendor No.", "Item No.", "Standard Task Code", "Work Center No.", "Variant Code", "Starting Date", "Unit of Measure Code", "Minimum Quantity", "Currency Code"); + ToolTip = 'Set up different prices for the vendor in subcontracting.'; + } + } + } +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Permissions/D365BasicSubcontracting.PermissionSetExt.al b/src/Apps/W1/Subcontracting/App/src/Permissions/D365BasicSubcontracting.PermissionSetExt.al new file mode 100644 index 0000000000..2de90c35de --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Permissions/D365BasicSubcontracting.PermissionSetExt.al @@ -0,0 +1,12 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using System.Security.AccessControl; + +permissionsetextension 99001502 "D365 BASIC - Subcontracting" extends "D365 BASIC" +{ + IncludedPermissionSets = "Subcontract. - Read"; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Permissions/D365BusFullAccessSubcontracting.PermissionSetExt.al b/src/Apps/W1/Subcontracting/App/src/Permissions/D365BusFullAccessSubcontracting.PermissionSetExt.al new file mode 100644 index 0000000000..86a171820c --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Permissions/D365BusFullAccessSubcontracting.PermissionSetExt.al @@ -0,0 +1,12 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using System.Security.AccessControl; + +permissionsetextension 99001501 "D365 BUS FULL ACCESS - Subcontracting" extends "D365 BUS FULL ACCESS" +{ + IncludedPermissionSets = "Subcontract. - Edit"; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Permissions/D365ReadSubcontracting.PermissionSetExt.al b/src/Apps/W1/Subcontracting/App/src/Permissions/D365ReadSubcontracting.PermissionSetExt.al new file mode 100644 index 0000000000..b69754142f --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Permissions/D365ReadSubcontracting.PermissionSetExt.al @@ -0,0 +1,12 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +using System.Security.AccessControl; + +permissionsetextension 99001500 "D365 READ - Subcontracting" extends "D365 READ" +{ + IncludedPermissionSets = "Subcontract. - Read"; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractEdit.PermissionSet.al b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractEdit.PermissionSet.al new file mode 100644 index 0000000000..871f4ad41e --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractEdit.PermissionSet.al @@ -0,0 +1,18 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +permissionset 99001503 "Subcontract. - Edit" +{ + Caption = 'Subcontracting - Edit'; + Access = Public; + Assignable = true; + + IncludedPermissionSets = "Subcontract. - Read"; + + Permissions = + tabledata "Subcontractor Price" = IMD, + tabledata "Subcontractor WIP Ledger Entry" = IMD; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractObjs.PermissionSet.al b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractObjs.PermissionSet.al new file mode 100644 index 0000000000..78bea29794 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractObjs.PermissionSet.al @@ -0,0 +1,97 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +permissionset 99001501 "Subcontract. - Objs" +{ + Caption = 'Subcontracting - Objects'; + Assignable = true; + Access = Internal; + Permissions = + // Tables + table "Subcontractor Price" = X, + table "Subcontractor WIP Ledger Entry" = X, + + // Codeunits + codeunit "Subc. Session State" = X, + codeunit "Subc. Business Setup Ext." = X, + codeunit "Subc. Calc. Prod. Order Ext." = X, + codeunit "Subc. Calc.StandardCost Ext." = X, + codeunit "Subc. Calc BOM Tree Ext." = X, + codeunit "Subc. Calc Subcontracts Ext." = X, + codeunit "Subc. Carry Out Action Ext." = X, + codeunit "Subc. DirectTransferLine Ext." = X, + codeunit "Subc. Comp. Factbox Mgmt." = X, + codeunit "Subc. ProdO. Factbox Mgmt." = X, + codeunit "Subc. Purch. Factbox Mgmt." = X, + codeunit "Subc. Routing Factbox Mgmt." = X, + codeunit "Subc. ItemChargeAssPurchExt" = X, + codeunit "Subc. Item Extension" = X, + codeunit "Subc. ItemJnlPostLine Ext" = X, + codeunit "Subc. Notification Mgmt." = X, + codeunit "Subc. Planning Comp. Ext." = X, + codeunit "Subc. Planning Line Mgmt Ext." = X, + codeunit "Subc. Price Management" = X, + codeunit "Subc. Prod. Order Comp. Ext." = X, + codeunit "Subc. Prod. Order Rtng. Ext." = X, + codeunit "Subc. Prod. Ord. Comp. Res." = X, + codeunit "Subc. Purch. Post Ext" = X, + codeunit "Subc. Purchase Header Ext" = X, + codeunit "Subc. Purchase Line Ext" = X, + codeunit "Subc. Reporting Triggers Ext" = X, + codeunit "Subc. Req.Line Extension" = X, + codeunit "Subc. Req. Wksh. Make Ord." = X, + codeunit "Subcontracting Comp. Init." = X, + codeunit "Subcontracting Management" = X, + codeunit "Subc. Synchronize Management" = X, + codeunit "Subc. Transfer Header Ext." = X, + codeunit "Subc. Transfer Line Ext." = X, + codeunit "Subc. Transfer Management" = X, + codeunit "Subc. Transfer Rcpt Line Ext." = X, + codeunit "Subc. Transfer Shpt Line Ext." = X, + codeunit "Subc. TransOrderPostRcpt Ext" = X, + codeunit "Subc. TransOrderPostShpt Ext" = X, + codeunit "Subc. TransOrderPostTrans Ext" = X, + codeunit "Subc. Trans Rcpt Header Ext" = X, + codeunit "Subc. Trans Shpt Header Ext" = X, + codeunit "Subc. Vendor Extension" = X, + codeunit "Subc. WhsePostReceipt Ext" = X, + codeunit "Subc. WhsePurchRelease Ext" = X, + codeunit "Subc. Work Center Extension" = X, + codeunit "Subcontracting Install" = X, + codeunit "Subc. Change Prod.Order Status" = X, + codeunit "Subc. Posting Preview Binding" = X, + codeunit "Subc. Posting Preview Subscr." = X, + codeunit "Subc. Pst. Prev. Event Handler" = X, + codeunit "Subc. Purchase Order Creator" = X, + codeunit "Subc. Transfer WIP Posting" = X, + codeunit "Subc. WhsePostShipment Ext" = X, + codeunit "Subc. WIP Item Ledg Find Entry" = X, + codeunit "Subc. Application Area Mgmt." = X, +#if not CLEAN28 +#pragma warning disable AL0432 + codeunit "Subc. Feature Flag Handler" = X, +#pragma warning restore AL0432 +#endif + codeunit "Subc. Upgrade Tag Def. Ext." = X, + codeunit "Subc. Worksheet Handler" = X, + + // Pages + page "Subc. Prod. Order Components" = X, + page "Subc. Subcontracting Worksheet" = X, + page "Subc. Purchase Line Factbox" = X, + page "Subc. Routing Info Factbox" = X, + page "Subc. Transfer Line Factbox" = X, + page "Subcontractor Prices" = X, + page "Subc. WIP Adjustment" = X, + page "Subc. WIP Ledger Entries" = X, + + // Reports + report "Subc. Calculate Subcontracts" = X, + report "Subc. Create Transf. Order" = X, + report "Subc. Create SubCReturnOrder" = X, + report "Subc. Detailed Calculation" = X, + report "Subc. Dispatching List" = X; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractRead.PermissionSet.al b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractRead.PermissionSet.al new file mode 100644 index 0000000000..2bbbecde21 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Permissions/SubcontractRead.PermissionSet.al @@ -0,0 +1,18 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ +namespace Microsoft.Manufacturing.Subcontracting; + +permissionset 99001502 "Subcontract. - Read" +{ + Caption = 'Subcontracting - Read'; + Access = Public; + Assignable = true; + + IncludedPermissionSets = "Subcontract. - Objs"; + + Permissions = + tabledata "Subcontractor Price" = R, + tabledata "Subcontractor WIP Ledger Entry" = R; +} \ No newline at end of file diff --git a/src/Apps/W1/Subcontracting/App/src/Purchase/Rep99001500.SubcDetailedCalculation.rdl b/src/Apps/W1/Subcontracting/App/src/Purchase/Rep99001500.SubcDetailedCalculation.rdl new file mode 100644 index 0000000000..f941688ff9 --- /dev/null +++ b/src/Apps/W1/Subcontracting/App/src/Purchase/Rep99001500.SubcDetailedCalculation.rdl @@ -0,0 +1,5957 @@ + + + 0 + + + + SQL + + + None + 76c8b53c-5c88-4136-be7b-4e803ebab26d + + + + + + + + + + + 1.16906cm + + + 1.40236cm + + + 2.22494cm + + + 1.45001cm + + + 1.5873cm + + + 1.12222cm + + + 1.65001cm + + + 1.95001cm + + + 1.7873cm + + + 1.5873cm + + + 0.95237cm + + + 1.26985cm + + + + + 0.35278cm + + + + + true + true + + + + + =First(Fields!ItemFilterCaption.Value) + + + + + + + Textbox1 + + + 12 + + + + + + + + + + + + + + + + + 0.35278cm + + + + + true + true + + + + + + + + + + + + Textbox2 + + + + + + + + true + true + + + + + + + + + + + + Textbox3 + + + + + + + + true + true + + + + + + + + + + + + Textbox4 + + + + + + + + true + true + + + + + + + + + + + + Textbox5 + + + + + + + + true + true + + + + + + + + + + + + Textbox6 + + + + + + + + true + true + + + + + + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox8 + + + + + + + + true + true + + + + + + + + + + + + Textbox9 + + + + + + + + true + true + + + + + + + + + + + + Textbox10 + + + + + + + + true + true + + + + + + + + + + + + Textbox11 + + + + + + + + true + true + + + + + + + + + + + + Textbox12 + + + + + + + + true + true + + + + + + + + + + + + Textbox13 + + + + + + + + 0.35278cm + + + + + true + true + + + + + =Parameters!No_ItemCaption.Value + + + + + + + Textbox14 + + + 2 + + + + + + + true + true + + + + + + + + + + + + Textbox15 + + + + + + + + true + true + + + + + =Fields!No_Item.Value + + + + + + + Textbox16 + + + Bottom + 5pt + 5pt + + + 5 + + + + + + + + + + true + true + + + + + + + + + + + + Textbox17 + + + + + + + + true + true + + + + + + + + + + + + Textbox18 + + + + + + + + true + true + + + + + + + + + + + + Textbox19 + + + + + + + + true + true + + + + + + + + + + + + Textbox20 + + + + + + + + 0.4064cm + + + + + true + true + + + + + =Parameters!Description_ItemCaption.Value + + + + + + + Textbox21 + + + 3 + + + + + + + + true + true + + + + + =Fields!Description_Item.Value + + + + + + + Textbox22 + + + 6 + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox23 + + + + + + + + true + true + + + + + + + + + + + + Textbox24 + + + + + + + + true + true + + + + + + + + + + + + Textbox25 + + + + + + + + 0.35278cm + + + + + true + true + + + + + =Parameters!ProductionBOMNo_ItemCaption.Value + + + + + + + Textbox26 + + + 3 + + + + + + + + true + true + + + + + =Fields!ProductionBOMNo_Item.Value + + + + + + + Textbox27 + + + 2 + + + + + + + true + true + + + + + =Fields!PBOMVersionCode1.Value + + + + + + + Textbox28 + + + 2 + + + + + + + true + true + + + + + + + + + + + + Textbox29 + + + + + + + + true + true + + + + + + + + + + + + Textbox30 + + + + + + + + true + true + + + + + + + + + + + + Textbox32 + + + + + + + + true + true + + + + + + + + + + + + Textbox34 + + + + + + + + true + true + + + + + + + + + + + + Textbox35 + + + + + + + + 0.35278cm + + + + + true + true + + + + + =Parameters!LotSize_ItemCaption.Value + + + + + + + Textbox36 + + + 3 + + + + + + + + true + true + + + + + =Fields!LotSize_Item.Value + + + + + + + Textbox37 + + + 2 + + + + + + + true + true + + + + + =Fields!BaseUnitOfMeasure_Item.Value + + + + + + 2 + + + + + + + true + true + + + + + + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox40 + + + + + + + + true + true + + + + + + + + + + + + Textbox41 + + + + + + + + true + true + + + + + + + + + + + + Textbox42 + + + + + + + + true + true + + + + + + + + + + + + Textbox43 + + + + + + + + 0.35278cm + + + + + true + true + + + + + =Parameters!RoutingNo_ItemCaption.Value + + + + + + + Textbox44 + + + 3 + + + + + + + + true + true + + + + + =Fields!RoutingNo_Item.Value + + + + + + + Textbox45 + + + 2 + + + + + + + true + true + + + + + =Fields!RtngVersionCode.Value + + + + + + + Textbox46 + + + 2 + + + + + + + true + true + + + + + + + + + + + + Textbox47 + + + + + + + + true + true + + + + + + + + + + + + Textbox48 + + + + + + + + true + true + + + + + + + + + + + + Textbox49 + + + + + + + + true + true + + + + + + + + + + + + Textbox50 + + + + + + + + true + true + + + + + + + + + + + + Textbox51 + + + + + + + + 0.35278cm + + + + + true + true + + + + + + + + + + + + Textbox52 + + + 12 + + + + + + + + + + + + + + + + + 0.35278cm + + + + + true + true + + + + + =Parameters!OperationNo_RtngLineCaption.Value + + + + + + + Textbox53 + + + 2 + + + + + + + true + true + + + + + =Parameters!Type_RtngLineCaption.Value + + + + + + + Textbox54 + + + + + + + + true + true + + + + + =Parameters!No_RtngLineCaption.Value + + + + + + + Textbox55 + + + + + + + + true + true + + + + + =Parameters!Description_ItemCaption.Value + + + + + + + Textbox56 + + + 2 + + + + + + + true + true + + + + + =Parameters!SetupTime_RtngLineCaption.Value + + + + + + + Textbox57 + + + + + + + + true + true + + + + + =Parameters!RunTime_RtngLineCaption.Value + + + + + + + Textbox58 + + + + + + + + true + true + + + + + =Fields!CostTimeCaption.Value + + + + + + + Textbox59 + + + + + + + + true + true + + + + + =Fields!UnitCostCaption.Value + + + + + + + Textbox60 + + + + + + + + true + true + + + + + =Fields!TotalCostCaption.Value + + + + + + + Textbox62 + + + 2 + + + + + + + 0.17638cm + + + + + true + true + + + + + + + + + + + + Textbox63 + + + 12 + + + + + + + + + + + + + + + + + 0.17638cm + + + + + true + true + + + + + + + + + + + + Textbox64 + + + + + + Bottom + 5pt + + + 12 + + + + + + + + + + + + + + + + + 0.35278cm + + + + + true + true + + + + + =Fields!TypeCaption.Value + + + + + + + Textbox65 + + + + + + + + true + true + + + + + =Fields!NoCaption.Value + + + + + + + Textbox66 + + + + + + + + true + true + + + + + =Fields!DescriptionCaption.Value + + + + + + + Textbox67 + + + 2 + + + + + + + true + true + + + + + =Fields!QuantityCaption.Value + + + + + + + Textbox68 + + + + + + + + true + true + + + + + =Fields!BaseUnitOfMeasureCaption.Value + + + + + + + Textbox69 + + + 2 + + + + + + + true + true + + + + + =Fields!UnitCostCaption.Value + + + + + + + Textbox70 + + + + + + + + true + true + + + + + =Fields!TotalCost1Caption.Value + + + + + + + Textbox71 + + + + + + + + true + true + + + + + + + + + + + + Textbox72 + + + + + + + + true + true + + + + + + + + + + + + Textbox73 + + + + + + + + true + true + + + + + + + + + + + + Textbox74 + + + + + + + + 0.17638cm + + + + + true + true + + + + + + + + + + + + Textbox75 + + + 12 + + + + + + + + + + + + + + + + + 0.17638cm + + + + + true + true + + + + + + + + + + + + Textbox77 + + + + + + Bottom + 5pt + + + 12 + + + + + + + + + + + + + + + + + 0.35278cm + + + + + true + true + + + + + =Fields!OperationNo_RtngLine.Value + + + + + + + Textbox78 + + + 2 + + + + + + + true + true + + + + + =Fields!Type_RtngLine.Value + + + + + + + Textbox79 + + + + + + + + true + true + + + + + =Fields!No_RtngLine.Value + + + + + + + Textbox80 + + + + + + + + true + true + + + + + =Fields!Description_RtngLine.Value + + + + + + + Textbox81 + + + 2 + + + + + + + true + true + + + + + =Fields!SetupTime_RtngLine.Value + + + + + + + Textbox82 + + + + + + + + true + true + + + + + =Fields!RunTime_RtngLine.Value + + + + + + + Textbox83 + + + + + + + + true + true + + + + + =Fields!CostTime.Value + + + + + + + Textbox84 + + + + + + + + true + true + + + + + =Fields!ProdUnitCost.Value + + + + + + + Textbox85 + + + + + + + + true + true + + + + + =Fields!ProdTotalCost.Value + + + + + + + Textbox86 + + + 2 + + + + + + + 0.35278cm + + + + + true + true + + + + + =Fields!ProdBOMLineLevelType.Value + + + + + + + Textbox87 + + + + + + + + true + true + + + + + =Fields!ProdBOMLineLevelNo.Value + + + + + + + Textbox88 + + + + + + + + true + true + + + + + =Fields!ProdBOMLineLevelDesc.Value + + + + + + + Textbox89 + + + 2 + + + + + + + true + true + + + + + =Fields!ProdBOMLineLevelQuantity.Value + + + + + + + Textbox90 + + + + + + + + true + true + + + + + =Fields!CompItemBaseUOM.Value + + + + + + + Textbox91 + + + 2 + + + + + + + true + true + + + + + =Fields!CompItemUnitCost.Value + + + + + + + Textbox92 + + + + + + + + true + true + + + + + =Fields!CostTotal.Value + + + + + + + Textbox93 + + + + + + + + true + true + + + + + + + + + + + + Textbox94 + + + + + + + + true + true + + + + + + + + + + + + Textbox95 + + + + + + + + true + true + + + + + + + + + + + + Textbox96 + + + + + + + + 0.17638cm + + + + + true + true + + + + + + + + + + + + Textbox97 + + + 12 + + + + + + + + + + + + + + + + + 0.17638cm + + + + + true + true + + + + + + + + + + + + Textbox98 + + + 8 + + + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox99 + + + + + + Top + 5pt + + + + + + + + true + true + + + + + + + + + + + + Textbox100 + + + 3 + + + + + + + + 0.35278cm + + + + + true + true + + + + + + + + + + + + Textbox101 + + + + + + + + true + true + + + + + + + + + + + + Textbox102 + + + + + + + + true + true + + + + + + + + + + + + Textbox103 + + + + + + + + true + true + + + + + + + + + + + + Textbox104 + + + + + + + + true + true + + + + + + + + + + + + Textbox105 + + + + + + + + true + true + + + + + =Fields!TotalCost1Caption.Value + + + + + + + Textbox106 + + + 3 + + + + + + + + true + true + + + + + =Sum(Fields!CostTotal.Value) + + + + + + + Textbox107 + + + + + + + + true + true + + + + + + + + + Textbox108 + + + + + + + + true + true + + + + + + + + + + + + Textbox109 + + + + + + + + true + true + + + + + + + + + + + + Textbox110 + + + + + + + + 0.17638cm + + + + + true + true + + + + + + + + + + + + Textbox111 + + + + + + + + true + true + + + + + + + + + + + + Textbox112 + + + + + + + + true + true + + + + + + + + + + + + Textbox113 + + + + + + + + true + true + + + + + + + + + + + + Textbox114 + + + + + + + + true + true + + + + + + + + + + + + Textbox115 + + + + + + + + true + true + + + + + + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox117 + + + + + + + + true + true + + + + + + + + + + + + Textbox118 + + + + + + + + true + true + + + + + + + + + + + + Textbox119 + + + + + + + + true + true + + + + + + + + + + + + Textbox120 + + + + + + + + true + true + + + + + + + + + + + + Textbox121 + + + + + + + + true + true + + + + + + + + + + + + Textbox122 + + + + + + + + 0.17638cm + + + + + true + true + + + + + + + + + + + + Textbox123 + + + 11 + + + + + + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox124 + + + + + + Top + 5pt + + + + + + + + 0.35278cm + + + + + true + true + + + + + + + + + Textbox125 + + + 7 + + + + + + + + + + + + true + true + + + + + =First(Fields!TotalCostCaption.Value) + + + + + + + Textbox126 + + + 4 + + + + + + + + + true + true + + + + + =Sum(Fields!ProdTotalCost.Value) + + + + + + + Textbox127 + + + + + + + + 0.35278cm + + + + + true + true + + + + + + + + + Textbox128 + + + 7 + + + + + + + + + + + + true + true + + + + + + + + + Textbox129 + + + + + + + + true + true + + + + + + + + + Textbox130 + + + + + + + + true + true + + + + + + + + + Textbox131 + + + + + + + + true + true + + + + + + + + + Textbox132 + + + + + + + + true + true + + + + + + + + + + + + Textbox133 + + + + + + + + 0.35278cm + + + + + true + true + + + + + + + + + + + + Textbox134 + + + 7 + + + + + + + + + + + + true + true + + + + + =Last(Fields!CostOfProductionCaption.Value) + + + + + + + Textbox135 + + + 4 + + + + + + + + + true + true + + + + + =Sum(Fields!FooterProdTotalCost.Value) + + + + + + + Textbox136 + + + + + + + + 0.35278cm + + + + + true + true + + + + + + + + + + + + Textbox137 + + + 7 + + + + + + + + + + + + true + true + + + + + =Last(Fields!CostOfComponentsCaption.Value) + + + + + + + Textbox138 + + + 4 + + + + + + + + + true + true + + + + + =Sum(Fields!FooterCostTotal.Value) + + + + + + + Textbox139 + + + + + + + + 0.35278cm + + + + + true + true + + + + + + + + + + + + Textbox140 + + + 7 + + + + + + + + + + + + true + true + + + + + =Last(Fields!SingleLevelMfgOverheadCostCaption.Value) + + + + + + + Textbox141 + + + 4 + + + + + + + + + true + true + + + + + =Sum(Fields!SingleLevelMfgOvhd.Value) + + + + + + + Textbox142 + + + + + + + + 0.17638cm + + + + + true + true + + + + + + + + + + + + Textbox143 + + + 7 + + + + + + + + + + + + true + true + + + + + + + + + Textbox144 + + + + + + + + true + true + + + + + + + + + + + + Textbox145 + + + + + + + + true + true + + + + + + + + + Textbox146 + + + + + + + + true + true + + + + + + + + + Textbox147 + + + + + + + + true + true + + + + + + + + + + + + Textbox148 + + + + + + + + 0.17638cm + + + + + true + true + + + + + + + + + + + + Textbox149 + + + 11 + + + + + + + + + + + + + + + + true + true + + + + + + + + + + + + Textbox150 + + + + + + Top + 5pt + + + + + + + + 0.35278cm + + + + + true + true + + + + + + + + + + + + Textbox151 + + + 7 + + + + + + + + + + + + true + true + + + + + + + + + Textbox152 + + + + + + + + true + true + + + + + =Last(Fields!UnitCostCaption.Value) + + + + + + + Textbox153 + + + 3 + + + + + + + + true + true + + + + + =Sum(Fields!UnitCost_Item.Value) + + + + + + + Textbox154 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =iif(Fields!ItemFilter.Value = "",true,false) + + After + true + + + + =iif(Fields!ItemFilter.Value = "",true,false) + + After + true + + + + + =Fields!No_Item.Value + + + End + + + + + After + true + + + After + true + + + After + true + + + After + true + + + After + true + + + After + true + + + + + =Fields!InRouting.Value + + + + + + =iif(Fields!InRouting.Value,false,true) + + After + true + + + + =iif(Fields!InRouting.Value,false,true) + + After + true + + + + =iif(Fields!InRouting.Value,false,true) + + After + + + + + =Fields!InBOM.Value + + + + + + =iif(Fields!InBOM.Value,false,true) + + After + true + + + + =iif(Fields!InBOM.Value,false,true) + + After + true + + + + =iif(Fields!InBOM.Value,false,true) + + After + + + + Detail + + + + + =iif(Fields!OperationNo_RtngLine.Value = "",true,false) + + + + + =iif(Fields!ShowLine.Value,false,true) + + + + Detail_Collection + Output + true + + + + =iif(Fields!TotalCost1Caption.Value = "",true,false) + + Before + + + + =iif(Fields!TotalCost1Caption.Value = "",true,false) + + Before + + + + =iif(Fields!TotalCost1Caption.Value = "",true,false) + + Before + true + + + + =iif(Fields!TotalCostCaption.Value = "",true,false) + + Before + true + + + + =iif(Fields!TotalCostCaption.Value = "",true,false) + + Before + + + + + + =iif(First(Fields!TotalCostCaption.Value) = "",true,false) + + Before + true + + + + =iif(First(Fields!TotalCostCaption.Value) = "",true,false) + + Before + true + + + + + Before + true + + + Before + true + + + Before + true + + + Before + true + + + Before + + + Before + true + + + + + + DataSet_Result + 8.52024cm + 18.15273cm + + + + + + + true + + + + + =Fields!PageNoCaption.Value + + + + + + + 0.3595cm + 12.57817cm + 11pt + 5.10758cm + 1 + + + + true + + + + + =Fields!CalculateDate.Value + + + + + + + true + + + + + =Fields!CompanyName.Value + + + + + + + true + + + + + =Fields!TodayFormatted.Value + + + + + + + 12.50762cm + 11pt + 5.64511cm + 4 + + + + true + true + + + + + =User!UserID + + + + + + + 0.75075cm + 14.41376cm + 11pt + 3.73896cm + 5 + + =iif(Fields!DetailedCalculationCaption.Value = "",true,false) + + NoOutput + + + + + + + + 29.7cm + 21cm + 1.76389cm + 1.05833cm + 1.05833cm + 1.48167cm + 1.27cm +