public DataMapAutoCashCalculation[] CalculatePayrollCashflow(DataMapAutoCashCalculation[] cashTable, string payrollDataFilePath)
        {
            DataMapPayrollCashflow[] payrollData = GetPayrollData(payrollDataFilePath);

            WeekendSkipper weekendSkipper = new WeekendSkipper();

            PayrollTaxScheduler payrollTaxScheduler = new PayrollTaxScheduler();

            for (int i = 0; i < payrollData.Length; i++)
            {
                if (payrollData[i].Eingerechnet == false)
                {
                    //Scheduled paymemt to employees on 28th
                    DateTime employeePayDate = payrollData[i].Faellig;
                    employeePayDate = new DateTime(employeePayDate.Year, employeePayDate.Month, 28);
                    int daysTillPayable = Convert.ToInt32((employeePayDate - cashTable[0].Datum).TotalDays);
                    daysTillPayable += weekendSkipper.SkipWeekend(employeePayDate);
                    employeePayDate  = cashTable[daysTillPayable].Datum;
                    cashTable[daysTillPayable].Payroll += payrollData[i].Nettogehaelter;

                    //Payroll taxes payable next month
                    cashTable[daysTillPayable + payrollTaxScheduler.CalcDaysTillPayrollTaxClearing(employeePayDate)].Payroll += payrollData[i].Lohnabgaben;

                    payrollData[i].Eingerechnet = true;
                }
            }
            SavePayrollData(payrollData, payrollDataFilePath);
            Log.Information("Sales data processed, status saved to " + payrollDataFilePath);
            return(cashTable);
        }
Exemplo n.º 2
0
        public DataMapAutoCashCalculation[] CalculateSalesCashflow(DataMapAutoCashCalculation[] cashTable, string salesDataFilePath)
        {
            DataMapSalesCashflow[] salesData = GetSalesData(salesDataFilePath);

            WeekendSkipper weekendSkipper = new WeekendSkipper();

            SalesTaxScheduler salesTaxScheduler = new SalesTaxScheduler();

            for (int i = 0; i < salesData.Length; i++)
            {
                if (salesData[i].Eingerechnet == false)
                {
                    int daysTillDelivery = Convert.ToInt32((salesData[i].Lieferdatum - cashTable[0].Datum).TotalDays);


                    //customer's prepayment 9 days before delivery
                    int daysTillPrepayment = daysTillDelivery - 9;
                    //wire only on work days
                    DateTime prepaymentDate = cashTable[daysTillPrepayment].Datum;
                    daysTillPrepayment += weekendSkipper.SkipWeekend(prepaymentDate);
                    prepaymentDate      = cashTable[daysTillPrepayment].Datum;
                    //prepayment, incl value added tax
                    cashTable[daysTillPrepayment].Sales += (salesData[i].Nettopreis * 0.2) * 1.2;
                    //VAT clearing
                    cashTable[daysTillPrepayment + salesTaxScheduler.CalcDaysTillVATclearing(prepaymentDate)].Sales -= (salesData[i].Nettopreis * 0.2) * 0.2;


                    //vendor's material purchase 5 days before delivery
                    int daysTillMaterialPurchase = daysTillDelivery - 5;
                    //money transfer works only on work days
                    DateTime materialPurchaseDate = cashTable[daysTillMaterialPurchase].Datum;
                    daysTillMaterialPurchase += weekendSkipper.SkipWeekend(materialPurchaseDate);
                    materialPurchaseDate      = cashTable[daysTillMaterialPurchase].Datum;
                    //material purchase, incl. value added tax
                    cashTable[daysTillMaterialPurchase].Sales -= (salesData[i].Nettopreis * 0.17) * 1.2;
                    //VAT clearing
                    cashTable[daysTillMaterialPurchase + salesTaxScheduler.CalcDaysTillVATclearing(materialPurchaseDate)].Sales += (salesData[i].Nettopreis * 0.17) * 0.2;

                    //remaining 80% paid by customer on delivery day, incl. value added tax
                    //do weekend skipping needed, because delivery can be entered with weekdays only
                    cashTable[daysTillDelivery].Sales += (salesData[i].Nettopreis * 0.8) * 1.2;
                    //VAT clearing
                    cashTable[daysTillDelivery + salesTaxScheduler.CalcDaysTillVATclearing(salesData[i].Lieferdatum)].Sales -= (salesData[i].Nettopreis * 0.8) * 0.2;

                    salesData[i].Eingerechnet = true;
                }
            }
            SaveSalesData(salesData, salesDataFilePath);
            Log.Information("Sales data processed, status saved to " + salesDataFilePath);
            return(cashTable);
        }
        public int CalcDaysTillPayrollTaxClearing(DateTime date)
        {
            int daysTillpayrollTax;

            DateTime calcPayrollTaxclearingDate = date;

            WeekendSkipper weekendSkipper = new WeekendSkipper();

            calcPayrollTaxclearingDate = new DateTime(calcPayrollTaxclearingDate.Year, calcPayrollTaxclearingDate.Month + 1, 15);

            daysTillpayrollTax = Convert.ToInt32((calcPayrollTaxclearingDate - date).TotalDays) + weekendSkipper.SkipWeekend(calcPayrollTaxclearingDate);

            return(daysTillpayrollTax);
        }
        public int CalcDaysTillVATclearing(DateTime date)
        {
            int daysTillVAT;

            DateTime calcVATclearingDate = date;

            WeekendSkipper weekendSkipper = new WeekendSkipper();

            calcVATclearingDate = new DateTime(calcVATclearingDate.Year, calcVATclearingDate.Month + 2, 15);



            daysTillVAT = Convert.ToInt32((calcVATclearingDate - date).TotalDays) + weekendSkipper.SkipWeekend(calcVATclearingDate);

            Console.WriteLine("date  " + date);
            Console.WriteLine("calcVATclearingDate " + calcVATclearingDate);
            Console.WriteLine("daysTillVAT  " + daysTillVAT);


            return(daysTillVAT);
        }