public static ReportInvoiceViewModel GenerateInvoiceViewModel(RunPrintBillingsDTO serviceModel)
 {
     return(new ReportInvoiceViewModel
     {
         Kunrg = serviceModel._printBillingHeader.KUNRG,
         Name1 = serviceModel._printBillingHeader.NAME1,
         Name2 = serviceModel._printBillingHeader.NAME2,
         Name3 = serviceModel._printBillingHeader.NAME3,
         Name4 = serviceModel._printBillingHeader.NAME4,
         Street = serviceModel._printBillingHeader.STREET,
         Vtext = serviceModel._printBillingHeader.VTEXT,
         Waerk = serviceModel._printBillingHeader.WAERK,
         City1 = serviceModel._printBillingHeader.CITY1,
         PostCode1 = serviceModel._printBillingHeader.POST_CODE1,
         InvoiceNo = serviceModel._printBillingHeader.VBELN,
         Fkdat = DateTime.ParseExact(serviceModel._printBillingHeader.FKDAT,
                                     "yyyy-MM-dd", CultureInfo.CurrentCulture).ToString("dd.MM.yyyy"),
         Htotal1 = serviceModel._printBillingHeader.HTOTAL1,
         Htotal2 = Convert.ToDecimal(serviceModel._printBillingHeader.HTOTAL2).ToString("#,##0"),
         Htotal3 = Convert.ToDecimal(serviceModel._printBillingHeader.HTOTAL3).ToString("#,##0"),
         FakturPajak = serviceModel._printBillingHeader.FPAJAK_NO,
         Stceg = serviceModel._printBillingHeader.STCEG,
         Tdline = serviceModel._printBillingHeader.TDLINE,
         Text1 = serviceModel._printBillingHeader.TEXT1,
         Zterm = serviceModel._printBillingHeader.ZTERM,
         TotalInvoice = Convert.ToDecimal(Convert.ToDecimal(serviceModel._printBillingHeader.HTOTAL2) + Convert.ToDecimal(serviceModel._printBillingHeader.HTOTAL3)).ToString("#,##0"),
     });
 }
Beispiel #2
0
        public SAPResponse GetBillingsToPrintHeader(string user, string billingNumber)
        {
            var cred = ParseCredential(user);
            var dest = SAPConnectionFactory.Instance.GetRfcDestination(cred);

            if (dest == null)
            {
                return(null);
            }
            var getitem = "";

            // if (anvoiceDetail.ToUpper()=="X" || appendix.ToUpper()=="X")
            // {
            getitem = "";
            //}

            const string FUNCTIONAL_BAPI1 = "ZBAPI_PRINT_BILLING";

            var repo  = dest.Repository;
            var func1 = repo.CreateFunction(FUNCTIONAL_BAPI1);

            func1.SetValue("BILL_NO", billingNumber);
            func1.SetValue("PROFORMA_FLAG", " ");

            func1.SetValue("ITEM_FLAG", getitem);

            func1.SetValue("BILLING_BLOCK", " ");
            func1.SetValue("REASON_FOR_REJECTION", " ");
            func1.Invoke(dest);

            //var proformaTbl = func1.GetTable("PROFORMA");

            var headerTbl = func1.GetTable("HEADER");

            headerTbl.CurrentIndex = 0;
            var headerStruct = headerTbl.CurrentRow;


            var ret = new RunPrintBillingsDTO();

            ret._printBillingHeader = new PrintBillingHeaderDTO();

            ret._printBillingHeader.ReportInvoiceDetail = new List <PrintBillingItemDTO>();
            var ReportInvoiceDetailExcel = new List <ContractItem>();

            SAPDataCopier.Instance.CopyFromStruct(headerStruct, ret._printBillingHeader);


            return(ret);
        }
        public static ReportInvoiceDetailViewModel GenerateInvoiceDetailViewModel(RunPrintBillingsDTO serviceModel)
        {
            return(new ReportInvoiceDetailViewModel
            {
                //properti unntuk Header
                Name1 = serviceModel._printBillingHeader.NAME1 ?? string.Empty,
                Tdline = serviceModel._printBillingHeader.TDLINE ?? string.Empty,
                TotalCharges = Convert.ToDecimal(serviceModel._printBillingHeader.HTOTAL5).ToString("#,##0") ?? string.Empty,
                Deduction = Convert.ToDecimal(serviceModel._printBillingHeader.HTOTAL4).ToString("#,##0") ?? string.Empty,
                TotatalChargesAfterDiscount = Convert.ToDecimal(serviceModel._printBillingHeader.HTOTAL2).ToString("#,##0") ?? string.Empty,
                InvoiceNo = serviceModel._printBillingHeader.VBELN ?? string.Empty,
                Currency = serviceModel._printBillingHeader.WAERK ?? string.Empty,

                //tabel item properti
                ReportInvoiceDetailLineViewModelList = serviceModel._printBillingHeader.ReportInvoiceDetail.Select(a => new ReportInvoiceDetailLineViewModel
                {
                    MaterialCategoryName = a.MaterialCategoryName ?? string.Empty,
                    Qty = a.Qty ?? string.Empty,
                    TotalCharges = Convert.ToDecimal(a.TotalCharges).ToString("#,##0") ?? string.Empty,
                    MaterialSubCategoryLineViewModels = a.MaterialSubCategoryLineViewModel.Select(b => new MaterialSubCategoryLineViewModel
                    {
                        MaterialSubCategoryName = b.MaterialSubCategoryName ?? string.Empty,
                        SubQty = b.SubQty ?? string.Empty,
                        SubTotalCharges = Convert.ToDecimal(b.SubTotalCharges).ToString("#,##0") ?? string.Empty,
                        DetailMaterialSubCategoryLineViewModels = b.MaterialSubCategoryLineViewModel.Select(c => new DetailMaterialSubCategoryLineViewModel
                        {
                            MaterialNo = c.MaterialNo ?? string.Empty,
                            MaterialDescription = c.MaterialDescription ?? string.Empty,
                            SubTotal = Convert.ToDecimal(c.SubTotal).ToString("#,##0") ?? string.Empty,
                            MaterialQty = c.MatQty ?? string.Empty,
                            DetailMaterialRate = Convert.ToDecimal(c.MatCharge).ToString("#,##0") ?? string.Empty,
                            DetailSubMaterialDescriptionLineViewModels = c.DetailSubMaterialDescriptionLineViewModels.Select(d => new DetailSubMaterialDescriptionLineViewModel
                            {
                                No = d.No ?? string.Empty,
                                DetailSubDescription = d.DetailSubDescription ?? string.Empty,
                                ChargesDetailSubMaterialDescription = Convert.ToDecimal(d.ChargesDetailSubMaterialDescription).ToString("#,##0") ?? string.Empty,
                                RateDetailSubMaterialDescription = Convert.ToDecimal(d.ChargesDetailSubMaterialDescription).ToString("#,##0") ?? string.Empty
                            })
                        })
                    })
                })
            });
        }
