Page 1003 Job Task Card, source in 29
Source29
src/Layers/W1/BaseApp/Projects/Project/Job/JobTaskCard.Page.al784 lines, Copyright (c) Microsoft Corporation. MIT
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.Projects.Project.Job;
using Microsoft.Assembly.Document;
using Microsoft.CRM.Contact;
using Microsoft.Foundation.Address;
using Microsoft.Foundation.Reporting;
using Microsoft.Inventory.BOM;
using Microsoft.Pricing.Calculation;
using Microsoft.Projects.Project.Planning;
using Microsoft.Sales.Customer;
using Microsoft.Sales.Document;
page 1003 "Job Task Card"
{
Caption = 'Project Task Card';
DataCaptionExpression = Rec.Caption();
PageType = Card;
SourceTable = "Job Task";
layout
{
area(content)
{
group(General)
{
Caption = 'General';
field("Job Task No."; Rec."Job Task No.")
{
ApplicationArea = Jobs;
}
field(Description; Rec.Description)
{
ApplicationArea = Jobs;
}
field("Job Task Type"; Rec."Job Task Type")
{
ApplicationArea = Jobs;
}
field("Sell-to Customer No."; Rec."Sell-to Customer No.")
{
ApplicationArea = Jobs;
Caption = 'Customer No.';
Visible = PerTaskBillingFieldsVisible;
}
field("Sell-to Customer Name"; Rec."Sell-to Customer Name")
{
ApplicationArea = Jobs;
Caption = 'Customer Name';
Importance = Promoted;
NotBlank = true;
Visible = PerTaskBillingFieldsVisible;
trigger OnValidate()
begin
Rec.SelltoCustomerNoOnAfterValidate(Rec, xRec);
CurrPage.Update();
end;
trigger OnLookup(var Text: Text): Boolean
begin
exit(Rec.LookupSellToCustomerName(Text));
end;
}
field("Sell-to Customer Name 2"; Rec."Sell-to Customer Name 2")
{
ApplicationArea = Jobs;
Caption = 'Customer Name 2';
Importance = Additional;
QuickEntry = false;
Visible = PerTaskBillingFieldsVisible;
}
group("Sell-to")
{
Caption = 'Sell-to';
Visible = PerTaskBillingFieldsVisible;
field("Sell-to Address"; Rec."Sell-to Address")
{
ApplicationArea = Jobs;
Caption = 'Address';
Importance = Additional;
QuickEntry = false;
}
field("Sell-to Address 2"; Rec."Sell-to Address 2")
{
ApplicationArea = Jobs;
Caption = 'Address 2';
Importance = Additional;
QuickEntry = false;
}
field("Sell-to City"; Rec."Sell-to City")
{
ApplicationArea = Jobs;
Caption = 'City';
Importance = Additional;
QuickEntry = false;
}
group(Control60)
{
ShowCaption = false;
Visible = IsSellToCountyVisible;
field("Sell-to County"; Rec."Sell-to County")
{
ApplicationArea = Jobs;
CaptionClass = '5,1,' + Rec."Sell-to Country/Region Code";
Importance = Additional;
QuickEntry = false;
}
}
field("Sell-to Post Code"; Rec."Sell-to Post Code")
{
ApplicationArea = Jobs;
Caption = 'Post Code';
Importance = Additional;
QuickEntry = false;
}
field("Sell-to Country/Region Code"; Rec."Sell-to Country/Region Code")
{
ApplicationArea = Jobs;
Caption = 'Country/Region Code';
Importance = Additional;
QuickEntry = false;
trigger OnValidate()
begin
IsSellToCountyVisible := FormatAddress.UseCounty(Rec."Sell-to Country/Region Code");
end;
}
field("Sell-to Contact No."; Rec."Sell-to Contact No.")
{
ApplicationArea = Jobs;
Caption = 'Contact No.';
Importance = Additional;
trigger OnLookup(var Text: Text): Boolean
begin
if not Rec.SelltoContactLookup() then
exit(false);
Text := Rec."Sell-to Contact No.";
SellToContact.Get(Rec."Sell-to Contact No.");
Rec."Sell-to Contact" := SellToContact.Name;
CurrPage.Update();
exit(true);
end;
trigger OnValidate()
begin
SellToContact.Get(Rec."Sell-to Contact No.");
Rec."Sell-to Contact" := SellToContact.Name;
CurrPage.Update();
end;
}
field("Sell-to Contact"; Rec."Sell-to Contact")
{
ApplicationArea = Jobs;
Caption = 'Contact';
Importance = Additional;
Editable = Rec."Sell-to Customer No." <> '';
}
}
field(Totaling; Rec.Totaling)
{
ApplicationArea = Jobs;
}
field("External Document No."; Rec."External Document No.")
{
ApplicationArea = Jobs;
Visible = PerTaskBillingFieldsVisible;
Tooltip = 'Specifies a document number that refers to the customer''s or vendor''s numbering system.';
}
field("Your Reference"; Rec."Your Reference")
{
ApplicationArea = Jobs;
Visible = PerTaskBillingFieldsVisible;
Tooltip = 'Specifies the customer''s reference. The content will be printed on sales documents.';
}
field("New Page"; Rec."New Page")
{
ApplicationArea = Jobs;
}
field("No. of Blank Lines"; Rec."No. of Blank Lines")
{
ApplicationArea = Jobs;
}
}
part(JobPlanningLines; "Job Planning Lines Part")
{
ApplicationArea = Jobs;
SubPageLink = "Job No." = field("Job No."),
"Job Task No." = field("Job Task No.");
}
group(Posting)
{
Caption = 'Posting';
field("Job Posting Group"; Rec."Job Posting Group")
{
ApplicationArea = Jobs;
}
field("WIP Method"; Rec."WIP Method")
{
ApplicationArea = Jobs;
ToolTip = 'Specifies the method that is used to calculate the value of work in process for the project.';
}
field("Location Code"; Rec."Location Code")
{
ApplicationArea = Jobs;
}
field("Bin Code"; Rec."Bin Code")
{
ApplicationArea = Jobs;
}
}
group("Invoice and Shipping")
{
Caption = 'Invoice and Shipping';
Visible = PerTaskBillingFieldsVisible;
group("Bill-to")
{
Caption = 'Bill-to';
field(BillToOptions; BillToOptions)
{
ApplicationArea = Jobs;
Caption = 'Bill-to';
ToolTip = 'Specifies the customer that the sales invoice will be sent to. Default (Customer): The same as the customer on the sales invoice. Another Customer: Any customer that you specify in the fields below.';
trigger OnValidate()
begin
if BillToOptions = BillToOptions::"Default (Customer)" then begin
Rec.Validate("Bill-to Customer No.", Rec."Sell-to Customer No.");
Rec.Validate("Bill-to Contact No.", Rec."Sell-to Contact No.");
end;
UpdateBillToInformationEditable();
end;
}
group(Control205)
{
ShowCaption = false;
Visible = not (BillToOptions = BillToOptions::"Default (Customer)");
field("Bill-to Customer No."; Rec."Bill-to Customer No.")
{
ApplicationArea = Jobs;
Importance = Promoted;
Visible = false;
trigger OnValidate()
begin
CurrPage.Update();
end;
}
field("Bill-to Name"; Rec."Bill-to Name")
{
Caption = 'Name';
ApplicationArea = Jobs;
Importance = Promoted;
Editable = ((BillToOptions = BillToOptions::"Another Customer") or ((BillToOptions = BillToOptions::"Custom Address") and not ShouldSearchForCustByName));
Enabled = ((BillToOptions = BillToOptions::"Another Customer") or ((BillToOptions = BillToOptions::"Custom Address") and not ShouldSearchForCustByName));
NotBlank = true;
trigger OnValidate()
begin
if not ((BillToOptions = BillToOptions::"Custom Address") and not ShouldSearchForCustByName) then begin
if Rec.GetFilter("Bill-to Customer No.") = xRec."Bill-to Customer No." then
if Rec."Bill-to Customer No." <> xRec."Bill-to Customer No." then
Rec.SetRange("Bill-to Customer No.");
CurrPage.Update();
end;
end;
}
field("Bill-to Name 2"; Rec."Bill-to Name 2")
{
ApplicationArea = Jobs;
Caption = 'Name 2';
Editable = (BillToOptions = BillToOptions::"Another Customer");
Enabled = (BillToOptions = BillToOptions::"Another Customer");
Importance = Additional;
QuickEntry = false;
Visible = false;
}
field("Bill-to Address"; Rec."Bill-to Address")
{
Caption = 'Address';
ApplicationArea = Jobs;
Importance = Additional;
QuickEntry = false;
Editable = BillToInformationEditable;
Enabled = BillToInformationEditable;
}
field("Bill-to Address 2"; Rec."Bill-to Address 2")
{
Caption = 'Address 2';
ApplicationArea = Jobs;
Importance = Additional;
QuickEntry = false;
Editable = BillToInformationEditable;
Enabled = BillToInformationEditable;
}
field("Bill-to City"; Rec."Bill-to City")
{
Caption = 'City';
ApplicationArea = Jobs;
Importance = Additional;
QuickEntry = false;
Editable = BillToInformationEditable;
Enabled = BillToInformationEditable;
}
group(Control56)
{
ShowCaption = false;
Visible = IsBillToCountyVisible;
field("Bill-to County"; Rec."Bill-to County")
{
ApplicationArea = Jobs;
CaptionClass = '5,1,' + Rec."Bill-to Country/Region Code";
QuickEntry = false;
Importance = Additional;
Editable = BillToInformationEditable;
Enabled = BillToInformationEditable;
}
}
field("Bill-to Post Code"; Rec."Bill-to Post Code")
{
Caption = 'Post Code';
ApplicationArea = Jobs;
Importance = Additional;
QuickEntry = false;
Editable = BillToInformationEditable;
Enabled = BillToInformationEditable;
}
field("Bill-to Country/Region Code"; Rec."Bill-to Country/Region Code")
{
Caption = 'Country/Region';
ApplicationArea = Jobs;
Importance = Additional;
QuickEntry = false;
Editable = BillToInformationEditable;
Enabled = BillToInformationEditable;
trigger OnValidate()
begin
IsBillToCountyVisible := FormatAddress.UseCounty(Rec."Bill-to Country/Region Code");
end;
}
field("Bill-to Contact No."; Rec."Bill-to Contact No.")
{
Caption = 'Contact No.';
ApplicationArea = Jobs;
Importance = Additional;
Editable = BillToInformationEditable;
Enabled = BillToInformationEditable;
trigger OnLookup(var Text: Text): Boolean
begin
if not Rec.BilltoContactLookup() then
exit(false);
BillToContact.Get(Rec."Bill-to Contact No.");
Text := Rec."Bill-to Contact No.";
exit(true);
end;
trigger OnValidate()
begin
BillToContact.Get(Rec."Bill-to Contact No.");
end;
}
field("Bill-to Contact"; Rec."Bill-to Contact")
{
Caption = 'Contact';
ApplicationArea = Jobs;
Importance = Additional;
Editable = BillToInformationEditable;
Enabled = BillToInformationEditable;
}
}
}
group("Payment Terms")
{
caption = 'Payment Terms';
field("Payment Terms Code"; Rec."Payment Terms Code")
{
ApplicationArea = Jobs;
Tooltip = 'Specifies a formula that calculates the payment due date, payment discount date, and payment discount amount.';
}
field("Payment Method Code"; Rec."Payment Method Code")
{
ApplicationArea = Jobs;
Tooltip = 'Specifies how to make payment, such as with bank transfer, cash, or check.';
Importance = Additional;
}
}
group("Ship-to")
{
Caption = 'Ship-to';
field(ShippingOptions; ShipToOptions)
{
ApplicationArea = Jobs;
Caption = 'Ship-to';
ToolTip = 'Specifies the address that the products on the sales document are shipped to. Default (Sell-to Address): The same as the customer''s sell-to address. Alternate Ship-to Address: One of the customer''s alternate ship-to addresses. Custom Address: Any ship-to address that you specify in the fields below.';
trigger OnValidate()
var
ShipToAddress: Record "Ship-to Address";
ShipToAddressList: Page "Ship-to Address List";
begin
case ShipToOptions of
ShipToOptions::"Default (Sell-to Address)":
begin
Rec.Validate("Ship-to Code", '');
Rec.SyncShipToWithSellTo();
end;
ShipToOptions::"Alternate Shipping Address":
begin
ShipToAddress.SetRange("Customer No.", Rec."Sell-to Customer No.");
ShipToAddressList.LookupMode := true;
ShipToAddressList.SetTableView(ShipToAddress);
if ShipToAddressList.RunModal() = ACTION::LookupOK then begin
ShipToAddressList.GetRecord(ShipToAddress);
Rec.Validate("Ship-to Code", ShipToAddress.Code);
IsShipToCountyVisible := FormatAddress.UseCounty(ShipToAddress."Country/Region Code");
end else
ShipToOptions := ShipToOptions::"Custom Address";
end;
ShipToOptions::"Custom Address":
begin
Rec.Validate("Ship-to Code", '');
IsShipToCountyVisible := FormatAddress.UseCounty(Rec."Ship-to Country/Region Code");
end;
end;
end;
}
group(Control202)
{
ShowCaption = false;
Visible = not (ShipToOptions = ShipToOptions::"Default (Sell-to Address)");
field("Ship-to Code"; Rec."Ship-to Code")
{
ApplicationArea = Jobs;
Caption = 'Code';
Editable = ShipToOptions = ShipToOptions::"Alternate Shipping Address";
Importance = Promoted;
trigger OnValidate()
var
ShipToAddress: Record "Ship-to Address";
begin
if (xRec."Ship-to Code" <> '') and (Rec."Ship-to Code" = '') then
Error(EmptyShipToCodeErr);
if Rec."Ship-to Code" <> '' then begin
ShipToAddress.Get(Rec."Sell-to Customer No.", Rec."Ship-to Code");
IsShipToCountyVisible := FormatAddress.UseCounty(ShipToAddress."Country/Region Code");
end else
IsShipToCountyVisible := false;
end;
}
field("Ship-to Name"; Rec."Ship-to Name")
{
ApplicationArea = Jobs;
Caption = 'Name';
Editable = ShipToOptions = ShipToOptions::"Custom Address";
}
field("Ship-to Name 2"; Rec."Ship-to Name 2")
{
ApplicationArea = Jobs;
Caption = 'Name 2';
Editable = ShipToOptions = ShipToOptions::"Custom Address";
Importance = Additional;
QuickEntry = false;
Visible = false;
}
field("Ship-to Address"; Rec."Ship-to Address")
{
ApplicationArea = Jobs;
Caption = 'Address';
Editable = ShipToOptions = ShipToOptions::"Custom Address";
QuickEntry = false;
}
field("Ship-to Address 2"; Rec."Ship-to Address 2")
{
ApplicationArea = Jobs;
Caption = 'Address 2';
Editable = ShipToOptions = ShipToOptions::"Custom Address";
QuickEntry = false;
}
field("Ship-to City"; Rec."Ship-to City")
{
ApplicationArea = Jobs;
Caption = 'City';
Editable = ShipToOptions = ShipToOptions::"Custom Address";
QuickEntry = false;
}
group(Control82)
{
ShowCaption = false;
Visible = IsShipToCountyVisible;
field("Ship-to County"; Rec."Ship-to County")
{
ApplicationArea = Jobs;
CaptionClass = '5,1,' + Rec."Ship-to Country/Region Code";
Editable = ShipToOptions = ShipToOptions::"Custom Address";
QuickEntry = false;
}
}
field("Ship-to Post Code"; Rec."Ship-to Post Code")
{
ApplicationArea = Jobs;
Caption = 'Post Code';
Editable = ShipToOptions = ShipToOptions::"Custom Address";
QuickEntry = false;
}
field("Ship-to Country/Region Code"; Rec."Ship-to Country/Region Code")
{
ApplicationArea = Jobs;
Caption = 'Country/Region';
Editable = ShipToOptions = ShipToOptions::"Custom Address";
Importance = Additional;
QuickEntry = false;
trigger OnValidate()
begin
IsShipToCountyVisible := FormatAddress.UseCounty(Rec."Ship-to Country/Region Code");
end;
}
}
field("Ship-to Contact"; Rec."Ship-to Contact")
{
ApplicationArea = Jobs;
Caption = 'Contact';
}
}
}
group("Foreign Trade")
{
Caption = 'Foreign Trade';
Visible = PerTaskBillingFieldsVisible;
field("Invoice Currency Code"; Rec."Invoice Currency Code")
{
ApplicationArea = Suite;
Editable = InvoiceCurrencyCodeEditable;
}
field("Price Calculation Method"; Rec."Price Calculation Method")
{
Visible = ExtendedPriceEnabled;
ApplicationArea = Basic, Suite;
Importance = Promoted;
}
field("Language Code"; Rec."Language Code")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
}
}
area(factboxes)
{
systempart(Control1900383207; Links)
{
ApplicationArea = RecordLinks;
Visible = false;
}
systempart(Control1905767507; Notes)
{
ApplicationArea = Notes;
Visible = false;
}
}
}
actions
{
area(navigation)
{
group("&Job Task")
{
Caption = '&Project Task';
Image = Task;
action(Dimensions)
{
ApplicationArea = Dimensions;
Caption = 'Dimensions';
Image = Dimensions;
RunObject = Page "Job Task Dimensions";
RunPageLink = "Job No." = field("Job No."),
"Job Task No." = field("Job Task No.");
ShortCutKey = 'Alt+D';
ToolTip = 'View or edit dimensions, such as area, project, or department, that you can assign to sales and purchase documents to distribute costs and analyze transaction history.';
}
action("Assigned Resources")
{
ApplicationArea = Jobs;
Caption = 'Assigned Resources';
Image = Users;
ToolTip = 'View or edit the additional resources that are explicitly assigned to this project task. Project-level assignments are managed from the project and are not shown on the project tasks.';
trigger OnAction()
var
JobAssignedResourcesPage: Page "Job Assigned Resources";
begin
if JobAssignedResourcesPage.SetJobTaskContext(Rec) then
JobAssignedResourcesPage.Run();
end;
}
action(AssemblyOrders)
{
AccessByPermission = TableData "BOM Component" = R;
ApplicationArea = Assembly;
Caption = 'Assembly Orders';
Image = AssemblyOrder;
ToolTip = 'View ongoing assembly orders related to the project task. ';
trigger OnAction()
var
Job: Record Job;
AssembleToOrderLink: Record "Assemble-to-Order Link";
begin
Job.Get(Rec."Job No.");
AssembleToOrderLink.ShowAsmOrders(Job, Rec."Job Task No.");
end;
}
}
}
area(reporting)
{
action("Report Job Task Quote")
{
ApplicationArea = Suite;
Caption = 'Preview Project Task Quote';
Image = "Report";
ToolTip = 'Open the Project Task Quote report.';
Visible = PerTaskBillingFieldsVisible;
trigger OnAction()
var
JobTask: Record "Job Task";
ReportSelection: Record "Report Selections";
begin
JobTask.SetCurrentKey("Job No.", "Job Task No.");
JobTask.SetFilter("Job No.", Rec."Job No.");
JobTask.SetFilter("Job Task No.", Rec."Job Task No.");
ReportSelection.PrintWithDialogForCust(
ReportSelection.Usage::"Job Task Quote", JobTask, true, Rec.FieldNo("Bill-to Customer No."));
end;
}
action("Send Job Task Quote")
{
ApplicationArea = Suite;
Caption = 'Send Project Task Quote';
Image = SendTo;
ToolTip = 'Send the project task quote to the customer. You can change the way that the document is sent in the window that appears.';
Visible = PerTaskBillingFieldsVisible;
trigger OnAction()
begin
Codeunit.Run(Codeunit::"Job Tasks-Send", Rec);
end;
}
}
area(Promoted)
{
group(Category_Category8)
{
Caption = 'Print/Send', Comment = 'Generated from the PromotedActionCategories property index 7.';
actionref("Report Job Task Quote_Promoted"; "Report Job Task Quote")
{
}
actionref("Send Job Task Quote_Promoted"; "Send Job Task Quote")
{
}
}
}
}
var
SellToContact: Record Contact;
BillToContact: Record Contact;
FormatAddress: Codeunit "Format Address";
BillToInformationEditable: Boolean;
InvoiceCurrencyCodeEditable: Boolean;
IsBillToCountyVisible: Boolean;
IsSellToCountyVisible: Boolean;
IsShipToCountyVisible: Boolean;
ExtendedPriceEnabled: Boolean;
EmptyShipToCodeErr: Label 'The Code field can only be empty if you select Custom Address in the Ship-to field.';
protected var
ShipToOptions: Enum "Sales Ship-to Options";
BillToOptions: Enum "Sales Bill-to Options";
ShouldSearchForCustByName: Boolean;
PerTaskBillingFieldsVisible: Boolean;
trigger OnAfterGetCurrRecord()
begin
if GuiAllowed() then
SetControlVisibility();
end;
trigger OnAfterGetRecord()
begin
if GuiAllowed() then
SetControlVisibility();
UpdateShipToBillToGroupVisibility();
SellToContact.GetOrClear(Rec."Sell-to Contact No.");
BillToContact.GetOrClear(Rec."Bill-to Contact No.");
UpdateBillToInformationEditable();
UpdateInvoiceCurrencyCodeEditable();
end;
trigger OnOpenPage()
begin
ActivateFields();
end;
local procedure ActivateFields()
var
Job: Record Job;
PriceCalculationMgt: Codeunit "Price Calculation Mgt.";
begin
IsBillToCountyVisible := FormatAddress.UseCounty(Rec."Bill-to Country/Region Code");
IsSellToCountyVisible := FormatAddress.UseCounty(Rec."Sell-to Country/Region Code");
IsShipToCountyVisible := FormatAddress.UseCounty(Rec."Ship-to Country/Region Code");
if Job.Get(Rec."Job No.") then
PerTaskBillingFieldsVisible := Job."Task Billing Method" = Job."Task Billing Method"::"Multiple customers";
ExtendedPriceEnabled := PriceCalculationMgt.IsExtendedPriceCalculationEnabled();
end;
local procedure UpdateShipToBillToGroupVisibility()
begin
case true of
(Rec."Ship-to Code" = '') and Rec.ShipToNameEqualsSellToName() and Rec.ShipToAddressEqualsSellToAddress():
ShipToOptions := ShipToOptions::"Default (Sell-to Address)";
(Rec."Ship-to Code" = '') and (not Rec.ShipToNameEqualsSellToName() or not Rec.ShipToAddressEqualsSellToAddress()):
ShipToOptions := ShipToOptions::"Custom Address";
Rec."Ship-to Code" <> '':
ShipToOptions := ShipToOptions::"Alternate Shipping Address";
end;
case true of
(Rec."Bill-to Customer No." = Rec."Sell-to Customer No.") and Rec.BillToAddressEqualsSellToAddress():
BillToOptions := BillToOptions::"Default (Customer)";
(Rec."Bill-to Customer No." = Rec."Sell-to Customer No.") and (not Rec.BillToAddressEqualsSellToAddress()):
BillToOptions := BillToOptions::"Custom Address";
Rec."Bill-to Customer No." <> Rec."Sell-to Customer No.":
BillToOptions := BillToOptions::"Another Customer";
end;
end;
local procedure UpdateBillToInformationEditable()
begin
BillToInformationEditable :=
(BillToOptions = BillToOptions::"Custom Address") or
(Rec."Bill-to Customer No." <> Rec."Sell-to Customer No.");
end;
local procedure UpdateInvoiceCurrencyCodeEditable()
var
Job: Record Job;
begin
if Job.Get(Rec."Job No.") then
InvoiceCurrencyCodeEditable := Job."Currency Code" = '';
end;
local procedure SetControlVisibility()
begin
ShouldSearchForCustByName := Rec.ShouldSearchForCustomerByName(Rec."Sell-to Customer No.");
end;
}