Skip to content

Commit e728059

Browse files
committed
Internal feedback from testing
1 parent c8bc883 commit e728059

File tree

4 files changed

+19
-42
lines changed

4 files changed

+19
-42
lines changed

src/Apps/W1/Subscription Billing/App/Billing/Codeunits/SubBillingBackgroundJobs.Codeunit.al

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ codeunit 8034 "Sub. Billing Background Jobs"
5858

5959
local procedure CreateJobQueueEntryForAutomatedBilling(var BillingTemplate: Record "Billing Template"; var JobQueueEntry: Record "Job Queue Entry")
6060
begin
61-
JobQueueEntry.ScheduleRecurrentJobQueueEntryWithFrequency(JobQueueEntry."Object Type to Run"::Codeunit, Codeunit::"Auto Contract Billing", BillingTemplate.RecordId, BillingTemplate."Minutes between runs", BillingTemplate."Automation Start Time");
61+
JobQueueEntry.ScheduleRecurrentJobQueueEntryWithFrequency(JobQueueEntry."Object Type to Run"::Codeunit, Codeunit::"Auto Contract Billing", BillingTemplate.RecordId, BillingTemplate."Minutes between runs");
6262
BillingTemplate."Batch Recurrent Job Id" := JobQueueEntry.ID;
6363
BillingTemplate.Modify();
6464

@@ -71,7 +71,6 @@ codeunit 8034 "Sub. Billing Background Jobs"
7171
local procedure UpdateJobQueueEntryForAutomatedBilling(var BillingTemplate: Record "Billing Template"; var JobQueueEntry: Record "Job Queue Entry")
7272
begin
7373
JobQueueEntry.Get(BillingTemplate."Batch Recurrent Job Id");
74-
JobQueueEntry."Starting Time" := BillingTemplate."Automation Start Time";
7574
JobQueueEntry."No. of Minutes between Runs" := BillingTemplate."Minutes between runs";
7675
JobQueueEntry."No. of Attempts to Run" := 0;
7776
JobQueueEntry.Modify();

src/Apps/W1/Subscription Billing/App/Billing/Pages/BillingTemplates.Page.al

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,17 @@ page 8066 "Billing Templates"
6060
field(Automation; Rec.Automation)
6161
{
6262
}
63-
field("Automation Start Time"; Rec."Automation Start Time")
64-
{
65-
Enabled = Rec.Automation = Rec.Automation::"Create Billing Proposal and Documents";
66-
}
6763
field("Minutes between runs"; Rec."Minutes between runs")
6864
{
6965
Enabled = Rec.Automation = Rec.Automation::"Create Billing Proposal and Documents";
7066
}
7167
field("Batch Recurrent Job Id"; Rec."Batch Recurrent Job Id")
7268
{
7369
Enabled = Rec.Automation = Rec.Automation::"Create Billing Proposal and Documents";
74-
Visible = false;
70+
trigger OnAssistEdit()
71+
begin
72+
Rec.LookupJobEntryQueue();
73+
end;
7574
}
7675
}
7776
}

src/Apps/W1/Subscription Billing/App/Billing/Pages/RecurringBilling.Page.al

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,12 @@ page 8067 "Recurring Billing"
261261
ErrorMessageMgt.Activate(ErrorMessageHandler);
262262
ErrorMessageMgt.PushContext(ErrorContextElement, 0, 0, '');
263263
Commit(); //commit to database before processing
264-
BillingTemplate.CalculateDocumentDates(PostingDate, DocumentDate, false);
265-
if BillingTemplate.Partner = BillingTemplate.Partner::Customer then
266-
CreateBillingDocuments.SetCustomerRecurringBillingGrouping(BillingTemplate."Customer Document per");
267-
CreateBillingDocuments.SetDocumentDataFromRequestPage(DocumentDate, PostingDate, false, false);
264+
if BillingTemplate.Get(BillingTemplate.Code) then begin
265+
BillingTemplate.CalculateDocumentDates(PostingDate, DocumentDate, false);
266+
if BillingTemplate.Partner = BillingTemplate.Partner::Customer then
267+
CreateBillingDocuments.SetCustomerRecurringBillingGrouping(BillingTemplate."Customer Document per");
268+
CreateBillingDocuments.SetDocumentDataFromRequestPage(DocumentDate, PostingDate, false, false);
269+
end;
268270
IsSuccess := CreateBillingDocuments.Run(Rec);
269271
if not IsSuccess then
270272
ErrorMessageHandler.ShowErrors();

src/Apps/W1/Subscription Billing/App/Billing/Tables/BillingTemplate.Table.al

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace Microsoft.SubscriptionBilling;
22