Beispiel #4
0
        public ActionResult DetailSubMaterialDescription()
        {
            RunPrintBillingsDTO serviceModel = null;

            try
            {
                serviceModel =
                    WCFClientManager.SAPServiceClient.GetBillingsToPrint(UserManagementHelper.GetSessionId(),
                                                                         "1960007091") as RunPrintBillingsDTO;
            }
            catch (Exception)
            {
                var mockedServiceModel = BillingReportingHelper.GenerateMockedInvoiceDetailViewModel();
                var mock = BillingReportingHelper.GenerateInvoiceViewModel(mockedServiceModel);
                return(View(mock));
            }

            var viewModel = BillingReportingHelper.GenerateInvoiceViewModel(serviceModel);

            return(View(viewModel));

            //return RedirectToAction("GenerateInvoice");
        }
 public static HeaderInoviceDetailViewModel GenerateHeaderInvoiceDetailViewModel(RunPrintBillingsDTO serviceModel)
 {
     return(new HeaderInoviceDetailViewModel
     {
         PayerName = serviceModel._printBillingHeader.NAME1,
         Currency = serviceModel._printBillingHeader.WAERK,
         HeaderNote = serviceModel._printBillingHeader.TDLINE,
         InvoiceNo = serviceModel._printBillingHeader.VBELN
     });
 }
