Table of Contents

Class DocumentExtension

Namespace
RetailForce.Fiscalisation.Model.Document
Assembly
RetailForce.Fiscalisation.Model.dll
public static class DocumentExtension
Inheritance
DocumentExtension
Inherited Members

Methods

CalculateDiscountedValues(DocumentPositionSubItem, DocumentPositionItem)

Calculates the gross, net, tax and tax2 values of subitems to reflect discounts, added to the parent item.

public static (decimal grossValue, decimal netValue, decimal taxValue, decimal? taxValue2) CalculateDiscountedValues(this DocumentPositionSubItem subItem, DocumentPositionItem parent)

Parameters

subItem DocumentPositionSubItem

The subitem

parent DocumentPositionItem

The parent of the subitem. It is needed to calculate the discount factor (rabattFactor). The discount value is calculated as GrossValue (the gross value with discount) / BaseGrossValue (the gross value without discount)

Returns

(decimal grossValue, decimal netValue, decimal taxValue, decimal? taxValue2)

GetBookingPositions(Document)

Returns all positions of type DocumentPositionBooking.

public static List<DocumentPositionBooking> GetBookingPositions(this Document document)

Parameters

document Document

The document to fetch the positions.

Returns

List<DocumentPositionBooking>

GetBusinessTransactionTypePositions(Document, BusinessTransactionType?)

Returns all business type transaction positions.

public static IEnumerable<IBusinessTransactionTypePosition> GetBusinessTransactionTypePositions(this Document document, BusinessTransactionType? businessTransactionType = null)

Parameters

document Document

The document where the positions are stored.

businessTransactionType BusinessTransactionType?

A filter to fetch only positions having this business transaction type. Optional.

Returns

IEnumerable<IBusinessTransactionTypePosition>

All business type transaction positions.

Remarks

If document or document.Positions is null this method returns null.

GetItemAndBookingPositions(Document?, Func<IBusinessTransactionTypePosition, bool>?)

Returns all positions of type DocumentPositionItem and DocumentPositionBooking.

public static IEnumerable<IBusinessTransactionTypePosition>? GetItemAndBookingPositions(this Document? document, Func<IBusinessTransactionTypePosition, bool>? positionFilter = null)

Parameters

document Document

The document to fetch the positions.

positionFilter Func<IBusinessTransactionTypePosition, bool>

Optional. A possible positionFilter expression.

Returns

IEnumerable<IBusinessTransactionTypePosition>

A list of type DocumentPositionVatPosition representing all positions of type DocumentPositionItem and DocumentPositionBooking.

Remarks

This method does not include sub item positions.

GetItemPositions(Document)

Returns all positions of type DocumentPositionItem.

public static List<DocumentPositionItem> GetItemPositions(this Document document)

Parameters

document Document

The document to fetch the positions.

Returns

List<DocumentPositionItem>

Remarks

This method does not include sub item positions.

GetTaxPositions(Document, ItemType, bool)

The summary of the tax positions for the document for the given item tax type.

public static List<DocumentTaxPosition> GetTaxPositions(this Document document, ItemType taxType, bool valuePositionCalculation)

Parameters

document Document

The document to fetch the positions.

taxType ItemType

The item type to filter the tax positions.

valuePositionCalculation bool

Returns

List<DocumentTaxPosition>

A list of tax positions representing the tax of document grouped by vat rates.

GetTaxPositions(Document?, bool, Func<IBusinessTransactionTypePosition, bool>?, bool, bool)

The summary of the tax positions for the document.

public static IEnumerable<DocumentTaxPosition>? GetTaxPositions(this Document? document, bool notUseTaxPositions = true, Func<IBusinessTransactionTypePosition, bool>? positionFilter = null, bool valuePositionCalculation = false, bool roundTwoDigitsBeforeSum = false)

Parameters

document Document

The document to fetch the positions.

notUseTaxPositions bool

Optional. If tax positions of document are manually set and this parameter is true, the document tax positions will not be used.

positionFilter Func<IBusinessTransactionTypePosition, bool>

Optional. A possible positionFilter expression.

valuePositionCalculation bool
roundTwoDigitsBeforeSum bool

rounds to two digits before sum

Returns

IEnumerable<DocumentTaxPosition>

GetTaxPositions(IEnumerable<IBusinessTransactionTypePosition>, bool, bool)

The summary of the tax positions for the given positions.

public static IEnumerable<DocumentTaxPosition> GetTaxPositions(this IEnumerable<IBusinessTransactionTypePosition> positions, bool valuePositionCalculation, bool roundTwoDigitsBeforeSum = false)

Parameters

positions IEnumerable<IBusinessTransactionTypePosition>
valuePositionCalculation bool
roundTwoDigitsBeforeSum bool

