Пример #1
0
        public LoadVatReturnRawData(int nCustomerMarketplaceID)
        {
            m_oSp = new SpLoadVatReturnRawData(nCustomerMarketplaceID, DB, Log);

            VatReturnRawData   = new VatReturnRawData[0];
            RtiTaxMonthRawData = new RtiTaxMonthRawData[0];
        }         // constructor
Пример #2
0
        }         // HmrcRtiTaxMonthConversion

        private VatReturnRawData[] HmrcVatReturnConversion(IHarvester oHarvester)
        {
            var oVatRecords = new List <VatReturnRawData>();

            foreach (KeyValuePair <string, ISeeds> pair in ((Ezbob.HmrcHarvester.Harvester)oHarvester).Hopper.Seeds[DataType.VatReturn])
            {
                var oData = (VatReturnSeeds)pair.Value;

                var oEntry = new VatReturnRawData {
                    BusinessAddress = oData.BusinessAddress,
                    BusinessName    = oData.BusinessName,
                    DateDue         = oData.DateDue,
                    DateFrom        = oData.DateFrom,
                    DateTo          = oData.DateTo,
                    Period          = oData.Period,
                    RegistrationNo  = oData.RegistrationNo,
                };

                foreach (KeyValuePair <string, Ezbob.HmrcHarvester.Coin> oBoxData in oData.ReturnDetails)
                {
                    oEntry.Data[oBoxData.Key] = new Ezbob.Backend.Models.Coin {
                        Amount       = oBoxData.Value.Amount,
                        CurrencyCode = oBoxData.Value.CurrencyCode,
                    };
                }                 // for each box

                oVatRecords.Add(oEntry);
            }             // for each file

            return(oVatRecords.ToArray());
        }         // HmrcVatReturnConversion
Пример #3
0
            }             // Delete

            private void AddHistoryItem(VatReturnRawData oDeletedItem)
            {
                oDeletedItem.IsDeleted = true;

                HistoryItems.Add(new HistoryItem {
                    DeleteRecordInternalID = oDeletedItem.InternalID,
                    ReasonID = (int)DeleteReasons.ManualDeleted,
                });
            }             // AddHistoryItem
Пример #4
0
        public void CalculateBankStatements(VatReturnRawData lastVatReturn, BankStatementDataModel bankStatement)
        {
            decimal box3 = 0;
            decimal box4 = 0;
            decimal box6 = 0;
            decimal box7 = 0;

            if (lastVatReturn != null)
            {
                foreach (KeyValuePair <string, Coin> vat in lastVatReturn.Data)
                {
                    if (vat.Key.Contains("(Box 3)"))
                    {
                        box3 = vat.Value.Amount;
                    }
                    else if (vat.Key.Contains("(Box 4)"))
                    {
                        box4 = vat.Value.Amount;
                    }
                    else if (vat.Key.Contains("(Box 6)"))
                    {
                        box6 = vat.Value.Amount;
                    }
                    else if (vat.Key.Contains("(Box 7)"))
                    {
                        box7 = vat.Value.Amount;
                    }
                }         // foreach
            }             // if

            var vatRevenues = 1 + (box6 == 0 ? 0 : (box3 / box6));
            var vatOpex     = 1 + (box7 == 0 ? 0 : (box4 / box7));

            BankStatement.Revenues          = vatRevenues == 0 ? bankStatement.Revenues : bankStatement.Revenues / (double)vatRevenues;
            BankStatement.Opex              = Math.Abs(vatOpex == 0 ? bankStatement.Opex : bankStatement.Opex / (double)vatOpex);
            BankStatement.TotalValueAdded   = bankStatement.Revenues - bankStatement.Opex;
            BankStatement.PercentOfRevenues = Math.Abs(bankStatement.Revenues - 0) < 0.01 ? 0 : bankStatement.TotalValueAdded / bankStatement.Revenues;
            BankStatement.Ebida             = bankStatement.TotalValueAdded + (bankStatement.Salaries + bankStatement.Tax);
            BankStatement.FreeCashFlow      = bankStatement.Ebida - bankStatement.ActualLoansRepayment;

            if (BankStatement.PeriodMonthsNum == 0)
            {
                return;
            }

            const int year = 12;

            BankStatementAnnualized.Revenues          = (BankStatement.Revenues / BankStatement.PeriodMonthsNum * year);
            BankStatementAnnualized.Opex              = (BankStatement.Opex / BankStatement.PeriodMonthsNum * year);
            BankStatementAnnualized.TotalValueAdded   = BankStatementAnnualized.Revenues - BankStatementAnnualized.Opex;
            BankStatementAnnualized.PercentOfRevenues = Math.Abs(BankStatementAnnualized.Revenues) < 0.01 ? 0 : BankStatementAnnualized.TotalValueAdded / BankStatementAnnualized.Revenues;
            BankStatementAnnualized.Salaries          = (BankStatement.Salaries / BankStatement.PeriodMonthsNum * year);
            BankStatementAnnualized.Tax   = (BankStatement.Tax / BankStatement.PeriodMonthsNum * year);
            BankStatementAnnualized.Ebida = BankStatementAnnualized.TotalValueAdded + (BankStatementAnnualized.Salaries + BankStatementAnnualized.Tax);
            BankStatementAnnualized.ActualLoansRepayment = (BankStatement.ActualLoansRepayment / BankStatement.PeriodMonthsNum * year);
            BankStatementAnnualized.FreeCashFlow         = BankStatementAnnualized.Ebida - BankStatementAnnualized.ActualLoansRepayment;
        } // CalculateBankStatements
