コード例 #1
0
        private (PkudatYomanShura[] shuras, bool isBalanced) GeneratePkudatYoman(GeneralBillingSummary dbSummary, DateTime dateOfRegistration, SupplierEntity supplier = null)
        {
            string dateOfRegistrationString = dateOfRegistration.ToString("yyyyMMdd");
            string DateOfValueString        = dbSummary.DateOfValue.ToString("yyyyMMdd");

            if (dbSummary != null)
            {
                supplier = supplier == null ? new SuppliersService(context).GetSuppliersByCustomer(new CustomerEntity {
                    Id = dbSummary.CustomerId
                }).FirstOrDefault(x => x.Id == dbSummary.SupplierId && x.IsEnable):supplier;
                var budgetsContracts = new BudgetContractService(context).GetRelationshipBySupplier(supplier);
                var contracts        = new ContractsService(context).GetBySupplier(supplier).Result;
                var banks            = new BankAccountsService(context).GetBySupplier(supplier);
                switch (Convert.ToInt32(dbSummary.SupplierId))
                {
                case (int)Enums.Suppliers.Bezek:
                    return(createPkudaForBezek(dbSummary, dateOfRegistrationString, supplier, DateOfValueString, budgetsContracts, contracts, banks).Result);

                case (int)Enums.Suppliers.Electricity:
                    return(createPkudaForElectricity(dbSummary, dateOfRegistrationString, supplier, DateOfValueString, budgetsContracts, contracts, banks).Result);

                default:
                    return(createPkudaForPrivateSupplier(dbSummary, dateOfRegistrationString, supplier, DateOfValueString, budgetsContracts, contracts, banks).Result);
                }
            }
            return(null, false);
        }
