Cross-company data sharing vs. Duplication in Dynamics

Cross-company data sharing vs. Duplication in Dynamics

Cross-company data sharing

Cross-company data sharing in Dynamics 365 for Finance and SCM (see System administration > Setup > Configure cross-company data sharing) supposed to be a valid replacement of the virtual companies in Dynamics AX2012 and earlier. I don’t know how about you, but I get the error “Table … is a Main table as specified by the table group and may not be shared unless its Data Sharing Type is Duplicate” every time I wish to share something useful.

It looks for the TableGroup property in the D365 table metadata and practically rejects any table which is not a Group or does not have a simple primary key. What is left for sharing? Some little configuration tables such as the Delivery terms (INCOTERMS), Payment terms ans so on: only these have the TableGroup = Group.  This rules out the most interesting tables in Dynamics such as the InventTable (Product list), CustTable (Customers) or VendTable (Suppliers) (well, this is not entirely true: for the latter there is a dedicated Feature Customer and Vendor master data sharing available for activation). Namely, these have TableGroup = Main.

The TableGroup property of the standard tables is not extendable. The developers left a backdoor: a Main table with the property DataSharingType explicitly set to Single or Duplicate may be eligible too. CustTable is an example. Needless to say, the DataSharingType is not extendable either. There seems to be a yet another backdoor in the form of the SysDataSharingTypeTableConfiguration table where this DataSharingType is supposed to be configured. However, this feature is protected by the flight EnableSysDataSharingTypeTableConfiguration. As with every flight it is very promising and tempting but it remains hard-locked in any production environment.

Dead end? Not quite.

Recurring ‘Copy into legal entity’ data project 

In Data management, create a new data project of the Copy into legal entity kind, select the destination company(ies) and the appropriate entity or entities:

It should not grab unfinished work, though. In this example it is obvious to only consider an approved bill of materials. The BOM lines do not have an approved  flag, but if there is no BOMId, no line can be copied either, i.e. it is sufficient to only filter the BOM headers. In general, you should take care of the data consistency. In the particular case of the bills of materials, they should not contain any unknown items or refer to any local inventory dimension such as the site, warehouse or the warehouse location: ensure the default sites in all companies in question have the same code “STD” or “DEF”, and set the Resource consumption checkbox in all lines to make them warehouse-agnostic. The Approver is not a problem, since the employee list is technically shared across all legal entities.

Click Copy into legal entity in batch and set a Recurrence e.g. every weekday. The data project may be run over and over again in a cycle copying the same data, but it is not a problem as it works in the UPSERT mode in Dynamics. However, as the data grows the data project runs slower. We should restrict the set and take only the changes of the day, for example. If you are lucky, there will be a ModifiedDateTime column you can use in the Filter:

(here with a Join and an advanced moving date query).

German travel expenses in Dynamics 365 – Part 2

German travel expenses in Dynamics 365 – Part 2

Confinued from German travel expenses in Dynamics 365 / Deutsche Reisekostenabrechnung 2022

Domestic business travel – Case 2 “3 days of training with hotel”

The 2nd case requires a receipt, a bill for the accommodation at a hotel. The VAT from domestic invoices may be recovered, and we need a country-specific setup for the VAT (…> Setup > General > Tax configurations) where the host country is associated with a tax group containing both full (19%) and reduced (7%) tax codes.

Set up an additional category of the type “Hotel”, assign the reduced 7% tax group to this category. Let the user enter a line against his category as an amount including tax, and select the  Country/region = DEU. The domestic VAT is derived automatically by the system: €9,58.

The two lunches reduce the per diems by €22,40 down to €33,60 as required:

Domestic business travel – Case 3 “Hotel breakfast”

This time the hotel served Erika breakfasts. The breakfast is presented on the bill separately, since the accommodation and meals are subsidized through the reduced VAT of 7%, but beverages other than water are taxed at the full rate of 19%:

Hotel Rechnung mit Frühstück
This requires an “Itemization” and at least 2 expense Subcategories under the main expense category Hotel. You can deactivate all standard subcategories but the Daily room rate, Restaurant and Loungebar and apply the full rate to the latter. The VAT amount by the “item” can be reviewed under Itemization details, the total VAT amount from the itemizations is not visible elsewhere. 

If this is considered an unreasonable workload, you may abandon the itemization and simply edit the total VAT receivable in the Actual VAT amount field.

