public Task <int> UpdateAsync(int id, GarmentShippingPaymentDispositionRecapModel model)
        {
            var modelToUpdate = _dbSet
                                .Include(i => i.Items)
                                .FirstOrDefault(s => s.Id == id);

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

            foreach (var itemToUpdate in modelToUpdate.Items)
            {
                var item = model.Items.FirstOrDefault(i => i.Id == itemToUpdate.Id);
                if (item == null)
                {
                    itemToUpdate.FlagForDelete(_identityProvider.Username, UserAgent);
                }
                else
                {
                    itemToUpdate.SetService(item.Service, _identityProvider.Username, UserAgent);
                    itemToUpdate.FlagForUpdate(_identityProvider.Username, UserAgent);
                }
            }

            foreach (var item in model.Items.Where(w => w.Id == 0))
            {
                item.FlagForCreate(_identityProvider.Username, UserAgent);

                modelToUpdate.Items.Add(item);
            }

            return(_dbContext.SaveChangesAsync());
        }
Exemplo n.º 2
0
        private PaymentDispositionRecapViewModel MapToViewModel(GarmentShippingPaymentDispositionRecapModel model)
        {
            PaymentDispositionRecapViewModel viewModel = new PaymentDispositionRecapViewModel
            {
                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,

                recapNo = model.RecapNo,
                date    = model.Date,
                emkl    = new EMKL
                {
                    Id      = model.EmklId,
                    Code    = model.EMKLCode,
                    Name    = model.EMKLName,
                    address = model.EMKLAddress,
                    npwp    = model.EMKLNPWP,
                },

                items = (model.Items ?? new List <GarmentShippingPaymentDispositionRecapItemModel>()).Select(i => new PaymentDispositionRecapItemViewModel
                {
                    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,

                    paymentDisposition = new GarmentShippingPaymentDispositionViewModel
                    {
                        Id = i.PaymentDispositionId
                    },
                    service         = i.Service,
                    othersPayment   = i.OthersPayment,
                    truckingPayment = i.TruckingPayment,
                    vatService      = i.VatService,
                    amountService   = i.AmountService
                }).ToList()
            };

            return(viewModel);
        }
        public Task <int> InsertAsync(GarmentShippingPaymentDispositionRecapModel model)
        {
            model.FlagForCreate(_identityProvider.Username, UserAgent);

            foreach (var item in model.Items)
            {
                item.FlagForCreate(_identityProvider.Username, UserAgent);
            }

            _dbSet.Add(model);
            return(_dbContext.SaveChangesAsync());
        }
Exemplo n.º 4
0
        public void Read_Success()
        {
            var model = new GarmentShippingPaymentDispositionRecapModel("", DateTimeOffset.Now, 1, "", "", "", "", new List <GarmentShippingPaymentDispositionRecapItemModel>());

            var repoMock = new Mock <IGarmentShippingPaymentDispositionRecapRepository>();

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

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

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

            Assert.NotEmpty(result.Data);
        }
        public Task <int> InsertAsync(GarmentShippingPaymentDispositionRecapModel model)
        {
            model.FlagForCreate(_identityProvider.Username, UserAgent);

            foreach (var item in model.Items)
            {
                item.FlagForCreate(_identityProvider.Username, UserAgent);

                var paymentDisposition = _garmentShippingPaymentDispositionDbSet.FirstOrDefault(entity => entity.Id == item.PaymentDispositionId);
                if (paymentDisposition != null)
                {
                    paymentDisposition.SetIncomeTaxValue(item.PaymentDisposition.IncomeTaxValue, _identityProvider.Username, UserAgent);
                }
            }

            _dbSet.Add(model);
            return(_dbContext.SaveChangesAsync());
        }
        public Task <int> UpdateAsync(int id, GarmentShippingPaymentDispositionRecapModel model)
        {
            var modelToUpdate = _dbSet
                                .Include(i => i.Items)
                                .FirstOrDefault(s => s.Id == id);

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

            foreach (var itemToUpdate in modelToUpdate.Items)
            {
                var item = model.Items.FirstOrDefault(i => i.Id == itemToUpdate.Id);
                if (item == null)
                {
                    itemToUpdate.FlagForDelete(_identityProvider.Username, UserAgent);
                }
                else
                {
                    itemToUpdate.SetService(item.Service, _identityProvider.Username, UserAgent);
                    itemToUpdate.SetOthersPayment(item.OthersPayment, _identityProvider.Username, UserAgent);
                    itemToUpdate.SetTruckingPayment(item.TruckingPayment, _identityProvider.Username, UserAgent);
                    itemToUpdate.SetVatService(item.VatService, _identityProvider.Username, UserAgent);
                    itemToUpdate.SetAmountService(item.AmountService, _identityProvider.Username, UserAgent);

                    var paymentDisposition = _garmentShippingPaymentDispositionDbSet.FirstOrDefault(entity => entity.Id == itemToUpdate.PaymentDispositionId);
                    if (paymentDisposition != null)
                    {
                        paymentDisposition.SetIncomeTaxValue(item.PaymentDisposition.IncomeTaxValue, _identityProvider.Username, UserAgent);
                    }
                    itemToUpdate.FlagForUpdate(_identityProvider.Username, UserAgent);
                }
            }

            foreach (var item in model.Items.Where(w => w.Id == 0))
            {
                item.FlagForCreate(_identityProvider.Username, UserAgent);

                modelToUpdate.Items.Add(item);
            }

            return(_dbContext.SaveChangesAsync());
        }
Exemplo n.º 7
0
        public async Task <int> Update(int id, PaymentDispositionRecapViewModel viewModel)
        {
            GarmentShippingPaymentDispositionRecapModel model = MapToModel(viewModel);

            foreach (var item in model.Items)
            {
                var vmItem = viewModel.items.FirstOrDefault(i => i.Id == item.Id);
                if (vmItem != null)
                {
                    var paymentDisposition = await _garmentShippingPaymentDispositionRepository.ReadByIdAsync(item.PaymentDispositionId);

                    if (paymentDisposition != null)
                    {
                        paymentDisposition.SetIncomeTaxValue(vmItem.paymentDisposition.incomeTaxValue, "", "");
                        item.SetPaymentDisposition(paymentDisposition);
                    }
                }
            }
            return(await _recapRepository.UpdateAsync(id, model));
        }
Exemplo n.º 8
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.º 9
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());
        }
Exemplo n.º 10
0
        public async Task <int> Update(int id, PaymentDispositionRecapViewModel viewModel)
        {
            GarmentShippingPaymentDispositionRecapModel model = MapToModel(viewModel);

            return(await _recapRepository.UpdateAsync(id, model));
        }
Exemplo n.º 11
0
        public async Task <int> Create(PaymentDispositionRecapViewModel viewModel)
        {
            GarmentShippingPaymentDispositionRecapModel model = MapToModel(viewModel);

            return(await _recapRepository.InsertAsync(model));
        }