rounds to two digits before sum

Returns

IEnumerable<DocumentTaxPosition>

GetTotalBaseGrossAmount(Document?, Func<IBusinessTransactionTypePosition, bool>?)

Returns the total base gross amount of the given document.

public static decimal GetTotalBaseGrossAmount(this Document? document, Func<IBusinessTransactionTypePosition, bool>? positionFilter = null)

Parameters

document Document

The document to evaluate the total gross amount.

positionFilter Func<IBusinessTransactionTypePosition, bool>

Optional. A possible positionFilter expression.

Returns

decimal

The total base gross amount of the given document.

Remarks

The value is returned without regarding the document type.

GetTotalDiscountAmount(Document?, Func<DocumentPositionItem, bool>?)

Returns the total discount amount of the given document.

public static decimal GetTotalDiscountAmount(this Document? document, Func<DocumentPositionItem, bool>? positionFilter = null)

Parameters

document Document

The document to evaluate the total net amount.

positionFilter Func<DocumentPositionItem, bool>

Optional. A possible positionFilter expression.

Returns

decimal

The total net amount of the given document.

Remarks

The value is returned without regarding the document type.

GetTotalDiscountQuantity(Document?, Func<DocumentPositionItem, bool>?)

Returns the total discount quantity of the given document.

public static int GetTotalDiscountQuantity(this Document? document, Func<DocumentPositionItem, bool>? positionFilter = null)

Parameters

document Document

The document to evaluate the discount quantity.

positionFilter Func<DocumentPositionItem, bool>

Optional. A possible positionFilter expression.

Returns

int

The discount quantity of the given document.

Remarks

The value is returned without regarding the document type.

GetTotalGrossAmount(Document?, Func<IBusinessTransactionTypePosition, bool>?)

Returns the total gross amount of the given document.

public static decimal GetTotalGrossAmount(this Document? document, Func<IBusinessTransactionTypePosition, bool>? positionFilter = null)

Parameters

document Document

The document to evaluate the total gross amount.

positionFilter Func<IBusinessTransactionTypePosition, bool>

Optional. A possible positionFilter expression.

Returns

decimal

The total gross amount of the given document.

Remarks

The value is returned without regarding the document type.

GetTotalNetAmount(Document?, Func<IBusinessTransactionTypePosition, bool>?)

Returns the total net amount of the given document.

public static decimal GetTotalNetAmount(this Document? document, Func<IBusinessTransactionTypePosition, bool>? positionFilter = null)

Parameters

document Document

The document to evaluate the total net amount.

positionFilter Func<IBusinessTransactionTypePosition, bool>

Optional. A possible positionFilter expression.

Returns

decimal

The total net amount of the given document.

Remarks

The value is returned without regarding the document type.

NOTE: diese funktion unterstützt derzeit noch nicht das Flag UseSubItemVatCalculation --> sollte sie schon, aber nicht ohne vorherige Rücksprache mit Wolfgang ändern, weil zu zentrale Codestelle! --> siehe Ticket RF #1539

GetTotalTaxAmount(Document, Func<IBusinessTransactionTypePosition, bool>?)

Returns the total tax amount of the given document.

public static decimal GetTotalTaxAmount(this Document document, Func<IBusinessTransactionTypePosition, bool>? positionFilter = null)

Parameters

document Document

The document to evaluate the total tax amount.

positionFilter Func<IBusinessTransactionTypePosition, bool>

Optional. A possible positionFilter expression.

Returns

decimal

The total tax amount of the given document.

Remarks

The value is returned without regarding the document type.

GetTotalTaxAmount2(Document, Func<IBusinessTransactionTypePosition, bool>?)

Returns the total tax amount 2 of the given document.

public static decimal GetTotalTaxAmount2(this Document document, Func<IBusinessTransactionTypePosition, bool>? positionFilter = null)

Parameters

document Document

The document to evaluate the total tax amount 2.

positionFilter Func<IBusinessTransactionTypePosition, bool>

Optional. A possible positionFilter expression.

Returns

decimal

The total tax amount 2 of the given document.

Remarks

The value is returned without regarding the document type.

GetVoucherIds(Document)

Returns all voucher id's for the document (including id's of booking elements, not only payments).

public static List<string> GetVoucherIds(this Document document)

Parameters

document Document

The document to get all voucher id's.

Returns

List<string>

All voucher id's for the document (including id's of booking elements, not only payments).

calculateGrossFromNet(decimal, decimal, decimal?)

Calculates gross value from net amount and the vat percentages

public static decimal calculateGrossFromNet(decimal netAmount, decimal vatPercent1, decimal? vatPercent2)

Parameters

netAmount decimal
vatPercent1 decimal
vatPercent2 decimal?

Returns

decimal