Ejemplo n.º 1
0
 public Invoice InvoiceGenerator(GoodsMovement _goodsMovement, bool _toPay, double _discount, Customer _subject, string _employeeCode, bool _isPerc)
 {
     if (_isPerc)
     {
         return(InvoiceFactory.CreateInvoice(UpdateProgressiveNumber(), _toPay, Services.CalculateDiscountPerc(_discount, Services.CalculateAmount(_goodsMovement)), _discount, _subject, new Employee(_employeeCode), _goodsMovement));
     }
     else
     {
         return(InvoiceFactory.CreateInvoice(UpdateProgressiveNumber(), _toPay, Services.CalculateAmountWithDiscount(Services.CalculateAmount(_goodsMovement), _discount), _discount, _subject, new Employee(_employeeCode), _goodsMovement));
     }
 }
Ejemplo n.º 2
0
        protected void UploadInvoice(string strFlag, int selIndex)
        {
            try
            {
                Seller seller = new Seller();
                seller.SellerDaTa = new List <Seller>();

                //TEMPORARY SOLUTION
                Invoice b2bInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BInvoice);
                seller.Invoice = b2bInvoice;

                seller.SellerDaTa = (List <Seller>)Session["SellerDaTa"];
                int result = seller.Invoice.UploadInvoice(seller.SellerDaTa, strInvoiceNo);

                if (result > 0)
                {
                    if (Session["SellerDaTa"] != null)
                    {
                        Session["SellerDaTa"] = null;
                    }

                    BindGrid();

                    if (strFlag == "all")
                    {
                        BtnUpload.Attributes.Add("style", "display:none");
                    }
                    else if (strFlag == "single")
                    {
                        // GVUploadInvoice.Rows[selIndex].FindControl("lnkUpload").Visible = false;
                    }
                    BALAJI.GSP.APPLICATION.User.User masterPage = this.Master as BALAJI.GSP.APPLICATION.User.User;
                    //  masterPage.ShowModalPopupSuccess();
                    ////masterPage.ErrorMessage = "Data Uploaded Successfully !!!";
                }
                else
                {
                    if (Session["SellerDaTa"] != null)
                    {
                        Session["SellerDaTa"] = null;
                    }
                    BALAJI.GSP.APPLICATION.User.User masterPage = this.Master as BALAJI.GSP.APPLICATION.User.User;
                    ////masterPage.ShowModalPopup();
                    ////masterPage.ErrorMessage = "Error !!! Unable to Upload Data!";
                }
            }
            catch (Exception ex)
            {
                cls_ErrorLog ob = new cls_ErrorLog();
                cls_ErrorLog.LogError(ex, Common.LoggedInUserID());
            }
        }