The entertainment (de: Bewirtung) may be dealt with similarly: 2 subcategories or even 3, as the tips (de: Trinkgeld) are VAT free. A mandatory list of guests may be enforced with a travel expense policy (Expense management > Setup > Policies > Expense report) where a submission to the workflow is prevented with an error message if the Number of persons entertained = 0 for any expense category of the Entertainment type:

Case 4 “Travelling abroad”

As we have learned already, daily allowances are country-specific. The reduced domestic rate for Germany is 50%, but the reduced foreign rates are close to 66% (but not exactly): here is an example for Switzerland, note the ratio:

  Full 24h day “First/last day” Ratio
– Geneva €66 €44 66,67%
– the rest of Switzerland €64 €43 67,19%

The reduced rates are rounded by the government to whole euros. To match the reduced foreign rate, I use a tailored percentage. It should approximate the daily rate with a deviation less than €0,01:
44/66 = 0,6666… => 66,00 * 66,67% = 44,0022 ~= 44,00
43/64 = 0,671875 => 64,00 * 67,19% = 43,0016 ~= 43,00

The respective setup of per diems and tiers per location is shown on the following screenshot:

Note that the rates are updated by the BMF every year and have to be regularly re-imported with validity dates. This is also true for the calculated percentage for first/last day.

The meals reduction and per diem calculation now caters for the rates in Geneva:

Switzerland does not belong to the EU, and their foreign VAT on the hotel bill is not recoverable, the selection of the right country code removes the VAT. No itemization is needed, the hotel bill may be entered as a lump sum in Swiss francs. The amount paid in Swiss francs is converted to euro at the intrinsic System exchange rate type, or at a user-defined rate.

German travel expenses in Dynamics 365 / Deutsche Reisekostenabrechnung 2022

TANSTAAFL: "there ain’t no such thing as a free lunch" from "The Moon Is a Harsh Mistress" by Robert A. Heinlein

German travel expenses in Dynamics 365 / Deutsche Reisekostenabrechnung 2022

Travel expense reporting in Germany may be implemented in Dynamics 365 for Finance with literally no customizations. A special attention must be paid to the per diem calculation.


In general, per diem in Germany is an allowance for catering. Hotel bills are reimbursed in full. An employee of a German company – let’s call her Erika Mustermann – typically gets reimbursed for meals a fixed statutory amount per day. If she is paid above the legally prescribed daily rate, the difference would be subject to her income tax.

For domestic trips within Germany she becomes 28 Euro per day, yet this full rate is only applied from the second day on multi-day business trips. For the first and the last day Erika becomes only ½ of the daily ration  = €14:

Length of the tripPer diems rate 2020-2022
Less than 8 hours0 EUR
More than 8, less than 24 hours14 EUR
24 hours (a full calendar day)28 EUR
First day (arrival) or last day (departure)14 EUR

Erika is obliged to report every free meal sponsored by the employer or customer, reduce the daily allowance in accordance with the “20-40-40” rule:

Meal typeReductionReduction amount
“Free” breakfast at the hotel20%-€5,60
Free lunch at work40%-€11,20
Dinner sponsored by the boss40%-€11,20

The statutory per diem rates vary by country and sometimes specific to a city. The rates are regularly updated by the federal government and rounded to full euros: The “20-40-40” meal reduction rule also applies to destinations abroad, based on the full 24h rate.

In the following chapters 4 distinct realistic cases are explored, with the appropriate setup in Dynamics 365 for Finance:

 NarrativePer diems calculation

Case 1

“One-day training”

Erika attended a daily training nearby and was absent from 9:00 till 19:00. One lunch was provided by the training centre.
One day	€14,00
Reduction	-€11,20
Grand total	€2,80

Case 2

“3 days of training with hotel”

Same as before, but the business trip now took 3 days in total:

  • from 18:00 on Monday
  • whole Tuesday
  • until 19:00 on Wednesday.

This included 2 nights at a hotel without breakfast at €73,25. 2 lunches were served.

First day	€14,00
Day between	€28,00
Last day	€14,00
Reduction	-€11,20*2 = -€22,40
Total	€33,60
2 nights	€73,25*2 = €146,50
Grand total	€180,10

Case 3

“Hotel breakfast”

Same as before: 3 days in total, but the hotel bill included 2 breakfasts. The breakfasts are separately shown: €9 inkl. VAT 7% (e.g. bread) and 19% (e.g. coffee) each:
2 lunches were consumed for free at the training center. In addition, Erika invited a potential customer to a restaurant.
First day	€14,00
Day between	€28,00
Last day	€14,00
Reduction	-€11,20*2 -€5,60*2= -€33,60
Total	€22,40
2 nights	€73,25*2 = €146,50
2 breakfasts	€9*2 = €18,00
Hotel	€164,50
Dinner 	€115,00
Grand total	€301,90