コード例 #2
0
 private (GeneralBillingSummary summary, string invoiceNumber) InsertExcelRowToGeneralBilling(ExcelRange row, int customerId, string supplierId)
 {
     try
     {
         var maxEntity = context.GeneralBillingSummary;
         int maxId     = maxEntity != null && maxEntity.Count() > 0 ? maxEntity.Max(x => x.RowId) + 1 : 1;
         GeneralBillingSummary generalBillingSummary = new GeneralBillingSummary();
         generalBillingSummary.CustomerId            = customerId;
         generalBillingSummary.BillFromDate          = DateTime.ParseExact(row[2, 7].Text, "dd/MM/yyyy", null);
         generalBillingSummary.BillToDate            = DateTime.ParseExact(row[2, 8].Text, "dd/MM/yyyy", null);
         generalBillingSummary.SupplierClientNumber  = Convert.ToInt32(row[2, 2].Text);
         generalBillingSummary.SupplierId            = supplierId;
         generalBillingSummary.SupplierPayerId       = Convert.ToInt32(row[2, 1].Text);
         generalBillingSummary.TotalInvoice          = Convert.ToDecimal(row[2, 20].Text);
         generalBillingSummary.TotalInvoiceBeforeTax = Convert.ToDecimal(row[2, 15].Text);
         generalBillingSummary.TotalChangableBilling = Convert.ToDecimal(row[2, 10].Text);
         generalBillingSummary.TotalCredit           = Convert.ToDecimal(row[2, 13].Text);
         generalBillingSummary.TotalDebit            = Convert.ToDecimal(row[2, 24].Text);
         generalBillingSummary.TotalFixedBilling     = Convert.ToDecimal(row[2, 9].Text);
         generalBillingSummary.TotalOneTimeBilling   = Convert.ToDecimal(row[2, 11].Text);
         generalBillingSummary.TotalExtraPayments    = Convert.ToDecimal(row[2, 21].Text) + Convert.ToDecimal(row[2, 22].Text);
         generalBillingSummary.DateOfValue           = DateTime.ParseExact(row[2, 4].Text, "dd/MM/yyyy", null);
         generalBillingSummary.RowId = maxId;
         context.GeneralBillingSummary.Add(generalBillingSummary);
         return(generalBillingSummary, row[2, 6].Text);
コード例 #3
0
        private GeneralBillingSummary createGeneralBillingDefaults(FileEntity file, ExcelWorksheet sheet)
        {
            var      maxEntity            = context.GeneralBillingSummary;
            int      maxId                = maxEntity != null && maxEntity.Count() > 0 ? maxEntity.Max(x => x.RowId) + 1 : 1;
            DateTime now                  = DateTime.Now;
            DateTime fromDate             = now.AddMonths(-1);
            GeneralBillingSummary summary = new GeneralBillingSummary()
            {
                CustomerId           = file.CustomerId,
                SupplierId           = file.SupplierId,
                RowId                = maxId,
                SupplierPayerId      = 0,
                SupplierClientNumber = 0,
                Sent                  = false,
                TotalInvoice          = 0,
                TotalInvoiceBeforeTax = 0,
            };

            summary.BillFromDate = string.IsNullOrEmpty(sheet.Cells[2, 1].Text.Trim()) ? new DateTime(fromDate.Year, fromDate.Month, DateTime.DaysInMonth(fromDate.Year, fromDate.Month)) : DateTime.ParseExact(sheet.Cells[2, 1].Text.Trim(), "dd/MM/yyyy", null);
            summary.BillToDate   = string.IsNullOrEmpty(sheet.Cells[2, 2].Text.Trim()) ? new DateTime(now.Year, now.Month, DateTime.DaysInMonth(now.Year, now.Month)) : DateTime.ParseExact(sheet.Cells[2, 2].Text.Trim(), "dd/MM/yyyy", null);
            int totalFixedBilling = 0;

            summary.TotalFixedBilling = int.TryParse(sheet.Cells[2, 3].Text.Trim(), out totalFixedBilling) ? totalFixedBilling : 0;
            int totalChangableBilling = 0;

            summary.TotalChangableBilling = int.TryParse(sheet.Cells[2, 4].Text.Trim(), out totalChangableBilling) ? totalChangableBilling : 0;
            int totalOneTimeBilling = 0;

            summary.TotalOneTimeBilling = int.TryParse(sheet.Cells[2, 5].Text.Trim(), out totalOneTimeBilling) ? totalOneTimeBilling : 0;
            int totalExtraPayments = 0;

            summary.TotalExtraPayments = int.TryParse(sheet.Cells[2, 6].Text.Trim(), out totalExtraPayments) ? totalExtraPayments : 0;
            return(summary);
        }
コード例 #4
0
        public async Task <bool> GetDataFromExcel(FileEntity fileEntity, bool hasHeader = true)
        {
            using (var transaction = context.Database.BeginTransaction())
            {
                try
                {
                    GeneralBillingSummary billingSummary = createGeneralBillingDefaults(fileEntity);
                    var result = await Task.Run(() => {
                        using (var file = new StreamReader(fileEntity.File.OpenReadStream(), Encoding.GetEncoding("Windows-1255")))
                        {
                            string line = "";
                            int counter = 1;
                            List <ElectricityFileInfo> electricities = new List <ElectricityFileInfo>();
                            while ((line = file.ReadLine()) != null)
                            {
                                electricities.Add(createElectricityFileInfoRow(line, counter++, ref billingSummary));
                            }
                            billingSummary.BillFromDate          = electricities.Min(x => x.BillCreatingDate);
                            billingSummary.BillToDate            = electricities.Max(x => x.BillCreatingDate);
                            billingSummary.TotalChangableBilling = billingSummary.TotalDebit;
                            context.ElectricityFileInfo.AddRange(electricities);
                            return(true);
                        }
                    });

                    if (result)
                    {
                        context.GeneralBillingSummary.Add(billingSummary);
                        context.SaveChanges();
                        transaction.Commit();
                    }
                    return(result);
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    throw e;
                }
            }
        }
コード例 #5
0
        private BezekFileInfo[] disassembleCreditDebitWS(ExcelWorksheet excel, bool hasHeader, GeneralBillingSummary generalInsertResult, string invoiceNumber)
        {
            var startRow = hasHeader ? 2 : 1;
            List <BezekFileInfo> bezeks = new List <BezekFileInfo>();

            for (int rowNum = startRow; rowNum <= excel.Dimension.End.Row; rowNum++)
            {
                if (!string.IsNullOrEmpty(excel.Cells[rowNum, 1].Text))
                {
                    bezeks.Add(CreateExcelRowToBezekTable(excel, rowNum, generalInsertResult, invoiceNumber));
                }
                else
                {
                    break;
                }
            }
            return(bezeks.ToArray());
        }
コード例 #6
0
 private async Task <BezekFileInfo[]> disassembleExcel(List <ExcelWorksheet> excel, bool hasHeader, GeneralBillingSummary generalInsertResult, string invoiceNumber)
 {
     if (generalInsertResult.TotalExtraPayments == 0)
     {
         return(await Task.Run(() =>
         {
             return disassembleCreditDebitWS(excel[0], hasHeader, generalInsertResult, invoiceNumber);
         }));
     }
     else
     {
         List <Task <BezekFileInfo[]> > tasks = new List <Task <BezekFileInfo[]> >();
         tasks.Add(Task.Run(() =>
         {
             return(disassembleCreditDebitWS(excel.SingleOrDefault(x => x.Name == "חיובים וזיכויים"), hasHeader, generalInsertResult, invoiceNumber));
         }));
         tasks.Add(Task.Run(() =>
         {
             return(disassemblePreviousPaymentsWS(excel.SingleOrDefault(x => x.Name == "סכומים מחשבוניות קודמות"), hasHeader, generalInsertResult, invoiceNumber, excel.SingleOrDefault(x => x.Name == "חיובים וזיכויים").Dimension.End.Row + 1));
         }));
         var result = Task.WhenAll(tasks).Result;
         result[0] = result[0].Concat(result[1]).ToArray();
         return(result[0]);
     }
 }
コード例 #7
0
 private BezekFileInfo CreateExcelRowToBezekTablePreviousPayments(ExcelWorksheet sheet, int rowNum, GeneralBillingSummary generalSummary, string invoiceNumber, int rowId)
 {
     try
     {
         BezekFileInfo fileInfo = new BezekFileInfo();
         fileInfo.BillingAmountAfterTax = string.IsNullOrEmpty(sheet.Cells[rowNum, 7].Text.Trim()) ? 0 : decimal.Parse(sheet.Cells[rowNum, 7].Text.Trim());
         fileInfo.BillingAmount         = string.IsNullOrEmpty(sheet.Cells[rowNum, 5].Text.Trim()) ? 0 : decimal.Parse(sheet.Cells[rowNum, 5].Text.Trim());
         fileInfo.BillingDescription    = sheet.Cells[rowNum, 10].Text.Trim();
         fileInfo.BillingType           = sheet.Cells[rowNum, 4].Text.Trim();
         fileInfo.CallRate              = 0;
         fileInfo.CallsAmount           = 0;
         fileInfo.GeneralRowId          = generalSummary.RowId;
         fileInfo.CallTime              = "";
         fileInfo.DepartmentNumber      = "";
         fileInfo.ClientNumber          = sheet.Cells[rowNum, 1].Text.Trim();
         fileInfo.ConsumptionAmount     = 0;
         fileInfo.CustomerId            = generalSummary.CustomerId;
         fileInfo.DiscountPrecent       = 0;
         fileInfo.FreeTimeUsage         = "";
         fileInfo.FreeTimeUsageSupplier = "";
         fileInfo.HebServiceType        = "";
         fileInfo.OriginalClient        = "";
         fileInfo.OriginalPayer         = 0;
         int     paymentsLeft  = string.IsNullOrEmpty(sheet.Cells[rowNum, 15].Text.Trim()) ? 0 : int.Parse(sheet.Cells[rowNum, 15].Text.Trim());
         decimal paymentsSoFar = string.IsNullOrEmpty(sheet.Cells[rowNum, 13].Text.Trim()) ? 0 : decimal.Parse(sheet.Cells[rowNum, 13].Text.Trim());
         int     totalPayments = Convert.ToInt32(paymentsSoFar / fileInfo.BillingAmountAfterTax) + paymentsLeft;
         fileInfo.MonthlyRate          = fileInfo.BillingAmountAfterTax;
         fileInfo.PayerNumberBezek     = Convert.ToInt32(sheet.Cells[rowNum, 2].Text.Trim());
         fileInfo.PriceBeforeDiscount  = 0;
         fileInfo.SecondaryServiceType = "";
         fileInfo.ServiceType          = "";
         fileInfo.StartDateBilling     = string.IsNullOrEmpty(sheet.Cells[rowNum, 9].Text.Trim()) ? generalSummary.BillFromDate : DateTime.ParseExact(sheet.Cells[rowNum, 9].Text.Trim(), "dd/MM/yyyy", null);
         fileInfo.EndDateBilling       = totalPayments != 0 ? fileInfo.StartDateBilling.Value.AddMonths(totalPayments) : fileInfo.StartDateBilling.Value;
         fileInfo.SubscriptionNumber   = Convert.ToInt32(sheet.Cells[rowNum, 3].Text.Trim().Replace("-", ""));
         fileInfo.TimePeriodText       = "";
         fileInfo.IsMatched            = false;
         fileInfo.RowId         = rowId;
         fileInfo.InvoiceNumber = invoiceNumber;
         decimal taxAmount = string.IsNullOrEmpty(sheet.Cells[rowNum, 6].Text.Trim()) ? 0 : decimal.Parse(sheet.Cells[rowNum, 6].Text.Trim());
         fileInfo.TaxRate = taxAmount != 0 && fileInfo.BillingAmount != 0 ? Convert.ToInt32((((taxAmount + fileInfo.BillingAmount) / fileInfo.BillingAmount) - 1) * 100) : 0;
         return(fileInfo);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
コード例 #8
0
 private BezekFileInfo CreateExcelRowToBezekTable(ExcelWorksheet sheet, int rowNum, GeneralBillingSummary generalSummary, string invoiceNumber)
 {
     try
     {
         BezekFileInfo fileInfo = new BezekFileInfo();
         fileInfo.BillingAmount         = string.IsNullOrEmpty(sheet.Cells[rowNum, 9].Text.Trim()) ? 0 : decimal.Parse(sheet.Cells[rowNum, 9].Text.Trim());
         fileInfo.BillingDescription    = sheet.Cells[rowNum, 8].Text.Trim();
         fileInfo.BillingType           = sheet.Cells[rowNum, 7].Text.Trim();
         fileInfo.CallRate              = string.IsNullOrEmpty(sheet.Cells[rowNum, 19].Text.Trim()) ? 0 : decimal.Parse(sheet.Cells[rowNum, 19].Text.Trim());
         fileInfo.CallsAmount           = string.IsNullOrEmpty(sheet.Cells[rowNum, 18].Text.Trim()) ? 0 : int.Parse(sheet.Cells[rowNum, 18].Text.Trim());
         fileInfo.GeneralRowId          = generalSummary.RowId;
         fileInfo.CallTime              = sheet.Cells[rowNum, 17].Text.Trim();
         fileInfo.DepartmentNumber      = sheet.Cells[rowNum, 3].Text.Trim();
         fileInfo.ClientNumber          = sheet.Cells[rowNum, 1].Text.Trim();
         fileInfo.ConsumptionAmount     = string.IsNullOrEmpty(sheet.Cells[rowNum, 11].Text.Trim()) ? 0 : int.Parse(sheet.Cells[rowNum, 11].Text.Trim());
         fileInfo.TaxRate               = string.IsNullOrEmpty(sheet.Cells[rowNum, 10].Text.Trim()) ? 0 : int.Parse(sheet.Cells[rowNum, 10].Text.Trim());
         fileInfo.CustomerId            = generalSummary.CustomerId;
         fileInfo.DiscountPrecent       = string.IsNullOrEmpty(sheet.Cells[rowNum, 16].Text.Trim()) ? 0.0 : double.Parse(sheet.Cells[rowNum, 16].Text.Trim());
         fileInfo.EndDateBilling        = string.IsNullOrEmpty(sheet.Cells[rowNum, 6].Text.Trim()) ? generalSummary.BillToDate : DateTime.ParseExact(sheet.Cells[rowNum, 6].Text.Trim(), "dd/MM/yyyy", null);
         fileInfo.FreeTimeUsage         = sheet.Cells[rowNum, 20].Text.Trim();
         fileInfo.FreeTimeUsageSupplier = sheet.Cells[rowNum, 20].Text.Trim();
         fileInfo.HebServiceType        = sheet.Cells[rowNum, 25].Text.Trim();
         fileInfo.MonthlyRate           = string.IsNullOrEmpty(sheet.Cells[rowNum, 12].Text.Trim()) ? 0 : decimal.Parse(sheet.Cells[rowNum, 12].Text.Trim());
         fileInfo.OriginalClient        = sheet.Cells[rowNum, 14].Text.Trim();
         fileInfo.OriginalPayer         = string.IsNullOrEmpty(sheet.Cells[rowNum, 15].Text.Trim()) ? 0 : int.Parse(sheet.Cells[rowNum, 15].Text.Trim());
         fileInfo.PayerNumberBezek      = Convert.ToInt32(sheet.Cells[rowNum, 2].Text.Trim());
         fileInfo.PriceBeforeDiscount   = string.IsNullOrEmpty(sheet.Cells[rowNum, 13].Text.Trim()) ? 0 : decimal.Parse(sheet.Cells[rowNum, 13].Text.Trim());
         fileInfo.SecondaryServiceType  = sheet.Cells[rowNum, 24].Text.Trim();
         fileInfo.ServiceType           = sheet.Cells[rowNum, 23].Text.Trim();
         fileInfo.StartDateBilling      = string.IsNullOrEmpty(sheet.Cells[rowNum, 5].Text.Trim()) ? generalSummary.BillFromDate : DateTime.ParseExact(sheet.Cells[rowNum, 5].Text.Trim(), "dd/MM/yyyy", null);
         fileInfo.SubscriptionNumber    = Convert.ToInt32(sheet.Cells[rowNum, 4].Text.Trim().Replace("-", ""));
         fileInfo.TimePeriodText        = sheet.Cells[rowNum, 21].Text.Trim();
         fileInfo.IsMatched             = false;
         fileInfo.RowId                 = rowNum;
         fileInfo.InvoiceNumber         = invoiceNumber;
         fileInfo.BillingAmountAfterTax = Math.Round(fileInfo.BillingAmount * ((fileInfo.TaxRate != 0 ? Convert.ToDecimal(fileInfo.TaxRate) / 100 : 0) + 1), 2);
         return(fileInfo);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
コード例 #9
0
 private async Task <PrivateSupplierFileInfo[]> disassembleExcel(ExcelWorksheet excel, bool hasHeader, GeneralBillingSummary generalInsertResult)
 {
     return(await Task.Run(() =>
     {
         var startRow = hasHeader ? 2 : 1;
         List <PrivateSupplierFileInfo> privateSuppliers = new List <PrivateSupplierFileInfo>();
         for (int rowNum = startRow; rowNum <= excel.Dimension.End.Row; rowNum++)
         {
             if (!string.IsNullOrEmpty(excel.Cells[rowNum, 1].Text))
             {
                 var result = CreateExcelRowToPrivateTable(excel, rowNum, ref generalInsertResult);
                 if (result != null)
                 {
                     privateSuppliers.Add(result);
                 }
                 else
                 {
                     return null;
                 }
             }
             else
             {
                 break;
             }
         }
         return privateSuppliers.ToArray();;
     }));
 }
コード例 #10
0
        private PrivateSupplierFileInfo CreateExcelRowToPrivateTable(ExcelWorksheet sheet, int rowNum, ref GeneralBillingSummary generalSummary)
        {
            try
            {
                PrivateSupplierFileInfo fileInfo = new PrivateSupplierFileInfo();

                int contract = 0;
                if (int.TryParse(sheet.Cells[rowNum, 2].Text.Trim(), out contract))
                {
                    fileInfo.Contract = contract;
                    int invoice = 0;
                    if (int.TryParse(sheet.Cells[rowNum, 1].Text.Trim(), out invoice))
                    {
                        DateTime dateOfValue = new DateTime(1, 1, 1);
                        if (DateTime.TryParseExact(sheet.Cells[rowNum, 5].Text.Trim(), "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.AssumeLocal, out dateOfValue))
                        {
                            fileInfo.Amount             = string.IsNullOrEmpty(sheet.Cells[rowNum, 4].Text.Trim()) ? 0 : decimal.Parse(sheet.Cells[rowNum, 4].Text.Trim());
                            fileInfo.TaxRate            = string.IsNullOrEmpty(sheet.Cells[rowNum, 6].Text.Trim().Replace("%", "")) ? 0 : int.Parse(sheet.Cells[rowNum, 6].Text.Trim().Replace("%", ""));
                            fileInfo.AmountAfterTax     = fileInfo.Amount * (fileInfo.TaxRate != 0 ? (Convert.ToDecimal(fileInfo.TaxRate) / 100) : 0 + 1);
                            generalSummary.TotalCredit += fileInfo.AmountAfterTax < 0 ? -1 * fileInfo.AmountAfterTax : 0;
                            generalSummary.TotalDebit  += fileInfo.AmountAfterTax < 0 ? fileInfo.AmountAfterTax : 0;
                            fileInfo.Description        = sheet.Cells[rowNum, 3].Text.Trim();
                            fileInfo.GeneralRowId       = generalSummary.RowId;
                            fileInfo.CustomerId         = generalSummary.CustomerId;
                            fileInfo.DateOfValue        = dateOfValue;
                            fileInfo.RowId              = rowNum;
                            fileInfo.Invoice            = invoice;
                            return(fileInfo);
                        }
                    }
                }
                return(null);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
コード例 #11
0
        private ElectricityFileInfo createElectricityFileInfoRow(string line, int rowId, ref GeneralBillingSummary summary)
        {
            string[]            values = line.Split(';');
            ElectricityFileInfo info   = new ElectricityFileInfo();

            info.GeneralRowId       = summary.RowId;
            info.RowId              = rowId;
            info.CustomerId         = summary.CustomerId;
            info.BillCreatingDate   = DateTime.ParseExact(values[6], "yyMMdd", null);
            info.NumberOfCreditDays = Convert.ToInt32(values[7].Substring(1));
            info.Amount             = Convert.ToDecimal(values[8]) / 100;
            info.PaymentDate        = DateTime.ParseExact(values[9], "yyMMdd", null);
            info.ConsumerAddress    = values[11];
            info.ConsumerName       = values[10];
            info.BankCode           = Convert.ToInt32(values[13]);
            info.BankBranch         = Convert.ToInt32(values[14]);
            info.BankAccount        = Convert.ToInt32(values[15]);
            info.BankAccountType    = Convert.ToInt32(values[16]);
            info.MonthOfLastInvoice = DateTime.ParseExact(values[17], "MMyy", null).Month;
            info.YearOfLastInvoice  = DateTime.ParseExact(values[17], "MMyy", null).Year;
            info.ConsumerNumber     = Convert.ToInt32(values[18]);
            info.Contract           = Convert.ToInt32(values[19]);
            info.Invoice            = Convert.ToInt64(values[20]);
            summary.DateOfValue     = summary.DateOfValue.Year != 1 ? summary.DateOfValue : new DateTime(info.PaymentDate.Year, info.PaymentDate.Month, DateTime.DaysInMonth(info.PaymentDate.Year, info.PaymentDate.Month));
            summary.TotalCredit    += info.Amount < 0 ? -1 * info.Amount : 0;
            summary.TotalDebit     += info.Amount >= 0 ? info.Amount : 0;
            return(info);
        }
コード例 #12
0
        private (bool isSuccess, string msg) sendPkuda(PkudatYomanShura[] yomanShuras, SupplierEntity supplier, GeneralBillingSummary summary, UserEntity user, DateTime dateOfRegistration)
        {
            SystemHeader             systemHeader             = getSystemHeader(user);
            CreatePkudatYomanRequest createPkudatYomanRequest = getYomanRequest(user, supplier, dateOfRegistration.ToString("yyyyMMdd"), summary.DateOfValue.ToString("yyyyMMdd"));

            createPkudatYomanRequest.Rows = yomanShuras;
            foreach (var row in createPkudatYomanRequest.Rows)
            {
                row.Teur = row.Teur.Replace("emitetad", summary.DateOfValue.ToString("MM/yy"));
                row.Teur = row.Teur.Replace("rebmuntneilc", summary.SupplierClientNumber.ToString());
            }
            return(true, "פעולת היומן שוגרה בהצלחה לפיננסים");  //delete in case of real sending
            //var msg = new PkudatYomanWSClient().createPkudatYoman(systemHeader, createPkudatYomanRequest);
            //if (msg.Msg.RcType == 1)
            //{
            //    var dbSupplier = context.Suppliers.FirstOrDefault(x => x.SupplierCustomerId == supplier.CustomerId && x.SupplierId == supplier.Id);
            //    dbSupplier.SupplierPkudatYomanNumber += 1;
            //    summary.Sent = true;
            //    context.SaveChanges();
            //    return (true, "פעולת היומן שוגרה בהצלחה לפיננסים");
            //}
            //else
            //{
            //    return (false, msg.Msg.RcMessage);
            //}
        }
コード例 #13
0
        private async Task <(PkudatYomanShura[] shuras, bool isBalanced)> createPkudaForBezek(GeneralBillingSummary summary, string dateOfRegistration, SupplierEntity supplier, string DateOfValueString,
                                                                                              BudgetContractEntity[] budgetsContracts, ContractEntity[] contracts, BankAccountEntity[] banks)
        {
            var dbData = await context.BezekFileInfo.Where(x => x.GeneralRowId == summary.RowId && x.CustomerId == summary.CustomerId && x.IsMatched).ToArrayAsync();

            var invoiceData = dbData.GroupBy(x => x.InvoiceNumber);
            int rowAmount   = 0;
            Dictionary <long, Dictionary <(long, int), PkudatYomanShura> > invoices = new Dictionary <long, Dictionary <(long, int), PkudatYomanShura> >();

            return(await Task.Run(() =>
            {
                foreach (var invoice in invoiceData)
                {
                    var data = invoice.GroupBy(x => x.SubscriptionNumber);
                    Dictionary <(long, int), PkudatYomanShura> pkudatYomanShuras = new Dictionary <(long, int), PkudatYomanShura>();
                    Dictionary <(long, int), PkudatYomanShura> pkudatYomanShurasBanks = new Dictionary <(long, int), PkudatYomanShura>();
                    pkudatYomanShuras.Add((supplier.SupplierNumberInFinance, 2), createPkduatYomanSupplierRow(summary, supplier, dateOfRegistration, DateOfValueString, invoice.Key));
                    foreach (var row in data)
                    {
                        var contract = contracts.FirstOrDefault(x => x.Id == row.Key);
                        if (contract == null)
                        {
                            break;
                        }
                        var budgets = getContractBudgets(budgetsContracts, row.Key);
                        for (int j = 0; j < budgets.Length; j++)
                        {
                            double amount = row.Sum(x => Convert.ToDouble(x.BillingAmountAfterTax)) * budgets[j].Precent / 100;
                            PkudatYomanShura pkudatYomanShura = new PkudatYomanShura();
                            if (pkudatYomanShuras.TryGetValue((budgets[j].BudgetId, 1), out pkudatYomanShura))
                            {
                                pkudatYomanShura.Schum += amount;
                            }