Table of Contents

KVSADVFinalInvAmountCalcLib

Summary: Library codeunit for calculating the final invoice amount considering advance closingcredit memos.

Procedures

CalcAmounts(Record Sales Invoice Header, Decimal, Decimal) :

Summary: Calculates the due payable amount and the total prepaid amount for a sales invoice.

procedure CalcAmounts(var SalesInvoiceHeader: Record "Sales Invoice Header"; var DuePayableAmount: Decimal; var TotalPrepaidAmount: Decimal): 

Parameters:

  • SalesInvoiceHeader: The sales invoice header for which to calculate the amounts.
  • DuePayableAmount: The calculated due payable amount for the sales invoice.
  • TotalPrepaidAmount: The calculated total prepaid amount for the sales invoice.

Remarks: Calculates the prepaid amount from advance closing credit memos and subtracts it from the invoice total.

CalcAdvClosCreditMemoTotalAmountForPostedInvoice(Record Sales Invoice Header) : Decimal

Summary: Calculates the total amount of advance closing credit memos for a posted invoice.

procedure CalcAdvClosCreditMemoTotalAmountForPostedInvoice(var SalesInvoiceHeader: Record "Sales Invoice Header"): Decimal

Parameters:

  • SalesInvoiceHeader: The posted sales invoice header for which to calculate the total advance closing credit memo amount.

Returns: The total amount of advance closing credit memos applied to the posted invoice.

Remarks: This procedure calculates the total amount of advance closing credit memos for a posted sales invoice. It iterates through all relevant credit memos and sums their amounts.

AddAdvClosCreditMemoToPostedInvoice(Record Sales Invoice Header, Record KVSADVEdocInvRefBuffer) :

Summary: Adds advance invoice references to the posted invoice buffer.

procedure AddAdvClosCreditMemoToPostedInvoice(var DocumentHeader: Record "Sales Invoice Header"; var TempEDocInvRefBuffer: Record "KVSADVEdocInvRefBuffer" temporary): 

Parameters:

  • DocumentHeader: The posted invoice header to which advance closing credit memos will be added.
  • TempEDocInvRefBuffer: Temporary buffer for E-Document Invoice References.

Remarks: Adds only advance invoice reference data to the buffer.

AddAdvClosCreditMemoToPostedInvoiceExtended(Record Sales Invoice Header, Record KVSADVEdocInvRefBuffer) :

Summary: Adds advance invoice references and payment data to the posted invoice buffer.

procedure AddAdvClosCreditMemoToPostedInvoiceExtended(var DocumentHeader: Record "Sales Invoice Header"; var TempEDocInvRefBuffer: Record "KVSADVEdocInvRefBuffer" temporary): 

Parameters:

  • DocumentHeader: The posted invoice header to which advance closing credit memos will be added.
  • TempEDocInvRefBuffer: Temporary buffer for E-Document Invoice References.

Remarks: Adds advance invoice references and the additional payment and tax data required for ZUGFeRD Extended.

Events

OnAfterSetFilterForPOstedClosCreditMemo(Code[20], Record Sales Cr.Memo Header) :

Summary: Event raised after setting the filter for posted closing credit memos.

[IntegrationEvent(false, false)]
local procedure OnAfterSetFilterForPOstedClosCreditMemo(InvoiceNo: Code[20]; var CreditMemos: Record "Sales Cr.Memo Header"): 

Parameters:

  • InvoiceNo: The invoice number for which the filter is set.
  • CreditMemos: The record of sales credit memos with the applied filter.

OnAfterCalcAdvClosCreditMemoTotalAmountForPostedInvoice(Record Sales Invoice Header, Record Sales Cr.Memo Header, Decimal) :

Summary: Event raised after calculating the total amount of advance closing credit memos for a posted invoice.

[IntegrationEvent(false, false)]
local procedure OnAfterCalcAdvClosCreditMemoTotalAmountForPostedInvoice(var DocumentHeader: Record "Sales Invoice Header"; var ClosCreditMemo: Record "Sales Cr.Memo Header"; var TotalClosCrMemoAmount: Decimal): 

Parameters:

  • DocumentHeader: The posted sales invoice header for which the calculation was performed.
  • ClosCreditMemo: The record of the closing credit memo being considered in the calculation.
  • TotalClosCrMemoAmount: The total amount of advance closing credit memos calculated for the posted invoice.

OnBeforeAddAdvClosCreditMemoToPostedInvoice(Record Sales Invoice Header, Record KVSADVEdocInvRefBuffer, Boolean) :

Summary: Event raised before populating the buffer with advance invoice references.

[IntegrationEvent(false, false)]
local procedure OnBeforeAddAdvClosCreditMemoToPostedInvoice(var DocumentHeader: Record "Sales Invoice Header"; var TempEDocInvRefBuffer: Record "KVSADVEdocInvRefBuffer" temporary; var IsHandled: Boolean): 

Parameters:

  • DocumentHeader: The posted sales invoice header for which references are collected.
  • TempEDocInvRefBuffer: The temporary buffer for the advance invoice references.
  • IsHandled: Set to true to skip the default buffer population.

Remarks: The default implementation adds only advance invoice reference data. The event is raised before the buffer is cleared.

OnBeforeAddAdvClosCreditMemoToPostedInvoiceExtended(Record Sales Invoice Header, Record KVSADVEdocInvRefBuffer, Boolean) :

Summary: Event raised before populating the buffer with advance invoice references and payment data.

[IntegrationEvent(false, false)]
local procedure OnBeforeAddAdvClosCreditMemoToPostedInvoiceExtended(var DocumentHeader: Record "Sales Invoice Header"; var TempEDocInvRefBuffer: Record "KVSADVEdocInvRefBuffer" temporary; var IsHandled: Boolean): 

Parameters:

  • DocumentHeader: The posted sales invoice header for which references are collected.
  • TempEDocInvRefBuffer: The temporary buffer for the advance invoice references and payment data.
  • IsHandled: Set to true to skip the default buffer population.

Remarks: The default implementation adds advance invoice references and payment and tax data for ZUGFeRD Extended. The event is raised before the buffer is cleared.