Exemplo n.º 1
0
        public async Task Should_Success_Create_Data()
        {
            string testName  = GetCurrentMethod() + "Create";
            var    dbContext = DbContext(testName);

            var serviceProvider = GetServiceProviderMock(dbContext).Object;
            var repo            = new GarmentShippingPaymentDispositionRecapRepository(dbContext, serviceProvider);
            var repoDispo       = new GarmentShippingPaymentDispositionRepository(dbContext, serviceProvider);

            var bills = new HashSet <GarmentShippingPaymentDispositionBillDetailModel> {
                new GarmentShippingPaymentDispositionBillDetailModel("", 1)
            };
            var units = new HashSet <GarmentShippingPaymentDispositionUnitChargeModel> {
                new GarmentShippingPaymentDispositionUnitChargeModel(1, "", 1, 1)
            };
            var invoices = new HashSet <GarmentShippingPaymentDispositionInvoiceDetailModel> {
                new GarmentShippingPaymentDispositionInvoiceDetailModel("", 1, 1, 1, 1, 1, 1, 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, 10, 10, 10, 10)
            {
                Id = 1
            };

            item.SetPaymentDisposition(dispoModel);
            var items = new HashSet <GarmentShippingPaymentDispositionRecapItemModel> {
                item
            };

            var data = new GarmentShippingPaymentDispositionRecapModel("", DateTimeOffset.Now, 1, "", "", "", "", items);

            await repoDispo.InsertAsync(dispoModel);

            foreach (var itemToUpdate in data.Items)
            {
                var paymentDisposition = await repoDispo.ReadByIdAsync(itemToUpdate.PaymentDispositionId);

                if (paymentDisposition != null)
                {
                    paymentDisposition.SetIncomeTaxValue(1 + item.PaymentDisposition.IncomeTaxValue, "", "");;
                    itemToUpdate.SetPaymentDisposition(paymentDisposition);
                }
            }

            var result = await repo.InsertAsync(data);

            Assert.NotEqual(0, result);
        }
        public async Task Create_Success()
        {
            var repoMock = new Mock <IGarmentShippingPaymentDispositionRecapRepository>();

            repoMock.Setup(s => s.InsertAsync(It.IsAny <GarmentShippingPaymentDispositionRecapModel>()))
            .ReturnsAsync(1);
            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingPaymentDispositionRecapModel>().AsQueryable());

            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 dispoRepoMock = new Mock <IGarmentShippingPaymentDispositionRepository>();

            dispoRepoMock.Setup(s => s.ReadByIdAsync(It.IsAny <int>()))
            .ReturnsAsync(dispoModel);

            var spMock = GetServiceProvider(repoMock.Object);

            spMock.Setup(s => s.GetService(typeof(IGarmentShippingPaymentDispositionRepository)))
            .Returns(dispoRepoMock.Object);

            var service = GetService(spMock.Object);

            var result = await service.Create(ViewModel);

            Assert.NotEqual(0, result);
        }
        public void Read_Success()
        {
            var model = new GarmentShippingPaymentDispositionModel("", "", "", "", "", 1, "", "", "", 1, "", "", 1, "", "", 1, "", "", "", "", "", DateTimeOffset.Now, "", 1, 1, 1, "", 1, 1, 1, DateTimeOffset.Now, "", "", true, "", "", DateTimeOffset.Now, "", "", "", new List <GarmentShippingPaymentDispositionInvoiceDetailModel>(), new List <GarmentShippingPaymentDispositionBillDetailModel>(), new List <GarmentShippingPaymentDispositionUnitChargeModel>());

            var repoMock = new Mock <IGarmentShippingPaymentDispositionRepository>();

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

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

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

            Assert.NotEmpty(result.Data);
        }
Exemplo n.º 4
0
        public Task <int> InsertAsync(GarmentShippingPaymentDispositionModel model)
        {
            model.FlagForCreate(_identityProvider.Username, UserAgent);

            foreach (var unitCharge in model.UnitCharges)
            {
                unitCharge.FlagForCreate(_identityProvider.Username, UserAgent);
            }

            foreach (var bill in model.BillDetails)
            {
                bill.FlagForCreate(_identityProvider.Username, UserAgent);
            }

            foreach (var invoice in model.InvoiceDetails)
            {
                invoice.FlagForCreate(_identityProvider.Username, UserAgent);
            }

            _dbSet.Add(model);
            return(_dbContext.SaveChangesAsync());
        }
        public async Task ReadById_Success()
        {
            var bills = new HashSet <GarmentShippingPaymentDispositionBillDetailModel> {
                new GarmentShippingPaymentDispositionBillDetailModel("", 1)
            };
            var units = new HashSet <GarmentShippingPaymentDispositionUnitChargeModel> {
                new GarmentShippingPaymentDispositionUnitChargeModel(1, "", 1, 1)
            };
            var invoices = new HashSet <GarmentShippingPaymentDispositionInvoiceDetailModel> {
                new GarmentShippingPaymentDispositionInvoiceDetailModel("", 1, 1, 1, 1, 1, 1, 1)
            };
            var model = new GarmentShippingPaymentDispositionModel("", "", "", "", "", 1, "", "", "", 1, "", "", 1, "", "", 1, "", "", "", "", "", DateTimeOffset.Now, "", 1, 1, 1, "", 1, 1, 1, DateTimeOffset.Now, "", "", true, "", "", DateTimeOffset.Now, "", "", "", invoices, bills, units);

            var repoMock = new Mock <IGarmentShippingPaymentDispositionRepository>();

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

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

            var result = await service.ReadById(1);

            Assert.NotNull(result);
        }
