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
2 changes: 1 addition & 1 deletion .github/AL-Go-Settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"runs-on": "windows-latest",
"cacheImageName": "",
"UsePsSession": false,
"artifact": "https://bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net/sandbox/28.0.43307.0/base",
"artifact": "https://bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net/sandbox/28.0.43704.0/base",
"country": "base",
"useProjectDependencies": true,
"repoVersion": "28.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ codeunit 11732 "Alt. Cust. VAT Reg. Impl. CZZ" implements "Alt. Cust. VAT Reg. A
DontShowMsg: Label 'Don''t show';
AddAltCustVATRegNotificationNameTok: Label 'Suggest an alternative customer VAT registration from sales advance letter';
AddAltCustVATRegNotificationDescTok: Label 'Suggest the user to add an alternative customer VAT registration when choosing a VAT country different from the customer''s';
DiffVATRegNoMsg: Label 'The VAT Registration No. in the sales advance letter is different than the one in the document.';
DiffVATRegNoNotificationNameTxt: Label 'Different VAT Registration No. in sales advance letter';
DiffVATRegNoNotificationDescriptionTxt: Label 'Warn if VAT Registration No. in sales advance letter is different than in the document.';

procedure Init(var SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ"; xSalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ")
begin
Expand Down Expand Up @@ -276,6 +279,32 @@ codeunit 11732 "Alt. Cust. VAT Reg. Impl. CZZ" implements "Alt. Cust. VAT Reg. A
exit('34c4fa1d-07b6-450b-b524-0d367b1e6221')
end;

procedure ThrowDiffVATRegNoNotification()
var
MyNotifications: Record "My Notifications";
Notification: Notification;
begin
if not MyNotifications.IsEnabled(DiffVATRegNoNotificationId()) then
exit;
Notification.Id(DiffVATRegNoNotificationId());
Notification.Message(DiffVATRegNoMsg);
Notification.AddAction(DontShowMsg, Codeunit::"Alt. Cust. VAT Reg. Impl. CZZ", 'DisableDiffVATRegNoNotification');
Notification.Send();
end;

procedure DisableDiffVATRegNoNotification(Notification: Notification)
var
MyNotifications: Record "My Notifications";
begin
if not MyNotifications.Disable(Notification.Id()) then
MyNotifications.InsertDefault(Notification.Id(), DiffVATRegNoNotificationNameTxt, DiffVATRegNoNotificationDescriptionTxt, false);
end;

local procedure DiffVATRegNoNotificationId(): Text
begin
exit('150bf347-91ac-4e52-8520-e8024bf08e4c');
end;