Beispiel #6
0
        public SAPResponse GetBillingsToPrint(string user, string billingNumber /*,string invoiceDetail="x",string appendix="x"*/)
        {
            var cred = ParseCredential(user);
            var dest = SAPConnectionFactory.Instance.GetRfcDestination(cred);

            if (dest == null)
            {
                return(null);
            }
            var getitem = "";


            const string FUNCTIONAL_BAPI1 = "ZBAPI_PRINT_BILLING";

            var repo  = dest.Repository;
            var func1 = repo.CreateFunction(FUNCTIONAL_BAPI1);

            func1.SetValue("BILL_NO", billingNumber);
            func1.SetValue("PROFORMA_FLAG", "X");

            func1.SetValue("ITEM_FLAG", getitem);

            func1.SetValue("BILLING_BLOCK", " ");
            func1.SetValue("REASON_FOR_REJECTION", " ");
            func1.Invoke(dest);

            var proformaTbl = func1.GetTable("PROFORMA");
            var itemTbl     = func1.GetTable("ITEM");

            var headerTbl = func1.GetTable("HEADER");

            headerTbl.CurrentIndex = 0;
            var headerStruct = headerTbl.CurrentRow;


            var ret = new RunPrintBillingsDTO();

            ret._printBillingHeader = new PrintBillingHeaderDTO();

            ret._printBillingHeader.ReportInvoiceDetail = new List <PrintBillingItemDTO>();
            var ReportInvoiceDetailExcel = new List <ContractItem>();

            SAPDataCopier.Instance.CopyFromStruct(headerStruct, ret._printBillingHeader);


            for (var a = 0; a < proformaTbl.RowCount; a++)
            {
                proformaTbl.CurrentIndex = a;

                if (proformaTbl.CurrentRow.GetString("VBELN") != "")
                {
                    var pit = new ContractItem();
                    SAPDataCopier.Instance.CopyFromStruct(proformaTbl.CurrentRow, pit);
                    ReportInvoiceDetailExcel.Add(pit);
                }
            }



            var It           = ReportInvoiceDetailExcel.ToList();
            var categorylist = (from c in It
                                select c.CATEGORY).Distinct().ToList();
            Int32 j  = 0;
            Int64 jj = 0;

            foreach (var category in categorylist)
            {
                PrintBillingItemDTO cat = new PrintBillingItemDTO();
                cat.MaterialSubCategoryLineViewModel = new List <MaterialSubCategory>();
                cat.MaterialCategoryName             = category;

                var subcategorylist = (from c in It
                                       where c.CATEGORY == category
                                       select c.SUBCATEGORY).Distinct().ToList();

                Int32 k  = 0;
                Int64 kk = 0;
                foreach (var subcategory in subcategorylist)
                {
                    MaterialSubCategory subCat = new MaterialSubCategory();
                    subCat.MaterialSubCategoryLineViewModel = new List <DetailMaterialSubCategory>();
                    var materiallist = (from c in It
                                        where c.SUBCATEGORY == subcategory && c.CATEGORY == category
                                        select new { c.MATNR }).Distinct().ToList();
                    int   l  = 0;
                    Int64 ll = 0;
                    foreach (var material in materiallist)
                    {
                        DetailMaterialSubCategory mat = new DetailMaterialSubCategory();

                        mat.DetailSubMaterialDescriptionLineViewModels = new List <DetailSubMaterialDescription>();

                        var billinglist = It.Where(x => x.CATEGORY == category && x.SUBCATEGORY == subcategory && x.MATNR == material.MATNR);

                        Int32 i  = 0;
                        Int64 ii = Convert.ToInt64(billinglist.Sum(x => double.Parse(x.TOTAL5)));
                        ll = ll + ii;
                        foreach (var lineitem in billinglist)
                        {
                            i++;
                            DetailSubMaterialDescription subMat = new DetailSubMaterialDescription();
                            subMat.No = i.ToString();
                            subMat.ChargesDetailSubMaterialDescription = ii.ToString();
                            subMat.DetailSubDescription = "Holder : " + lineitem.VBAK_EMPNAME + "; SN : " + lineitem.VBAK_PERNR2 + "Location : " + lineitem.VBAK_SUBAREA_T;

                            subMat.ChargesDetailSubMaterialDescription = lineitem.TOTAL5;
                            mat.MatCharge = lineitem.TOTAL5;

                            mat.MaterialDescription = lineitem.ARKTX;
                            mat.DetailSubMaterialDescriptionLineViewModels.Add(subMat);
                        }
                        l = l + i;

                        mat.MaterialNo = material.MATNR;
                        mat.SubTotal   = ii.ToString();
                        mat.MatQty     = billinglist.Count().ToString();
                        subCat.MaterialSubCategoryLineViewModel.Add(mat);
                    }
                    kk = kk + ll;

                    k             = k + l;
                    subCat.SubQty = materiallist.Count().ToString();
                    subCat.MaterialSubCategoryName = subcategory;
                    subCat.SubTotalCharges         = ll.ToString();
                    subCat.SubQty = k.ToString();

                    cat.MaterialSubCategoryLineViewModel.Add(subCat);
                }
                j  = j + k;
                jj = jj + kk;

                cat.MaterialCategoryName = category;
                cat.Qty          = k.ToString();
                cat.TotalCharges = kk.ToString();
                ret._printBillingHeader.ReportInvoiceDetail.Add(cat);
            }



            return(ret);
        }