Exemplo n.º 6
0
 public void SetPaymentDisposition(GarmentShippingPaymentDispositionModel paymentDisposition)
 {
     PaymentDisposition = paymentDisposition;
 }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        public void GetReportData_Success()
        {
            var bills = new List <GarmentShippingPaymentDispositionBillDetailModel>
            {
                new GarmentShippingPaymentDispositionBillDetailModel("", 6000)
                {
                    PaymentDispositionId = 1
                },
                new GarmentShippingPaymentDispositionBillDetailModel("", 4000)
                {
                    PaymentDispositionId = 1
                },
            };

            var invoices = new List <GarmentShippingPaymentDispositionInvoiceDetailModel>
            {
                new GarmentShippingPaymentDispositionInvoiceDetailModel("DL/1", 1, 1, 1, 1, 1, 1, 1)
                {
                    PaymentDispositionId = 1
                },
                new GarmentShippingPaymentDispositionInvoiceDetailModel("DL/2", 2, 1, 1, 1, 1, 1, 1)
                {
                    PaymentDispositionId = 1
                },
            };

            var units = new List <GarmentShippingPaymentDispositionUnitChargeModel>
            {
                new GarmentShippingPaymentDispositionUnitChargeModel(1, "C2A", 15, 1500)
                {
                    PaymentDispositionId = 1
                },
                new GarmentShippingPaymentDispositionUnitChargeModel(2, "C2B", 25, 2500)
                {
                    PaymentDispositionId = 1
                },
                new GarmentShippingPaymentDispositionUnitChargeModel(3, "C2C", 20, 2000)
                {
                    PaymentDispositionId = 1
                },
                new GarmentShippingPaymentDispositionUnitChargeModel(4, "C1A", 10, 1000)
                {
                    PaymentDispositionId = 1
                },
                new GarmentShippingPaymentDispositionUnitChargeModel(5, "C1B", 30, 3000)
                {
                    PaymentDispositionId = 1
                },
            };

            var model = new GarmentShippingPaymentDispositionModel("", "EMKL", "", "", "", 1, "", "", "", 1, "", "", 1, "", "", 1, "", "", "", "", "", DateTimeOffset.Now, "", 1, 1, 1, "", 1, 1, 1, DateTimeOffset.Now, "", "", true, "", "", DateTimeOffset.Now, "", "", "", invoices, bills, units)
            {
                Id = 1
            };

            var items = new List <GarmentShippingPaymentDispositionRecapItemModel>
            {
                new GarmentShippingPaymentDispositionRecapItemModel(1, 6000, 7000, 8000, 9000, 10000)
                {
                    RecapId = 1
                },
                new GarmentShippingPaymentDispositionRecapItemModel(1, 4000, 5000, 6000, 7000, 8000)
                {
                    RecapId = 1
                },
            };

            var model1 = new GarmentShippingPaymentDispositionRecapModel("", DateTimeOffset.Now, 1, "", "", "", "", items)
            {
                Id = 1
            };

            var repoMock = new Mock <IGarmentShippingPaymentDispositionRecapRepository>();

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

            repoMock.Setup(s => s.ReadItemAll())
            .Returns(items.AsQueryable());

            var repoMock1 = new Mock <IGarmentShippingPaymentDispositionRepository>();

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

            repoMock1.Setup(s => s.ReadInvAll())
            .Returns(invoices.AsQueryable());

            repoMock1.Setup(s => s.ReadUnitAll())
            .Returns(units.AsQueryable());

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

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

            Assert.NotEmpty(result.ToList());
        }
        public GarmentShippingPaymentDispositionViewModel MapToViewModel(GarmentShippingPaymentDispositionModel model)
        {
            GarmentShippingPaymentDispositionViewModel viewModel = new GarmentShippingPaymentDispositionViewModel
            {
                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,

                dispositionNo = model.DispositionNo,
                accNo         = model.AccNo,
                address       = model.Address,
                paidAt        = model.PaidAt,
                buyerAgent    = new BuyerAgent
                {
                    Name = model.BuyerAgentName,
                    Id   = model.BuyerAgentId,
                    Code = model.BuyerAgentCode
                },
                bank      = model.Bank,
                billValue = model.BillValue,
                courier   = new Courier
                {
                    Name = model.CourierName,
                    Code = model.CourierCode,
                    Id   = model.CourierId
                },
                emkl = new EMKL
                {
                    Name = model.EMKLName,
                    Code = model.EMKLCode,
                    Id   = model.EMKLId
                },
                forwarder = new Forwarder
                {
                    name = model.ForwarderName,
                    code = model.ForwarderCode,
                    id   = model.ForwarderId
                },
                freightBy   = model.FreightBy,
                freightDate = model.FreightDate,
                freightNo   = model.FreightNo,
                incomeTax   = new IncomeTax
                {
                    id   = model.IncomeTaxId,
                    name = model.IncomeTaxName,
                    rate = (double)model.IncomeTaxRate
                },
                IncomeTaxValue   = model.IncomeTaxValue,
                invoiceDate      = model.InvoiceDate,
                invoiceNumber    = model.InvoiceNumber,
                invoiceTaxNumber = model.InvoiceTaxNumber,
                isFreightCharged = model.IsFreightCharged,
                npwp             = model.NPWP,
                paymentDate      = model.PaymentDate,
                paymentMethod    = model.PaymentMethod,
                paymentTerm      = model.PaymentTerm,
                paymentType      = model.PaymentType,
                remark           = model.Remark,
                sendBy           = model.SendBy,
                totalBill        = model.TotalBill,
                vatValue         = model.VatValue,
                flightVessel     = model.FlightVessel,
                destination      = model.Destination,
                unitCharges      = (model.UnitCharges ?? new List <GarmentShippingPaymentDispositionUnitChargeModel>()).Select(i => new GarmentShippingPaymentDispositionUnitChargeViewModel
                {
                    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,

                    amountPercentage     = i.AmountPercentage,
                    billAmount           = i.BillAmount,
                    paymentDispositionId = i.PaymentDispositionId,
                    unit = new Unit
                    {
                        Id   = i.UnitId,
                        Code = i.UnitCode
                    }
                }).ToList(),
                invoiceDetails = (model.InvoiceDetails ?? new List <GarmentShippingPaymentDispositionInvoiceDetailModel>()).Select(i => new GarmentShippingPaymentDispositionInvoiceDetailViewModel
                {
                    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,

                    amount               = i.Amount,
                    chargeableWeight     = i.ChargeableWeight,
                    grossWeight          = i.GrossWeight,
                    invoiceId            = i.InvoiceId,
                    invoiceNo            = i.InvoiceNo,
                    paymentDispositionId = i.PaymentDispositionId,
                    quantity             = i.Quantity,
                    totalCarton          = i.TotalCarton,
                    volume               = i.Volume
                }).ToList(),
                billDetails = (model.BillDetails ?? new List <GarmentShippingPaymentDispositionBillDetailModel>()).Select(i => new GarmentShippingPaymentDispositionBillDetailViewModel
                {
                    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,

                    amount          = i.Amount,
                    billDescription = i.BillDescription
                }).ToList()
            };

            return(viewModel);
        }
        public void GenerateExcel_Success()
        {
            var bills = new List <GarmentShippingPaymentDispositionBillDetailModel>
            {
                new GarmentShippingPaymentDispositionBillDetailModel("", 6000)
                {
                    PaymentDispositionId = 1
                },
                new GarmentShippingPaymentDispositionBillDetailModel("", 4000)
                {
                    PaymentDispositionId = 1
                },
            };

            var invoices = new List <GarmentShippingPaymentDispositionInvoiceDetailModel>
            {
                new GarmentShippingPaymentDispositionInvoiceDetailModel("DL/1", 1, 1, 1, 1, 1, 1, 1)
                {
                    PaymentDispositionId = 1
                },
                new GarmentShippingPaymentDispositionInvoiceDetailModel("DL/2", 2, 1, 1, 1, 1, 1, 1)
                {
                    PaymentDispositionId = 1
                },
            };

            var units = new List <GarmentShippingPaymentDispositionUnitChargeModel>
            {
                new GarmentShippingPaymentDispositionUnitChargeModel(1, "C2A", 15, 1500)
                {
                    PaymentDispositionId = 1
                },
                new GarmentShippingPaymentDispositionUnitChargeModel(2, "C2B", 25, 2500)
                {
                    PaymentDispositionId = 1
                },
                new GarmentShippingPaymentDispositionUnitChargeModel(3, "C2C", 20, 2000)
                {
                    PaymentDispositionId = 1
                },
                new GarmentShippingPaymentDispositionUnitChargeModel(4, "C1A", 10, 1000)
                {
                    PaymentDispositionId = 1
                },
                new GarmentShippingPaymentDispositionUnitChargeModel(5, "C1B", 30, 3000)
                {
                    PaymentDispositionId = 1
                },
            };

            var model = 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 repoMock = new Mock <IGarmentShippingPaymentDispositionRepository>();

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

            repoMock.Setup(s => s.ReadUnitAll())
            .Returns(units.AsQueryable());

            repoMock.Setup(s => s.ReadInvAll())
            .Returns(invoices.AsQueryable());

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

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

            Assert.NotNull(result);
        }