Ejemplo n.º 3
0
        //打印住院发票
        public static void Print(int CostMasterID)
        {
            grproLib.GridppReport Report = new grproLib.GridppReport();
            string ReportPath;
            string PrinterName;
            Object invoice;

            //广东发票打印
            //ReportPath = Constant.ApplicationDirectory + "\\report\\住院发票.grf";
            //PrinterName = HIS_PublicManager.PublicPrintSet.GetPrinterNameByReport("住院发票.grf");
            //invoice =InvoiceFactory.CreateInvoice(CostMasterID,"广东");
            //湖南发票打印
            ReportPath  = Constant.ApplicationDirectory + "\\report\\住院发票_HN.grf";
            PrinterName = HIS_PublicManager.PublicPrintSet.GetPrinterNameByReport("住院发票_HN.grf");
            invoice     = InvoiceFactory.CreateInvoice(CostMasterID, "湖南");


            Report.LoadFromFile(ReportPath);
            Report.Printer.PrinterName = PrinterName;
            GWI_DesReport.HisReport.FillRecordToReport(Report, invoice);
            Report.ParameterByName("WorkName").AsString = HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.WorkName;

            #region 发票项目
            DataTable dt = ((AbstractInvoice)invoice).发票项目费用;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = 1; j <= Report.Parameters.Count; j++)
                {
                    if (dt.Rows[i]["itemname"].ToString().Trim() == Report.Parameters[j].Name)
                    {
                        Report.Parameters[j].Value = dt.Rows[i]["Tolal_Fee"].ToString();
                    }
                }
            }
            #endregion

            if (Report.Printer.PrinterName == null || Report.Printer.PrinterName == "")
            {
                MessageBox.Show("请先设置好此报表的打印机!", "询问", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                return;
            }
#if DEBUG
            Report.PrintPreview(false);
#else
            //Report.PrintPreview(false);
            Report.Print(false);
#endif
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Mapped ebInterface4p2 InvoiceType auf InvoiceType Model
        /// </summary>
        /// <param name="source">ebInterface4p2 InvoiceType</param>
        /// <returns>InvoiceType Model</returns>
        internal static IInvoiceModel MapV4P2ToVm(SRC.InvoiceType source)
        {
            IInvoiceModel invoice = InvoiceFactory.CreateInvoice();

            #region Rechnungskopf
            invoice.InvoiceNumber    = source.InvoiceNumber;
            invoice.InvoiceDate      = source.InvoiceDate;
            invoice.GeneratingSystem = source.GeneratingSystem;
            invoice.DocumentTitle    = source.DocumentTitle;
            invoice.DocumentType     = source.DocumentType.ConvertEnum <DocumentTypeType>();
            invoice.InvoiceCurrency  = source.InvoiceCurrency.ToEnum(ModelConstants.CurrencyCodeFixed); // source.InvoiceCurrency.ConvertEnum<CurrencyType>();
            if (!string.IsNullOrEmpty(source.Language))
            {
                invoice.Language = source.Language.ToEnum(ModelConstants.LanguangeCodeFixed);  //source.Language.ConvertEnum<LanguageType>();
                // invoice.LanguageSpecified = true;
            }
            else
            {
                // invoice.LanguageSpecified = false;
                invoice.Language = ModelConstants.LanguangeCodeFixed;
            }
            invoice.Comment = source.Comment;
            if (source.CancelledOriginalDocument == null)
            {
                invoice.CancelledOriginalDocument = null;
            }
            else
            {
                invoice.CancelledOriginalDocument = new CancelledOriginalDocumentType()
                {
                    Comment               = source.CancelledOriginalDocument.Comment,
                    DocumentType          = source.CancelledOriginalDocument.DocumentType.ConvertEnum <DocumentTypeType>(),
                    DocumentTypeSpecified = source.CancelledOriginalDocument.DocumentTypeSpecified,
                    InvoiceDate           = source.CancelledOriginalDocument.InvoiceDate,
                    InvoiceNumber         = source.CancelledOriginalDocument.InvoiceNumber
                };
            }
            #endregion
            #region Releated Document
            if (source.RelatedDocument != null && source.RelatedDocument.Any())
            {
                invoice.RelatedDocument = new List <RelatedDocumentType>();
                foreach (SRC.RelatedDocumentType relDoc in source.RelatedDocument)
                {
                    var newRel = new RelatedDocumentType()
                    {
                        Comment = relDoc.Comment,
                        DocumentTypeSpecified = relDoc.DocumentTypeSpecified,
                        InvoiceDateSpecified  = relDoc.InvoiceDateSpecified,
                        InvoiceNumber         = relDoc.InvoiceNumber
                    };
                    if (relDoc.InvoiceDateSpecified)
                    {
                        newRel.InvoiceDate = relDoc.InvoiceDate;
                    }
                    if (relDoc.DocumentTypeSpecified)
                    {
                        newRel.DocumentType = relDoc.DocumentType.ConvertEnum <DocumentTypeType>();
                    }
                    invoice.RelatedDocument.Add(newRel);
                }
            }

            #endregion

            #region Delivery
            if (source.Delivery != null)
            {
                if (source.Delivery.Item is SRC.PeriodType)
                {
                    var deliveryType = new PeriodType
                    {
                        FromDate = ((SRC.PeriodType)source.Delivery.Item).FromDate,
                        ToDate   = ((SRC.PeriodType)source.Delivery.Item).ToDate
                    };
                    invoice.Delivery.Item = deliveryType;
                }
                else
                {
                    // Invoice.Delivery.Item = source.Delivery.Item;
                    var period = new PeriodType();
                    if (source.Delivery.Item != null)
                    {
                        period.FromDate = (DateTime)source.Delivery.Item;
                    }
                    invoice.Delivery.Item = period;    // für das Model immer eine Lieferperiode, damit von/bis leichter abgebildet werden kann
                }
            }
            #endregion

            #region Biller
            invoice.Biller.VATIdentificationNumber   = source.Biller.VATIdentificationNumber;
            invoice.Biller.InvoiceRecipientsBillerID = source.Biller.InvoiceRecipientsBillerID;
            invoice.Biller.Address = GetAddress(source.Biller.Address);
            invoice.Biller.Contact = GetContact(source.Biller.Address);
            invoice.Biller.FurtherIdentification = GetFurtherIdentification(source.Biller.FurtherIdentification);

            #endregion

            #region InvoiceRecipient
            invoice.InvoiceRecipient.BillersInvoiceRecipientID = source.InvoiceRecipient.BillersInvoiceRecipientID;
            invoice.InvoiceRecipient.VATIdentificationNumber   = source.InvoiceRecipient.VATIdentificationNumber;
            invoice.InvoiceRecipient.Address = GetAddress(source.InvoiceRecipient.Address);
            invoice.InvoiceRecipient.Contact = GetContact(source.InvoiceRecipient.Address);
            invoice.InvoiceRecipient.OrderReference.OrderID = source.InvoiceRecipient.OrderReference.OrderID;
            invoice.InvoiceRecipient.OrderReference.ReferenceDateSpecified = source.InvoiceRecipient.OrderReference.ReferenceDateSpecified;
            invoice.InvoiceRecipient.OrderReference.ReferenceDate          = source.InvoiceRecipient.OrderReference.ReferenceDate;
            invoice.InvoiceRecipient.FurtherIdentification = GetFurtherIdentification(source.InvoiceRecipient.FurtherIdentification);
            #endregion

            #region Details
            invoice.Details.HeaderDescription = source.Details.HeaderDescription;
            invoice.Details.FooterDescription = source.Details.FooterDescription;

            invoice.Details.ItemList = new List <ItemListType>();

            if (source.Details.ItemList != null)
            {
                foreach (SRC.ItemListType srcItemList in source.Details.ItemList)
                {
                    ItemListType item = new ItemListType
                    {
                        ListLineItem = new List <ListLineItemType>()
                    };
                    foreach (SRC.ListLineItemType srcLineItem in srcItemList.ListLineItem)
                    {
                        ListLineItemType lineItem = new ListLineItemType
                        {
                            AdditionalInformation = null,
                            PositionNumber        = srcLineItem.PositionNumber,
                            Description           = new List <string>()
                        };
                        if (srcLineItem.Description != null)
                        {
                            lineItem.Description = srcLineItem.Description.ToList();
                        }

                        lineItem.ArticleNumber = GetArtikelList(srcLineItem.ArticleNumber);

                        // Menge
                        lineItem.Quantity = new UnitType
                        {
                            Unit  = srcLineItem.Quantity.Unit,
                            Value = srcLineItem.Quantity.Value
                        };

                        // Einzelpreis
                        lineItem.UnitPrice = new UnitPriceType()
                        {
                            Value = srcLineItem.UnitPrice.Value
                        };

                        // Auftragsreferenz
                        lineItem.InvoiceRecipientsOrderReference.OrderID =
                            srcLineItem.InvoiceRecipientsOrderReference.OrderID;
                        lineItem.InvoiceRecipientsOrderReference.OrderPositionNumber =
                            srcLineItem.InvoiceRecipientsOrderReference.OrderPositionNumber;


                        // Rabatte / Zuschläge
                        if (srcLineItem.ReductionAndSurchargeListLineItemDetails != null)
                        {
                            lineItem.ReductionAndSurchargeListLineItemDetails = GetReductionDetails(srcLineItem.ReductionAndSurchargeListLineItemDetails);
                        }
                        lineItem.Description = new List <string>();
                        if (srcLineItem.Description != null)
                        {
                            lineItem.Description = srcLineItem.Description.ToList();
                        }

                        //lineItem.LineItemAmount = srcLineItem.LineItemAmount;
                        lineItem.ReCalcLineItemAmount();
                        // Steuer
                        lineItem.TaxItem = MapVatItemType2Vm(srcLineItem.Item, lineItem.LineItemAmount);
                        item.ListLineItem.Add(lineItem);
                    }
                    invoice.Details.ItemList.Add(item);
                }
            }

            if (source.Details.BelowTheLineItem != null)
            {
                //    if (source.Details.BelowTheLineItem.Length > 0)
                //    {
                //        List<BelowTheLineItemType> belowItems = new List<BelowTheLineItemType>();
                //        foreach (SRC.BelowTheLineItemType item in source.Details.BelowTheLineItem)
                //        {
                //            belowItems.Add(new BelowTheLineItemType()
                //            {
                //                Description = item.Description,
                //                LineItemAmount = item.LineItemAmount
                //            });
                //        }
                //        Invoice.Details.BelowTheLineItem.AddRange(belowItems);
                //    }
                Mapping.MapInvoice.MappingErrors.Add(new MappingError(source.Details.BelowTheLineItem.GetType(), "BelowTheLineItem nicht konvertiert."));
            }
            #endregion

            #region Tax
            invoice.CalculateTotals();


            #endregion

            #region Amount
            invoice.TotalGrossAmount = source.TotalGrossAmount;
            invoice.PayableAmount    = source.PayableAmount;
            #endregion

            #region PaymentMethod
            invoice.PaymentMethod.Comment = source.PaymentMethod.Comment;

            if (source.PaymentMethod.Item != null && source.PaymentMethod.Item.GetType() == typeof(SRC.UniversalBankTransactionType))
            {
                SRC.UniversalBankTransactionType txType = source.PaymentMethod.Item as SRC.UniversalBankTransactionType;
                invoice.PaymentMethod = new PaymentMethodType
                {
                    Item = new UniversalBankTransactionType()
                };
                ((UniversalBankTransactionType)invoice.PaymentMethod.Item).BeneficiaryAccount = new List <AccountType>()
                {
                    new AccountType()
                    {
                        BIC              = txType.BeneficiaryAccount[0].BIC,
                        BankName         = txType.BeneficiaryAccount[0].BankName,
                        IBAN             = txType.BeneficiaryAccount[0].IBAN,
                        BankAccountOwner = txType.BeneficiaryAccount[0].BankAccountOwner
                    },
                };
            }

            #endregion

            #region PaymentConditions
            invoice.PaymentConditions.DueDate = source.PaymentConditions.DueDate;
            if (source.PaymentConditions.Discount != null)
            {
                invoice.PaymentConditions.Discount.Clear();
                foreach (SRC.DiscountType srcDiscount in source.PaymentConditions.Discount)
                {
                    DiscountType discount = new DiscountType()
                    {
                        Amount              = srcDiscount.Amount,
                        AmountSpecified     = srcDiscount.AmountSpecified,
                        BaseAmount          = srcDiscount.BaseAmount,
                        BaseAmountSpecified = srcDiscount.BaseAmountSpecified,
                        PaymentDate         = srcDiscount.PaymentDate,
                        Percentage          = srcDiscount.Percentage,
                        PercentageSpecified = srcDiscount.PercentageSpecified
                    };
                    invoice.PaymentConditions.Discount.Add(discount);
                }
            }

            #endregion
            return(invoice);
        }
Ejemplo n.º 5
0
        public static IUnityContainer Register4Unity()
        {
            IConfigurationSource source = ConfigurationSourceFactory.Create();
            var validationFactory       = ConfigurationValidatorFactory.FromConfigurationSource(source);
            // Unitiy Container
            IUnityContainer uc = new UnityContainer()
                                 .AddNewExtension <SimpleEventBrokerExtension>()
                                 .AddNewExtension <Interception>();

            uc.RegisterInstance(uc, new ContainerControlledLifetimeManager());

            uc.RegisterInstance <ValidatorFactory>(validationFactory);
            //   uc.RegisterInstance<ThisDocument>(Globals.ThisDocument);

            // Error Handler
            uc.RegisterType <ErrorViewModel>();
            uc.RegisterType <ErrorActionPaneViewModel>();
            uc.RegisterType <ErrorActionsPaneControl>();

            // RegisterEventSubscriber();

            // Dialogservice
            uc.RegisterType <ISaveFileDialog, SaveFileDialogViewModel>();
            uc.RegisterType <IOpenFileDialog, OpenFileDialogViewModel>();
            uc.RegisterType <IFolderBrowserDialog, FolderBrowserDialogViewModel>();
            uc.RegisterType <IDialogService, DialogService>();
            uc.RegisterType <FrmSelectVersion>();

            Invoice = InvoiceFactory.CreateInvoice();
            uc.RegisterInstance <IInvoiceModel>(Invoice, new ContainerControlledLifetimeManager());

            // Viewmodels

            uc.RegisterType <RibbonViewModel>();
            uc.RegisterType <InvoiceViewModel>();
            uc.RegisterType <VatViewModel>();
            uc.RegisterType <DetailsViewModel>();
            uc.RegisterType <DetailsViewModels>();
            uc.RegisterType <SkontoViewModel>();
            uc.RegisterType <SkontoViewModels>();
            uc.RegisterType <ProgressViewModel>();
            uc.RegisterType <AboutViewModel>();
            uc.RegisterType <RelatedDocumentType>();

            // Settings
            uc.RegisterType <SettingsViewModel>();

            uc.RegisterType <CurrencyListViewModel>();
            uc.RegisterType <CurrencyListViewModels>();
            uc.RegisterType <BillerSettingsViewModel>();
            uc.RegisterType <HandySignSettingsViewModel>();
            uc.RegisterType <KontoSettingsViewModel>();
            uc.RegisterType <MailSettingsViewModel>();
            uc.RegisterType <SaveLocationSettingsViewModel>();
            uc.RegisterType <SettingsViewModel>();
            uc.RegisterType <UidAbfrageSettingsViewModel>();
            uc.RegisterType <ZustellSettingsViewModel>();

            // Settings Forms
            uc.RegisterType <FrmBillerSettingsView>();
            uc.RegisterType <FrmHandySignSettingsView>();
            uc.RegisterType <FrmKontoSettingsView>();
            uc.RegisterType <FrmMailSettingsView>();
            uc.RegisterType <FrmSaveLocationView>();
            uc.RegisterType <FrmUidAbfrageSettingsView>();

            // Forms
            uc.RegisterType <FrmShowProgress>();
            uc.RegisterType <FrmDetailsList>();
            uc.RegisterType <FrmDetailsEdit>();
            uc.RegisterType <FrmSkontoList>();
            uc.RegisterType <FrmAboutView>();
            uc.RegisterType <FrmBillerSettingsView>();



            // Services
            uc.RegisterType <ISendMailService, SendMailService>();
            uc.RegisterType <IUidAbfrageDienst, UidAbfrageDienst>();
            uc.RegisterType <IStartProcessDienst, StartProcessDienst>();

            //foreach (var reg in uc.Registrations)
            //{
            //    Log.LogWrite(CallerInfo.Create(),"Name:" + reg.Name + ", mapped to:" + reg.MappedToType.Name);
            //}
            return(uc);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Mapped ebInterface4p1 InvoiceType auf InvoiceType Model
        /// </summary>
        /// <param name="source">ebInterface4p1 InvoiceType</param>
        /// <returns>InvoiceType Model</returns>
        internal static IInvoiceModel MapV4P0ToVm(SRC.InvoiceType source)
        {
            IInvoiceModel invoice = InvoiceFactory.CreateInvoice();

            #region Rechnungskopf
            invoice.InvoiceNumber    = source.InvoiceNumber;
            invoice.InvoiceDate      = source.InvoiceDate;
            invoice.GeneratingSystem = source.GeneratingSystem;
            invoice.DocumentTitle    = source.DocumentTitle;
            invoice.DocumentType     = source.DocumentType.ConvertEnum <DocumentTypeType>();
            invoice.InvoiceCurrency  = source.InvoiceCurrency.ConvertEnum <CurrencyType>(); // source.InvoiceCurrency.ConvertEnum<CurrencyType>();
            invoice.Language         = source.Language.ConvertEnum <LanguageType>();

            if (source.CancelledOriginalDocument == null)
            {
                invoice.CancelledOriginalDocument = null;
            }
            else
            {
                invoice.CancelledOriginalDocument = new CancelledOriginalDocumentType()
                {
                    DocumentTypeSpecified = false,

                    InvoiceNumber = source.CancelledOriginalDocument
                };
            }
            #endregion

            #region Delivery
            if (source.Delivery != null)
            {
                if (source.Delivery.Item is SRC.PeriodType)
                {
                    var deliveryType = new PeriodType
                    {
                        FromDate = ((SRC.PeriodType)source.Delivery.Item).FromDate,
                        ToDate   = ((SRC.PeriodType)source.Delivery.Item).ToDate
                    };
                    invoice.Delivery.Item = deliveryType;
                }
                else
                {
                    var period = new PeriodType();
                    if (source.Delivery.Item != null)
                    {
                        period.FromDate = (DateTime)source.Delivery.Item;
                    }
                    invoice.Delivery.Item = period;    // für das Model immer eine Lieferperiode, damit von/bis leichter abgebildet werden kann
                }
            }
            #endregion

            #region Biller
            invoice.Biller.VATIdentificationNumber   = source.Biller.VATIdentificationNumber;
            invoice.Biller.InvoiceRecipientsBillerID = source.Biller.InvoiceRecipientsBillerID;
            invoice.Biller.Address = GetAddress(source.Biller.Address);
            invoice.Biller.Contact = GetContact(source.Biller.Address);
            invoice.Biller.FurtherIdentification = GetFurtherIdentification(source.Biller.FurtherIdentification);

            #endregion

            #region InvoiceRecipient
            invoice.InvoiceRecipient.BillersInvoiceRecipientID = source.InvoiceRecipient.BillersInvoiceRecipientID;
            invoice.InvoiceRecipient.VATIdentificationNumber   = source.InvoiceRecipient.VATIdentificationNumber;
            invoice.InvoiceRecipient.Address = GetAddress(source.InvoiceRecipient.Address);
            invoice.InvoiceRecipient.Contact = GetContact(source.InvoiceRecipient.Address);
            if (source.InvoiceRecipient.OrderReference != null)
            {
                invoice.InvoiceRecipient.OrderReference.OrderID = source.InvoiceRecipient.OrderReference.OrderID;
                invoice.InvoiceRecipient.OrderReference.ReferenceDateSpecified = source.InvoiceRecipient.OrderReference.ReferenceDateSpecified;
                invoice.InvoiceRecipient.OrderReference.ReferenceDate          = source.InvoiceRecipient.OrderReference.ReferenceDate;
            }
            invoice.InvoiceRecipient.FurtherIdentification = null;
            invoice.InvoiceRecipient.SubOrganizationID     = source.InvoiceRecipient.SubOrganizationID;
            invoice.InvoiceRecipient.AccountingArea        = source.InvoiceRecipient.AccountingArea;
            #endregion

            #region Details
            invoice.Details.HeaderDescription = source.Details.HeaderDescription;
            invoice.Details.FooterDescription = source.Details.FooterDescription;

            invoice.Details.ItemList = new List <ItemListType>();
            if (source.Details.ItemList != null)
            {
                foreach (SRC.ItemListType srcItemList in source.Details.ItemList)
                {
                    ItemListType item = new ItemListType
                    {
                        ListLineItem = new List <ListLineItemType>()
                    };
                    foreach (SRC.ListLineItemType srcLineItem in srcItemList.ListLineItem)
                    {
                        ListLineItemType lineItem = new ListLineItemType
                        {
                            AdditionalInformation = null,
                            PositionNumber        = srcLineItem.PositionNumber,
                            Description           = new List <string>()
                        };
                        if (srcLineItem.Description != null)
                        {
                            lineItem.Description = srcLineItem.Description.ToList();
                        }

                        lineItem.ArticleNumber = GetArtikelList(srcLineItem.ArticleNumber);

                        // Menge
                        lineItem.Quantity = new UnitType
                        {
                            Unit  = srcLineItem.Quantity.Unit,
                            Value = srcLineItem.Quantity.Value
                        };

                        // Einzelpreis
                        lineItem.UnitPrice = new UnitPriceType()
                        {
                            Value = srcLineItem.UnitPrice
                        };

                        // Auftragsreferenz
                        lineItem.InvoiceRecipientsOrderReference.OrderID =
                            srcLineItem?.InvoiceRecipientsOrderReference?.OrderID;
                        lineItem.InvoiceRecipientsOrderReference.OrderPositionNumber =
                            srcLineItem?.InvoiceRecipientsOrderReference?.OrderPositionNumber;

                        // Rabatte / Zuschläge
                        if (srcLineItem.ReductionAndSurchargeListLineItemDetails != null)
                        {
                            lineItem.ReductionAndSurchargeListLineItemDetails = GetReductionDetails(srcLineItem.ReductionAndSurchargeListLineItemDetails);
                        }
                        lineItem.Description = new List <string>();
                        if (srcLineItem.Description != null)
                        {
                            lineItem.Description = srcLineItem.Description.ToList();
                        }

                        lineItem.LineItemAmount = srcLineItem.LineItemAmount;

                        // Steuer
                        lineItem.TaxItem = MapVatItemType2Vm(srcLineItem.TaxRate, lineItem.LineItemAmount);
                        lineItem.ReCalcLineItemAmount();
                        item.ListLineItem.Add(lineItem);
                    }
                    invoice.Details.ItemList.Add(item);
                }
            }

            #endregion

            #region Tax
            invoice.CalculateTotals();

            #endregion

            #region Amount
            invoice.TotalGrossAmount = source.TotalGrossAmount;
            invoice.PayableAmount    = source.TotalGrossAmount;
            #endregion

            #region PaymentMethod
            invoice.PaymentMethod.Comment = source.PaymentMethod.Comment;
            {
                SRC.UniversalBankTransactionType txType = source.PaymentMethod as SRC.UniversalBankTransactionType;
                invoice.PaymentMethod = new PaymentMethodType
                {
                    Item = new UniversalBankTransactionType()
                };
                ((UniversalBankTransactionType)invoice.PaymentMethod.Item).BeneficiaryAccount = new List <AccountType>()
                {
                    new AccountType()
                    {
                        BIC              = txType.BeneficiaryAccount.First().BIC,
                        BankName         = txType.BeneficiaryAccount.First().BankName,
                        IBAN             = txType.BeneficiaryAccount.First().IBAN,
                        BankAccountOwner = txType.BeneficiaryAccount.First().BankAccountOwner
                    },
                };
            }

            #endregion

            #region Paymentconditions
            invoice.PaymentConditions.DueDate = source.PaymentConditions.DueDate;
            if (source.PaymentConditions.Discount != null)
            {
                invoice.PaymentConditions.Discount.Clear();
                foreach (SRC.DiscountType srcDiscount in source.PaymentConditions.Discount)
                {
                    DiscountType discount = new DiscountType()
                    {
                        Amount              = srcDiscount.Amount,
                        AmountSpecified     = srcDiscount.AmountSpecified,
                        BaseAmount          = srcDiscount.BaseAmount,
                        BaseAmountSpecified = srcDiscount.BaseAmountSpecified,
                        PaymentDate         = srcDiscount.PaymentDate,
                        Percentage          = srcDiscount.Percentage,
                        PercentageSpecified = srcDiscount.PercentageSpecified
                    };
                    invoice.PaymentConditions.Discount.Add(discount);
                }
            }
            #endregion
            return(invoice);
        }
Ejemplo n.º 7
0
        private DataSet ViewInvoice(string SellerGSTN, string FromDt, String Todate)
        {
            Seller seller = new Seller();

            seller.Reciever  = new Reciever();
            seller.Consignee = new Consignee();
            int       p = 0; int m = 0;
            DataTable dt           = new DataTable();
            string    strInvoiceNo = string.Empty;


            #region INVOICE_TYPE
            switch (strInvoiceType)
            {
            case "B2BInvoice":
                Invoice b2bInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BInvoice);
                seller.Invoice = b2bInvoice;
                break;

            case "AmendedB2BInvoice":
                Invoice AmendedB2BInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BInvoice);
                seller.Invoice = AmendedB2BInvoice;
                break;

            case "B2CLargeInvoice":
                Invoice B2CLargeInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2CLargeInvoice);
                seller.Invoice = B2CLargeInvoice;
                break;

            case "AmendedB2CLargeInvoice":
                Invoice AmendedB2CLargeInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2CLargeInvoice);
                seller.Invoice = AmendedB2CLargeInvoice;
                break;

            case "B2BCreditNotesInvoice":
                Invoice B2BCreditNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BCreditNotesInvoice);
                seller.Invoice = B2BCreditNotesInvoice;
                break;

            case "B2BDebitNotesInvoice":
                Invoice B2BDebitNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BDebitNotesInvoice);
                seller.Invoice = B2BDebitNotesInvoice;
                break;

            case "AmendedB2BCreditNotesInvoice":
                Invoice AmendedB2BCreditNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BCreditNotesInvoice);
                seller.Invoice = AmendedB2BCreditNotesInvoice;
                break;

            case "AmendedB2BDebitNotesInvoice":
                Invoice AmendedB2BDebitNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BDebitNotesInvoice);
                seller.Invoice = AmendedB2BDebitNotesInvoice;
                break;

            case "B2BExportInvoice":
                Invoice B2BExportInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BExportInvoice);
                seller.Invoice = B2BExportInvoice;
                break;

            case "AmendedB2BExportInvoice":
                Invoice AmendedB2BExportInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BExportInvoice);
                seller.Invoice = AmendedB2BExportInvoice;
                break;
            }
            #endregion

            seller.Invoice.LineEntry = new List <LineEntry>();
            LineEntry line;

            DataSet ds = new DataSet();


            ds = seller.Invoice.ViewInvoice(SellerGSTN, FromDt, Todate);

            seller.SellerDaTa = new List <Seller>();

            if (ds.Tables.Count > 0)
            {
                #region B2B
                if (ds.Tables.Contains("SellerDtls"))
                {
                    if (ds.Tables["SellerDtls"].Rows.Count > 0)
                    {
                        int j = ds.Tables[0].Rows.Count;

                        for (int i = 0; i <= j - 1; i++)
                        {
                            seller.SellerInvoice         = (ds.Tables[0].Rows[i]["InvoiceNo"]).ToString();
                            seller.DateOfInvoice         = (ds.Tables[0].Rows[i]["Invoicedate"]).ToString();
                            seller.GSTIN                 = (ds.Tables[0].Rows[i]["SellerGSTN"]).ToString();
                            seller.NameAsOnGST           = (ds.Tables[0].Rows[i]["SellerName"]).ToString();
                            seller.Reciever.GSTIN        = (ds.Tables[0].Rows[i]["ReceiverGSTN"]).ToString();
                            seller.Reciever.NameAsOnGST  = (ds.Tables[0].Rows[i]["ReceiverName"]).ToString();
                            seller.Consignee.GSTIN       = (ds.Tables[0].Rows[i]["ConsigneeGSTN"]).ToString();
                            seller.Consignee.NameAsOnGST = (ds.Tables[0].Rows[i]["ConsigneeName"]).ToString();
                            seller.Address               = (ds.Tables[0].Rows[i]["SellerAddress"]).ToString();
                            seller.SellerStateCode       = (ds.Tables[0].Rows[i]["SellerStateCode"]).ToString();
                            seller.SellerStateName       = (ds.Tables[0].Rows[i]["SellerStateName"]).ToString();
                            seller.SellerStateCodeID     = (ds.Tables[0].Rows[i]["SellerStateCodeID"]).ToString();
                            seller.Reciever.StateCode    = (ds.Tables[0].Rows[i]["ReceiverStateCode"]).ToString();
                            seller.Consignee.StateCode   = (ds.Tables[0].Rows[i]["ConsigneeStateCode"]).ToString();
                            seller.Invoice.Freight       = Convert.ToInt32(ds.Tables[0].Rows[i]["Freight"]);
                            seller.Invoice.Insurance     = Convert.ToInt32(ds.Tables[0].Rows[i]["Insurance"]);
                            seller.Invoice.PackingAndForwadingCharges = Convert.ToInt32(ds.Tables[0].Rows[i]["PackingAndForwadingCharges"]);

                            seller.SellerGrossTurnOver      = Convert.ToDecimal(ds.Tables[0].Rows[i]["SellerGrossTurnOver"]);
                            seller.SellerFinancialPeriod    = (ds.Tables[0].Rows[i]["SellerFinancialPeriod"]).ToString();
                            seller.Reciever.FinancialPeriod = (ds.Tables[0].Rows[i]["ReceiverFinancialPeriod"]).ToString();

                            seller.Reciever.StateName  = (ds.Tables[0].Rows[i]["ReceiverStateName"]).ToString();
                            seller.Consignee.StateName = (ds.Tables[0].Rows[i]["ConsigneeStateName"]).ToString();


                            //if (((ds.Tables[0].Rows[i]["IsElectronicReferenceNoGenerated"]).ToString()) == "True")
                            //{
                            //    seller.IsElectronicReferenceNoGenerated = true;
                            //}
                            //else
                            //{
                            //    seller.IsElectronicReferenceNoGenerated = false;
                            //}


                            //seller.ElectronicReferenceNoGenerated = (ds.Tables[0].Rows[i]["ElectronicReferenceNoGenerated"]).ToString();
                            //seller.ElectronicReferenceNoGeneratedDate = (ds.Tables[0].Rows[i]["ElectronicReferenceNoGeneratedDate"]).ToString();

                            seller.Invoice.IsAdvancePaymentChecked = false;
                            seller.Invoice.IsExportChecked         = false;


                            int n = ds.Tables[1].Rows.Count;
                            for (m = p; m <= n - 1; m++)
                            {
                                if ((ds.Tables[0].Rows[i]["InvoiceNo"]).ToString() == (ds.Tables[1].Rows[m]["InvoiceNo"]).ToString())
                                {
                                    line = new LineEntry();

                                    line.HSN = new com.B2B.GST.GSTInvoices.HSN();

                                    //InvoiceNo	Invoicedate	SellerGSTN	ReceiverGSTN	InvoiceSeed	LineID	Description	HSN	Qty	Unit	Rate	Total	Discount
                                    //TaxableValue	AmountWithTax	IGSTRate	IGSTAmt	CGSTRate	CGSTAmt	SGSTRate	SGSTAmt	TotalQty	TotalRate	TotalAmount	TotalDiscount
                                    //TotalTaxableAmount	TotalCGSTAmount	TotalSGSTAmount	TotalIGSTAmount	TotalAmountWithTax	GrandTotalAmount	GrandTotalAmountInWord	isHSNNilRated
                                    //isHSNExempted	isHSNZeroRated	isHSNNonGSTGoods	isSACNilRated	isSACEcxempted	isSACZeroRated	isSACNonGSTService	IsNotifedGoods	IsNotifiedSAC
                                    //IsElectronicReferenceNoGenerated	IsInter	SellerStateCode	SellerStateName	ReceiverStateCode	ReceiverStateName	ConsigneeStateCode	ConsigneeStateName
                                    line.LineID                = Convert.ToInt32(ds.Tables[1].Rows[m]["LineID"]);
                                    line.HSN.Description       = (ds.Tables[1].Rows[m]["Description"]).ToString();
                                    line.HSN.HSNNumber         = (ds.Tables[1].Rows[m]["HSN"]).ToString();
                                    line.Qty                   = Convert.ToDecimal(ds.Tables[1].Rows[m]["Qty"]);
                                    line.HSN.UnitOfMeasurement = (ds.Tables[1].Rows[m]["Unit"]).ToString();
                                    line.PerUnitRate           = Convert.ToDecimal(ds.Tables[1].Rows[m]["Rate"]);
                                    line.TotalLineIDWise       = Convert.ToDecimal(ds.Tables[1].Rows[m]["Total"]);
                                    line.Discount              = Convert.ToDecimal(ds.Tables[1].Rows[m]["Discount"]);
                                    line.TaxValue              = Convert.ToDecimal(ds.Tables[1].Rows[m]["TaxableValue"]);
                                    line.AmountWithTax         = Convert.ToDecimal(ds.Tables[1].Rows[m]["AmountWithTax"]);
                                    line.HSN.RateIGST          = Convert.ToDecimal(ds.Tables[1].Rows[m]["IGSTRate"]);
                                    line.AmtIGSTLineIDWise     = Convert.ToDecimal(ds.Tables[1].Rows[m]["IGSTAmt"]);
                                    line.HSN.RateCGST          = Convert.ToDecimal(ds.Tables[1].Rows[m]["CGSTRate"]);
                                    line.AmtCGSTLineIDWise     = Convert.ToDecimal(ds.Tables[1].Rows[m]["CGSTAmt"]);
                                    line.HSN.RateSGST          = Convert.ToDecimal(ds.Tables[1].Rows[m]["SGSTRate"]);
                                    line.AmtSGSTLineIDWise     = Convert.ToDecimal(ds.Tables[1].Rows[m]["SGSTAmt"]);
                                    line.HSN.Cess              = Convert.ToDecimal(ds.Tables[1].Rows[m]["Cess"]);

                                    seller.TotalQty               = Convert.ToDecimal(ds.Tables[1].Rows[m]["TotalQty"]);
                                    seller.TotalRate              = Convert.ToDecimal(ds.Tables[1].Rows[m]["TotalRate"]);
                                    seller.TotalAmount            = Convert.ToDecimal(ds.Tables[1].Rows[m]["TotalAmount"]);
                                    seller.TotalDiscount          = Convert.ToDecimal(ds.Tables[1].Rows[m]["TotalDiscount"]);
                                    seller.TotalTaxableAmount     = Convert.ToDecimal(ds.Tables[1].Rows[m]["TotalTaxableAmount"]);
                                    seller.TotalCGSTAmount        = Convert.ToDecimal(ds.Tables[1].Rows[m]["TotalCGSTAmount"]);
                                    seller.TotalSGSTAmount        = Convert.ToDecimal(ds.Tables[1].Rows[m]["TotalSGSTAmount"]);
                                    seller.TotalIGSTAmount        = Convert.ToDecimal(ds.Tables[1].Rows[m]["TotalIGSTAmount"]);
                                    seller.TotalAmountWithTax     = Convert.ToDecimal(ds.Tables[1].Rows[m]["TotalAmountWithTax"]);
                                    seller.GrandTotalAmount       = Convert.ToDecimal(ds.Tables[1].Rows[m]["GrandTotalAmount"]);
                                    seller.GrandTotalAmountInWord = Convert.ToString(ds.Tables[1].Rows[m]["GrandTotalAmountInWord"]);


                                    if (((ds.Tables[1].Rows[m]["IsInter"]).ToString()) == "True")
                                    {
                                        line.IsInter = true;
                                    }
                                    else
                                    {
                                        line.IsInter = false;
                                    }

                                    seller.Invoice.LineEntry.Add(line);
                                    p = 1 + p;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            seller.SellerDaTa.Add(seller);
                            Session["SellerDaTa"] = seller.SellerDaTa;

                            seller            = new Seller();
                            seller.Reciever   = new Reciever();
                            seller.Consignee  = new Consignee();
                            seller.SellerDaTa = new List <Seller>();


                            #region INVOICE_TYPE
                            switch (strInvoiceType)
                            {
                            case "B2BInvoice":
                                Invoice b2bInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BInvoice);
                                seller.Invoice = b2bInvoice;
                                break;

                            case "AmendedB2BInvoice":
                                Invoice AmendedB2BInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BInvoice);
                                seller.Invoice = AmendedB2BInvoice;
                                break;

                            case "B2CLargeInvoice":
                                Invoice B2CLargeInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2CLargeInvoice);
                                seller.Invoice = B2CLargeInvoice;
                                break;

                            case "AmendedB2CLargeInvoice":
                                Invoice AmendedB2CLargeInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2CLargeInvoice);
                                seller.Invoice = AmendedB2CLargeInvoice;
                                break;

                            case "B2BCreditNotesInvoice":
                                Invoice B2BCreditNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BCreditNotesInvoice);
                                seller.Invoice = B2BCreditNotesInvoice;
                                break;

                            case "B2BDebitNotesInvoice":
                                Invoice B2BDebitNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BDebitNotesInvoice);
                                seller.Invoice = B2BDebitNotesInvoice;
                                break;

                            case "AmendedB2BCreditNotesInvoice":
                                Invoice AmendedB2BCreditNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BCreditNotesInvoice);
                                seller.Invoice = AmendedB2BCreditNotesInvoice;
                                break;

                            case "AmendedB2BDebitNotesInvoice":
                                Invoice AmendedB2BDebitNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BDebitNotesInvoice);
                                seller.Invoice = AmendedB2BDebitNotesInvoice;
                                break;

                            case "B2BExportInvoice":
                                Invoice B2BExportInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BExportInvoice);
                                seller.Invoice = B2BExportInvoice;
                                break;

                            case "AmendedB2BExportInvoice":
                                Invoice AmendedB2BExportInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BExportInvoice);
                                seller.Invoice = AmendedB2BExportInvoice;
                                break;
                            }
                            #endregion

                            seller.Invoice.LineEntry = new List <LineEntry>();

                            if ((List <Seller>)Session["SellerDaTa"] != null)
                            {
                                seller.SellerDaTa = (List <Seller>)Session["SellerDaTa"];
                            }
                        }
                    }
                }
                else
                {
                    //change master page here--Ashish
                    BALAJI.GSP.APPLICATION.User.User masterPage = this.Master as BALAJI.GSP.APPLICATION.User.User;
                    ////masterPage.ShowModalPopup();
                    ////masterPage.ErrorMessage = "System error occured during data population of SellerDtls table !!!";
                }
                #endregion

                #region ADVANCE
                if (ds.Tables.Contains("AdvanceSellerDtls"))
                {
                    p = 0; m = 0;
                    if (ds.Tables["AdvanceSellerDtls"].Rows.Count > 0)
                    {
                        int j = ds.Tables[3].Rows.Count;

                        for (int i = 0; i <= j - 1; i++)
                        {
                            seller.SellerInvoice         = (ds.Tables[3].Rows[i]["VoucherNo"]).ToString();
                            seller.DateOfInvoice         = (ds.Tables[3].Rows[i]["Voucherdate"]).ToString();
                            seller.GSTIN                 = (ds.Tables[3].Rows[i]["SellerGSTN"]).ToString();
                            seller.NameAsOnGST           = (ds.Tables[3].Rows[i]["SellerName"]).ToString();
                            seller.Reciever.GSTIN        = (ds.Tables[3].Rows[i]["ReceiverGSTN"]).ToString();
                            seller.Reciever.NameAsOnGST  = (ds.Tables[3].Rows[i]["ReceiverName"]).ToString();
                            seller.Consignee.GSTIN       = (ds.Tables[3].Rows[i]["ConsigneeGSTN"]).ToString();
                            seller.Consignee.NameAsOnGST = (ds.Tables[3].Rows[i]["ConsigneeName"]).ToString();
                            seller.Address               = (ds.Tables[3].Rows[i]["SellerAddress"]).ToString();
                            seller.SellerStateCode       = (ds.Tables[3].Rows[i]["SellerStateCode"]).ToString();
                            seller.SellerStateName       = (ds.Tables[3].Rows[i]["SellerStateName"]).ToString();
                            seller.SellerStateCodeID     = (ds.Tables[3].Rows[i]["SellerStateCodeID"]).ToString();
                            seller.Reciever.StateCode    = (ds.Tables[3].Rows[i]["ReceiverStateCode"]).ToString();
                            seller.Consignee.StateCode   = (ds.Tables[3].Rows[i]["ConsigneeStateCode"]).ToString();
                            seller.Invoice.Freight       = Convert.ToInt32(ds.Tables[3].Rows[i]["Freight"]);
                            seller.Invoice.Insurance     = Convert.ToInt32(ds.Tables[3].Rows[i]["Insurance"]);
                            seller.Invoice.PackingAndForwadingCharges = Convert.ToInt32(ds.Tables[3].Rows[i]["PackingAndForwadingCharges"]);

                            seller.Invoice.IsAdvancePaymentChecked = true;
                            seller.Invoice.IsExportChecked         = false;

                            //if (((ds.Tables[3].Rows[i]["IsElectronicReferenceNoGenerated"]).ToString()) == "True")
                            //{
                            //    seller.IsElectronicReferenceNoGenerated = true;
                            //}
                            //else
                            //{
                            //    seller.IsElectronicReferenceNoGenerated = false;
                            //}


                            //seller.ElectronicReferenceNoGenerated = (ds.Tables[3].Rows[i]["ElectronicReferenceNoGenerated"]).ToString();
                            //seller.ElectronicReferenceNoGeneratedDate = (ds.Tables[3].Rows[i]["ElectronicReferenceNoGeneratedDate"]).ToString();

                            int n = ds.Tables[4].Rows.Count;
                            for (m = p; m <= n - 1; m++)
                            {
                                if ((ds.Tables[3].Rows[i]["VoucherNo"]).ToString() == (ds.Tables[4].Rows[m]["VoucherNo"]).ToString())
                                {
                                    line = new LineEntry();

                                    line.HSN = new com.B2B.GST.GSTInvoices.HSN();

                                    line.LineID                = Convert.ToInt32(ds.Tables[4].Rows[m]["LineID"]);
                                    line.HSN.Description       = (ds.Tables[4].Rows[m]["Description"]).ToString();
                                    line.HSN.HSNNumber         = (ds.Tables[4].Rows[m]["HSN"]).ToString();
                                    line.Qty                   = Convert.ToDecimal(ds.Tables[4].Rows[m]["Qty"]);
                                    line.HSN.UnitOfMeasurement = (ds.Tables[4].Rows[m]["Unit"]).ToString();
                                    line.PerUnitRate           = Convert.ToDecimal(ds.Tables[4].Rows[m]["Rate"]);
                                    line.TotalLineIDWise       = Convert.ToDecimal(ds.Tables[4].Rows[m]["Total"]);
                                    line.Discount              = Convert.ToDecimal(ds.Tables[4].Rows[m]["Discount"]);
                                    line.TaxValue              = Convert.ToDecimal(ds.Tables[4].Rows[m]["TaxableValue"]);
                                    line.AmountWithTax         = Convert.ToDecimal(ds.Tables[4].Rows[m]["AmountWithTax"]);
                                    line.HSN.RateIGST          = Convert.ToDecimal(ds.Tables[4].Rows[m]["IGSTRate"]);
                                    line.AmtIGSTLineIDWise     = Convert.ToDecimal(ds.Tables[4].Rows[m]["IGSTAmt"]);
                                    line.HSN.RateCGST          = Convert.ToDecimal(ds.Tables[4].Rows[m]["CGSTRate"]);
                                    line.AmtCGSTLineIDWise     = Convert.ToDecimal(ds.Tables[4].Rows[m]["CGSTAmt"]);
                                    line.HSN.RateSGST          = Convert.ToDecimal(ds.Tables[4].Rows[m]["SGSTRate"]);
                                    line.AmtSGSTLineIDWise     = Convert.ToDecimal(ds.Tables[4].Rows[m]["SGSTAmt"]);
                                    line.HSN.Cess              = Convert.ToDecimal(ds.Tables[4].Rows[m]["Cess"]);



                                    seller.TotalQty               = Convert.ToDecimal(ds.Tables[4].Rows[m]["TotalQty"]);
                                    seller.TotalRate              = Convert.ToDecimal(ds.Tables[4].Rows[m]["TotalRate"]);
                                    seller.TotalAmount            = Convert.ToDecimal(ds.Tables[4].Rows[m]["TotalAmount"]);
                                    seller.TotalDiscount          = Convert.ToDecimal(ds.Tables[4].Rows[m]["TotalDiscount"]);
                                    seller.TotalTaxableAmount     = Convert.ToDecimal(ds.Tables[4].Rows[m]["TotalTaxableAmount"]);
                                    seller.TotalCGSTAmount        = Convert.ToDecimal(ds.Tables[4].Rows[m]["TotalCGSTAmount"]);
                                    seller.TotalSGSTAmount        = Convert.ToDecimal(ds.Tables[4].Rows[m]["TotalSGSTAmount"]);
                                    seller.TotalIGSTAmount        = Convert.ToDecimal(ds.Tables[4].Rows[m]["TotalIGSTAmount"]);
                                    seller.TotalAmountWithTax     = Convert.ToDecimal(ds.Tables[4].Rows[m]["TotalAmountWithTax"]);
                                    seller.GrandTotalAmount       = Convert.ToDecimal(ds.Tables[4].Rows[m]["GrandTotalAmount"]);
                                    seller.GrandTotalAmountInWord = Convert.ToString(ds.Tables[4].Rows[m]["GrandTotalAmountInWord"]);


                                    seller.Invoice.LineEntry.Add(line);
                                    p = 1 + p;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            seller.SellerDaTa.Add(seller);
                            Session["SellerDaTa"] = seller.SellerDaTa;

                            seller            = new Seller();
                            seller.Reciever   = new Reciever();
                            seller.Consignee  = new Consignee();
                            seller.SellerDaTa = new List <Seller>();


                            #region INVOICE_TYPE
                            switch (strInvoiceType)
                            {
                            case "B2BInvoice":
                                Invoice b2bInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BInvoice);
                                seller.Invoice = b2bInvoice;
                                break;

                            case "AmendedB2BInvoice":
                                Invoice AmendedB2BInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BInvoice);
                                seller.Invoice = AmendedB2BInvoice;
                                break;

                            case "B2CLargeInvoice":
                                Invoice B2CLargeInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2CLargeInvoice);
                                seller.Invoice = B2CLargeInvoice;
                                break;

                            case "AmendedB2CLargeInvoice":
                                Invoice AmendedB2CLargeInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2CLargeInvoice);
                                seller.Invoice = AmendedB2CLargeInvoice;
                                break;

                            case "B2BCreditNotesInvoice":
                                Invoice B2BCreditNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BCreditNotesInvoice);
                                seller.Invoice = B2BCreditNotesInvoice;
                                break;

                            case "B2BDebitNotesInvoice":
                                Invoice B2BDebitNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BDebitNotesInvoice);
                                seller.Invoice = B2BDebitNotesInvoice;
                                break;

                            case "AmendedB2BCreditNotesInvoice":
                                Invoice AmendedB2BCreditNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BCreditNotesInvoice);
                                seller.Invoice = AmendedB2BCreditNotesInvoice;
                                break;

                            case "AmendedB2BDebitNotesInvoice":
                                Invoice AmendedB2BDebitNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BDebitNotesInvoice);
                                seller.Invoice = AmendedB2BDebitNotesInvoice;
                                break;

                            case "B2BExportInvoice":
                                Invoice B2BExportInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BExportInvoice);
                                seller.Invoice = B2BExportInvoice;
                                break;

                            case "AmendedB2BExportInvoice":
                                Invoice AmendedB2BExportInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BExportInvoice);
                                seller.Invoice = AmendedB2BExportInvoice;
                                break;
                            }
                            #endregion

                            seller.Invoice.LineEntry = new List <LineEntry>();

                            if ((List <Seller>)Session["SellerDaTa"] != null)
                            {
                                seller.SellerDaTa = (List <Seller>)Session["SellerDaTa"];
                            }
                        }
                    }
                }
                else
                {
                    //UserInterface.loggedIn_applicationMasterPage masterPage = this.Master as UserInterface.loggedIn_applicationMasterPage;
                    ////masterPage.ShowModalPopup();
                    ////masterPage.ErrorMessage = "System error occured during data population of SellerDtls table !!!";
                }
                #endregion

                #region EXPORT
                if (ds.Tables.Contains("EXPORTSellerDtls"))
                {
                    p = 0; m = 0;
                    if (ds.Tables["EXPORTSellerDtls"].Rows.Count > 0)
                    {
                        int j = ds.Tables[6].Rows.Count;

                        for (int i = 0; i <= j - 1; i++)
                        {
                            seller.SellerInvoice         = (ds.Tables[6].Rows[i]["ExportNo"]).ToString();
                            seller.DateOfInvoice         = (ds.Tables[6].Rows[i]["Exportdate"]).ToString();
                            seller.GSTIN                 = (ds.Tables[6].Rows[i]["SellerGSTN"]).ToString();
                            seller.NameAsOnGST           = (ds.Tables[6].Rows[i]["SellerName"]).ToString();
                            seller.Reciever.GSTIN        = (ds.Tables[6].Rows[i]["ReceiverGSTN"]).ToString();
                            seller.Reciever.NameAsOnGST  = (ds.Tables[6].Rows[i]["ReceiverName"]).ToString();
                            seller.Consignee.GSTIN       = (ds.Tables[6].Rows[i]["ConsigneeGSTN"]).ToString();
                            seller.Consignee.NameAsOnGST = (ds.Tables[6].Rows[i]["ConsigneeName"]).ToString();
                            seller.Address               = (ds.Tables[6].Rows[i]["SellerAddress"]).ToString();
                            seller.SellerStateCode       = (ds.Tables[6].Rows[i]["SellerStateCode"]).ToString();
                            seller.SellerStateName       = (ds.Tables[6].Rows[i]["SellerStateName"]).ToString();
                            seller.SellerStateCodeID     = (ds.Tables[6].Rows[i]["SellerStateCodeID"]).ToString();
                            seller.Reciever.StateCode    = (ds.Tables[6].Rows[i]["ReceiverStateCode"]).ToString();
                            seller.Consignee.StateCode   = (ds.Tables[6].Rows[i]["ConsigneeStateCode"]).ToString();
                            seller.Invoice.Freight       = Convert.ToInt32(ds.Tables[6].Rows[i]["Freight"]);
                            seller.Invoice.Insurance     = Convert.ToInt32(ds.Tables[6].Rows[i]["Insurance"]);
                            seller.Invoice.PackingAndForwadingCharges = Convert.ToInt32(ds.Tables[6].Rows[i]["PackingAndForwadingCharges"]);


                            seller.Invoice.IsAdvancePaymentChecked = false;
                            seller.Invoice.IsExportChecked         = true;

                            //if (((ds.Tables[6].Rows[i]["IsElectronicReferenceNoGenerated"]).ToString()) == "True")
                            //{
                            //    seller.IsElectronicReferenceNoGenerated = true;
                            //}
                            //else
                            //{
                            //    seller.IsElectronicReferenceNoGenerated = false;
                            //}


                            //seller.ElectronicReferenceNoGenerated = (ds.Tables[6].Rows[i]["ElectronicReferenceNoGenerated"]).ToString();
                            //seller.ElectronicReferenceNoGeneratedDate = (ds.Tables[6].Rows[i]["ElectronicReferenceNoGeneratedDate"]).ToString();

                            int n = ds.Tables[7].Rows.Count;
                            for (m = p; m <= n - 1; m++)
                            {
                                if ((ds.Tables[6].Rows[i]["ExportNo"]).ToString() == (ds.Tables[7].Rows[m]["ExportNo"]).ToString())
                                {
                                    line = new LineEntry();

                                    line.HSN                   = new com.B2B.GST.GSTInvoices.HSN();
                                    line.LineID                = Convert.ToInt32(ds.Tables[7].Rows[m]["LineID"]);
                                    line.HSN.Description       = (ds.Tables[7].Rows[m]["Description"]).ToString();
                                    line.HSN.HSNNumber         = (ds.Tables[7].Rows[m]["HSN"]).ToString();
                                    line.Qty                   = Convert.ToDecimal(ds.Tables[7].Rows[m]["Qty"]);
                                    line.HSN.UnitOfMeasurement = (ds.Tables[7].Rows[m]["Unit"]).ToString();
                                    line.PerUnitRate           = Convert.ToDecimal(ds.Tables[7].Rows[m]["Rate"]);
                                    line.TotalLineIDWise       = Convert.ToDecimal(ds.Tables[7].Rows[m]["Total"]);
                                    line.Discount              = Convert.ToDecimal(ds.Tables[7].Rows[m]["Discount"]);
                                    line.TaxValue              = Convert.ToDecimal(ds.Tables[7].Rows[m]["TaxableValue"]);
                                    line.AmountWithTax         = Convert.ToDecimal(ds.Tables[7].Rows[m]["AmountWithTax"]);
                                    line.HSN.RateIGST          = Convert.ToDecimal(ds.Tables[7].Rows[m]["IGSTRate"]);
                                    line.AmtIGSTLineIDWise     = Convert.ToDecimal(ds.Tables[7].Rows[m]["IGSTAmt"]);
                                    line.HSN.RateCGST          = Convert.ToDecimal(ds.Tables[7].Rows[m]["CGSTRate"]);
                                    line.AmtCGSTLineIDWise     = Convert.ToDecimal(ds.Tables[7].Rows[m]["CGSTAmt"]);
                                    line.HSN.RateSGST          = Convert.ToDecimal(ds.Tables[7].Rows[m]["SGSTRate"]);
                                    line.AmtSGSTLineIDWise     = Convert.ToDecimal(ds.Tables[7].Rows[m]["SGSTAmt"]);
                                    line.HSN.Cess              = Convert.ToDecimal(ds.Tables[7].Rows[m]["Cess"]);


                                    seller.TotalQty               = Convert.ToDecimal(ds.Tables[7].Rows[m]["TotalQty"]);
                                    seller.TotalRate              = Convert.ToDecimal(ds.Tables[7].Rows[m]["TotalRate"]);
                                    seller.TotalAmount            = Convert.ToDecimal(ds.Tables[7].Rows[m]["TotalAmount"]);
                                    seller.TotalDiscount          = Convert.ToDecimal(ds.Tables[7].Rows[m]["TotalDiscount"]);
                                    seller.TotalTaxableAmount     = Convert.ToDecimal(ds.Tables[7].Rows[m]["TotalTaxableAmount"]);
                                    seller.TotalCGSTAmount        = Convert.ToDecimal(ds.Tables[7].Rows[m]["TotalCGSTAmount"]);
                                    seller.TotalSGSTAmount        = Convert.ToDecimal(ds.Tables[7].Rows[m]["TotalSGSTAmount"]);
                                    seller.TotalIGSTAmount        = Convert.ToDecimal(ds.Tables[7].Rows[m]["TotalIGSTAmount"]);
                                    seller.TotalAmountWithTax     = Convert.ToDecimal(ds.Tables[7].Rows[m]["TotalAmountWithTax"]);
                                    seller.GrandTotalAmount       = Convert.ToDecimal(ds.Tables[7].Rows[m]["GrandTotalAmount"]);
                                    seller.GrandTotalAmountInWord = Convert.ToString(ds.Tables[7].Rows[m]["GrandTotalAmountInWord"]);


                                    seller.Invoice.LineEntry.Add(line);
                                    p = 1 + p;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            seller.SellerDaTa.Add(seller);
                            Session["SellerDaTa"] = seller.SellerDaTa;

                            seller            = new Seller();
                            seller.Reciever   = new Reciever();
                            seller.Consignee  = new Consignee();
                            seller.SellerDaTa = new List <Seller>();



                            #region INVOICE_TYPE
                            switch (strInvoiceType)
                            {
                            case "B2BInvoice":
                                Invoice b2bInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BInvoice);
                                seller.Invoice = b2bInvoice;
                                break;

                            case "AmendedB2BInvoice":
                                Invoice AmendedB2BInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BInvoice);
                                seller.Invoice = AmendedB2BInvoice;
                                break;

                            case "B2CLargeInvoice":
                                Invoice B2CLargeInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2CLargeInvoice);
                                seller.Invoice = B2CLargeInvoice;
                                break;

                            case "AmendedB2CLargeInvoice":
                                Invoice AmendedB2CLargeInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2CLargeInvoice);
                                seller.Invoice = AmendedB2CLargeInvoice;
                                break;

                            case "B2BCreditNotesInvoice":
                                Invoice B2BCreditNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BCreditNotesInvoice);
                                seller.Invoice = B2BCreditNotesInvoice;
                                break;

                            case "B2BDebitNotesInvoice":
                                Invoice B2BDebitNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BDebitNotesInvoice);
                                seller.Invoice = B2BDebitNotesInvoice;
                                break;

                            case "AmendedB2BCreditNotesInvoice":
                                Invoice AmendedB2BCreditNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BCreditNotesInvoice);
                                seller.Invoice = AmendedB2BCreditNotesInvoice;
                                break;

                            case "AmendedB2BDebitNotesInvoice":
                                Invoice AmendedB2BDebitNotesInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BDebitNotesInvoice);
                                seller.Invoice = AmendedB2BDebitNotesInvoice;
                                break;

                            case "B2BExportInvoice":
                                Invoice B2BExportInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BExportInvoice);
                                seller.Invoice = B2BExportInvoice;
                                break;

                            case "AmendedB2BExportInvoice":
                                Invoice AmendedB2BExportInvoice = InvoiceFactory.CreateInvoice(InvoiceType.AmendedB2BExportInvoice);
                                seller.Invoice = AmendedB2BExportInvoice;
                                break;
                            }
                            #endregion

                            seller.Invoice.LineEntry = new List <LineEntry>();

                            if ((List <Seller>)Session["SellerDaTa"] != null)
                            {
                                seller.SellerDaTa = (List <Seller>)Session["SellerDaTa"];
                            }
                        }
                    }
                }
                else
                {
                    BALAJI.GSP.APPLICATION.User.User masterPage = this.Master as BALAJI.GSP.APPLICATION.User.User;
                    ////masterPage.ShowModalPopup();
                    ////masterPage.ErrorMessage = "System error occured during data population of SellerDtls table !!!";
                }
                #endregion
            }
            else
            {
                BALAJI.GSP.APPLICATION.User.User masterPage = this.Master as BALAJI.GSP.APPLICATION.User.User;
                ////masterPage.ShowModalPopup();
                ////masterPage.ErrorMessage = "System Error !!!";
            }
            if (ds.Tables["SellerDtls"].Rows.Count == 0 && ds.Tables["AdvanceSellerDtls"].Rows.Count == 0 && ds.Tables["EXPORTSellerDtls"].Rows.Count == 0)
            {
                BALAJI.GSP.APPLICATION.User.User masterPage = this.Master as BALAJI.GSP.APPLICATION.User.User;
                ////masterPage.ShowModalPopup();
                ////masterPage.ErrorMessage = "No data to upload !!!";

                BtnUpload.Attributes.Add("style", "display:none");
            }

            return(ds);
        }