Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EN16931 XRechnung (CII) Fehler #423

Open
goedo opened this issue Nov 7, 2024 · 0 comments
Open

EN16931 XRechnung (CII) Fehler #423

goedo opened this issue Nov 7, 2024 · 0 comments

Comments

@goedo
Copy link

goedo commented Nov 7, 2024

Hi!
Ich habe nochmal die neueste Version heruntergeladen, die gibt noch folgende KOSIT-Fehlermeldungen:

image

und

image

Lösung in InvoiceDescriptor23CIIWriter.cs:

Zeile 29

 public class BG23 : Tax //roger
 {
     public new decimal TaxAmount { get; set; } // comes from tax
     public decimal BT116 { get; set; } // comes from tax
     public decimal BT131 { get; set; } // comes from tax
     public decimal BT99 { get; set; }
     public decimal BT92 { get; set; }
 }

Zeile 324

 #region ChargePercentage
 if (tradeAllowanceCharge.ChargePercentage.HasValue)
 {
     //Writer.WriteStartElement("ram", "CalculationPercent", profile: Profile.Extended | Profile.XRechnung); //roger
     Writer.WriteStartElement("ram", "CalculationPercent", profile: Profile.Extended);//roger not allowed EN16931 (CII) (val-sch.1)
     Writer.WriteValue(_formatDecimal(tradeAllowanceCharge.ChargePercentage.Value, 2));
     Writer.WriteEndElement();
 }
 #endregion

Zeile 896

 #region ApplicableTradeTax
 //  11. ApplicableTradeTax (optional)
 //_writeOptionalTaxes(Writer); //roger
 _writeOptionalTaxesNew(Writer); //roger
 #endregion

Neue Funktion

        private void _writeOptionalTaxesNew(ProfileAwareXmlTextWriter writer) //roger
        {
            List<BG23> BG23List = new List<BG23>();
            // collect tax info
            foreach (Tax tax in this.Descriptor.Taxes)
            {
                // new bg32 object
                BG23 bg23 = new BG23();

                bg23.AllowanceChargeBasisAmount = tax.AllowanceChargeBasisAmount;
                bg23.Percent = tax.Percent;
                bg23.ExemptionReasonCode = tax.ExemptionReasonCode;
                bg23.ExemptionReason = tax.ExemptionReason;
                bg23.BasisAmount = tax.BasisAmount;
                bg23.TaxAmount = tax.TaxAmount;
                bg23.CategoryCode = tax.CategoryCode;
                bg23.TypeCode = tax.TypeCode;
                BG23 checkBG23 = BG23List.Find(x => x.CategoryCode == bg23.CategoryCode && x.Percent == bg23.Percent && x.ExemptionReasonCode == bg23.ExemptionReasonCode
                    );
                // add BT values 
                if (checkBG23 == null) // neu
                {
                    bg23.BT116 = tax.BasisAmount;
                    bg23.TypeCode = bg23.TypeCode;
                    bg23.BT131 = tax.BasisAmount;
                    BG23List.Add(bg23);
                }
                else // vorhanden
                {
                    bg23 = checkBG23;
                    bg23.BT131 += tax.BasisAmount;
                    bg23.BT116 += tax.BasisAmount;
                    bg23.BasisAmount += tax.BasisAmount;
                    bg23.TaxAmount += tax.TaxAmount;
                }
                // BT-116 sum of Invoice line net amounts (BT-131) plus the sum of document level charge amounts (BT-99) minus the sum of document level allowance amounts (BT-92) 
                //Console.WriteLine(string.Format("1 BG-23 BT-116:{0} BT-131:{1} BT-117:{2})", bg23.BT116, bg23.BT131, bg23.TaxAmount));
            }
            foreach (var c in this.Descriptor.GetTradeAllowanceCharges())
            {
                BG23 bg23 = BG23List.Find(x => x.CategoryCode == c.Tax.CategoryCode);
                if (bg23 == null)
                {
                    // cannot be!
                    throw (new Exception("BG23List error"));
                }
                if (c.ChargeIndicator == true)
                {
                    bg23.BT99 += c.ActualAmount;
                    bg23.BT116 += c.ActualAmount;
                }
                else
                {
                    bg23.BT92 += c.ActualAmount;
                    bg23.BT116 -= c.ActualAmount;
                }
                //Console.WriteLine(string.Format("2 BG-23 BT-116:{0} BT-131:{1} BT-117:{2})", bg23.BT116, bg23.BT131, bg23.TaxAmount));
            }
            foreach (BG23 bg23 in BG23List)
            {
#if DEBUG
                //Console.WriteLine(string.Format("BG-23 BT-116: {0}/BT-131: {1})", bg23.BT116, bg23.BT131));
#endif
                writer.WriteStartElement("ram", "ApplicableTradeTax");

                writer.WriteStartElement("ram", "CalculatedAmount");
                writer.WriteValue(_formatDecimal(bg23.TaxAmount));
                writer.WriteEndElement(); // !CalculatedAmount

                writer.WriteElementString("ram", "TypeCode", bg23.TypeCode.EnumToString());
                writer.WriteOptionalElementString("ram" ,"ExemptionReason", bg23.ExemptionReason);
                writer.WriteStartElement("ram", "BasisAmount");
                // sum of Invoice line net amounts (BT-131) plus the sum of document level charge amounts (BT-99) minus the sum of document level allowance amounts (BT-92) 
                writer.WriteValue(_formatDecimal(bg23.BT131));
                //writer.WriteValue(_formatDecimal(bg23.BT116));
                writer.WriteEndElement(); // !BasisAmount

                if (bg23.CategoryCode.HasValue)
                {
                    writer.WriteElementString("ram" ,"CategoryCode", bg23.CategoryCode?.EnumToString());
                }

                if (bg23.ExemptionReasonCode.HasValue)
                {
                    writer.WriteElementString("ram" ,"ExemptionReasonCode", bg23.ExemptionReasonCode?.EnumToString());
                }

                writer.WriteElementString("ram" ,"RateApplicablePercent", _formatDecimal(bg23.Percent));
                writer.WriteEndElement(); // !RateApplicablePercent
            }
        } // !_writeOptionalTaxesNew()

HTH!
VG
Roger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant