public void GetReportData_Success()
        {
            var model = new GarmentShippingInvoiceModel(1, "", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "", DateTimeOffset.Now,
                                                        "", DateTimeOffset.Now, "", "", null, 1, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", null)
            {
                Id = 1
            };

            var model1 = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", false, false, 1, "", GarmentPackingListStatusEnum.CREATED, "", false, "", false, false, false, "")
            {
                Id = 1
            };

            var repoMock = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model
            }.AsQueryable());

            var repoMock1 = new Mock <IGarmentPackingListRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model1
            }.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock.Object, repoMock1.Object).Object);

            var result = service.GetReportData(model1.TruckingDate.Month, model1.TruckingDate.Year, 7);

            Assert.NotEmpty(result.ToList());
        }
Beispiel #2
0
        public void Should_Null_Get_BuyerViewModel()
        {
            var items = new HashSet <GarmentShippingInvoiceItemModel> {
                new GarmentShippingInvoiceItemModel("ro", "scno", 1, "buyerbrandname", 1, 1, "comocode", "comoname", "comodesc", "comodesc", "comodesc", "comodesc", 1, "pcs", 10, 10, 100, "usd", 1, "unitcode", 3, 1)
            };
            var adjustments = new HashSet <GarmentShippingInvoiceAdjustmentModel> {
                new GarmentShippingInvoiceAdjustmentModel(1, "fee", 100, 1)
            };
            var units = new HashSet <GarmentShippingInvoiceUnitModel> {
                new GarmentShippingInvoiceUnitModel(1, "unitcode", 3, 1)
            };

            var model = new GarmentShippingInvoiceModel(1, "invoiceno", DateTimeOffset.Now, "from", "to", 1, "buyercode", "buyername", "consignee", "lcno", "issuedby", 1, "sectioncode", "shippingper", DateTimeOffset.Now, "confNo", 1, "staff", 1, "cottn", 1, "mandiri", 10, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", "", items, 1000, "dddd", "dsdsds", "memo", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, adjustments, 100000, "aa", "aa", units);

            var repoMock = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock.Setup(s => s.ReadByIdAsync(It.IsAny <int>()))
            .ReturnsAsync(model);


            var service = GetService(GetServiceProvider_Error(repoMock.Object).Object);
            var result  = service.GetBuyer(It.IsAny <int>());

            Assert.Null(result);
        }
        private GarmentShippingInvoiceModel MapToModel(GarmentShippingInvoiceViewModel viewModel)
        {
            var items = (viewModel.Items ?? new List <GarmentShippingInvoiceItemViewModel>()).Select(i =>
            {
                i.BuyerBrand = i.BuyerBrand ?? new BuyerBrand();
                i.Uom        = i.Uom ?? new UnitOfMeasurement();
                i.Unit       = i.Unit ?? new Unit();
                i.Comodity   = i.Comodity ?? new Comodity();
                return(new GarmentShippingInvoiceItemModel(i.RONo, i.SCNo, i.BuyerBrand.Id, i.BuyerBrand.Name, i.Quantity, i.Comodity.Id, i.Comodity.Code, i.Comodity.Name, i.ComodityDesc, i.Desc2, i.Desc3, i.Desc4, i.Uom.Id.GetValueOrDefault(), i.Uom.Unit, i.Price, i.PriceRO, i.Amount, i.CurrencyCode, i.Unit.Id, i.Unit.Code, i.CMTPrice, i.PackingListItemId)
                {
                    Id = i.Id
                });
            }).ToList();


            viewModel.Section    = viewModel.Section ?? new Section();
            viewModel.BuyerAgent = viewModel.BuyerAgent ?? new BuyerAgent();
            var garmentshippinginvoiceadjustment = (viewModel.GarmentShippingInvoiceAdjustments ?? new List <GarmentShippingInvoiceAdjustmentViewModel>()).Select(m => new GarmentShippingInvoiceAdjustmentModel(m.GarmentShippingInvoiceId, m.AdjustmentDescription, m.AdjustmentValue, m.AdditionalChargesId)
            {
                Id = m.Id
            }).ToList();
            var garmentshippinginvoiceUnit = (viewModel.GarmentShippingInvoiceUnits ?? new List <GarmentShippingInvoiceUnitViewModel>()).Select(m => {
                m.Unit = m.Unit ?? new Unit();
                return(new GarmentShippingInvoiceUnitModel(m.Unit.Id, m.Unit.Code, m.AmountPercentage, m.QuantityPercentage)
                {
                    Id = m.Id
                });
            }).ToList();

            GarmentShippingInvoiceModel garmentShippingInvoiceModel = new GarmentShippingInvoiceModel(viewModel.PackingListId, viewModel.InvoiceNo, viewModel.InvoiceDate, viewModel.From, viewModel.To, viewModel.BuyerAgent.Id, viewModel.BuyerAgent.Code, viewModel.BuyerAgent.Name, viewModel.Consignee, viewModel.LCNo, viewModel.IssuedBy, viewModel.Section.Id, viewModel.Section.Code, viewModel.ShippingPer, viewModel.SailingDate, viewModel.ConfirmationOfOrderNo, viewModel.ShippingStaffId, viewModel.ShippingStaff, viewModel.FabricTypeId, viewModel.FabricType, viewModel.BankAccountId, viewModel.BankAccount, viewModel.PaymentDue, viewModel.PEBNo, viewModel.PEBDate.GetValueOrDefault(), viewModel.NPENo, viewModel.NPEDate.GetValueOrDefault(), viewModel.Description, viewModel.Remark, items, viewModel.AmountToBePaid, viewModel.AmountCA, viewModel.CPrice, viewModel.Say, viewModel.Memo, viewModel.IsUsed, viewModel.BL, viewModel.BLDate.GetValueOrDefault(), viewModel.CO, viewModel.CODate.GetValueOrDefault(), viewModel.COTP, viewModel.COTPDate.GetValueOrDefault(), garmentshippinginvoiceadjustment, viewModel.TotalAmount, viewModel.ConsigneeAddress, viewModel.DeliverTo, garmentshippinginvoiceUnit);

            return(garmentShippingInvoiceModel);
        }
Beispiel #4
0
        public void Read_Success()
        {
            var items = new HashSet <GarmentShippingInvoiceItemModel> {
                new GarmentShippingInvoiceItemModel("ro", "scno", 1, "buyerbrandname", 1, 1, "comocode", "comoname", "comodesc", "comodesc", "comodesc", "comodesc", 1, "pcs", 10, 10, 100, "usd", 1, "unitcode", 3, 1)
            };
            var adjustments = new HashSet <GarmentShippingInvoiceAdjustmentModel> {
                new GarmentShippingInvoiceAdjustmentModel(1, "fee", 100, 1)
            };
            var units = new HashSet <GarmentShippingInvoiceUnitModel> {
                new GarmentShippingInvoiceUnitModel(1, "unitcode", 3, 1)
            };
            var model = new GarmentShippingInvoiceModel(1, "invoiceno", DateTimeOffset.Now, "from", "to", 1, "buyercode", "buyername", "consignee", "lcno", "issuedby", 1, "sectioncode", "shippingper", DateTimeOffset.Now, "confNo", 1, "staff", 1, "cottn", 1, "mandiri", 10, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", "", items, 1000, "23", "dsdsds", "memo", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, adjustments, 100000, "aa", "aa", units);

            var repoMock = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model
            }.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock.Object).Object);

            var result = service.Read(1, 25, "{}", "{}", null);

            Assert.NotEmpty(result.Data);
        }
        public Task <int> InsertAsync(GarmentShippingInvoiceModel model)
        {
            model.FlagForCreate(_identityProvider.Username, USER_AGENT);
            var packingListModel = _garmentpackingListDbSet.FirstOrDefault(entity => entity.Id == model.PackingListId);

            packingListModel.SetIsUsed(true, _identityProvider.Username, USER_AGENT);
            foreach (var item in model.Items)
            {
                item.FlagForCreate(_identityProvider.Username, USER_AGENT);
            }

            foreach (var adjustment in model.GarmentShippingInvoiceAdjustment)
            {
                adjustment.FlagForCreate(_identityProvider.Username, USER_AGENT);
            }

            foreach (var unit in model.GarmentShippingInvoiceUnit)
            {
                unit.FlagForCreate(_identityProvider.Username, USER_AGENT);
            }

            _garmentshippingInvoiceDbSet.Add(model);

            return(_dbContext.SaveChangesAsync());
        }
        public async override Task Should_Success_Delete()
        {
            string testName        = GetCurrentMethod();
            var    dbContext       = DbContext(testName);
            var    serviceProvider = GetServiceProviderMock(dbContext).Object;

            GarmentPackingListRepository repoPL = new GarmentPackingListRepository(dbContext, serviceProvider);
            GarmentPackingListDataUtil   utilPL = new GarmentPackingListDataUtil(repoPL);
            GarmentPackingListModel      dataPL = utilPL.GetModel();
            var dataPackingList = await repoPL.InsertAsync(dataPL);

            GarmentShippingInvoiceRepository repo            = new GarmentShippingInvoiceRepository(dbContext, serviceProvider);
            GarmentShippingInvoiceDataUtil   invoiceDataUtil = new GarmentShippingInvoiceDataUtil(repo, utilPL);
            GarmentShippingInvoiceModel      data            = invoiceDataUtil.GetModel();

            data.PackingListId = dataPL.Id;
            var dataInvoice = await repo.InsertAsync(data);

            GarmentShippingInstructionRepository repoInstruction     = new GarmentShippingInstructionRepository(dbContext, serviceProvider);
            GarmentShippingInstructionDataUtil   InstructionDataUtil = new GarmentShippingInstructionDataUtil(repoInstruction, invoiceDataUtil);
            GarmentShippingInstructionModel      dataInstruction     = InstructionDataUtil.GetModel();

            dataInstruction.SetInvoiceId(data.Id, "test", "unitTest");
            var result = await repoInstruction.InsertAsync(dataInstruction);

            var resultdelete = await repoInstruction.DeleteAsync(dataInstruction.Id);

            Assert.NotEqual(0, resultdelete);
        }
        public async Task <int> Create(GarmentShippingInvoiceViewModel viewModel)
        {
            GarmentShippingInvoiceModel model = MapToModel(viewModel);

            int Created = await _repository.InsertAsync(model);

            return(Created);
        }
        public void GetReportData_Success()
        {
            var packinglistmodel = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "USA", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, true, true, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", true, true, 1, "", GarmentPackingListStatusEnum.CREATED, "", false, "", false, false, false, "")
            {
                Id = 1
            };

            var invoiceItemModels = new HashSet <GarmentShippingInvoiceItemModel> {
                new GarmentShippingInvoiceItemModel("ro", "scno", 1, "buyerbrandname", 10, 1, "comocode", "comoname", "comodesc", "comodesc", "comodesc", "comodesc", 1, "PCS", 10, 10, 100, "usd", 1, "unitcode", 3, 1)
                {
                    Id = 1
                },
                new GarmentShippingInvoiceItemModel("ro", "scno", 1, "buyerbrandname", 15, 1, "comocode", "comoname", "comodesc", "comodesc", "comodesc", "comodesc", 2, "SETS", 20, 20, 300, "usd", 1, "unitcode", 3, 2)
                {
                    Id = 1
                }
            };
            var invoiceUnitModels = new HashSet <GarmentShippingInvoiceUnitModel> {
                new GarmentShippingInvoiceUnitModel(1, "unitcode", 3, 1)
                {
                    Id = 1
                }
            };
            var invoiceModel = new GarmentShippingInvoiceModel(1, "invoiceno", DateTimeOffset.Now, "from", "to", 1, "buyercode", "buyername", "consignee", "lcno", "issuedby", 1, "sectioncode", "shippingper", DateTimeOffset.Now, "confNo", 1, "staff", 1, "cottn", 1, "mandiri", 10, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", "", invoiceItemModels, 1000, 1000, "23", "dsdsds", "memo", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 100000, "aa", "aa", invoiceUnitModels)
            {
                Id = 1,
            };


            var repoMock = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                invoiceModel
            }.AsQueryable());

            var repoMock2 = new Mock <IGarmentPackingListRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                packinglistmodel
            }.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock.Object, repoMock2.Object).Object);

            var result = service.GetReportData(packinglistmodel.TruckingDate.Year);

            Assert.NotEmpty(result.Items);
        }
        public void GenerateExcel_Success()
        {
            var packingListModel = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", false, false, 1, "", GarmentPackingListStatusEnum.CREATED, "")
            {
                Id = 1
            };

            var packingListRepoMock = new Mock <IGarmentPackingListRepository>();

            packingListRepoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                packingListModel
            }.AsQueryable());

            var invoiceItemModels = new HashSet <GarmentShippingInvoiceItemModel> {
                new GarmentShippingInvoiceItemModel("ro", "scno", 1, "buyerbrandname", 1, 1, "comocode", "comoname", "comodesc", "comodesc", "comodesc", "comodesc", 1, "pcs", 10, 10, 100, "usd", 1, "unitcode", 3)
                {
                    Id = 1
                }
            };
            var invoiceUnitModels = new HashSet <GarmentShippingInvoiceUnitModel> {
                new GarmentShippingInvoiceUnitModel(1, "unitcode", 3, 1)
                {
                    Id = 1
                }
            };
            var invoiceModel = new GarmentShippingInvoiceModel(1, "invoiceno", DateTimeOffset.Now, "from", "to", 1, "buyercode", "buyername", "consignee", "lcno", "issuedby", 1, "sectioncode", "shippingper", DateTimeOffset.Now, "confNo", 1, "staff", 1, "cottn", 1, "mandiri", 10, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", invoiceItemModels, 1000, "23", "dsdsds", "memo", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 100000, "aa", "aa", invoiceUnitModels)
            {
                Id            = 1,
                PackingListId = packingListModel.Id
            };

            var invoiceRepoMock = new Mock <IGarmentShippingInvoiceRepository>();

            invoiceRepoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                invoiceModel
            }.AsQueryable());

            var spMock  = GetServiceProvider(invoiceRepoMock.Object, packingListRepoMock.Object);
            var service = GetService(spMock.Object);

            var result = service.GenerateExcel(invoiceModel.InvoiceDate.Year);

            Assert.NotNull(result.Data);
        }