Case 4

“Travelling abroad”

Erika went to Switzerland. On the same dates as above she flew to Geneva, resided 2 nights at the “President Wilson” and slowly consumed 2 exquisite breakfasts served on the Lac Leman shore.
First day	€44,00
Day between	€66,00
Last day	€44,00
Reduction	-€13,20*2 = -€26,40
Total	€127,60
2 nights	2*770,0 CHF = 1440,00 CHF
2 breakfasts	2*45,00 CHF = 90,00 CHF
2 city tax	2*4,75 CHF = 9,50 CHF
Hotel	1639,50 CHF ~= €1573,92

Domestic business travel – Case 1 “One-day training”

Let’s start setting up the system for the Case 1. First of all, we require a shared expense category PerDiem of the type “Allowance”. This expense category is then selected under local legal entity expense categories (Expense management > Setup >  General > Expense categories). In Germany the allowance excludes tax, i.e. the VAT may not be claimed:

The right per diem parameters (Expense management > Setup > General > Expense management parameters) for Germany can be read from the following screenshot:

In our second case the allowance is paid for every of the 3 calendar days and the Base per diem calculation on must be Calendar day with time.  The Meal reductions are self-explaining. The First and last day defaults are used to model the reduced rate on the days of arrival and departure. The Per diem rounding = Normal rounding, because we don’t round up cents to whole euros.

The Calculate meal reduction by may be set to either Meal type per day and Meal type per trip, since the breakfast weights less than lunch/dinner and the meal reduction amount stays the same for the first/last/middle day.

Per diems locations shall be created next. Every leg in on the business trip has to be given a “location” to deduct the right allowance for that country or city. The rate per location is assigned here: Expense management> Setup > Calculations and codes > Per diems. The fist and the last day assume a reduced allowance, this can be modelled by means of the Per diem rate tiers:

The reduction (€14/€28 = 50%) is the same for the day of arrival and the day of departure, therefore the most concise setting is Apply to = Both. On an overnight stay, the 8 hours threshold is ignored: in the above examples 2-4 the first day is eligible despite it only lasted 24:00-18:00 = 6 hours. Therefore we may not set Minimum hours = 8; the threshold can be enforced differently with a customized “Expense report policy”, see below.

We now can test Case 1, but first make sure that the Meal reduction, Breakfast, Lunch, Dinner, Location fields are activated in the Expense management > Setup > General > Display fields.

In Expense management > My expenses > Expense reports, add a new report, choose the location, add a new line PerDiem. The UI automatically switches to the detailed mode where you can enter the start and the end date/time of your trip and choose the Per diem location:

On the Per diems tab, set Lunch = 1. The reduction of €11,20 is applied as expected, and the total allowance amount becomes €2,80. To post the expense report an approval workflow has to be in place.

Remember, a one-day trip less than 8 hours does not count as business travel. The per diem rate tiers cannot be used to enforce it, but here are 2 possible alternatives:

  • solve it organizationally, establish “human-driven” approval rules
  • make a small extension to the class TrvRuleExpressionSetup to enable the total trip duration, the start and the end date as parameters in the expense policy definition:

public FromDate parmPerDiemFromDate(CompanyId _companyId, TableId _tableId, RecId _recId)
TrvExpTrans trvExpTrans = TrvExpTrans::find(_recId);
return DateTimeUtil::date(DateTimeUtil::applyTimeZoneOffset(trvExpTrans.DateFrom, DateTimeUtil::getUserPreferredTimeZone()));
public ToDate parmPerDiemToDate(CompanyId _companyId, TableId _tableId, RecId _recId)
TrvExpTrans trvExpTrans = TrvExpTrans::find(_recId);
return DateTimeUtil::date(DateTimeUtil::applyTimeZoneOffset(trvExpTrans.DateTo, DateTimeUtil::getUserPreferredTimeZone()));
public Hours parmPerDiemHours(CompanyId _companyId, TableId _tableId, RecId _recId)
TrvExpTrans trvExpTrans = TrvExpTrans::find(_recId);
return any2real(DateTimeUtil::getDifference(trvExpTrans.DateTo, trvExpTrans.DateFrom)/3600);


Here: German travel expenses in Dynamics 365 – Part 2