Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions src/Apps/W1/Subcontracting/App/app.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
Original file line number Diff line number Diff line change
@@ -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
122 changes: 122 additions & 0 deletions src/Apps/W1/Subcontracting/App/src/General/SubcILEntries.PageExt.al
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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.") { }
}
}
Loading
Loading