Beispiel #10
0
        public void GenerateExcel_Success()
        {
            var model = new GarmentShippingLetterOfCreditModel("001", DateTimeOffset.Now, "", 1, "", "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", 1, 1, "", 2)
            {
                Id = 1
            };

            var model1 = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "LC", "001", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", false, false, 1, "", GarmentPackingListStatusEnum.CREATED, "")
            {
                Id = 1
            };

            var model2 = new GarmentShippingInvoiceModel(1, "", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "", DateTimeOffset.Now,
                                                         "", DateTimeOffset.Now, "", null, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", null)
            {
                Id = 1
            };

            var repoMock = new Mock <IGarmentLetterOfCreditRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingLetterOfCreditModel>()
            {
                model
            }.AsQueryable());

            var repoMock2 = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model2
            }.AsQueryable());

            var repoMock1 = new Mock <IGarmentPackingListRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model1
            }.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock.Object, repoMock2.Object, repoMock1.Object).Object);

            var result = service.GenerateExcel(model.ApplicantCode, null, DateTime.MinValue, DateTime.MaxValue, 7);

            Assert.NotNull(result);
        }
        public void GetReportData_Success()
        {
            var model = new GarmentShippingInvoiceModel(1, "", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "", DateTimeOffset.Now,
                                                        "", DateTimeOffset.Now, "", "", null, 1, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", null)
            {
                Id = 1
            };
            var model1 = new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "", "", "", "comodesc", "comodesc", "comodesc", 1, "", 1, 1, 1, "", 1, "C10", 1, 1)
            {
                GarmentShippingInvoiceId = 1
            };

            var model2 = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, true, true, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", true, true, 1, "", GarmentPackingListStatusEnum.CREATED, "", true, "", true, true, true, "")
            {
                Id = 1
            };

            var repoMock = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model
            }.AsQueryable());

            var repoMock1 = new Mock <IGarmentShippingInvoiceItemRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceItemModel>()
            {
                model1
            }.AsQueryable());

            var repoMock2 = new Mock <IGarmentPackingListRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model2
            }.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock.Object, repoMock1.Object, repoMock2.Object).Object);

            var result = service.GetReportData(model1.UnitCode, DateTime.MinValue, DateTime.Now, 0);

            Assert.NotEmpty(result.ToList());
        }
        public virtual async Task <int> Update(int id, GarmentPackingListViewModel viewModel)
        {
            viewModel.ShippingMarkImagePath = await UploadImage(viewModel.ShippingMarkImageFile, viewModel.Id, viewModel.ShippingMarkImagePath, viewModel.CreatedUtc);

            viewModel.SideMarkImagePath = await UploadImage(viewModel.SideMarkImageFile, viewModel.Id, viewModel.SideMarkImagePath, viewModel.CreatedUtc);

            viewModel.RemarkImagePath = await UploadImage(viewModel.RemarkImageFile, viewModel.Id, viewModel.RemarkImagePath, viewModel.CreatedUtc);

            GarmentPackingListModel garmentPackingListModel = MapToModel(viewModel);
            var invoice = _invoiceRepository.ReadAll();
            GarmentShippingInvoiceModel shippingInvoice = (from a in invoice
                                                           where a.InvoiceNo == garmentPackingListModel.InvoiceNo
                                                           select a).FirstOrDefault();

            if (shippingInvoice != null)
            {
                var invoiceItem = await _invoiceRepository.ReadByIdAsync(shippingInvoice.Id);

                GarmentShippingInvoiceModel shippingInvoiceItem = invoiceItem;

                if (shippingInvoiceItem != null)
                {
                    shippingInvoiceItem.InvoiceDate = garmentPackingListModel.Date;

                    await _invoiceRepository.UpdateAsync(shippingInvoiceItem.Id, shippingInvoiceItem);
                }
            }
            foreach (var item in garmentPackingListModel.Items)
            {
                foreach (var detail in item.Details)
                {
                    detail.SetNetNetWeight(detail.NetNetWeight == 0 ? 0.9 * detail.NetWeight : detail.NetNetWeight, _identityProvider.Username, UserAgent);
                }
            }

            var totalNnw = garmentPackingListModel.Items
                           .SelectMany(i => i.Details.Where(d => d.IsDeleted == false).Select(d => new { d.Carton1, d.Carton2, totalNetNetWeight = d.CartonQuantity * d.NetNetWeight }))
                           .GroupBy(g => new { g.Carton1, g.Carton2 }, (key, value) => value.First().totalNetNetWeight).Sum();

            garmentPackingListModel.SetNetNetWeight(totalNnw, _identityProvider.Username, UserAgent);

            return(await _packingListRepository.UpdateAsync(id, garmentPackingListModel));
        }
        public void ReadShippingPackingList()
        {
            var model1 = new GarmentShippingInvoiceModel(1, "", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "",
                                                         1, "", 1, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", "", null, 1, 1, "", "", "",
                                                         false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", null)
            {
                Id = 1
            };

            var model2 = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now.Date.AddMonths(-1), "", "", DateTimeOffset.Now.Date.AddMonths(-1), "", 1, "B10", "", "", "", "", DateTimeOffset.Now.Date.AddMonths(-1), DateTimeOffset.Now.Date.AddMonths(-1), DateTimeOffset.Now.Date.AddMonths(-1), true, true, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", true, true, 1, "", GarmentPackingListStatusEnum.CREATED, "", false, "", false, false, false, "")
            {
                Id = 1
            };


            var repoMock1 = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model1
            }.AsQueryable());

            var repoMock2 = new Mock <IGarmentPackingListRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model2
            }.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock1.Object, repoMock2.Object).Object);

            var result = service.ReadShippingPackingList(DateTimeOffset.Now.Month, DateTimeOffset.Now.Year);

            Assert.NotEmpty(result.ToList());
        }
        public void GetReportData_Success()
        {
            var packingListModel = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", false, false, 1, "", GarmentPackingListStatusEnum.CREATED, "", false, "", false, false, false, "")
            {
                Id = 1
            };

            var packingListRepoMock = new Mock <IGarmentPackingListRepository>();

            packingListRepoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                packingListModel
            }.AsQueryable());

            var invoiceItemModels = new HashSet <GarmentShippingInvoiceItemModel> {
                new GarmentShippingInvoiceItemModel("ro", "scno", 1, "buyerbrandname", 1, 1, "comocode", "comoname", "comodesc", "", "", "", 1, "pcs", 10, 10, 100, "usd", 1, "unitcode", 3, 1)
                {
                    Id = 1
                }
            };
            var invoiceUnitModels = new HashSet <GarmentShippingInvoiceUnitModel> {
                new GarmentShippingInvoiceUnitModel(1, "unitcode", 3, 1)
                {
                    Id = 1
                }
            };
            var invoiceModel = new GarmentShippingInvoiceModel(1, "invoiceno", DateTimeOffset.Now, "from", "to", 1, "buyercode", "buyername", "consignee", "lcno", "issuedby", 1, "sectioncode", "shippingper", DateTimeOffset.Now, "confNo", 1, "staff", 1, "cottn", 1, "mandiri", 10, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", "", invoiceItemModels, 1000, 1000, "23", "dsdsds", "memo", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 100000, "aa", "aa", invoiceUnitModels)
            {
                Id            = 1,
                PackingListId = packingListModel.Id
            };

            var invoiceRepoMock = new Mock <IGarmentShippingInvoiceRepository>();

            invoiceRepoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                invoiceModel
            }.AsQueryable());

            var httpMock = new Mock <IHttpClientService>();

            httpMock.Setup(s => s.SendAsync(HttpMethod.Get, It.IsAny <string>(), It.IsAny <HttpContent>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(new { data = new List <GarmentCurrency> {
                                                                                  new GarmentCurrency()
                                                                                  {
                                                                                      code = "usd"
                                                                                  }
                                                                              } }))
            });

            var spMock = GetServiceProvider(packingListRepoMock.Object, invoiceRepoMock.Object);

            spMock.Setup(s => s.GetService(typeof(IHttpClientService)))
            .Returns(httpMock.Object);

            var service = GetService(spMock.Object);

            var result = service.GetReportData(packingListModel.TruckingDate.Month, packingListModel.TruckingDate.Year);

            Assert.NotEmpty(result.Data);
        }
        public void GetReportData_Success()
        {
            var items = new List <GarmentShippingInvoiceItemModel>
            {
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "MENS SHIRT", "", "", "comodesc", "comodesc", "comodesc", 1, "PCS", 1, 1, 1, "USD", 1, "C10", 1, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "LADIES BLOUSE", "", "", "comodesc", "comodesc", "comodesc", 1, "SETS", 1, 1, 1, "USD", 1, "C10", 1, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "BOYS SHIRT", "", "", "comodesc", "comodesc", "comodesc", 1, "PCS", 1, 1, 1, "USD", 1, "C10", 1, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
            };

            var model = new GarmentShippingInvoiceModel(1, "DL/219999", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "123456", DateTimeOffset.Now,
                                                        "", DateTimeOffset.Now, "", "", items, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", null)
            {
                Id = 1
            };

            var model1 = new GarmentPackingListModel("DL/219999", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, true, true, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", false, false, 1, "", GarmentPackingListStatusEnum.CREATED, "", false, "")
            {
                Id = 1
            };

            var repoMock = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model
            }.AsQueryable());

            var repoMock1 = new Mock <IGarmentPackingListRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model1
            }.AsQueryable());

            var repoMock3 = new Mock <IGarmentShippingInvoiceItemRepository>();

            repoMock3.Setup(s => s.ReadAll())
            .Returns(items.AsQueryable());


            var httpMock = new Mock <IHttpClientService>();

            httpMock.Setup(s => s.SendAsync(HttpMethod.Get, It.IsAny <string>(), It.IsAny <HttpContent>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(new { data = new List <GarmentCurrency> {
                                                                                  new GarmentCurrency()
                                                                                  {
                                                                                      code = "USD"
                                                                                  }
                                                                              } }))
            });

            var spMock = GetServiceProvider(repoMock.Object, repoMock1.Object, repoMock3.Object);

            spMock.Setup(s => s.GetService(typeof(IHttpClientService)))
            .Returns(httpMock.Object);

            var service = GetService(spMock.Object);

            var result = service.GetReportData(DateTime.MinValue, DateTime.MaxValue, 0);

            Assert.NotEmpty(result.Data);
        }
        public void GetReportData_Success()
        {
            var model = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", false, false, 1, "", GarmentPackingListStatusEnum.CREATED, "", false, "")
            {
                Id = 1
            };

            var model1 = new GarmentShippingInvoiceModel(1, "", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "", DateTimeOffset.Now,
                                                         "", DateTimeOffset.Now, "", "", null, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", null)
            {
                Id = 1
            };

            var model2 = new GarmentShippingInstructionModel("no", 1, DateTimeOffset.Now, 1, "", "", "", "", "", "", "", 1, "", "", "", DateTimeOffset.Now, "", "", "", "", "", "", "", "", 1, "", 1, "", "", "", "", "", DateTimeOffset.Now, "", "", "")
            {
                Id = 1
            };

            var model3 = new GarmentShippingCoverLetterModel(1, 1, "", DateTimeOffset.Now, 1, "", "", "", "", "", "", "", DateTimeOffset.Now, 1, "", "", 1, 1, 1, 1, 1, "", "", "", "", "", "", "", "", "", "", DateTimeOffset.Now, "", 1, "");

            var model4 = new GarmentShippingCreditAdviceModel(1, 1, "", DateTimeOffset.Now, 1, 1, "", "", "", true, "", 1, 1, "", DateTimeOffset.Now, DateTimeOffset.Now, "", 1, 1, 1, DateTimeOffset.Now, 1, 1, 1, 1, 1, 1, 1, "", 1, "", "", 1, "", "", 1, 1, 1, DateTimeOffset.Now, "", DateTimeOffset.Now, 1, "", DateTimeOffset.Now, 1, DateTimeOffset.Now, "");

            var repoMock1 = new Mock <IGarmentPackingListRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model
            }.AsQueryable());

            var repoMock2 = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model1
            }.AsQueryable());

            var repoMock3 = new Mock <IGarmentShippingInstructionRepository>();

            repoMock3.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInstructionModel>()
            {
                model2
            }.AsQueryable());

            var repoMock4 = new Mock <IGarmentCoverLetterRepository>();

            repoMock4.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingCoverLetterModel>()
            {
                model3
            }.AsQueryable());

            var repoMock5 = new Mock <IGarmentShippingCreditAdviceRepository>();

            repoMock5.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingCreditAdviceModel>()
            {
                model4
            }.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock1.Object, repoMock2.Object, repoMock3.Object, repoMock4.Object, repoMock5.Object).Object);

            var result = service.GetReportData(model2.BuyerAgentCode, null, DateTime.MinValue, DateTime.MaxValue, 0);

            Assert.NotEmpty(result.ToList());
        }
        public void GenerateExcel_Success()
        {
            var items = new List <GarmentShippingInvoiceItemModel>
            {
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "MS", "TES COMODITY 1", "", "comodesc", "comodesc", "comodesc", 1, "uom1", 1, 1, 1, "", 1, "C10", 1)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "LB", "TES COMODITY 2", "", "", "", "", 2, "Uom2", 1, 1, 1, "", 1, "C10", 1)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "GB", "TES COMODITY 3", "", "", "", "", 2, "Uom2", 1, 1, 1, "", 1, "B10", 1)
                {
                    GarmentShippingInvoiceId = 1
                },
            };
            var invoiceUnitModels = new HashSet <GarmentShippingInvoiceUnitModel> {
                new GarmentShippingInvoiceUnitModel(1, "unitcode", 3, 1)
                {
                    Id = 1
                }
            };
            var model = new GarmentShippingInvoiceModel(1, "", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "", DateTimeOffset.Now,
                                                        "", DateTimeOffset.Now, "", items, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", invoiceUnitModels)
            {
                Id = 1
            };

            var model2 = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "Australia", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, true, true, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", true, true, 1, "", GarmentPackingListStatusEnum.CREATED, "")
            {
                Id = 1
            };

            var repoMock = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model
            }.AsQueryable());

            var repoMock1 = new Mock <IGarmentShippingInvoiceItemRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(items.AsQueryable());

            var repoMock2 = new Mock <IGarmentPackingListRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model2
            }.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock.Object, repoMock1.Object, repoMock2.Object).Object);

            var result = service.GenerateExcel(DateTime.MinValue, DateTime.Now, 7);

            Assert.NotNull(result);
        }
