Beispiel #1
0
        public void Should_Validator_Success()
        {
            var dataUtil = new MaterialDeliveryNoteViewModel()
            {
                DateSJ = DateTimeOffset.UtcNow.AddHours(-5)
            };
            var validator = new MaterialDeliveryNoteValidator();
            var result    = validator.Validate(dataUtil);

            Assert.NotEqual(0, result.Errors.Count);

            dataUtil.DateSJ = DateTimeOffset.UtcNow.AddDays(1);
            result          = validator.Validate(dataUtil);
            Assert.NotEqual(0, result.Errors.Count);

            dataUtil.DateSJ = DateTimeOffset.UtcNow.AddDays(-1);
            result          = validator.Validate(dataUtil);
            Assert.NotEqual(0, result.Errors.Count);

            dataUtil.Items = new List <ItemsViewModel>()
            {
                new ItemsViewModel()
            };
            result = validator.Validate(dataUtil);
            Assert.NotEqual(0, result.Errors.Count);
        }
Beispiel #2
0
        public void Validate_DefaultValue()
        {
            MaterialDeliveryNoteViewModel viewModel = new MaterialDeliveryNoteViewModel();

            var result = viewModel.Validate(null);

            Assert.True(result.Count() > 0);
        }
        public void Validate_Default()
        {
            MaterialDeliveryNoteViewModel defaultViewModel = new MaterialDeliveryNoteViewModel();

            var defaultValidationResult = defaultViewModel.Validate(null);

            Assert.True(defaultValidationResult.Count() > 0);
        }
        public void Validate_When_DateSJ_Empty()
        {
            MaterialDeliveryNoteViewModel viewModel = new MaterialDeliveryNoteViewModel();

            viewModel.DateSJ = default(DateTimeOffset);


            var defaultValidationResult = viewModel.Validate(null);

            Assert.True(defaultValidationResult.Count() > 0);
        }
Beispiel #5
0
        public void Validate_When_ItemsMaterialDeliveryNoteWeaving_moreThan1()
        {
            MaterialDeliveryNoteViewModel viewModel = new MaterialDeliveryNoteViewModel();

            viewModel.Items = new List <ItemsViewModel>()
            {
                new ItemsViewModel()
            };

            var result = viewModel.Validate(null);

            Assert.True(result.Count() > 0);
        }
Beispiel #6
0
 public MaterialDeliveryNotePdfTemplate(MaterialDeliveryNoteViewModel model, int timeoffset)
 {
     Title = GetTitle();
     //Title_New = Get_Title_New();
     AddressTitle     = GetAddressTitle();
     DocumentTitle    = GetDocumentTitle();
     DocumentISO      = GetISO();
     DocumentInfo     = GetBuyerInfo(model, timeoffset);
     GroupDetailInfo  = GetGroupDetailInfo(model);
     DetailInfo       = GetDetailInfo(model, timeoffset);
     NettoSection     = GetNettoSection();
     SignatureSection = GetSignatureSection(model, timeoffset);
 }
        public void Validate_When_Items_More_Than1()
        {
            MaterialDeliveryNoteViewModel viewModel = new MaterialDeliveryNoteViewModel();

            viewModel.DateTo = default(DateTimeOffset);
            viewModel.Items  = new List <ItemsViewModel>()
            {
                new ItemsViewModel()
                {
                    WeightBruto = 0,
                    WeightBale  = 0,
                    WeightCone  = "",
                    WeightDOS   = ""
                }
            };


            var defaultValidationResult = viewModel.Validate(null);

            Assert.True(defaultValidationResult.Count() > 0);
        }
        public void Validate_When_WeightDosCone_text_failed()
        {
            MaterialDeliveryNoteViewModel viewModel = new MaterialDeliveryNoteViewModel();

            viewModel.DateTo   = DateTimeOffset.Now.AddDays(1);
            viewModel.DateFrom = DateTimeOffset.Now.AddDays(2);
            viewModel.Items    = new List <ItemsViewModel>()
            {
                new ItemsViewModel()
                {
                    WeightBruto = 0,
                    WeightBale  = 0,
                    WeightCone  = "asd",
                    WeightDOS   = "asd"
                }
            };


            var defaultValidationResult = viewModel.Validate(null);

            Assert.True(defaultValidationResult.Count() > 0);
        }
Beispiel #9
0
        public async Task <IActionResult> Post([FromBody] MaterialDeliveryNoteViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                var result = new
                {
                    error = ResultFormatter.FormatErrorMessage(ModelState)
                };
                return(new BadRequestObjectResult(result));
            }
            try
            {
                VerifyUser();
                ValidateService.Validate(viewModel);
                await _service.Create(viewModel);

                return(Created("/", new
                {
                }));
            }
            catch (ServiceValidationException ex)
            {
                var Result = new
                {
                    error      = ResultFormatter.Fail(ex),
                    apiVersion = "1.0.0",
                    statusCode = HttpStatusCode.BadRequest,
                    message    = "Data does not pass validation"
                };

                return(new BadRequestObjectResult(Result));
            }
            catch (Exception ex)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Beispiel #10