Пример #5
0
        }         // Name

        public override void Execute()
        {
            var oVat = new SortedDictionary <int, VatReturnRawData>();
            var oRti = new List <RtiTaxMonthRawData>();

            m_oSp.ForEachRowSafe((sr, bRowsetStart) => {
                string sRowType = sr["RowType"];

                switch (sRowType)
                {
                case "record":
                    var r            = sr.Fill <VatReturnRawData>();
                    oVat[r.RecordID] = r;
                    break;

                case "entry":
                    oVat[sr["RecordID"]].Data[sr["Name"]] = new Coin(sr["Amount"], sr["CurrencyCode"]);
                    break;

                case "rti":
                    oRti.Add(sr.Fill <RtiTaxMonthRawData>());
                    break;
                }                 // switch

                return(ActionResult.Continue);
            });

            if (oVat.Count > 0)
            {
                VatReturnRawData = new VatReturnRawData[oVat.Count];
                oVat.Values.CopyTo(VatReturnRawData, 0);
                Array.Sort(VatReturnRawData);
            }             // if

            if (oRti.Count > 0)
            {
                RtiTaxMonthRawData = oRti.ToArray();
                Array.Sort(RtiTaxMonthRawData);
            }     // if
        }         // Execute
Пример #6
0
            }             // HistoryItem

            private VatReturnRawData Delete(VatReturnRawData oItem)
            {
                this.m_oOldDeletedItems.Add(oItem.RecordID);
                return(oItem);
            }             // Delete
Пример #7
0
            }             // IsEmptyInput

            public void AddHistoryItem(VatReturnRawData oOld, VatReturnRawData oNew)
            {
                // At this point oOld and oNew have overlapping date intervals
                // and same registration # and oNew is not deleted.

                DeleteReasons    nReason;
                VatReturnRawData oDeletedItem;
                VatReturnRawData oReasonItem;

                switch (oOld.SourceType)
                {
                case VatReturnSourceType.Linked:
                    if (oNew.SourceType == VatReturnSourceType.Linked)
                    {
                        oDeletedItem = Delete(oOld);
                        oReasonItem  = oNew;
                        nReason      = DeleteReasons.LinkedUpdated;
                    }
                    else
                    {
                        oDeletedItem = oNew;
                        oReasonItem  = oOld;
                        nReason      = oNew.SourceType == VatReturnSourceType.Manual
                                                        ? DeleteReasons.ManualRejectedByLinked
                                                        : DeleteReasons.UploadedRejectedByLinked;
                    }
                    break;

                case VatReturnSourceType.Uploaded:
                    switch (oNew.SourceType)
                    {
                    case VatReturnSourceType.Linked:
                        oDeletedItem = Delete(oOld);
                        oReasonItem  = oNew;
                        nReason      = DeleteReasons.UploadedRejectedByLinked;
                        break;

                    case VatReturnSourceType.Uploaded:
                        oDeletedItem = oNew;
                        oReasonItem  = oOld;
                        nReason      = oOld.SameAs(oNew) ? DeleteReasons.UploadedEqual : DeleteReasons.UploadedNotEqual;
                        break;

                    case VatReturnSourceType.Manual:
                        oDeletedItem = oNew;
                        oReasonItem  = oOld;
                        nReason      = DeleteReasons.ManualRejectedByUploaded;
                        break;

                    default:
                        throw new StrategyAlert(this.m_oStrategy, "Non implemented VAT return source type: " + oNew.SourceType);
                    }                     // switch

                    break;

                case VatReturnSourceType.Manual:
                    oDeletedItem = Delete(oOld);
                    oReasonItem  = oNew;

                    switch (oNew.SourceType)
                    {
                    case VatReturnSourceType.Linked:
                        nReason = DeleteReasons.ManualRejectedByLinked;
                        break;

                    case VatReturnSourceType.Uploaded:
                        nReason = DeleteReasons.OverriddenByUploaded;
                        break;

                    case VatReturnSourceType.Manual:
                        nReason = DeleteReasons.ManualUpdated;
                        break;

                    default:
                        throw new StrategyAlert(this.m_oStrategy, "Non implemented VAT return source type: " + oNew.SourceType);
                    }                     // switch

                    break;

                default:
                    throw new StrategyAlert(this.m_oStrategy, "Non implemented VAT return source type: " + oNew.SourceType);
                }                 // switch

                oDeletedItem.IsDeleted = true;

                HistoryItems.Add(new HistoryItem {
                    DeleteRecordInternalID = oDeletedItem.InternalID,
                    ReasonRecordInternalID = oReasonItem.InternalID,
                    ReasonID = (int)nReason,
                });
            }             // AddHistoryItem