[IntegrationEvent(false, false)]
local procedure OnAfterBuildFieldChangeBuffer(var TempChangeLogEntry: Record "Change Log Entry" temporary; SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ");
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ using Microsoft.CashFlow.Forecast;
using Microsoft.CashFlow.Setup;
using Microsoft.CashFlow.Worksheet;
using Microsoft.EServices.EDocument;
using Microsoft.Finance.CashDesk;
using Microsoft.Finance.FinancialReports;
using Microsoft.Finance.GeneralLedger.Journal;
using Microsoft.Finance.VAT.Ledger;
using Microsoft.Finance.VAT.Reporting;
using Microsoft.Finance.VAT.Setup;
using Microsoft.Foundation.AuditCodes;
using Microsoft.Foundation.Company;
using Microsoft.Foundation.Reporting;
using Microsoft.Purchases.History;
using Microsoft.Purchases.Payables;
using Microsoft.Sales.History;
using Microsoft.Sales.Receivables;
using System.Upgrade;
using Microsoft.Finance.CashDesk;

#pragma warning disable AL0432
codeunit 31087 "Install Application CZZ"
Expand Down Expand Up @@ -57,6 +58,8 @@ codeunit 31087 "Install Application CZZ"
var
InstallApplicationsMgtCZL: Codeunit "Install Applications Mgt. CZL";
AppInfo: ModuleInfo;
CloseAdvanceSourceCodeTxt: Label 'CLADVANCE', MaxLength = 10;
CloseAdvanceSourceCodeDescriptionTxt: Label 'Close Advance Letter', MaxLength = 100;

trigger OnInstallAppPerCompany()
begin
Expand All @@ -80,6 +83,7 @@ codeunit 31087 "Install Application CZZ"
CopyVendorLedgerEntries();
MoveIncomingDocument();
ModifyReportSelections();
InitSourceCodeSetup();
end;

local procedure CopyCustomerLedgerEntries()
Expand Down Expand Up @@ -203,6 +207,7 @@ codeunit 31087 "Install Application CZZ"
begin
InitAdvancePaymentsReportSelections();
ModifyReportSelections();
CreateSourceCodeSetup();

DataClassEvalHandlerCZZ.ApplyEvaluationClassificationsForPrivacy();
UpgradeTag.SetAllUpgradeTags();
Expand All @@ -217,4 +222,48 @@ codeunit 31087 "Install Application CZZ"
ReportSelectionHandlerCZZ.InsertRepSelection(Enum::"Report Selection Usage"::"Sales Advance Letter CZZ", '1', Report::"Sales - Advance Letter CZZ");
ReportSelectionHandlerCZZ.InsertRepSelection(Enum::"Report Selection Usage"::"Sales Advance VAT Document CZZ", '1', Report::"Sales - Advance VAT Doc. CZZ");
end;

local procedure CreateSourceCodeSetup()
var
SourceCodeSetup: Record "Source Code Setup";
PrevSourceCodeSetup: Record "Source Code Setup";
begin
if not SourceCodeSetup.Get() then
exit;
PrevSourceCodeSetup := SourceCodeSetup;
if SourceCodeSetup."Close Advance Letter CZZ" = '' then
InsertSourceCode(SourceCodeSetup."Close Advance Letter CZZ", CloseAdvanceSourceCodeTxt, CloseAdvanceSourceCodeDescriptionTxt);

if SourceCodeSetup."Close Advance Letter CZZ" <> PrevSourceCodeSetup."Close Advance Letter CZZ" then
SourceCodeSetup.Modify();
end;

local procedure InitSourceCodeSetup()
var
SourceCodeSetup: Record "Source Code Setup";
PrevSourceCodeSetup: Record "Source Code Setup";
begin
if not SourceCodeSetup.Get() then begin
SourceCodeSetup.Init();
SourceCodeSetup.Insert();
end;
PrevSourceCodeSetup := SourceCodeSetup;
InsertSourceCode(SourceCodeSetup."Close Advance Letter CZZ", CloseAdvanceSourceCodeTxt, CloseAdvanceSourceCodeDescriptionTxt);

if SourceCodeSetup."Close Advance Letter CZZ" <> PrevSourceCodeSetup."Close Advance Letter CZZ" then
SourceCodeSetup.Modify();
end;

local procedure InsertSourceCode(var SourceCodeDefCode: Code[10]; "Code": Code[10]; Description: Text[100])
var
SourceCode: Record "Source Code";
begin
SourceCodeDefCode := Code;
if SourceCode.Get(Code) then
exit;
SourceCode.Init();
SourceCode.Code := Code;
SourceCode.Description := Description;
SourceCode.Insert();
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
AdvanceLetterApplicationCZZ: Record "Advance Letter Application CZZ";
AdvanceLetterTemplateCZZ: Record "Advance Letter Template CZZ";
PurchAdvLetterEntryCZZ: Record "Purch. Adv. Letter Entry CZZ";
SourceCodeSetup: Record "Source Code Setup";
NoSeriesBatch: Codeunit "No. Series - Batch";
NextEntryNo: Integer;
GetDocNoFromNoSeries: Boolean;
Expand Down Expand Up @@ -1185,6 +1186,11 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
NextEntryNo := GenJnlPostLine.GetNextEntryNo();
end;

if AdvancePostingParametersCZZ."Source Code" = '' then begin
SourceCodeSetup.Get();
AdvancePostingParametersCZZ."Source Code" := SourceCodeSetup."Close Advance Letter CZZ";
end;

PurchAdvLetterEntryCZZ.SetRange("Purch. Adv. Letter No.", PurchAdvLetterHeaderCZZ."No.");
PurchAdvLetterEntryCZZ.SetRange("Entry Type", PurchAdvLetterEntryCZZ."Entry Type"::Payment);
PurchAdvLetterEntryCZZ.SetRange(Cancelled, false);
Expand Down Expand Up @@ -1247,6 +1253,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
GenJournalLine."Document Date" := AdvancePostingParametersCZZ."Document Date";
GenJournalLine."VAT Reporting Date" := AdvancePostingParametersCZZ."VAT Date";
GenJournalLine."Original Doc. VAT Date CZL" := AdvancePostingParametersCZZ."Original Document VAT Date";
GenJournalLine."Source Code" := AdvancePostingParametersCZZ."Source Code";
GenJournalLine."Adv. Letter No. (Entry) CZZ" := PurchAdvLetterEntryCZZ."Purch. Adv. Letter No.";
GenJournalLine."Use Advance G/L Account CZZ" := true;
GenJournalLine.SetCurrencyFactor(
Expand Down Expand Up @@ -1298,6 +1305,7 @@ codeunit 31142 "Purch. Adv. Letter-Post CZZ"
GenJournalLine."Document Date" := AdvancePostingParametersCZZ."Document Date";
GenJournalLine."VAT Reporting Date" := AdvancePostingParametersCZZ."VAT Date";
GenJournalLine."Original Doc. VAT Date CZL" := AdvancePostingParametersCZZ."Original Document VAT Date";
GenJournalLine."Source Code" := AdvancePostingParametersCZZ."Source Code";
GenJournalLine.SetCurrencyFactor(
AdvancePostingParametersCZZ."Currency Code", AdvancePostingParametersCZZ."Currency Factor");
GenJournalLine.Amount := RemainingAmount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
AdvanceLetterApplicationCZZ: Record "Advance Letter Application CZZ";
AdvanceLetterTemplateCZZ: Record "Advance Letter Template CZZ";
SalesAdvLetterEntryCZZ: Record "Sales Adv. Letter Entry CZZ";
SourceCodeSetup: Record "Source Code Setup";
NoSeriesBatch: Codeunit "No. Series - Batch";
NextEntryNo: Integer;
GetDocNoFromNoSeries: Boolean;
Expand Down Expand Up @@ -1033,6 +1034,11 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
NextEntryNo := GenJnlPostLine.GetNextEntryNo();
end;

if AdvancePostingParametersCZZ."Source Code" = '' then begin
SourceCodeSetup.Get();
AdvancePostingParametersCZZ."Source Code" := SourceCodeSetup."Close Advance Letter CZZ";
end;

SalesAdvLetterEntryCZZ.SetRange("Sales Adv. Letter No.", SalesAdvLetterHeaderCZZ."No.");
SalesAdvLetterEntryCZZ.SetRange("Entry Type", SalesAdvLetterEntryCZZ."Entry Type"::Payment);
SalesAdvLetterEntryCZZ.SetRange(Cancelled, false);
Expand Down Expand Up @@ -1095,6 +1101,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
GenJournalLine."Document Date" := AdvancePostingParametersCZZ."Document Date";
GenJournalLine."VAT Reporting Date" := AdvancePostingParametersCZZ."VAT Date";
GenJournalLine."Original Doc. VAT Date CZL" := AdvancePostingParametersCZZ."Original Document VAT Date";
GenJournalLine."Source Code" := AdvancePostingParametersCZZ."Source Code";
GenJournalLine."Adv. Letter No. (Entry) CZZ" := SalesAdvLetterEntryCZZ."Sales Adv. Letter No.";
GenJournalLine."Use Advance G/L Account CZZ" := true;
GenJournalLine.SetCurrencyFactor(
Expand Down Expand Up @@ -1146,6 +1153,7 @@ codeunit 31143 "Sales Adv. Letter-Post CZZ"
GenJournalLine."Document Date" := AdvancePostingParametersCZZ."Document Date";
GenJournalLine."VAT Reporting Date" := AdvancePostingParametersCZZ."VAT Date";
GenJournalLine."Original Doc. VAT Date CZL" := AdvancePostingParametersCZZ."Original Document VAT Date";
GenJournalLine."Source Code" := AdvancePostingParametersCZZ."Source Code";
GenJournalLine.SetCurrencyFactor(
AdvancePostingParametersCZZ."Currency Code", AdvancePostingParametersCZZ."Currency Factor");
GenJournalLine.Amount := -RemainingAmount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ codeunit 31127 "VAT Rep. Date Mgt. Handler CZZ"
UpdateRelatedGLEntries(VATEntry);
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"VAT Orig.Doc.VAT Date Mgt. CZL", 'OnAfterUpdateOrigDocVATDate', '', false, false)]
local procedure UpdateAdvanceLedgerEntriesOnAfterUpdateOrigDocVATDate(VATEntry: Record "VAT Entry")
var
PurchAdvLetterEntry: Record "Purch. Adv. Letter Entry CZZ";
begin
if VATEntry.Type <> VATEntry.Type::Purchase then
exit;

PurchAdvLetterEntry.SetCurrentKey("Document No.", "Posting Date");
PurchAdvLetterEntry.SetRange("Document No.", VATEntry."Document No.");
PurchAdvLetterEntry.SetRange("Posting Date", VATEntry."Posting Date");
PurchAdvLetterEntry.SetFilter("Original Document VAT Date", '<>%1', 0D);
PurchAdvLetterEntry.ModifyAll("Original Document VAT Date", VATEntry."Original Doc. VAT Date CZL");
end;

local procedure FilterRelatedVATEntries(VATEntry: Record "VAT Entry"; var RelatedVATEntry: Record "VAT Entry")
begin
RelatedVATEntry.SetFilter("Entry No.", '<>%1', VATEntry."Entry No.");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pageextension 31279 "Source Code Setup CZZ" extends "Source Code Setup"
{
layout
{
addlast(General)
{
field("Close Advance Letter CZZ"; Rec."Close Advance Letter CZZ")
{
ApplicationArea = Basic, Suite;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ page 31175 "Advance Letter Appl. Edit CZZ"
if Rec."Advance Letter No." <> '' then begin
TempAdvanceLetterApplication.Get(Rec."Advance Letter Type", Rec."Advance Letter No.", Rec."Document Type", Rec."Document No.");
Rec.CopyFrom(TempAdvanceLetterApplication);
end
Rec.CheckVATRegistrationNoDifference();
end;
end;

trigger OnLookup(var Text: Text): Boolean
Expand All @@ -39,6 +40,7 @@ page 31175 "Advance Letter Appl. Edit CZZ"

if Page.RunModal(Page::"Advance Letter Application CZZ", TempAdvanceLetterApplication) = Action::LookupOK then begin
Rec.CopyFrom(TempAdvanceLetterApplication);
Rec.CheckVATRegistrationNoDifference();
OnAfterOnLookupAdvanceLetterNo(Rec);
end;
end;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tableextension 31076 "Source Code Setup CZZ" extends "Source Code Setup"
{
fields
{
field(11760; "Close Advance Letter CZZ"; Code[10])
{
Caption = 'Close Advance Letter';
DataClassification = CustomerContent;
TableRelation = "Source Code";
ToolTip = 'Specifies the source code for closing sales and purchase advance letters.';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,29 @@ table 31007 "Advance Letter Application CZZ"
end;
end;

procedure CheckVATRegistrationNoDifference()
var
SalesAdvLetterHeaderCZZ: Record "Sales Adv. Letter Header CZZ";
SalesHeader: Record "Sales Header";
AltCustVATRegImplCZZ: Codeunit "Alt. Cust. VAT Reg. Impl. CZZ";
begin
if "Advance Letter Type" <> "Advance Letter Type"::Sales then
exit;

SalesAdvLetterHeaderCZZ.Get("Advance Letter No.");
case "Document Type" of
"Adv. Letter Usage Doc.Type CZZ"::"Sales Order":
SalesHeader.Get(SalesHeader."Document Type"::Order, "Document No.");
"Adv. Letter Usage Doc.Type CZZ"::"Sales Invoice":
SalesHeader.Get(SalesHeader."Document Type"::Invoice, "Document No.");
else
exit;
end;

if SalesAdvLetterHeaderCZZ."VAT Registration No." <> SalesHeader."VAT Registration No." then
AltCustVATRegImplCZZ.ThrowDiffVATRegNoNotification();
end;

[IntegrationEvent(false, false)]
local procedure OnGetPossiblePurchAdvanceOnBeforeInsertNewAdvanceLetterApplication(var NewAdvanceLetterApplicationCZZ: Record "Advance Letter Application CZZ"; AdvanceLetterApplicationCZZ: Record "Advance Letter Application CZZ")
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@ codeunit 31373 "Gen. Jnl.Post Line Handler CZA"
begin
GLEntryPostApplicationCZA.AutomatedGLEntryApplication(GenJournalLine, GLEntry);
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnAfterInitGLEntry', '', false, false)]
local procedure CloseZeroEntryOnAfterInitGLEntry(var GLEntry: Record "G/L Entry")
begin
if GLEntry.Amount <> 0 then
exit;

GLEntry."Closed CZA" := true;
GLEntry."Closed at Date CZA" := GLEntry."Posting Date";
end;
}
Loading
Loading