Beispiel #18
0
        public void GenerateExcel_Empty_Success()
        {
            var model1 = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", false, false, 1, "", GarmentPackingListStatusEnum.CREATED, "", false, "")
            {
                Id = 1
            };

            var model2 = new GarmentShippingInvoiceModel(1, "", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "", DateTimeOffset.Now,
                                                         "", DateTimeOffset.Now, "", "", null, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", null)
            {
                Id = 1
            };

            var iteminv = new List <GarmentShippingInvoiceItemModel>
            {
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "", "", "", "", "", "", 1, "", 1, 1, 1, "", 1, "C10", 1, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "", "", "", "", "", "", 1, "", 1, 1, 1, "", 1, "C10", 1, 2)
                {
                    GarmentShippingInvoiceId = 1
                },
            };

            var itemadj = new List <GarmentShippingInvoiceAdjustmentModel>
            {
                new GarmentShippingInvoiceAdjustmentModel(1, "", 100, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceAdjustmentModel(1, "", 25, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
            };

            var model3 = new GarmentShippingCoverLetterModel(1, 1, "", DateTimeOffset.Now, 1, "", "", "", "", "", "", "", DateTimeOffset.Now, 1, "", "", 1, 1, 1, 1, 1, "", "", "", "", "", "", "", "", "", "", DateTimeOffset.Now, "", 1, "");

            var model4 = new GarmentShippingCreditAdviceModel(1, 1, "", DateTimeOffset.Now, 1, 1, "", "", "", true, "", 1, 1, "", DateTimeOffset.Now, DateTimeOffset.Now, "", 1, 1, 1, DateTimeOffset.Now, 1, 1, 1, 1, 1, 1, 1, "", 1, "", "", 1, "", "", 1, 1, 1, DateTimeOffset.Now, "", DateTimeOffset.Now, 1, "", DateTimeOffset.Now, 1, DateTimeOffset.Now, "");

            var repoMock1 = new Mock <IGarmentPackingListRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>().AsQueryable());

            var repoMock2 = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>().AsQueryable());

            var repoMock3 = new Mock <IGarmentShippingInvoiceItemRepository>();

            repoMock3.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceItemModel>().AsQueryable());

            var repoMock4 = new Mock <IGarmentShippingInvoiceAdjustmentRepository>();

            repoMock4.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceAdjustmentModel>().AsQueryable());

            var repoMock5 = new Mock <IGarmentCoverLetterRepository>();

            repoMock5.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingCoverLetterModel>().AsQueryable());

            var repoMock6 = new Mock <IGarmentShippingCreditAdviceRepository>();

            repoMock6.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingCreditAdviceModel>().AsQueryable());

            var service = GetService(GetServiceProvider(repoMock1.Object, repoMock2.Object, repoMock3.Object, repoMock4.Object, repoMock5.Object, repoMock6.Object).Object);

            var result = service.GenerateExcel(null, null, null, null, 7);

            Assert.NotNull(result);
        }
        public void GenerateExcel_Empty_Success()
        {
            var model = new GarmentShippingInvoiceModel(1, "", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "", DateTimeOffset.Now,
                                                        "", DateTimeOffset.Now, "", "", null, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", null)
            {
                Id = 1
            };

            var model1 = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", false, false, 1, "", GarmentPackingListStatusEnum.CREATED, "", false, "")
            {
                Id = 1
            };

            var model2 = new GarmentShippingCreditAdviceModel(1, 1, "", DateTimeOffset.Now, 1, 1, "", "", "", true, "", 1, 1, "", DateTimeOffset.Now, DateTimeOffset.Now, "", 1, 1, 1, DateTimeOffset.Now, 1, 1, 1, 1, 1, 1, 1, "", 1, "", "", 1, "", "", 1, 1, 1, DateTimeOffset.Now, "", DateTimeOffset.Now, 1, "", DateTimeOffset.Now, 1, DateTimeOffset.Now, "");


            var model3 = new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "", "", "", "comodesc", "comodesc", "comodesc", 1, "", 1, 1, 1, "", 1, "C10", 1, 1)
            {
                GarmentShippingInvoiceId = 1
            };


            var repoMock = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model
            }.AsQueryable());

            var repoMock1 = new Mock <IGarmentPackingListRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model1
            }.AsQueryable());

            var repoMock2 = new Mock <IGarmentShippingCreditAdviceRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingCreditAdviceModel>()
            {
                model2
            }.AsQueryable());


            var repoMock3 = new Mock <IGarmentShippingInvoiceItemRepository>();

            repoMock3.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceItemModel>()
            {
                model3
            }.AsQueryable());


            var httpMock = new Mock <IHttpClientService>();

            httpMock.Setup(s => s.SendAsync(HttpMethod.Get, It.IsAny <string>(), It.IsAny <HttpContent>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(new { data = new List <GarmentCurrency> {
                                                                                  new GarmentCurrency()
                                                                                  {
                                                                                      code = "usd"
                                                                                  }
                                                                              } }))
            });

            var spMock = GetServiceProvider(repoMock.Object, repoMock1.Object, repoMock2.Object, repoMock3.Object);

            spMock.Setup(s => s.GetService(typeof(IHttpClientService)))
            .Returns(httpMock.Object);
            var service = GetService(spMock.Object);

            var result = service.GenerateExcel("n", null, null, 0);

            Assert.NotNull(result);
        }
        private GarmentShippingInvoiceViewModel MapToViewModel(GarmentShippingInvoiceModel model)
        {
            var vm = new GarmentShippingInvoiceViewModel()
            {
                Active            = model.Active,
                Id                = model.Id,
                CreatedAgent      = model.CreatedAgent,
                CreatedBy         = model.CreatedBy,
                CreatedUtc        = model.CreatedUtc,
                DeletedAgent      = model.DeletedAgent,
                DeletedBy         = model.DeletedBy,
                DeletedUtc        = model.DeletedUtc,
                IsDeleted         = model.IsDeleted,
                LastModifiedAgent = model.LastModifiedAgent,
                LastModifiedBy    = model.LastModifiedBy,
                LastModifiedUtc   = model.LastModifiedUtc,
                PackingListId     = model.PackingListId,
                InvoiceNo         = model.InvoiceNo,
                InvoiceDate       = model.InvoiceDate,
                From              = model.From,
                To                = model.To,
                BuyerAgent        = new BuyerAgent
                {
                    Id   = model.BuyerAgentId,
                    Code = model.BuyerAgentCode,
                    Name = model.BuyerAgentName
                },
                Consignee = model.Consignee,
                LCNo      = model.LCNo,
                IssuedBy  = model.IssuedBy,
                Section   = new Section
                {
                    Id   = model.SectionId,
                    Code = model.SectionCode
                },
                ShippingPer           = model.ShippingPer,
                SailingDate           = model.SailingDate,
                ConfirmationOfOrderNo = model.ConfirmationOfOrderNo,
                ShippingStaffId       = model.ShippingStaffId,
                ShippingStaff         = model.ShippingStaff,
                FabricTypeId          = model.FabricTypeId,
                FabricType            = model.FabricType,
                BankAccountId         = model.BankAccountId,
                BankAccount           = model.BankAccount,
                PaymentDue            = model.PaymentDue,
                PEBNo            = model.PEBNo,
                PEBDate          = model.PEBDate,
                NPENo            = model.NPENo,
                NPEDate          = model.NPEDate,
                BL               = model.BL,
                BLDate           = model.BLDate,
                CO               = model.CO,
                CODate           = model.CODate,
                COTP             = model.COTP,
                COTPDate         = model.COTPDate,
                Description      = model.Description,
                Remark           = model.Remark,
                AmountToBePaid   = model.AmountToBePaid,
                AmountCA         = model.AmountCA,
                CPrice           = model.CPrice,
                Memo             = model.Memo,
                TotalAmount      = model.TotalAmount,
                IsUsed           = model.IsUsed,
                ConsigneeAddress = model.ConsigneeAddress,
                DeliverTo        = model.DeliverTo,
                GarmentShippingInvoiceAdjustments = model.GarmentShippingInvoiceAdjustment.Select(i => new GarmentShippingInvoiceAdjustmentViewModel
                {
                    AdjustmentDescription = i.AdjustmentDescription,
                    AdjustmentValue       = i.AdjustmentValue,
                    Id = i.Id,
                    GarmentShippingInvoiceId = i.GarmentShippingInvoiceId,
                    AdditionalChargesId      = i.AdditionalChargesId
                }).ToList(),
                Items = model.Items.Select(i => new GarmentShippingInvoiceItemViewModel
                {
                    Active            = i.Active,
                    Id                = i.Id,
                    CreatedAgent      = i.CreatedAgent,
                    CreatedBy         = i.CreatedBy,
                    CreatedUtc        = i.CreatedUtc,
                    DeletedAgent      = i.DeletedAgent,
                    DeletedBy         = i.DeletedBy,
                    DeletedUtc        = i.DeletedUtc,
                    IsDeleted         = i.IsDeleted,
                    LastModifiedAgent = i.LastModifiedAgent,
                    LastModifiedBy    = i.LastModifiedBy,
                    LastModifiedUtc   = i.LastModifiedUtc,
                    RONo              = i.RONo,
                    SCNo              = i.SCNo,
                    BuyerBrand        = new BuyerBrand
                    {
                        Id   = i.BuyerBrandId,
                        Name = i.BuyerBrandName
                    },
                    Quantity = i.Quantity,
                    Comodity = new Comodity
                    {
                        Id   = i.ComodityId,
                        Code = i.ComodityCode,
                        Name = i.ComodityName
                    },
                    ComodityDesc = i.ComodityDesc,
                    Desc2        = i.Desc2,
                    Desc3        = i.Desc3,
                    Desc4        = i.Desc4,
                    Uom          = new UnitOfMeasurement
                    {
                        Id   = i.UomId,
                        Unit = i.UomUnit
                    },
                    Price   = i.Price,
                    PriceRO = i.PriceRO,
                    Amount  = i.Amount,

                    CurrencyCode = i.CurrencyCode,
                    CMTPrice     = i.CMTPrice,
                    Unit         = new Unit
                    {
                        Id   = i.UnitId,
                        Code = i.UnitCode
                    },
                    PackingListItemId = i.PackingListItemId
                }).ToList(),
                GarmentShippingInvoiceUnits = model.GarmentShippingInvoiceUnit.Select(i => new GarmentShippingInvoiceUnitViewModel
                {
                    Unit = new Unit
                    {
                        Id   = i.UnitId,
                        Code = i.UnitCode
                    },
                    Id = i.Id,
                    GarmentShippingInvoiceId = i.GarmentShippingInvoiceId,
                    AmountPercentage         = i.AmountPercentage,
                    QuantityPercentage       = i.QuantityPercentage
                }).ToList(),
            };

            return(vm);
        }
        public async Task <int> Update(int id, GarmentShippingInvoiceViewModel viewModel)
        {
            GarmentShippingInvoiceModel garmentPackingListModel = MapToModel(viewModel);

            return(await _repository.UpdateAsync(id, garmentPackingListModel));
        }
        public void GenerateExcel_Success()
        {
            var items = new List <GarmentShippingInvoiceItemModel>
            {
                new GarmentShippingInvoiceItemModel("", "", 1, "BRAND 1", 1, 1, "", "", "", "", "", "", 1, "uom1", 1, 1, 1, "", 1, "unitcode", 1, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 1, "BRAND 1", 1, 1, "", "", "", "", "", "", 2, "Uom2", 1, 1, 1, "", 1, "unitcode", 1, 2)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 1, "BRAND 1", 1, 1, "", "", "", "", "", "", 2, "Uom2", 1, 1, 1, "", 1, "unitcode", 1, 2)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 2, "BRAND 2", 1, 1, "", "", "", "", "", "", 1, "Uom1", 1, 1, 1, "", 1, "unitcode", 1, 3)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 2, "BRAND 2", 1, 1, "", "", "", "", "", "", 1, "Uom1", 1, 1, 1, "", 1, "unitcode", 1, 3)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 2, "BRAND 2", 1, 1, "", "", "", "", "", "", 2, "Uom2", 1, 1, 1, "", 1, "unitcode", 1, 3)
                {
                    GarmentShippingInvoiceId = 1
                },
            };
            var invoiceUnitModels = new HashSet <GarmentShippingInvoiceUnitModel> {
                new GarmentShippingInvoiceUnitModel(1, "unitcode", 3, 1)
                {
                    Id = 1
                }
            };
            var model = new GarmentShippingInvoiceModel(1, "DL/219998", DateTimeOffset.Now, "", "", 1, "B10", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "", DateTimeOffset.Now,
                                                        "", DateTimeOffset.Now, "", "", items, 1, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", invoiceUnitModels)
            {
                Id = 1
            };

            var model2 = new GarmentPackingListModel("", "DL/219998", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "B10", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, true, true, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", true, true, 1, "", GarmentPackingListStatusEnum.CREATED, "", false, "", false, false, false, "")
            {
                Id = 1
            };

            var repoMock = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model
            }.AsQueryable());

            var repoMock1 = new Mock <IGarmentShippingInvoiceItemRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(items.AsQueryable());

            var repoMock2 = new Mock <IGarmentPackingListRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model2
            }.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock.Object, repoMock1.Object, repoMock2.Object).Object);

            var result = service.GenerateExcel(items.FirstOrDefault().BuyerBrandName, DateTime.MinValue, DateTime.Now, 7);

            Assert.NotNull(result);
        }
        public Task <int> UpdateAsync(int id, GarmentShippingInvoiceModel model)
        {
            var modelToUpdate = _garmentshippingInvoiceDbSet
                                .Include(i => i.Items)
                                .Include(i => i.GarmentShippingInvoiceUnit)
                                .Include(i => i.GarmentShippingInvoiceAdjustment)
                                .FirstOrDefault(s => s.Id == id);

            modelToUpdate.SetFrom(model.From, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetTo(model.To, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetConsignee(model.Consignee, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetShippingPer(model.ShippingPer, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetSailingDate(model.SailingDate, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetConfirmationOfOrderNo(model.ConfirmationOfOrderNo, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetShippingStaffId(model.ShippingStaffId, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetShippingStaff(model.ShippingStaff, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetFabricTypeId(model.FabricTypeId, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetFabricType(model.FabricType, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetBankAccountId(model.BankAccountId, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetBankAccount(model.BankAccount, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetPaymentDue(model.PaymentDue, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetPEBNo(model.PEBNo, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetPEBDate(model.PEBDate, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetNPENo(model.NPENo, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetNPEDate(model.NPEDate, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetBL(model.BL, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetBLDate(model.BLDate, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetCO(model.CO, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetCODate(model.CODate, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetCOTP(model.COTP, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetCOTPDate(model.COTPDate, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetDescription(model.Description, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetCPrice(model.CPrice, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetAmountToBePaid(model.AmountToBePaid, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetMemo(model.Memo, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetTotalAmount(model.TotalAmount, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetConsigneeAddress(model.ConsigneeAddress, _identityProvider.Username, USER_AGENT);


            foreach (var itemToUpdate in modelToUpdate.Items)
            {
                var item = model.Items.FirstOrDefault(i => i.Id == itemToUpdate.Id);
                if (item != null)
                {
                    itemToUpdate.SetQuantity(item.Quantity, _identityProvider.Username, USER_AGENT);
                    itemToUpdate.SetPrice(item.Price, _identityProvider.Username, USER_AGENT);
                    itemToUpdate.SetAmount(item.Amount, _identityProvider.Username, USER_AGENT);
                    itemToUpdate.SetUomUnit(item.UomUnit, _identityProvider.Username, USER_AGENT);
                    itemToUpdate.SetUomId(item.UomId, _identityProvider.Username, USER_AGENT);
                    itemToUpdate.SetCMTPrice(item.CMTPrice, _identityProvider.Username, USER_AGENT);
                    itemToUpdate.SetComodityDesc(item.ComodityDesc, _identityProvider.Username, USER_AGENT);
                    itemToUpdate.SetDesc2(item.Desc2, _identityProvider.Username, USER_AGENT);
                    itemToUpdate.SetDesc3(item.Desc3, _identityProvider.Username, USER_AGENT);
                    itemToUpdate.SetDesc4(item.Desc4, _identityProvider.Username, USER_AGENT);
                }
                else
                {
                    itemToUpdate.FlagForDelete(_identityProvider.Username, USER_AGENT);
                }
            }
            foreach (var items in model.Items.Where(w => w.Id == 0))
            {
                modelToUpdate.Items.Add(items);
            }
            foreach (var adjToUpdate in modelToUpdate.GarmentShippingInvoiceAdjustment)
            {
                var adj = model.GarmentShippingInvoiceAdjustment.FirstOrDefault(i => i.Id == adjToUpdate.Id);
                if (adj != null)
                {
                    adjToUpdate.SetAdjustmentDescription(adj.AdjustmentDescription, _identityProvider.Username, USER_AGENT);
                    adjToUpdate.SetAdjustmentValue(adj.AdjustmentValue, _identityProvider.Username, USER_AGENT);
                    adjToUpdate.SetAdditionalChargesId(adj.AdditionalChargesId, _identityProvider.Username, USER_AGENT);
                }
                else
                {
                    adjToUpdate.FlagForDelete(_identityProvider.Username, USER_AGENT);
                }
            }

            foreach (var unitToUpdate in modelToUpdate.GarmentShippingInvoiceUnit)
            {
                var unit = model.GarmentShippingInvoiceUnit.FirstOrDefault(i => i.Id == unitToUpdate.Id);
                if (unit != null)
                {
                    unitToUpdate.SetAmountPercentage(unit.AmountPercentage, _identityProvider.Username, USER_AGENT);
                    unitToUpdate.SetQuantityPercentage(unit.QuantityPercentage, _identityProvider.Username, USER_AGENT);
                    unitToUpdate.SetUnitCode(unit.UnitCode, _identityProvider.Username, USER_AGENT);
                    unitToUpdate.SetUnitId(unit.UnitId, _identityProvider.Username, USER_AGENT);
                }
                else
                {
                    unitToUpdate.FlagForDelete(_identityProvider.Username, USER_AGENT);
                }
            }

            foreach (var items in model.GarmentShippingInvoiceAdjustment.Where(w => w.Id == 0))
            {
                modelToUpdate.GarmentShippingInvoiceAdjustment.Add(items);
            }

            foreach (var unit in model.GarmentShippingInvoiceUnit.Where(w => w.Id == 0))
            {
                modelToUpdate.GarmentShippingInvoiceUnit.Add(unit);
            }


            return(_dbContext.SaveChangesAsync());
        }
Beispiel #24
0
        public void GetReportData_Success()
        {
            var items = new List <GarmentShippingInvoiceItemModel>
            {
                new GarmentShippingInvoiceItemModel("2120001", "", 1, "", 12, 1, "", "", "", "comodesc", "comodesc", "comodesc", 1, "PCS", 1, 1, 1, "", 1, "C10", 1, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("2130001", "", 1, "", 21, 1, "", "", "", "comodesc", "comodesc", "comodesc", 2, "SETS", 1, 1, 1, "", 1, "C10", 1, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("2140001", "", 1, "", 31, 2, "", "", "", "comodesc", "comodesc", "comodesc", 1, "PCS", 1, 1, 1, "", 1, "C10", 1, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
            };

            var model = new GarmentShippingInvoiceModel(1, "DL/210001", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "", DateTimeOffset.Now,
                                                        "", DateTimeOffset.Now, "", "", items, 1, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", null)
            {
                Id = 1
            };

            var model1 = new GarmentPackingListModel("DL/210001", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", false, false, 1, "", GarmentPackingListStatusEnum.CREATED, "", false, "", false, false, false, "")
            {
                Id = 1
            };


            var repoMock = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model
            }.AsQueryable());

            var repoMock1 = new Mock <IGarmentPackingListRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model1
            }.AsQueryable());

            var repoMock3 = new Mock <IGarmentShippingInvoiceItemRepository>();

            repoMock3.Setup(s => s.ReadAll())
            .Returns(items.AsQueryable());

            var httpMock = new Mock <IHttpClientService>();

            httpMock.Setup(s => s.SendAsync(HttpMethod.Get, It.IsAny <string>(), It.IsAny <HttpContent>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(new { data = new List <GarmentCurrency> {
                                                                                  new GarmentCurrency()
                                                                                  {
                                                                                      code = "usd"
                                                                                  }
                                                                              } }))
            });

            httpMock.Setup(s => s.GetAsync(It.IsAny <string>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(new { data = new List <GarmentExpenditureGood> {
                                                                                  new GarmentExpenditureGood()
                                                                                  {
                                                                                      Id    = "111",
                                                                                      RONo  = "2120001",
                                                                                      Buyer = new Buyer2
                                                                                      {
                                                                                          Code = "Buyer1",
                                                                                          Name = "Buyer Coba 1"
                                                                                      },
                                                                                      Comodity = new GarmentComodity
                                                                                      {
                                                                                          Code = "MS",
                                                                                          Name = "MEN SHIRT"
                                                                                      },
                                                                                      Unit = new UnitDepartment
                                                                                      {
                                                                                          Code = "C1A",
                                                                                          Name = "CENTRAL 1A"
                                                                                      },
                                                                                      Invoice           = "DL/210001",
                                                                                      ExpenditureGoodNo = "EGEC10210001",
                                                                                      Article           = "ART 125214",
                                                                                      TotalQuantity     = 1250,
                                                                                  }
                                                                              } }))
            });

            var spMock = GetServiceProvider(repoMock.Object, repoMock1.Object, repoMock3.Object);

            spMock.Setup(s => s.GetService(typeof(IHttpClientService)))
            .Returns(httpMock.Object);

            var service = GetService(spMock.Object);

            var result = service.GetReportData(null, DateTime.MinValue, DateTime.MaxValue, 0);

            Assert.NotEmpty(result.Data);
        }
Beispiel #25
0
        public async Task ReadById_Success()
        {
            var bills = new HashSet <GarmentShippingPaymentDispositionBillDetailModel> {
                new GarmentShippingPaymentDispositionBillDetailModel("", 1)
                {
                    Id = 1
                }
            };
            var units = new HashSet <GarmentShippingPaymentDispositionUnitChargeModel> {
                new GarmentShippingPaymentDispositionUnitChargeModel(1, "", 1, 1)
                {
                    Id = 1
                }
            };
            var invoices = new HashSet <GarmentShippingPaymentDispositionInvoiceDetailModel> {
                new GarmentShippingPaymentDispositionInvoiceDetailModel("", 1, 1, 1, 1, 1, 1, 1)
                {
                    Id = 1
                }
            };
            var dispoModel = new GarmentShippingPaymentDispositionModel("", "", "", "", "", 1, "", "", "", 1, "", "", 1, "", "", 1, "", "", "", "", "", DateTimeOffset.Now, "", 1, 1, 1, "", 1, 1, 1, DateTimeOffset.Now, "", "", true, "", "", DateTimeOffset.Now, "", "", "", invoices, bills, units)
            {
                Id = 1
            };

            var item = new GarmentShippingPaymentDispositionRecapItemModel(1, 10)
            {
                Id = 1
            };

            item.SetPaymentDisposition(dispoModel);
            var items = new HashSet <GarmentShippingPaymentDispositionRecapItemModel> {
                item
            };
            var model = new GarmentShippingPaymentDispositionRecapModel("", DateTimeOffset.Now, 1, "", "", "", "", items)
            {
                Id = 1
            };

            var repoMock = new Mock <IGarmentShippingPaymentDispositionRecapRepository>();

            repoMock.Setup(s => s.ReadByIdAsync(It.IsAny <int>()))
            .ReturnsAsync(model);

            var dispoRepoMock = new Mock <IGarmentShippingPaymentDispositionRepository>();

            dispoRepoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingPaymentDispositionModel> {
                dispoModel
            }.AsQueryable());

            var itemsInvoice = new HashSet <GarmentShippingInvoiceItemModel> {
                new GarmentShippingInvoiceItemModel("ro", "scno", 1, "buyerbrandname", 1, 1, "comocode", "comoname", "comodesc", "comodesc", "comodesc", "comodesc", 1, "pcs", 10, 10, 100, "usd", 1, "unitcode", 3)
                {
                    Id = 1
                }
            };
            var adjustmentsInvoice = new HashSet <GarmentShippingInvoiceAdjustmentModel> {
                new GarmentShippingInvoiceAdjustmentModel(1, "fee", 100, 1)
                {
                    Id = 1
                }
            };
            var unitsInvoice = new HashSet <GarmentShippingInvoiceUnitModel> {
                new GarmentShippingInvoiceUnitModel(1, "unitcode", 3, 1)
                {
                    Id = 1
                }
            };
            var invoiceModel = new GarmentShippingInvoiceModel(1, "invoiceno", DateTimeOffset.Now, "from", "to", 1, "buyercode", "buyername", "consignee", "lcno", "issuedby", 1, "sectioncode", "shippingper", DateTimeOffset.Now, "confNo", 1, "staff", 1, "cottn", 1, "mandiri", 10, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", itemsInvoice, 1000, "dddd", "dsdsds", "memo", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, adjustmentsInvoice, 100000, "aa", "aa", unitsInvoice)
            {
                Id = 1
            };
            var invoiceRepoMock = new Mock <IGarmentShippingInvoiceRepository>();

            invoiceRepoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel> {
                invoiceModel
            }.AsQueryable());

            var measurements = new HashSet <GarmentPackingListMeasurementModel> {
                new GarmentPackingListMeasurementModel(1, 1, 1, 1)
                {
                    Id = 1
                }
            };
            var packingListModel = new GarmentPackingListModel("", "", "", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", "", "", null, 1, 1, 1, 1, measurements, "", "", "", "", "", "", "", false, false, 1, "", GarmentPackingListStatusEnum.CREATED, "")
            {
                Id = 1
            };
            var packingListRepoMock = new Mock <IGarmentPackingListRepository>();

            packingListRepoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel> {
                packingListModel
            }.AsQueryable());

            var spMock = GetServiceProvider(repoMock.Object);

            spMock.Setup(s => s.GetService(typeof(IGarmentShippingPaymentDispositionRepository)))
            .Returns(dispoRepoMock.Object);
            spMock.Setup(s => s.GetService(typeof(IGarmentShippingInvoiceRepository)))
            .Returns(invoiceRepoMock.Object);
            spMock.Setup(s => s.GetService(typeof(IGarmentPackingListRepository)))
            .Returns(packingListRepoMock.Object);

            var service = GetService(spMock.Object);

            var result = await service.ReadById(1);

            Assert.NotNull(result);
        }
        public async override Task Should_Success_Update()
        {
            string testName  = GetCurrentMethod();
            var    dbContext = DbContext(testName);

            var serviceProvider = GetServiceProviderMock(dbContext).Object;

            GarmentPackingListRepository repoPL = new GarmentPackingListRepository(dbContext, serviceProvider);
            GarmentPackingListDataUtil   utilPL = new GarmentPackingListDataUtil(repoPL);
            GarmentPackingListModel      dataPL = utilPL.GetModel();
            var dataPackingList = await repoPL.InsertAsync(dataPL);

            GarmentShippingInvoiceRepository repo            = new GarmentShippingInvoiceRepository(dbContext, serviceProvider);
            GarmentShippingInvoiceDataUtil   invoiceDataUtil = new GarmentShippingInvoiceDataUtil(repo, utilPL);
            GarmentShippingInvoiceModel      data            = invoiceDataUtil.GetModel();

            data.PackingListId = dataPL.Id;
            var dataInvoice = await repo.InsertAsync(data);

            GarmentShippingInstructionRepository repoInstruction = new GarmentShippingInstructionRepository(dbContext, serviceProvider);

            GarmentShippingInstructionRepository repoInstruction2    = new GarmentShippingInstructionRepository(dbContext, serviceProvider);
            GarmentShippingInstructionDataUtil   InstructionDataUtil = new GarmentShippingInstructionDataUtil(repoInstruction, invoiceDataUtil);
            GarmentShippingInstructionModel      oldModel            = InstructionDataUtil.GetModel();

            oldModel.SetInvoiceId(data.Id, "test", "unitTest");
            await repoInstruction.InsertAsync(oldModel);

            var model         = repoInstruction.ReadAll().FirstOrDefault();
            var modelToUpdate = await repoInstruction.ReadByIdAsync(model.Id);

            modelToUpdate.SetCarrier("model.Carrier", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetCartonNo("model.CartonNo", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetDate(model.Date.AddDays(1), data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetForwarderCode("model.ForwarderCode", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetForwarderId(2, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetForwarderName("model.ForwarderName", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetForwarderAddress("model.ForwarderName", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetForwarderPhone("model.ForwarderName", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetFeederVessel("model.FeederVessel", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetFlight("model.Flight", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetNotify("model.Notify", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetOceanVessel("model.OceanVessel", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetPlaceOfDelivery("model.PlaceOfDelivery", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetPortOfDischarge("model.PortOfDischarge", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetShippedBy("model.ShippedBy", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetSpecialInstruction("model.ins", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetTransit("model.transit", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetATTN("model.attn", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetCC("model.cc", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetFax("model.fax", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetPhone("model.phone", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetLadingBill("model.bill", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetFreight("model.freight", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetMarks("model.marks", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetLadingDate(model.Date.AddDays(1), data.LastModifiedBy, data.LastModifiedAgent);

            var result = await repoInstruction2.UpdateAsync(modelToUpdate.Id, modelToUpdate);

            Assert.NotEqual(0, result);
        }
        public void GetReportData_Success()
        {
            var items = new List <GarmentShippingInvoiceItemModel>
            {
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "", "", "", "", "", "", 1, "uom1", 1, 1, 1, "", 1, "C10", 1, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "", "", "", "", "", "", 2, "Uom2", 1, 1, 1, "", 1, "C10", 1, 2)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "", "", "", "", "", "", 2, "Uom2", 1, 1, 1, "", 1, "B10", 1, 3)
                {
                    GarmentShippingInvoiceId = 1
                },
            };
            var invoiceUnitModels = new HashSet <GarmentShippingInvoiceUnitModel> {
                new GarmentShippingInvoiceUnitModel(1, "unitcode", 3, 1)
                {
                    Id = 1
                }
            };
            var model = new GarmentShippingInvoiceModel(1, "", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "", DateTimeOffset.Now,
                                                        "", DateTimeOffset.Now, "", "", items, 1, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", invoiceUnitModels)
            {
                Id = 1
            };

            var model2 = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "B10", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, true, true, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", true, true, 1, "", GarmentPackingListStatusEnum.CREATED, "", false, "", false, false, false, "")
            {
                Id = 1
            };

            var repoMock = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model
            }.AsQueryable());

            var repoMock1 = new Mock <IGarmentShippingInvoiceItemRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(items.AsQueryable());

            var repoMock2 = new Mock <IGarmentPackingListRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model2
            }.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock.Object, repoMock1.Object, repoMock2.Object).Object);

            var result = service.GetReportData(model2.BuyerAgentCode, DateTime.MinValue, DateTime.Now, 0);

            Assert.NotEmpty(result.ToList());
        }
        public void GetReportData_Success()
        {
            var model1 = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", false, false, 1, "", GarmentPackingListStatusEnum.CREATED, "", false, "")
            {
                Id = 1
            };

            var items = new List <GarmentShippingInvoiceItemModel>
            {
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "", "", "", "", "", "", 1, "", 1, 1, 1, "", 1, "C1A", 1, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "", "", "", "", "", "", 1, "", 1, 1, 1, "", 1, "C2A", 1, 2)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "", "", "", "", "", "", 1, "", 1, 1, 1, "", 1, "C2B", 1, 3)
                {
                    GarmentShippingInvoiceId = 1
                },
            };


            var units = new List <GarmentShippingInvoiceUnitModel>
            {
                new GarmentShippingInvoiceUnitModel(1, "", 1, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
                new GarmentShippingInvoiceUnitModel(2, "", 1, 1)
                {
                    GarmentShippingInvoiceId = 1
                },
            };

            var model2 = new GarmentShippingInvoiceModel(1, "invoiceno", DateTimeOffset.Now, "from", "to", 1, "buyercode", "buyername", "consignee", "lcno", "issuedby", 1, "sectioncode", "shippingper", DateTimeOffset.Now, "confNo", 1, "staff", 1, "cottn", 1, "mandiri", 10, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", "", items, 1000, "23", "dsdsds", "memo", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 100000, "", "", units)
            {
                Id = 1
            };

            var repoMock1 = new Mock <IGarmentPackingListRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model1
            }.AsQueryable());

            var repoMock2 = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model2
            }.AsQueryable());

            var repoMock3 = new Mock <IGarmentShippingInvoiceItemRepository>();

            repoMock3.Setup(s => s.ReadAll())
            .Returns(items.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock1.Object, repoMock2.Object, repoMock3.Object).Object);

            var result = service.GetReportData(DateTime.MinValue, DateTime.MaxValue, 0);

            Assert.NotEmpty(result.ToList());
        }
        public async override Task Should_Success_Update()
        {
            string testName  = GetCurrentMethod();
            var    dbContext = DbContext(testName);

            var serviceProvider = GetServiceProviderMock(dbContext).Object;

            GarmentPackingListRepository repoPL = new GarmentPackingListRepository(dbContext, serviceProvider);
            GarmentPackingListDataUtil   utilPL = new GarmentPackingListDataUtil(repoPL);
            GarmentPackingListModel      dataPL = utilPL.GetModel();
            var dataPackingList = await repoPL.InsertAsync(dataPL);

            GarmentShippingInvoiceRepository repo            = new GarmentShippingInvoiceRepository(dbContext, serviceProvider);
            GarmentShippingInvoiceDataUtil   invoiceDataUtil = new GarmentShippingInvoiceDataUtil(repo, utilPL);
            GarmentShippingInvoiceModel      data            = invoiceDataUtil.GetModel();

            data.PackingListId = dataPL.Id;
            var dataInvoice = await repo.InsertAsync(data);

            GarmentShippingCreditAdviceRepository repoCreditAdvice = new GarmentShippingCreditAdviceRepository(dbContext, serviceProvider);

            GarmentShippingCreditAdviceRepository repoCreditAdvice2    = new GarmentShippingCreditAdviceRepository(dbContext, serviceProvider);
            GarmentCreditAdviceDataUtil           CreditAdviceDataUtil = new GarmentCreditAdviceDataUtil(repoCreditAdvice);
            GarmentShippingCreditAdviceModel      oldModel             = CreditAdviceDataUtil.GetModel();

            oldModel.SetInvoiceId(data.Id, "test", "unitTest");
            await repoCreditAdvice.InsertAsync(oldModel);

            var model         = repoCreditAdvice.ReadAll().FirstOrDefault();
            var modelToUpdate = await repoCreditAdvice.ReadByIdAsync(model.Id);

            modelToUpdate.SetValas(false, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetLCType("model.LCType", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetInkaso(model.Inkaso, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetDisconto(model.Disconto, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetSRNo("model.SRNo", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetNegoDate(model.NegoDate.AddDays(1), data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetPaymentDate(model.PaymentDate.AddDays(1), data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetReceiptNo("model.ReceiptNo", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetCondition("model.Condition", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetBankComission(model.BankComission, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetDiscrepancyFee(model.DiscrepancyFee, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetNettNego(model.NettNego, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetBTBCADate(model.BTBCADate.AddDays(1), data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetBTBAmount(model.BTBAmount, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetBTBRatio(model.BTBRatio, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetBTBRate(model.BTBRate, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetBTBTransfer(model.BTBTransfer, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetBTBMaterial(model.BTBMaterial, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetBillDays(model.BillDays, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetBillAmount(model.BillAmount, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetBillCA("model.BillCA", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetCreditInterest(model.CreditInterest, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetBankCharges(model.BankCharges, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetOtherCharge(model.OtherCharge, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetDocumentPresente(model.DocumentPresente.AddDays(1), data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetCargoPolicyNo("model.CargoPolicyNo", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetCargoPolicyDate(model.CargoPolicyDate.AddDays(1), data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetCargoPolicyValue(model.CargoPolicyValue, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetAccountsReceivablePolicyNo("model.AccountsReceivablePolicyNo", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetAccountsReceivablePolicyDate(model.AccountsReceivablePolicyDate.AddDays(1), data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetAccountsReceivablePolicyValue(model.AccountsReceivablePolicyValue, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetDocumentSendDate(model.DocumentSendDate.AddDays(1), data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetRemark("model.Remark", data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetAmountPaid(model.AmountPaid, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetBalanceAmount(model.BalanceAmount, data.LastModifiedBy, data.LastModifiedAgent);
            modelToUpdate.SetInvoiceId(model.InvoiceId, data.LastModifiedBy, data.LastModifiedAgent);

            var result = await repoCreditAdvice2.UpdateAsync(modelToUpdate.Id, modelToUpdate);

            Assert.NotEqual(0, result);
        }
        public override async Task <int> Update(int id, GarmentPackingListViewModel viewModel)
        {
            viewModel.ShippingMarkImagePath = await UploadImage(viewModel.ShippingMarkImageFile, viewModel.Id, viewModel.ShippingMarkImagePath, viewModel.CreatedUtc);

            viewModel.SideMarkImagePath = await UploadImage(viewModel.SideMarkImageFile, viewModel.Id, viewModel.SideMarkImagePath, viewModel.CreatedUtc);

            viewModel.RemarkImagePath = await UploadImage(viewModel.RemarkImageFile, viewModel.Id, viewModel.RemarkImagePath, viewModel.CreatedUtc);

            GarmentPackingListModel model = MapToModel(viewModel);
            GarmentPackingListModel modelToUpdate;
            var invoice = _invoiceRepository.ReadAll();
            GarmentShippingInvoiceModel shippingInvoice = (from a in invoice
                                                           where a.InvoiceNo == model.InvoiceNo
                                                           select a).FirstOrDefault();

            if (shippingInvoice != null)
            {
                shippingInvoice.ShippingStaffId = model.ShippingStaffId;
                shippingInvoice.ShippingStaff   = model.ShippingStaffName;
                await _invoiceRepository.UpdateAsync(shippingInvoice.Id, shippingInvoice);
            }
            if (model.Status == GarmentPackingListStatusEnum.DRAFT_APPROVED_SHIPPING)
            {
                modelToUpdate = _packingListRepository.Query
                                .Include(i => i.Items)
                                .ThenInclude(i => i.Details)
                                .Include(i => i.Measurements)
                                .FirstOrDefault(s => s.Id == id);

                foreach (var itemToUpdate in modelToUpdate.Items)
                {
                    var item = model.Items.First(i => i.Id == itemToUpdate.Id);
                    foreach (var detailToUpdate in itemToUpdate.Details)
                    {
                        var detail = item.Details.Where(d => d.Id == detailToUpdate.Id).First();
                        detailToUpdate.SetCarton1(detail.Carton1, _identityProvider.Username, UserAgent);
                        detailToUpdate.SetCarton2(detail.Carton2, _identityProvider.Username, UserAgent);
                        detailToUpdate.SetCartonQuantity(detail.CartonQuantity, _identityProvider.Username, UserAgent);
                        detailToUpdate.SetTotalQuantity(detail.TotalQuantity, _identityProvider.Username, UserAgent);
                    }
                }

                foreach (var measurementToUpdate in modelToUpdate.Measurements)
                {
                    var measurement = model.Measurements.First(m => m.Id == measurementToUpdate.Id);
                    measurementToUpdate.SetCartonsQuantity(measurement.CartonsQuantity, _identityProvider.Username, UserAgent);
                }
            }
            else
            {
                modelToUpdate = _packingListRepository.Query.FirstOrDefault(s => s.Id == id);
            }

            modelToUpdate.SetDate(model.Date, _identityProvider.Username, UserAgent);
            modelToUpdate.SetDestination(model.Destination, _identityProvider.Username, UserAgent);

            modelToUpdate.SetGrossWeight(model.GrossWeight, _identityProvider.Username, UserAgent);
            modelToUpdate.SetNettWeight(model.NettWeight, _identityProvider.Username, UserAgent);
            modelToUpdate.SetNetNetWeight(model.NetNetWeight, _identityProvider.Username, UserAgent);
            modelToUpdate.SetTotalCartons(model.TotalCartons, _identityProvider.Username, UserAgent);
            modelToUpdate.SetSayUnit(model.SayUnit, _identityProvider.Username, UserAgent);
            modelToUpdate.SetOtherCommodity(model.OtherCommodity, _identityProvider.Username, UserAgent);

            modelToUpdate.SetShippingMark(model.ShippingMark, _identityProvider.Username, UserAgent);
            modelToUpdate.SetSideMark(model.SideMark, _identityProvider.Username, UserAgent);
            modelToUpdate.SetRemark(model.Remark, _identityProvider.Username, UserAgent);

            modelToUpdate.SetShippingMarkImagePath(model.ShippingMarkImagePath, _identityProvider.Username, UserAgent);
            modelToUpdate.SetSideMarkImagePath(model.SideMarkImagePath, _identityProvider.Username, UserAgent);
            modelToUpdate.SetRemarkImagePath(model.RemarkImagePath, _identityProvider.Username, UserAgent);

            modelToUpdate.SetShippingStaff(model.ShippingStaffId, model.ShippingStaffName, _identityProvider.Username, UserAgent);

            modelToUpdate.SetDescription(model.Description, _identityProvider.Username, UserAgent);

            return(await _packingListRepository.SaveChanges());
        }