Exemplo n.º 11
0
        public Task <int> UpdateAsync(int id, GarmentShippingPaymentDispositionModel model)
        {
            var modelToUpdate = _dbSet
                                .Include(i => i.BillDetails)
                                .Include(i => i.InvoiceDetails)
                                .Include(i => i.UnitCharges)
                                .FirstOrDefault(s => s.Id == id);

            modelToUpdate.SetAccNo(model.AccNo, _identityProvider.Username, UserAgent);
            modelToUpdate.SetBank(model.Bank, _identityProvider.Username, UserAgent);
            modelToUpdate.SetBillValue(model.BillValue, _identityProvider.Username, UserAgent);
            modelToUpdate.SetBuyerAgentCode(model.BuyerAgentCode, _identityProvider.Username, UserAgent);
            modelToUpdate.SetBuyerAgentId(model.BuyerAgentId, _identityProvider.Username, UserAgent);
            modelToUpdate.SetBuyerAgentName(model.BuyerAgentName, _identityProvider.Username, UserAgent);
            modelToUpdate.SetAddress(model.Address, _identityProvider.Username, UserAgent);
            modelToUpdate.SetForwarderCode(model.ForwarderCode, _identityProvider.Username, UserAgent);
            modelToUpdate.SetForwarderId(model.ForwarderId, _identityProvider.Username, UserAgent);
            modelToUpdate.SetInvoiceDate(model.InvoiceDate, _identityProvider.Username, UserAgent);
            modelToUpdate.SetInvoiceNumber(model.InvoiceNumber, _identityProvider.Username, UserAgent);
            modelToUpdate.SetInvoiceTaxNumber(model.InvoiceTaxNumber, _identityProvider.Username, UserAgent);
            modelToUpdate.SetForwarderName(model.ForwarderName, _identityProvider.Username, UserAgent);
            modelToUpdate.SetNPWP(model.NPWP, _identityProvider.Username, UserAgent);
            modelToUpdate.SetFreightBy(model.FreightBy, _identityProvider.Username, UserAgent);
            modelToUpdate.SetFreightDate(model.FreightDate, _identityProvider.Username, UserAgent);
            modelToUpdate.SetFreightNo(model.FreightNo, _identityProvider.Username, UserAgent);
            modelToUpdate.SetIncomeIncomeTaxRate(model.IncomeTaxRate, _identityProvider.Username, UserAgent);
            modelToUpdate.SetIncomeTaxId(model.IncomeTaxId, _identityProvider.Username, UserAgent);
            modelToUpdate.SetIncomeTaxName(model.IncomeTaxName, _identityProvider.Username, UserAgent);
            modelToUpdate.SetIncomeTaxValue(model.IncomeTaxValue, _identityProvider.Username, UserAgent);
            modelToUpdate.SetIsFreightCharged(model.IsFreightCharged, _identityProvider.Username, UserAgent);
            modelToUpdate.SetPaymentDate(model.PaymentDate, _identityProvider.Username, UserAgent);
            modelToUpdate.SetPaymentMethod(model.PaymentMethod, _identityProvider.Username, UserAgent);
            modelToUpdate.SetPaymentTerm(model.PaymentTerm, _identityProvider.Username, UserAgent);
            modelToUpdate.SetRemark(model.Remark, _identityProvider.Username, UserAgent);
            modelToUpdate.SetSendBy(model.SendBy, _identityProvider.Username, UserAgent);
            modelToUpdate.SetTotalBill(model.TotalBill, _identityProvider.Username, UserAgent);
            modelToUpdate.SetEMKLCode(model.EMKLCode, _identityProvider.Username, UserAgent);
            modelToUpdate.SetEMKLName(model.EMKLName, _identityProvider.Username, UserAgent);
            modelToUpdate.SetEMKLId(model.EMKLId, _identityProvider.Username, UserAgent);
            modelToUpdate.SetCourierCode(model.CourierCode, _identityProvider.Username, UserAgent);
            modelToUpdate.SetCourierId(model.CourierId, _identityProvider.Username, UserAgent);
            modelToUpdate.SetCourierName(model.CourierName, _identityProvider.Username, UserAgent);
            modelToUpdate.SetDestination(model.Destination, _identityProvider.Username, UserAgent);
            modelToUpdate.SetFlightVessel(model.FlightVessel, _identityProvider.Username, UserAgent);
            modelToUpdate.SetVatValue(model.VatValue, _identityProvider.Username, UserAgent);

            foreach (var billToUpdate in modelToUpdate.BillDetails)
            {
                var bill = model.BillDetails.FirstOrDefault(i => i.Id == billToUpdate.Id);
                if (bill != null)
                {
                    billToUpdate.SetAmount(bill.Amount, _identityProvider.Username, UserAgent);
                    billToUpdate.SetBillDescription(bill.BillDescription, _identityProvider.Username, UserAgent);
                }
                else
                {
                    billToUpdate.FlagForDelete(_identityProvider.Username, UserAgent);
                }
            }

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

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

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

            foreach (var invoiceToUpdate in modelToUpdate.InvoiceDetails)
            {
                var invoice = model.InvoiceDetails.FirstOrDefault(i => i.Id == invoiceToUpdate.Id);
                if (invoice != null)
                {
                    invoiceToUpdate.SetAmount(invoice.Amount, _identityProvider.Username, UserAgent);
                    invoiceToUpdate.SetChargeableWeight(invoice.ChargeableWeight, _identityProvider.Username, UserAgent);
                    invoiceToUpdate.SetGrossWeight(invoice.GrossWeight, _identityProvider.Username, UserAgent);
                    invoiceToUpdate.SetQuantity(invoice.Quantity, _identityProvider.Username, UserAgent);
                    invoiceToUpdate.SetInvoiceId(invoice.InvoiceId, _identityProvider.Username, UserAgent);
                    invoiceToUpdate.SetInvoiceNo(invoice.InvoiceNo, _identityProvider.Username, UserAgent);
                    invoiceToUpdate.SetTotalCarton(invoice.TotalCarton, _identityProvider.Username, UserAgent);
                    invoiceToUpdate.SetVolume(invoice.Volume, _identityProvider.Username, UserAgent);
                }
                else
                {
                    invoiceToUpdate.FlagForDelete(_identityProvider.Username, UserAgent);
                }
            }

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

            return(_dbContext.SaveChangesAsync());
        }