0
        private PdfPTable GetSignatureSection(MaterialDeliveryNoteViewModel model, int timeoffset)
        {
            PdfPTable table = new PdfPTable(4)
            {
                WidthPercentage = 100
            };

            float[] widths = new float[] { 1f, 1f, 1f, 1f };
            table.SetWidths(widths);
            PdfPCell cell = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER,
                HorizontalAlignment = Element.ALIGN_CENTER,
                VerticalAlignment   = Element.ALIGN_MIDDLE,
            };

            PdfPCell cellLeft = new PdfPCell()
            {
                HorizontalAlignment = Element.ALIGN_LEFT,
                VerticalAlignment   = Element.ALIGN_MIDDLE,
            };

            PdfPCell cellColspan = new PdfPCell()
            {
                Colspan             = 4,
                Border              = Rectangle.NO_BORDER,
                HorizontalAlignment = Element.ALIGN_LEFT,
                VerticalAlignment   = Element.ALIGN_MIDDLE,
            };

            cellColspan.Phrase = new Phrase("No.FO : " + model.FONumber + "       Ex.Spn : " + model.storage.Name, TEXT_FONT);
            table.AddCell(cellColspan);

            cellColspan.Phrase = new Phrase("No.SC : " + model.salesContract.SalesContractNo, TEXT_FONT);
            table.AddCell(cellColspan);

            //cell.Phrase = new Phrase(" ", TEXT_FONT);
            //table.AddCell(cell);
            //cell.Phrase = new Phrase(" ", TEXT_FONT);
            //table.AddCell(cell);
            //cell.Phrase = new Phrase(" ", TEXT_FONT);
            //table.AddCell(cell);
            //cell.Phrase = new Phrase(" ", TEXT_FONT);
            //table.AddCell(cell);

            //cell.Phrase = new Phrase("Mengetahui", TEXT_FONT);
            //table.AddCell(cell);
            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase($"Sukoharjo, {model.DateSJ.AddHours(timeoffset):dd MMMM yyyy}", TEXT_FONT);
            table.AddCell(cell);

            //cell.Phrase = new Phrase("Kasubsie Gudang Dyeing Printing", TEXT_FONT);
            //table.AddCell(cell);
            cell.Phrase = new Phrase("Audit:", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("Ekspedisi:", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("Kabag:", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("Petugas Gudang:", TEXT_FONT);
            table.AddCell(cell);

            for (var i = 0; i < 11; i++)
            {
                cell.Phrase = new Phrase("", TEXT_FONT);
                table.AddCell(cell);
                cell.Phrase = new Phrase("", TEXT_FONT);
                table.AddCell(cell);
                cell.Phrase = new Phrase("", TEXT_FONT);
                table.AddCell(cell);
                cell.Phrase = new Phrase("", TEXT_FONT);
                table.AddCell(cell);
            }

            cell.Phrase = new Phrase("(                        )", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("(                        )", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("(                        )", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase($"({model.CreatedBy})", TEXT_FONT);
            table.AddCell(cell);



            return(table);
        }
Beispiel #11
0
        private PdfPTable GetDetailInfo(MaterialDeliveryNoteViewModel model, int timeoffset)
        {
            PdfPTable container = new PdfPTable(1)
            {
                WidthPercentage = 100
            };

            float[] containerWidths = new float[] { 1f };
            container.SetWidths(containerWidths);

            PdfPCell cellContainer = new PdfPCell()
            {
                //Border = Rectangle.NO_BORDER
            };

            PdfPTable table = new PdfPTable(bodyTableColumns.Count)
            {
                WidthPercentage = 100
            };

            float[] widths = new float[] { 0.5f, 3.5f, 1f, 1f };
            table.SetWidths(widths);
            PdfPCell cellHeader = new PdfPCell()
            {
                HorizontalAlignment = Element.ALIGN_CENTER,
                VerticalAlignment   = Element.ALIGN_MIDDLE,
            };

            PdfPCell cellRight = new PdfPCell()
            {
                HorizontalAlignment = Element.ALIGN_RIGHT,
                VerticalAlignment   = Element.ALIGN_MIDDLE,
            };

            PdfPCell cellLeft = new PdfPCell()
            {
                HorizontalAlignment = Element.ALIGN_LEFT,
                VerticalAlignment   = Element.ALIGN_MIDDLE,
            };

            foreach (var column in bodyTableColumns)
            {
                cellHeader.Phrase = new Phrase(column, TEXT_FONT_BOLD);
                table.AddCell(cellHeader);
            }

            double balTotal = 0;
            //decimal pieceTotal = 0;
            //decimal meterTotal = 0;
            double kgTotal = 0;
            int    index   = 1;

            foreach (var detail in model.Items)
            {
                cellHeader.Phrase = new Phrase(index++.ToString(), TEXT_FONT);
                table.AddCell(cellHeader);

                cellLeft.Phrase = new Phrase(detail.MaterialName, TEXT_FONT);
                table.AddCell(cellLeft);

                cellRight.Phrase = new Phrase(detail.WeightBale?.ToString("N2", CultureInfo.InvariantCulture), TEXT_FONT);
                table.AddCell(cellRight);
                balTotal += detail.WeightBale.GetValueOrDefault();

                cellRight.Phrase = new Phrase(detail.GetTotal?.ToString("N2", CultureInfo.InvariantCulture), TEXT_FONT);
                table.AddCell(cellRight);
                kgTotal += detail.GetTotal.GetValueOrDefault();
            }

            for (int i = 1; i <= 3; i++)
            {
                cellRight.Phrase = new Phrase(" ", TEXT_FONT);
                table.AddCell(cellRight);

                cellRight.Phrase = new Phrase(" ", TEXT_FONT);
                table.AddCell(cellRight);

                cellRight.Phrase = new Phrase(" ", TEXT_FONT);
                table.AddCell(cellRight);

                cellRight.Phrase = new Phrase(" ", TEXT_FONT);
                table.AddCell(cellRight);
            }

            foreach (var detail in model.Items)
            {
                cellRight.Phrase = new Phrase(" ", TEXT_FONT);
                table.AddCell(cellRight);

                cellLeft.Phrase = new Phrase("LOT." + detail.InputLot + " BRUTO = " + detail.WeightBruto + " KG", TEXT_FONT);
                table.AddCell(cellLeft);

                cellRight.Phrase = new Phrase(" ", TEXT_FONT);
                table.AddCell(cellRight);

                cellRight.Phrase = new Phrase(" ", TEXT_FONT);
                table.AddCell(cellRight);



                cellRight.Phrase = new Phrase(" ", TEXT_FONT);
                table.AddCell(cellRight);

                var dos  = detail.WeightDOS.Split(",");
                var cone = detail.WeightCone.Split(",");

                cellLeft.Phrase = new Phrase(dos[0] + "DOS@" + cone[0] + "CONE+" + dos[1] + "DOS@" + cone[1] + "CONE", TEXT_FONT);
                table.AddCell(cellLeft);

                cellRight.Phrase = new Phrase(" ", TEXT_FONT);
                table.AddCell(cellRight);

                cellRight.Phrase = new Phrase(" ", TEXT_FONT);
                table.AddCell(cellRight);


                cellRight.Phrase = new Phrase(" ", TEXT_FONT);
                table.AddCell(cellRight);

                cellLeft.Phrase = new Phrase($"PROD`{model.DateFrom.AddHours(timeoffset):dd}-{model.DateTo.AddHours(timeoffset):dd} {model.DateFrom.AddHours(timeoffset):y}", TEXT_FONT);
                table.AddCell(cellLeft);

                cellRight.Phrase = new Phrase(" ", TEXT_FONT);
                table.AddCell(cellRight);

                cellRight.Phrase = new Phrase(" ", TEXT_FONT);
                table.AddCell(cellRight);
            }

            //PdfPCell cellColspan = new PdfPCell()
            //{
            //    Colspan = 5,
            //    HorizontalAlignment = Element.ALIGN_CENTER,
            //    VerticalAlignment = Element.ALIGN_MIDDLE,
            //};

            //cellColspan.Phrase = new Phrase("Total", TEXT_FONT);
            //table.AddCell(cellColspan);

            cellRight.Phrase = new Phrase(" ", TEXT_FONT);
            table.AddCell(cellRight);

            cellRight.Phrase = new Phrase(" ", TEXT_FONT);
            table.AddCell(cellRight);

            cellRight.Phrase = new Phrase(balTotal == 0 ? "" : balTotal.ToString("N2", CultureInfo.InvariantCulture), TEXT_FONT);
            table.AddCell(cellRight);

            cellRight.Phrase = new Phrase(kgTotal == 0 ? "" : kgTotal.ToString("N2", CultureInfo.InvariantCulture), TEXT_FONT);
            table.AddCell(cellRight);

            container.AddCell(table);

            //cellContainer.Phrase = new Phrase("", TEXT_FONT);
            //container.AddCell(cellContainer);
            //cellContainer.Phrase = new Phrase("", TEXT_FONT);
            //container.AddCell(cellContainer);
            //cellContainer.Phrase = new Phrase("", TEXT_FONT);
            //container.AddCell(cellContainer);
            //cellContainer.Phrase = new Phrase("", TEXT_FONT);
            //container.AddCell(cellContainer);

            return(container);
        }
Beispiel #12
0
        private PdfPTable GetGroupDetailInfo(MaterialDeliveryNoteViewModel model)
        {
            PdfPTable container = new PdfPTable(2)
            {
                WidthPercentage = 100
            };

            float[] widths = new float[] { 1f, 1f };
            container.SetWidths(widths);

            PdfPCell cellContainer = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };

            PdfPTable table = new PdfPTable(3)
            {
                WidthPercentage = 100,
            };

            float[] tableWidths = new float[] { 1f, 5f, 2f };
            table.SetWidths(tableWidths);

            PdfPCell cellHeader = new PdfPCell()
            {
                HorizontalAlignment = Element.ALIGN_CENTER,
                VerticalAlignment   = Element.ALIGN_MIDDLE,
            };

            PdfPCell cellRight = new PdfPCell()
            {
                HorizontalAlignment = Element.ALIGN_RIGHT,
                VerticalAlignment   = Element.ALIGN_MIDDLE,
            };


            foreach (var column in groupTableColumns)
            {
                cellHeader.Phrase = new Phrase(column, TEXT_FONT_BOLD);
                table.AddCell(cellHeader);
            }

            cellHeader.Phrase = new Phrase("Total", TEXT_FONT);
            table.AddCell(cellHeader);

            cellHeader.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cellHeader);

            container.AddCell(table);

            cellContainer.Phrase = new Phrase("", TEXT_FONT);
            container.AddCell(cellContainer);

            cellContainer.Phrase = new Phrase("", TEXT_FONT);
            container.AddCell(cellContainer);

            cellContainer.Phrase = new Phrase("", TEXT_FONT);
            container.AddCell(cellContainer);

            cellContainer.Phrase = new Phrase("", TEXT_FONT);
            container.AddCell(cellContainer);

            cellContainer.Phrase = new Phrase("", TEXT_FONT);
            container.AddCell(cellContainer);

            cellContainer.Phrase = new Phrase("", TEXT_FONT);
            container.AddCell(cellContainer);

            cellContainer.Phrase = new Phrase("", TEXT_FONT);
            container.AddCell(cellContainer);

            return(container);
        }
Beispiel #13
0
        private PdfPTable GetBuyerInfo(MaterialDeliveryNoteViewModel model, int timeoffset)
        {
            PdfPTable table = new PdfPTable(3)
            {
                WidthPercentage = 100
            };

            float[] widths = new float[] { 1f, 1f, 1f };
            table.SetWidths(widths);
            PdfPCell cell = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER,
                HorizontalAlignment = Element.ALIGN_LEFT,
                VerticalAlignment   = Element.ALIGN_MIDDLE,
                PaddingBottom       = 2f
            };


            cell.Phrase = new Phrase($"Kepada Yth : {model.buyer.Name}", TEXT_FONT);
            table.AddCell(cell);

            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);

            cell.Phrase = new Phrase($"No. : {model.Code}", TEXT_FONT_BOLD);
            table.AddCell(cell);
            //cell.Phrase = new Phrase($"NO. : {model.BonNo}", TEXT_FONT);
            //table.AddCell(cell);

            //string buyerName = model.ShippingProductionOrders.FirstOrDefault()?.Buyer;
            //cell.Phrase = new Phrase($"U/ dikirim kepada: {buyerName}", TEXT_FONT);
            //table.AddCell(cell);

            //cell.Phrase = new Phrase("", TEXT_FONT);
            //table.AddCell(cell);

            //cell.Phrase = new Phrase($"Sesuai DO. NO. : {model.DeliveryOrder.No}", TEXT_FONT);
            //table.AddCell(cell);

            cell.Phrase = new Phrase($"U/dikirim Kpd : {model.unit.Name}", TEXT_FONT);
            table.AddCell(cell);

            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);

            //cell.Phrase = new Phrase($"Tanggal : { model.Date.AddHours(timeoffset).ToString("dd MMMM yyyy")}", TEXT_FONT);
            cell.Phrase = new Phrase($"Sesuai DO No. : {model.DONumber.DOSalesNo}", TEXT_FONT_BOLD);
            table.AddCell(cell);

            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);

            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);

            //cell.Phrase = new Phrase($"Jumlah Baris : { model.ShippingProductionOrders.Count }", TEXT_FONT);
            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);

            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);
            cell.Phrase = new Phrase("", TEXT_FONT);
            table.AddCell(cell);

            return(table);
        }