public async Task Should_Success_Get_Data_By_Id()
        {
            var            facade = new GarmentInvoiceFacade(_dbContext(GetCurrentMethod()), ServiceProvider);
            GarmentInvoice data   = await dataUtil(facade, GetCurrentMethod()).GetNewDataViewModel(USERNAME);

            var Responses = await facade.Create(data, USERNAME);

            var Response = facade.ReadById((int)data.Id);

            Assert.NotNull(Response);
        }
        public async void Should_Success_Delete_Data()
        {
            var            facade = new GarmentInvoiceFacade(_dbContext(GetCurrentMethod()), ServiceProvider);
            GarmentInvoice data   = await dataUtil(facade, GetCurrentMethod()).GetNewDataViewModel(USERNAME);

            await facade.Create(data, USERNAME);

            var Response = facade.Delete((int)data.Id, USERNAME);

            Assert.NotEqual(Response, 0);
        }
Exemple #3
0
        public async Task Should_Success_Get_Excel_Book_Report()
        {
            var httpClientService = new Mock <IHttpClientService>();

            httpClientService.Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("master/garment-suppliers"))))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(new CurrencyDataUtil().GetResultFormatterOkString())
            });
            var serviceProviderMock = new Mock <IServiceProvider>();

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IdentityService)))
            .Returns(new IdentityService {
                Username = "******", TimezoneOffset = 7
            });
            serviceProviderMock
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);

            var serviceProvider = GetServiceProvider().Object;
            var dbContext       = _dbContext(GetCurrentMethod());
            GarmentDeliveryOrderFacade facade = new GarmentDeliveryOrderFacade(serviceProvider, dbContext);
            var dataUtilDO                   = dataUtil(facade, GetCurrentMethod());
            var garmentBeacukaiFacade        = new GarmentBeacukaiFacade(dbContext, serviceProvider);
            var dataUtilBC                   = new GarmentBeacukaiDataUtil(dataUtilDO, garmentBeacukaiFacade);
            var invoicefacade                = new GarmentInvoiceFacade(dbContext, serviceProvider);
            var garmentInvoiceDetailDataUtil = new GarmentInvoiceDetailDataUtil();
            var garmentinvoiceItemDataUtil   = new GarmentInvoiceItemDataUtil(garmentInvoiceDetailDataUtil);
            var dataUtilInvo                 = new GarmentInvoiceDataUtil(garmentinvoiceItemDataUtil, garmentInvoiceDetailDataUtil, dataUtilDO, invoicefacade);
            var internnotefacade             = new GarmentInternNoteFacades(dbContext, serviceProvider);
            var dataUtilInternNote           = new GarmentInternNoteDataUtil(dataUtilInvo, internnotefacade);
            var correctionfacade             = new GarmentCorrectionNotePriceFacade(serviceProviderMock.Object, dbContext);
            var correctionDataUtil           = new GarmentCorrectionNoteDataUtil(correctionfacade, dataUtilDO);

            var dataDO = await dataUtilDO.GetNewData();

            await facade.Create(dataDO, USERNAME);

            var dataBC = await dataUtilBC.GetTestData(USERNAME, dataDO);

            var dataCorrection = await correctionDataUtil.GetTestData(dataDO);

            var dataInvo = await dataUtilInvo.GetTestData2(USERNAME, dataDO);

            var dataIntern = await dataUtilInternNote.GetNewData(dataInvo);

            await internnotefacade.Create(dataIntern, false, "Unit Test");

            var bookReportFacade = new GarmentPurchasingBookReportFacade(serviceProvider, dbContext);
            var Response         = bookReportFacade.GenerateExcelBookReport(null, null, null, null, null, 7);

            Assert.IsType <System.IO.MemoryStream>(Response);
        }
        public async Task Should_Success_Get_Data_For_InternNote()
        {
            var            facade = new GarmentInvoiceFacade(_dbContext(GetCurrentMethod()), ServiceProvider);
            GarmentInvoice data   = await dataUtil(facade, GetCurrentMethod()).GetNewDataViewModel(USERNAME);

            var Responses = await facade.Create(data, USERNAME);

            var Response = facade.ReadForInternNote(new List <long> {
                data.Id
            });

            Assert.NotEmpty(Response);
        }
        public async Task Should_Success_Get_Buku_Sub_Beli_Excel_Null_Parameter()
        {
            var            facade = new GarmentInvoiceFacade(_dbContext(GetCurrentMethod()), ServiceProvider);
            GarmentInvoice data   = await dataUtil(facade, GetCurrentMethod()).GetNewDataViewModel(USERNAME);

            GarmentDailyPurchasingReportFacade DataInv = new GarmentDailyPurchasingReportFacade(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));

            DateTime d1 = data.InvoiceDate.DateTime.AddDays(30);
            DateTime d2 = data.InvoiceDate.DateTime.AddDays(30);

            var Response = DataInv.GenerateExcelGDailyPurchasingReport(null, true, null, null, null, null, 7);

            Assert.IsType <System.IO.MemoryStream>(Response);
        }
        public async Task Should_Success_Get_Buku_Sub_Beli_Data()
        {
            var            facade = new GarmentInvoiceFacade(_dbContext(GetCurrentMethod()), ServiceProvider);
            GarmentInvoice data   = await dataUtil(facade, GetCurrentMethod()).GetNewDataViewModel(USERNAME);

            GarmentDailyPurchasingReportFacade DataInv = new GarmentDailyPurchasingReportFacade(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));

            DateTime d1 = data.InvoiceDate.DateTime;
            DateTime d2 = data.InvoiceDate.DateTime;

            var Response = DataInv.GetGDailyPurchasingReport(null, true, null, null, null, null, 7);

            Assert.NotNull(Response.Item1);
        }
        public async void Should_Success_Update_Data()
        {
            var            facade   = new GarmentInvoiceFacade(_dbContext(GetCurrentMethod()), ServiceProvider);
            var            facadeDO = new GarmentDeliveryOrderFacade(ServiceProvider, _dbContext(GetCurrentMethod()));
            GarmentInvoice data     = await dataUtil(facade, GetCurrentMethod()).GetNewDataViewModel(USERNAME);

            var ResponseUpdate = await facade.Update((int)data.Id, data, USERNAME);

            Assert.NotEqual(ResponseUpdate, 0);
            var newItem = new GarmentInvoiceItem
            {
                DeliveryOrderId = It.IsAny <int>(),
                DODate          = DateTimeOffset.Now,
                DeliveryOrderNo = "donos",
                ArrivalDate     = DateTimeOffset.Now,
                TotalAmount     = 2000,
                PaymentType     = "type",
                PaymentMethod   = "method",
                Details         = new List <GarmentInvoiceDetail>
                {
                    new GarmentInvoiceDetail
                    {
                        EPOId            = It.IsAny <int>(),
                        EPONo            = "epono",
                        IPOId            = It.IsAny <int>(),
                        PRItemId         = It.IsAny <int>(),
                        PRNo             = "prno",
                        RONo             = "12343",
                        ProductId        = It.IsAny <int>(),
                        ProductCode      = "code",
                        ProductName      = "name",
                        UomId            = It.IsAny <int>(),
                        UomUnit          = "ROLL",
                        DOQuantity       = 40,
                        PricePerDealUnit = 5000,
                        PaymentDueDays   = 2,
                        POSerialNumber   = "PM132434"
                    }
                }
            };
            List <GarmentInvoiceItem> Newitems = new List <GarmentInvoiceItem>(data.Items);

            Newitems.Add(newItem);
            data.Items = Newitems;

            var ResponseUpdate1 = await facade.Update((int)data.Id, data, USERNAME);

            Assert.NotEqual(ResponseUpdate, 0);
        }
        public async Task Should_Success_Create_Data()
        {
            var            facade = new GarmentInvoiceFacade(_dbContext(GetCurrentMethod()), ServiceProvider);
            GarmentInvoice data   = await dataUtil(facade, GetCurrentMethod()).GetNewDataViewModel(USERNAME);

            var Response = await facade.Create(data, USERNAME);

            Assert.NotEqual(Response, 0);
            GarmentInvoice data2 = await dataUtil(facade, GetCurrentMethod()).GetNewDataViewModel(USERNAME);

            DateTime dateWithoutOffset = new DateTime(2010, 8, 16, 13, 32, 00);

            data2.InvoiceDate = dateWithoutOffset;
            var Response1 = await facade.Create(data2, USERNAME);

            Assert.NotEqual(Response1, 0);
        }
        private GarmentInvoiceDataUtil dataUtil(GarmentInvoiceFacade facade, string testName)
        {
            var garmentInvoiceFacade           = new GarmentInvoiceFacade(_dbContext(testName), ServiceProvider);
            var garmentInvoiceDetailDataUtil   = new GarmentInvoiceDetailDataUtil();
            var garmentInvoiceItemDataUtil     = new GarmentInvoiceItemDataUtil(garmentInvoiceDetailDataUtil);
            var garmentDeliveryOrderFacade     = new GarmentDeliveryOrderFacade(GetServiceProvider().Object, _dbContext(testName));
            var garmentPurchaseRequestFacade   = new GarmentPurchaseRequestFacade(_dbContext(testName));
            var garmentPurchaseRequestDataUtil = new GarmentPurchaseRequestDataUtil(garmentPurchaseRequestFacade);

            var garmentInternalPurchaseOrderFacade   = new GarmentInternalPurchaseOrderFacade(_dbContext(testName));
            var garmentInternalPurchaseOrderDataUtil = new GarmentInternalPurchaseOrderDataUtil(garmentInternalPurchaseOrderFacade, garmentPurchaseRequestDataUtil);

            var garmentExternalPurchaseOrderFacade   = new GarmentExternalPurchaseOrderFacade(ServiceProvider, _dbContext(testName));
            var garmentExternalPurchaseOrderDataUtil = new GarmentExternalPurchaseOrderDataUtil(garmentExternalPurchaseOrderFacade, garmentInternalPurchaseOrderDataUtil);

            var garmentDeliveryOrderDataUtil = new GarmentDeliveryOrderDataUtil(garmentDeliveryOrderFacade, garmentExternalPurchaseOrderDataUtil);

            return(new GarmentInvoiceDataUtil(garmentInvoiceItemDataUtil, garmentInvoiceDetailDataUtil, garmentDeliveryOrderDataUtil, facade));
        }
        public async Task Should_Success_Update_Data2()
        {
            var            dbContext = _dbContext(GetCurrentMethod());
            var            facade    = new GarmentInvoiceFacade(dbContext, ServiceProvider);
            var            facadeDO  = new GarmentDeliveryOrderFacade(ServiceProvider, dbContext);
            GarmentInvoice data      = await dataUtil(facade, GetCurrentMethod()).GetNewDataViewModel(USERNAME);

            GarmentInvoiceItem item = await dataUtil(facade, GetCurrentMethod()).GetNewDataItem(USERNAME);

            var ResponseUpdate = await facade.Update((int)data.Id, data, USERNAME);

            Assert.NotEqual(ResponseUpdate, 0);

            List <GarmentInvoiceItem> Newitems = new List <GarmentInvoiceItem>(data.Items);

            Newitems.Add(item);
            data.Items = Newitems;

            var ResponseUpdate1 = await facade.Update((int)data.Id, data, USERNAME);

            Assert.NotEqual(ResponseUpdate, 0);

            dbContext.Entry(data).State = EntityState.Detached;
            foreach (var items in data.Items)
            {
                dbContext.Entry(items).State = EntityState.Detached;
                foreach (var detail in items.Details)
                {
                    dbContext.Entry(detail).State = EntityState.Detached;
                }
            }

            var newData = dbContext.GarmentInvoices.AsNoTracking()
                          .Include(m => m.Items)
                          .ThenInclude(i => i.Details)
                          .FirstOrDefault(m => m.Id == data.Id);

            newData.Items = newData.Items.Take(1).ToList();

            var ResponseUpdate2 = await facade.Update((int)newData.Id, newData, USERNAME);

            Assert.NotEqual(ResponseUpdate2, 0);
        }
        public async Task Should_Error_Update_Data()
        {
            var            facade = new GarmentInvoiceFacade(_dbContext(GetCurrentMethod()), ServiceProvider);
            GarmentInvoice data   = await dataUtil(facade, GetCurrentMethod()).GetNewData(USERNAME);

            List <GarmentInvoiceItem> item = new List <GarmentInvoiceItem>(data.Items);

            data.Items.Add(new GarmentInvoiceItem
            {
                DeliveryOrderId = It.IsAny <int>(),
                DODate          = DateTimeOffset.Now,
                DeliveryOrderNo = "donos",
                ArrivalDate     = DateTimeOffset.Now,
                TotalAmount     = 2000,
                Details         = null
            });

            var ResponseUpdate = await facade.Update((int)data.Id, data, USERNAME);

            Assert.NotEqual(ResponseUpdate, 0);
            var newItem = new GarmentInvoiceItem
            {
                DeliveryOrderId = It.IsAny <int>(),
                DODate          = DateTimeOffset.Now,
                DeliveryOrderNo = "dono",
                ArrivalDate     = DateTimeOffset.Now,
                TotalAmount     = 2000,
                Details         = null
            };
            List <GarmentInvoiceItem> Newitems = new List <GarmentInvoiceItem>(data.Items);

            Newitems.Add(newItem);
            data.Items = Newitems;

            Exception errorNullItems = await Assert.ThrowsAsync <Exception>(async() => await facade.Update((int)data.Id, data, USERNAME));

            Assert.NotNull(errorNullItems.Message);
        }
        public async Task Should_Error_Get_Xls_Payment()
        {
            var httpClientService = new Mock <IHttpClientService>();

            httpClientService.Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("master/garment-suppliers"))))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(new SupplierDataUtil().GetResultFormatterOkString())
            });
            httpClientService
            .Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("master/garment-currencies"))))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(new CurrencyDataUtil().GetMultipleResultFormatterOkString())
            });

            var serviceProviderMock = new Mock <IServiceProvider>();

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IdentityService)))
            .Returns(new IdentityService {
                Username = "******", TimezoneOffset = 7
            });
            serviceProviderMock
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(httpClientService.Object);
            var dbContext = _dbContext(GetCurrentMethod());
            //var serviceProvider = GetServiceProvider().Object;

            var facade = new GarmentInternNoteFacades(dbContext, serviceProviderMock.Object);
            var garmentcorrectionfacade            = new Lib.Facades.GarmentCorrectionNoteFacades.GarmentCorrectionNotePriceFacade(serviceProviderMock.Object, dbContext);
            var garmentPurchaseRequestFacade       = new GarmentPurchaseRequestFacade(serviceProviderMock.Object, dbContext);
            var garmentInternalPurchaseOrderFacade = new GarmentInternalPurchaseOrderFacade(dbContext);
            var garmentExternalPurchaseOrderFacade = new GarmentExternalPurchaseOrderFacade(serviceProviderMock.Object, dbContext);
            var garmentDeliveryOrderFacade         = new GarmentDeliveryOrderFacade(serviceProviderMock.Object, dbContext);
            var garmentInvoiceFacade         = new GarmentInvoiceFacade(dbContext, serviceProviderMock.Object);
            var prdatautil                   = new GarmentPurchaseRequestDataUtil(garmentPurchaseRequestFacade);
            var internalPoDatautil           = new GarmentInternalPurchaseOrderDataUtil(garmentInternalPurchaseOrderFacade, prdatautil);
            var datautilexpo                 = new GarmentExternalPurchaseOrderDataUtil(garmentExternalPurchaseOrderFacade, internalPoDatautil);
            var dataUtilDo                   = new GarmentDeliveryOrderDataUtil(garmentDeliveryOrderFacade, datautilexpo);
            var garmentInvoiceDetailDataUtil = new GarmentInvoiceDetailDataUtil();
            var garmentInvoiceItemDataUtil   = new GarmentInvoiceItemDataUtil(garmentInvoiceDetailDataUtil);
            var garmentInvoieDataUtil        = new GarmentInvoiceDataUtil(garmentInvoiceItemDataUtil, garmentInvoiceDetailDataUtil, dataUtilDo, garmentInvoiceFacade);
            var corecctiondatautil           = new GarmentCorrectionNoteDataUtil(garmentcorrectionfacade, dataUtilDo);

            var dataDo = await dataUtilDo.GetTestData();

            var dataCorr = await corecctiondatautil.GetTestData(dataDo);

            var invoData = await garmentInvoieDataUtil.GetTestData2("Test", dataDo);

            var dataIntern = await dataUtil(facade, GetCurrentMethod()).GetNewData(invoData);

            dataIntern.Items.FirstOrDefault().Details.FirstOrDefault().PaymentDueDate = DateTimeOffset.Now;
            await facade.Create(dataIntern, false, "Unit Test");

            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("Nomor", typeof(string));
            dataTable.Columns.Add("Tgl", typeof(DateTime));
            dataTable.Columns.Add("Jumlah", typeof(decimal));
            dataTable.Rows.Add("Nomor", "1970,1,1", 0);

            Mock <ILocalDbCashFlowDbContext> mockDbContext = new Mock <ILocalDbCashFlowDbContext>();

            mockDbContext.Setup(s => s.ExecuteReaderOnlyQuery(It.IsAny <string>()))
            .Throws(new Exception("Error ExecuteReader"));
            mockDbContext.Setup(s => s.ExecuteReader(It.IsAny <string>(), It.IsAny <List <SqlParameter> >()))
            .Throws(new Exception("Error ExecuteReader"));

            var facadepaymentstatus = new GarmentInternNotePaymentStatusFacade(serviceProviderMock.Object, dbContext, mockDbContext.Object);
            var Response            = Assert.ThrowsAny <Exception>(() => facadepaymentstatus.GetXLs(null, null, null, null, null, null, null, null, DateTime.Now.AddDays(1), null, DateTime.Now.AddDays(1), null, 7));

            Assert.NotNull(Response);
        }
Exemple #13
0
 public GarmentInvoiceDataUtil(GarmentInvoiceItemDataUtil GarmentInvoiceItemDataUtil, GarmentInvoiceDetailDataUtil GarmentInvoiceDetailDataUtil, GarmentDeliveryOrderDataUtil GarmentDeliveryOrderDataUtil, GarmentInvoiceFacade facade)
 {
     this.garmentInvoiceItemDataUtil   = GarmentInvoiceItemDataUtil;
     this.GarmentInvoiceDetailDataUtil = GarmentInvoiceDetailDataUtil;
     this.garmentDeliveryOrderDataUtil = GarmentDeliveryOrderDataUtil;
     this.facade = facade;
 }
Exemple #14
0
 public GarmentInvoiceDataUtil(GarmentInvoiceFacade facade)
 {
     this.facade = facade;
 }