33
using System.Security.User;
4-
using System.Utilities;
4+
using System.Threading;
55

66
table 8060 "Billing Template"
77
{
@@ -58,30 +58,19 @@ table 8060 "Billing Template"
5858
{
5959
Caption = 'Posting Date Formula';
6060
ToolTip = 'Specifies the date formula used to calculate the Posting Date. If the field is left empty, the Posting Date is prefilled with workdate, or with today when the process runs automatically.';
61-
trigger OnValidate()
62-
begin
63-
if Format("Posting Date Formula") <> '' then
64-
ThrowErrorIfAutomationIsNotSet(FieldCaption("Posting Date Formula"));
65-
end;
6661
}
6762
field(12; "Document Date Formula"; DateFormula)
6863
{
6964
Caption = 'Document Date Formula';
7065
ToolTip = 'Specifies the date formula used to calculate the Document Date. If the field is left empty, the Document Date is prefilled with workdate, or with today when the process runs automatically.';
71-
trigger OnValidate()
72-
begin
73-
if Format("Document Date Formula") <> '' then
74-
ThrowErrorIfAutomationIsNotSet(FieldCaption("Document Date Formula"));
75-
end;
7666
}
7767
field(13; "Customer Document per"; Enum "Customer Rec. Billing Grouping")
7868
{
7969
Caption = 'Customer Document per';
8070
ToolTip = 'Specifies how the Billing lines for customers are grouped in sales documents.';
8171
trigger OnValidate()
8272
begin
83-
if "Customer Document per" <> "Customer Document per"::Contract then
84-
ThrowErrorIfAutomationIsNotSet(FieldCaption("Customer Document per"));
73+
TestField(Partner, Partner::Customer);
8574
end;
8675
}
8776
field(15; Automation; Enum "Sub. Billing Automation")
@@ -95,32 +84,18 @@ table 8060 "Billing Template"
9584
case Automation of
9685
Automation::None:
9786
begin
98-
"Automation Start Time" := 0T;
9987
"Minutes between runs" := 0;
10088
end;
10189
Automation::"Create Billing Proposal and Documents":
10290
begin
10391
TestField(Partner, Partner::Customer);
10492
"My Suggestions Only" := false;
105-
"Automation Start Time" := 0T;
10693
"Minutes between runs" := 60;
10794
end;
10895
end;
10996
SubBillingBackgroundJobs.HandleAutomatedBillingJob(Rec);
11097
end;
11198
}
112-
field(16; "Automation Start Time"; Time)
113-
{
114-
Caption = 'Automation Start Time';
115-
ToolTip = 'Specifies the time of day when the billing process should start.';
116-
DataClassification = SystemMetadata;
117-
NotBlank = true;
118-
119-
trigger OnValidate()
120-
begin
121-
SubBillingBackgroundJobs.HandleAutomatedBillingJob(Rec);
122-
end;
123-
}
12499
field(17; "Minutes between runs"; Integer)
125100
{
126101
Caption = 'Minutes between runs';
@@ -168,7 +143,6 @@ table 8060 "Billing Template"
168143
UserSetup: Record "User Setup";
169144
SubBillingBackgroundJobs: Codeunit "Sub. Billing Background Jobs";
170145
AutoContractBillingNotAllowedErr: Label 'You cannot change the auto billing templates because you are not set up as an Auto Contract Billing user in the User Setup.';
171-
CanOnlyBeSetWhenAutomatedErr: Label 'You can only set the field %1 if %2 is set to %3', Comment = '%1 - Customer Document per Field Caption, %2 - Automation Field Caption, %3 - Automation Field Value';
172146

173147
internal procedure EditFilter(FieldNumber: Integer): Boolean
174148
var
@@ -342,9 +316,12 @@ table 8060 "Billing Template"
342316
DocumentDate := ReferenceDate;
343317
end;
344318

345-
local procedure ThrowErrorIfAutomationIsNotSet(FieldCaption: Text)
319+
internal procedure LookupJobEntryQueue()
320+
var
321+
JobQueueEntry: Record "Job Queue Entry";
346322
begin
347-
if Automation = Automation::None then
348-
Error(CanOnlyBeSetWhenAutomatedErr, FieldCaption, FieldCaption(Automation), Automation::"Create Billing Proposal and Documents");
323+
JobQueueEntry.Get("Batch Recurrent Job Id");
324+
JobQueueEntry.SetRecFilter();
325+
Page.Run(0, JobQueueEntry);
349326
end;
350327
}

0 commit comments

Comments
 (0)