public async Task <IActionResult> Edit(int id, GoodsReceivedNote goodsReceivedNote)
        {
            if (id != goodsReceivedNote.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    goodsReceivedNote.UpdateAt = DateTime.Now;
                    _context.Update(goodsReceivedNote);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GoodsReceivedNoteExists(goodsReceivedNote.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            var supplier = _context.Suppliers.Select(i => i.Name).ToList();

            ViewData["IdSupplier"] = new SelectList(_context.Suppliers, "Id", "Name", supplier);
            return(View(goodsReceivedNote));
        }
        public IHttpActionResult PostGoodsReceivedNote(GoodsReceivedNote goodsReceivedNote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.GoodsReceivedNotes.Add(goodsReceivedNote);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (GoodsReceivedNoteExists(goodsReceivedNote.RecNoteID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = goodsReceivedNote.RecNoteID }, goodsReceivedNote));
        }
        public async Task <HttpResult <bool> > AddGoodsReceivedNote(GoodsReceivedNote note, CancellationToken token = default(CancellationToken))
        {
            var result = new HttpResult <bool>();

            var model = new WebApiServer.Controllers.Note.ViewModel.AddGoodsReceivedNote
            {
                DocumentId = note.DocumentId,
                InvoiceId  = note.InvoiceId,
                IssueDate  = note.IssueDate,
                NoteEntry  = note
                             .NoteEntry
                             .Select(ne => new WebApiServer.Controllers.Note.ViewModel.NoteEntry
                {
                    Location = new Common.DTO.Location
                    {
                        Id   = ne.Location.Id,
                        Name = ne.Location.Name
                    },
                    Name = ne.Name
                })
                             .ToList(),
                ReceiveDate = note.ReceiveDate
            };

            await _unitOfWork.AddGoodsReceivedNote(model);

            return(result);
        }
        public IHttpActionResult PutGoodsReceivedNote(string id, GoodsReceivedNote goodsReceivedNote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != goodsReceivedNote.RecNoteID)
            {
                return(BadRequest());
            }

            db.Entry(goodsReceivedNote).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GoodsReceivedNoteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #5
0
        public IActionResult Update([FromBody] CrudViewModel <GoodsReceivedNote> payload)
        {
            GoodsReceivedNote goodsReceivedNote = payload.value;

            _context.GoodsReceivedNote.Update(goodsReceivedNote);
            _context.SaveChanges();
            return(Ok(goodsReceivedNote));
        }
Beispiel #6
0
        public IActionResult Insert([FromBody] CrudViewModel <GoodsReceivedNote> payload)
        {
            GoodsReceivedNote goodsReceivedNote = payload.value;

            goodsReceivedNote.GoodsReceivedNoteName = _numberSequence.GetNumberSequence("GRN");
            _context.GoodsReceivedNote.Add(goodsReceivedNote);
            _context.SaveChanges();
            return(Ok(goodsReceivedNote));
        }
Beispiel #7
0
        public IActionResult Remove([FromBody] CrudViewModel <GoodsReceivedNote> payload)
        {
            GoodsReceivedNote goodsReceivedNote = _context.GoodsReceivedNote
                                                  .Where(x => x.GoodsReceivedNoteId == (int)payload.key)
                                                  .FirstOrDefault();

            _context.GoodsReceivedNote.Remove(goodsReceivedNote);
            _context.SaveChanges();
            return(Ok(goodsReceivedNote));
        }
        public IActionResult Insert([FromBody] CrudViewModel <GoodsReceivedNote> payload)
        {
            GoodsReceivedNote value = payload.value;

            value.GoodsReceivedNoteName = _numberSequence.GetNumberSequence("GRN");
            var result = _functionalService.Insert <GoodsReceivedNote>(value);

            value = (GoodsReceivedNote)result.Data;
            return(Ok(value));
        }
Beispiel #9
0
 public bool SaveGRN(GoodsReceivedNote GRNEntity)
 {
     using (var dbContext = new SCMSEntities())
     {
         using (TransactionScope scope = new TransactionScope())
         {
             try
             {
                 dbContext.GoodsReceivedNotes.Add(GRNEntity);
                 foreach (POItemsView item in GRNEntity.POItemz)
                 {
                     var newEntity = new GoodsReceivedNoteItem()
                     {
                         Id = Guid.NewGuid(),
                         GoodsReceivedNoteId = GRNEntity.Id,
                         PurchaseOrderItemId = item.POItemId,
                         QuantityDelivered   = item.QtyDelivered,
                         QuantityDamaged     = item.QtyDamaged,
                         Comments            = item.comments,
                         IsInventory         = item.IsInventory
                     };
                     dbContext.GoodsReceivedNoteItems.Add(newEntity);
                 }
                 if ((dbContext.SaveChanges() > 0))
                 {
                     scope.Complete();
                     SessionData.CurrentSession.GoodsReceivedNoteList     = null;
                     SessionData.CurrentSession.GoodsReceivedNoteItemList = null;
                     SessionData.CurrentSession.PurchaseOrderList         = null;
                     SessionData.CurrentSession.ProcurementPlanList       = null;
                     return(true);
                 }
                 else
                 {
                     scope.Dispose(); return(false);
                 }
             }
             //catch (DbEntityValidationException e)
             //{
             //    foreach (var eve in e.EntityValidationErrors)
             //    {
             //        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
             //            eve.Entry.Entity.GetType().Name, eve.Entry.State);
             //        foreach (var ve in eve.ValidationErrors)
             //        {
             //            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
             //                ve.PropertyName, ve.ErrorMessage);
             //        }
             //    }
             //    throw;
             //}
             catch (Exception ex) { scope.Dispose(); throw ex; }
         }
     }
 }
        public async Task <GoodsReceivedNote> AddGoodsReceivedNoteAsync(GoodsReceivedNote goodsReceivedNote)
        {
            _context.Create(goodsReceivedNote);
            await _context.CommitAsync();

            return(await _context.GoodsReceivedNotes
                   .Include(p => p.PaymentType)
                   .Include(p => p.PurchaseOrder)
                   .Include(p => p.ReceivedUser)
                   .FirstAsync(e => e.Id == goodsReceivedNote.Id));
        }
        public IHttpActionResult GetGoodsReceivedNote(string id)
        {
            GoodsReceivedNote goodsReceivedNote = db.GoodsReceivedNotes.Find(id);

            if (goodsReceivedNote == null)
            {
                return(NotFound());
            }

            return(Ok(goodsReceivedNote));
        }
Beispiel #12
0
 public void UpdateGRN(GoodsReceivedNote grn)
 {
     using (var context = new SCMSEntities())
     {
         var existing = context.GoodsReceivedNotes.FirstOrDefault(p => p.Id == grn.Id);
         context.Entry(existing).CurrentValues.SetValues(grn);
         context.SaveChanges();
         SessionData.CurrentSession.PurchaseOrderList         = null;
         SessionData.CurrentSession.GoodsReceivedNoteList     = null;
         SessionData.CurrentSession.GoodsReceivedNoteItemList = null;
     }
 }
Beispiel #13
0
 public bool IsGRNVerified(GoodsReceivedNote GRNentity)
 {
     using (var context = new SCMSEntities())
     {
         using (TransactionScope scope = new TransactionScope())
         {
             foreach (GoodsReceivedNoteItem item in GRNentity.ItemColl)
             {
                 GoodsReceivedNoteItem grit = context.GoodsReceivedNoteItems.FirstOrDefault(p => p.Id == item.Id);
                 if (context.Inventories.Count(p => p.ItemId == grit.PurchaseOrderItem.Item.Id && p.WareHouseId == grit.GoodsReceivedNote.WareHouseId) > 0)
                 {
                     if (grit.PurchaseOrderItem.Item.ItemCategory.CategoryCode == "C")
                     {
                         Model.Inventory invt = context.Inventories.FirstOrDefault(p => p.ItemId == grit.PurchaseOrderItem.Item.Id && p.WareHouseId == grit.GoodsReceivedNote.WareHouseId);
                         invt.Quantity += (long)item.QuantityDelivered;
                         ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(invt, System.Data.EntityState.Modified);
                     }
                 }
                 else
                 {
                     long qty = 0;
                     if (grit.PurchaseOrderItem.Item.ItemCategory.CategoryCode == "C")
                     {
                         qty = (long)item.QuantityDelivered;
                     }
                     Model.Inventory newinvetoryEntity =
                         new Model.Inventory()
                     {
                         Id = Guid.NewGuid(), ItemId = grit.PurchaseOrderItem.Item.Id, Quantity = qty, CountryProgrammeId = GRNentity.CountryProgrammeId, WareHouseId = (Guid)grit.GoodsReceivedNote.WareHouseId
                     };
                     context.Inventories.Add(newinvetoryEntity);
                 }
                 Model.GoodsReceivedNoteItem grnitm = context.GoodsReceivedNoteItems.FirstOrDefault(p => p.Id == item.Id);
                 grnitm.QuantityDamaged = item.QuantityDamaged; grnitm.QuantityDelivered = item.QuantityDelivered;
                 ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(grnitm, System.Data.EntityState.Modified);
                 context.SaveChanges();
             }
             Model.GoodsReceivedNote grn = context.GoodsReceivedNotes.FirstOrDefault(p => p.Id == GRNentity.Id);
             grn.Verified            = true;
             grn.ApprovedOn          = DateTime.Now;
             grn.ReceptionApprovedBy = GRNentity.ReceptionApprovedBy;
             ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(grn, System.Data.EntityState.Modified);
             if (context.SaveChanges() > 0)
             {
                 scope.Complete(); return(true);
             }
             else
             {
                 scope.Dispose(); return(false);
             }
         }
     }
 }
        private void PopulateModel(GoodsReceivedNote model, IDictionary values)
        {
            string GOODS_RECEIVED_NOTE_ID = nameof(GoodsReceivedNote.GoodsReceivedNoteId);
            string GRNDATE = nameof(GoodsReceivedNote.GRNDate);
            string GOODS_RECEIVED_NOTE_NAME = nameof(GoodsReceivedNote.GoodsReceivedNoteName);
            string IS_FULL_RECEIVE          = nameof(GoodsReceivedNote.IsFullReceive);
            string PURCHASE_ORDER_ID        = nameof(GoodsReceivedNote.PurchaseOrderId);
            string VENDOR_DONUMBER          = nameof(GoodsReceivedNote.VendorDONumber);
            string VENDOR_INVOICE_NUMBER    = nameof(GoodsReceivedNote.VendorInvoiceNumber);
            string WAREHOUSE_ID             = nameof(GoodsReceivedNote.WarehouseId);

            if (values.Contains(GOODS_RECEIVED_NOTE_ID))
            {
                model.GoodsReceivedNoteId = Convert.ToInt32(values[GOODS_RECEIVED_NOTE_ID]);
            }

            if (values.Contains(GRNDATE))
            {
                model.GRNDate = (System.DateTimeOffset)Convert.ChangeType(values[GRNDATE], typeof(System.DateTimeOffset));
            }

            if (values.Contains(GOODS_RECEIVED_NOTE_NAME))
            {
                model.GoodsReceivedNoteName = Convert.ToString(values[GOODS_RECEIVED_NOTE_NAME]);
            }

            if (values.Contains(IS_FULL_RECEIVE))
            {
                model.IsFullReceive = Convert.ToBoolean(values[IS_FULL_RECEIVE]);
            }

            if (values.Contains(PURCHASE_ORDER_ID))
            {
                model.PurchaseOrderId = Convert.ToInt32(values[PURCHASE_ORDER_ID]);
            }

            if (values.Contains(VENDOR_DONUMBER))
            {
                model.VendorDONumber = Convert.ToString(values[VENDOR_DONUMBER]);
            }

            if (values.Contains(VENDOR_INVOICE_NUMBER))
            {
                model.VendorInvoiceNumber = Convert.ToString(values[VENDOR_INVOICE_NUMBER]);
            }

            if (values.Contains(WAREHOUSE_ID))
            {
                model.WarehouseId = Convert.ToInt32(values[WAREHOUSE_ID]);
            }
        }
        public async Task <IActionResult> Create(GoodsReceivedNote goodsReceivedNote)
        {
            if (ModelState.IsValid)
            {
                _context.Add(goodsReceivedNote);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            var supplier = _context.Suppliers.Select(i => i.Name).ToList();

            ViewData["IdSupplier"] = new SelectList(_context.Suppliers, "Id", "Name", supplier);
            return(View(goodsReceivedNote));
        }
        public IHttpActionResult DeleteGoodsReceivedNote(string id)
        {
            GoodsReceivedNote goodsReceivedNote = db.GoodsReceivedNotes.Find(id);

            if (goodsReceivedNote == null)
            {
                return(NotFound());
            }

            db.GoodsReceivedNotes.Remove(goodsReceivedNote);
            db.SaveChanges();

            return(Ok(goodsReceivedNote));
        }
Beispiel #17
0
 public void DeleteGRNById(Guid id)
 {
     using (var context = new SCMSEntities())
     {
         var grn = new GoodsReceivedNote {
             Id = id
         };
         context.GoodsReceivedNotes.Attach(grn);
         ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(grn, System.Data.EntityState.Deleted);
         context.SaveChanges();
         SessionData.CurrentSession.PurchaseOrderList         = null;
         SessionData.CurrentSession.GoodsReceivedNoteList     = null;
         SessionData.CurrentSession.GoodsReceivedNoteItemList = null;
     }
 }
        public override void BindItemToViewHolder(GoodsReceivedNote item, GoodsReceivedNotesViewHolder viewHolder)
        {
            viewHolder.GoodsReceivedNoteRowItemDocumentId.Text = item.DocumentId;
            viewHolder.GoodsReceivedNoteRowItemInvoiceId.Text  = item.Invoice.DocumentId;

            _styleProvider
            .Execute(item.LastModifiedAt,
                     viewHolder.GoodsReceivedNoteRowItemDocumentId);

            viewHolder.GoodsReceivedNoteRowItemInfo.SetOnClickListener(IOnClickListener);
            viewHolder.GoodsReceivedNoteRowItemDelete.SetOnClickListener(IOnClickListener);

            viewHolder.GoodsReceivedNoteRowItemInfo.Visibility   = ReadVisibility;
            viewHolder.GoodsReceivedNoteRowItemDelete.Visibility = DeleteVisibility;
        }
Beispiel #19
0
        private ActionResult LGRN(string viewname)
        {
            var model = new GoodsReceivedNote()
            {
                staffs = new SelectList(SessionData.CurrentSession.StaffList, "Id", "StaffName"),
                //ReceivedBy = currentStaff.Id,
                PurchaseOrders = new SelectList(gRNService.GetGRNPurchaseOrders(), "Id", "RefNumber"),
                SubOffices     = new SelectList(SessionData.CurrentSession.CountrySubOfficeList, "Id", "Name"),
                Warehouses     = new SelectList(SessionData.CurrentSession.WarehouseList, "Id", "Name"),
                ApproversList  = new SelectList(staffService.GetStaffByApprovalDoc(NotificationHelper.grnCode, countryProg.Id), "Id", "StaffName"),
                RefNumber      = string.Format("--{0}--", Resources.GoodsReceivedNote_LoadGRN_NewGRN),
                POItemz        = new List <POItemsView>()
            };

            return(View(viewname, model));
        }
        public async Task GetGoodsReceivedNoteFreeItemAsync_Returns_GoodsReceivedNoteFreeItem()
        {
            //Arrange
            var id      = 1;
            var service = new GoodsReceivedNoteFreeItemService(_myRestaurantContext);

            //Act
            var result = await service.GetGoodsReceivedNoteFreeItemAsync(d => d.Id == id);

            //Assert
            result.Should().BeAssignableTo <GoodsReceivedNoteFreeItem>();
            result !.GoodsReceivedNote.Should().BeAssignableTo <GoodsReceivedNote>();
            result.Id.Should().Be(id);
            result.Item.Name.Should().Be("Chips");
            result.Discount.Should().Be(0.1m);
        }
Beispiel #21
0
        public ActionResult LoadGRAssetItems(GoodsReceivedNote model)
        {
            model.ReceptionApprovedBy = currentStaff.Id;
            model.CountryProgrammeId  = countryProg.Id;
            if (gRNService.IsGRNVerified(model))
            {
                SessionData.CurrentSession.GoodsReceivedNoteList = null;
            }
            GoodsReceivedNote grn = gRNService.GetGRNById(model.Id);
            //send notification to preparer that GRN has been verified
            string notificationMsg = string.Format(NotificationHelper.grnApprovedMsgBody, grn.Staff1.Person.FirstName, grn.RefNumber);

            notificationService.SendNotification(grn.Staff1.Person.OfficialEmail, notificationMsg, NotificationHelper.grnsubject);
            //Notify RFP Prep Incharge
            notificationService.SendAuthorizedMsgToDocPreparers(NotificationHelper.grnCode, grn.Id);

            return(ViewGRNs());
        }
        public HttpResponseMessage Post(FormDataCollection form)
        {
            var model  = new GoodsReceivedNote();
            var values = JsonConvert.DeserializeObject <IDictionary>(form.Get("values"));

            PopulateModel(model, values);

            Validate(model);
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, GetFullErrorMessage(ModelState)));
            }

            var result = _context.GoodsReceivedNotes.Add(model);

            _context.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.Created, result.GoodsReceivedNoteId));
        }
Beispiel #23
0
        public IActionResult GetAmount([FromRoute] int id)
        {
            var  Amount = 0.0;
            Bill bill   = _functionalService.GetById <Bill>(id);

            if (bill != null)
            {
                GoodsReceivedNote grn = _functionalService.GetById <GoodsReceivedNote>(bill.GoodsReceivedNoteId);
                if (grn != null)
                {
                    PurchaseOrder purchaseOrder = _functionalService.GetById <PurchaseOrder>(grn.PurchaseOrderId);
                    if (purchaseOrder != null)
                    {
                        Amount = purchaseOrder.Total;
                    }
                }
            }
            return(Ok(new { Amount }));
        }
Beispiel #24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public string GenerateUniquNumber(CodeType type)
        {
            long   count = 1;
            string code  = string.Empty; // shd be generate not hard coded as in the switch loop

            using (var dbContext = new SCMSEntities())
            {
                switch (type)
                {
                case CodeType.GoodsReceivedNote:
                default:
                    code = "GRN/DRC/UG/";
                    GoodsReceivedNote grn = dbContext.GoodsReceivedNotes.OrderByDescending(x => x.Index).FirstOrDefault();
                    if (grn != null)
                    {
                        count = grn.Index + 1;
                    }
                    break;
                }

                if (count < 10000)
                {
                    if (count < 10)
                    {
                        return(code + "0000" + count);
                    }
                    if (count < 100 & count > 10)
                    {
                        return(code + "000" + count);
                    }
                    if (count < 1000 & count > 100)
                    {
                        return(code + "00" + count);
                    }
                    if (count < 10000 & count > 1000)
                    {
                        return(code + "0" + count);
                    }
                }
                return(code + count);
            }
        }
Beispiel #25
0
        public ActionResult LoadGRNItemDetais(Guid PoId, string viewName)
        {
            var model = new GoodsReceivedNote()
            {
                PurchaseOrderId = PoId,
                ReceivedBy      = currentStaff.Id,
                Supplier        = gRNService.GetPO(PoId).Supplier,
                SupplierId      = gRNService.GetPO(PoId).Supplier.Id,
                staffs          = new SelectList(SessionData.CurrentSession.StaffList, "Id", "StaffName"),
                PurchaseOrders  = new SelectList(gRNService.GetGRNPurchaseOrders(), "Id", "RefNumber"),
                SubOffices      = new SelectList(SessionData.CurrentSession.CountrySubOfficeList, "Id", "Name"),
                Warehouses      = new SelectList(gRNService.GetSubOfficeWareHouses(Guid.Empty), "Id", "Name"),
                ApproversList   = new SelectList(staffService.GetStaffByApprovalDoc(NotificationHelper.grnCode, countryProg.Id), "Id", "StaffName"),
                RefNumber       = string.Format("--{0}--", Resources.GoodsReceivedNote_LoadGRN_NewGRN),
                POItemz         = gRNService.GetPOItemsDetails(PoId),
                SupplierName    = gRNService.GetPO(PoId).Supplier.Name
            };

            return(View(viewName, model));
        }
Beispiel #26
0
        public void Migrate()
        {
            DropTables();
            CreateTables();

            if (UserRepository.Any())
            {
                return;
            }

            var currentDate = DateTime.Now;

            var roleClaims = ClaimsRepository
                             .GetClaims();

            var role = new Role
            {
                Name = "Administrator"
            };

            RoleRepository.Add(role);

            var role1 = new Role
            {
                Name = "Pracownik"
            };

            RoleRepository.Add(role1);

            var role2 = new Role
            {
                Name = "Księgowy"
            };

            RoleRepository.Add(role2);

            var role3 = new Role
            {
                Name = "Kierownik"
            };

            RoleRepository.Add(role3);

            var adminRoleClaims = roleClaims
                                  .Select(cl => new RoleClaim
            {
                RoleId     = role.Id,
                ClaimType  = cl.Type,
                ClaimValue = cl.Value
            });

            var kierownikRoleClaims = roleClaims
                                      .Skip(4)
                                      .Select(cl => new RoleClaim
            {
                RoleId     = role3.Id,
                ClaimType  = cl.Type,
                ClaimValue = cl.Value
            });

            var ksiegowyRoleClaims = roleClaims
                                     .Skip(8)
                                     .Select(cl => new RoleClaim
            {
                RoleId     = role2.Id,
                ClaimType  = cl.Type,
                ClaimValue = cl.Value
            });

            var pracownikRoleClaims = roleClaims
                                      .Skip(12)
                                      .Select(cl => new RoleClaim
            {
                RoleId     = role1.Id,
                ClaimType  = cl.Type,
                ClaimValue = cl.Value
            });

            RoleClaimRepository.AddRange(adminRoleClaims);
            RoleClaimRepository.AddRange(kierownikRoleClaims);
            RoleClaimRepository.AddRange(ksiegowyRoleClaims);
            RoleClaimRepository.AddRange(pracownikRoleClaims);

            var user = new User
            {
                UserName     = "******",
                FirstName    = "Jan",
                LastName     = "Kocur",
                Email        = "*****@*****.**",
                PasswordHash = _passwordManager.GetHash("123")
            };

            UserRepository.Add(user);

            var user1 = new User
            {
                UserName     = "******",
                FirstName    = "Władysław",
                LastName     = "Kocioł",
                Email        = "*****@*****.**",
                PasswordHash = _passwordManager.GetHash("123")
            };

            UserRepository.Add(user1);

            var user2 = new User
            {
                UserName     = "******",
                FirstName    = "Michał",
                LastName     = "Zbożny",
                Email        = "*****@*****.**",
                PasswordHash = _passwordManager.GetHash("123")
            };

            UserRepository.Add(user2);

            var user3 = new User
            {
                UserName     = "******",
                FirstName    = "Heniek",
                LastName     = "Luwer",
                Email        = "*****@*****.**",
                PasswordHash = _passwordManager.GetHash("123")
            };

            UserRepository.Add(user3);

            var userRole = new UserRole
            {
                RoleId = role.Id,
                UserId = user.Id
            };

            var userRole1 = new UserRole
            {
                RoleId = role2.Id,
                UserId = user1.Id
            };

            var userRole2 = new UserRole
            {
                RoleId = role1.Id,
                UserId = user2.Id
            };

            var userRole3 = new UserRole
            {
                RoleId = role3.Id,
                UserId = user3.Id
            };

            UserRoleRepository.Add(userRole);
            UserRoleRepository.Add(userRole1);
            UserRoleRepository.Add(userRole2);
            UserRoleRepository.Add(userRole3);

            var city = new City
            {
                Name = "Olsztyn"
            };

            CityRepository.Add(city);

            var city2 = new City
            {
                Name = "Warszawa"
            };

            CityRepository.Add(city2);

            var city3 = new City
            {
                Name = "Barczewo"
            };

            CityRepository.Add(city3);

            var city4 = new City
            {
                Name = "Gdańsk"
            };

            CityRepository.Add(city4);

            var city5 = new City
            {
                Name = "Kraków"
            };

            CityRepository.Add(city5);

            var counterparty = new Counterparty
            {
                Name        = "Firma sprzedajaca buty",
                NIP         = "1122334455",
                PhoneNumber = "1122334455666",
                Street      = "Lubelska 432",
                PostalCode  = "11-341",
                CityId      = city.Id
            };

            CounterpartyRepository.Add(counterparty);

            var counterparty1 = new Counterparty
            {
                Name        = "Firma sprzedajaca ubrania",
                NIP         = "2126337425",
                PhoneNumber = "1122334455666",
                Street      = "Lubelska 432",
                PostalCode  = "11-341",
                CityId      = city.Id
            };

            CounterpartyRepository.Add(counterparty1);

            var location = new Location
            {
                Name = "Półka X"
            };

            LocationRepository.Add(location);

            var location1 = new Location
            {
                Name = "Półka Y"
            };

            LocationRepository.Add(location1);

            var location2 = new Location
            {
                Name = "Półka Z"
            };

            LocationRepository.Add(location2);

            var location3 = new Location
            {
                Name = "Półka K"
            };

            LocationRepository.Add(location3);

            var invoice = new Invoice
            {
                DocumentId     = string.Format("FAK/{0:yyyyMMddhhmmssfff}", currentDate),
                CounterpartyId = counterparty.Id,
                CityId         = city.Id,
                InvoiceType    = Common.InvoiceType.Purchase,
                PaymentMethod  = Common.PaymentMethod.Card,
                IssueDate      = currentDate,
                CompletionDate = currentDate
            };

            InvoiceRepository.Add(invoice);

            var entries = new List <Entry>()
            {
                new Entry
                {
                    Name      = "Buty Halwin Meain XL",
                    InvoiceId = invoice.Id,
                    Price     = 22.22m,
                    Count     = 1000,
                    VAT       = 0.01m
                }
            };

            EntryRepository.AddRange(entries);

            invoice.Total = entries[0].Count * entries[0].Price;
            invoice.VAT   = invoice.Total * entries[0].VAT;
            InvoiceRepository.Update(invoice);

            currentDate = DateTime.Now;

            var invoice1 = new Invoice
            {
                DocumentId     = string.Format("FAK/{0:yyyyMMddhhmmssfff}", currentDate),
                CounterpartyId = counterparty.Id,
                CityId         = city.Id,
                InvoiceType    = Common.InvoiceType.Sales,
                PaymentMethod  = Common.PaymentMethod.Card,
                IssueDate      = currentDate,
                CompletionDate = currentDate
            };

            InvoiceRepository.Add(invoice1);

            var entries1 = new List <Entry>()
            {
                new Entry
                {
                    Name      = "Buty Halwin Meain XL",
                    InvoiceId = invoice1.Id,
                    Price     = 22.22m,
                    Count     = 100,
                    VAT       = 0.01m
                }
            };

            EntryRepository.AddRange(entries1);
            invoice1.Total = entries1[0].Count * entries1[0].Price;
            invoice1.VAT   = invoice1.Total * entries1[0].VAT;
            InvoiceRepository.Update(invoice1);

            currentDate = DateTime.Now;

            var invoice2 = new Invoice
            {
                DocumentId     = string.Format("FAK/{0:yyyyMMddhhmmssfff}", currentDate),
                CounterpartyId = counterparty.Id,
                CityId         = city.Id,
                InvoiceType    = Common.InvoiceType.Purchase,
                PaymentMethod  = Common.PaymentMethod.Card,
                IssueDate      = currentDate,
                CompletionDate = currentDate
            };

            InvoiceRepository.Add(invoice2);

            var entries2 = new List <Entry>()
            {
                new Entry
                {
                    Name      = "Czapka Xiaming",
                    InvoiceId = invoice2.Id,
                    Price     = 70.22m,
                    Count     = 400,
                    VAT       = 0.10m
                }
            };

            EntryRepository.AddRange(entries2);
            invoice2.Total = entries2[0].Count * entries2[0].Price;
            invoice2.VAT   = invoice2.Total * entries2[0].VAT;
            InvoiceRepository.Update(invoice2);

            currentDate = DateTime.Now;

            var invoice3 = new Invoice
            {
                DocumentId     = string.Format("FAK/{0:yyyyMMddhhmmssfff}", currentDate),
                CounterpartyId = counterparty.Id,
                CityId         = city.Id,
                InvoiceType    = Common.InvoiceType.Purchase,
                PaymentMethod  = Common.PaymentMethod.Card,
                IssueDate      = currentDate,
                CompletionDate = currentDate
            };

            InvoiceRepository.Add(invoice3);

            var entries3 = new List <Entry>()
            {
                new Entry
                {
                    Name      = "Spodnie Jeans Amba M",
                    InvoiceId = invoice3.Id,
                    Price     = 51.74m,
                    Count     = 300,
                    VAT       = 0.12m
                }
            };

            EntryRepository.AddRange(entries3);
            invoice3.Total = entries3[0].Count * entries3[0].Price;
            invoice3.VAT   = invoice3.Total * entries3[0].VAT;
            InvoiceRepository.Update(invoice3);

            var attribute = new Attribute
            {
                Name = "Firma"
            };

            AttributeRepository.Add(attribute);

            var attribute1 = new Attribute
            {
                Name = "Rodzaj"
            };

            AttributeRepository.Add(attribute1);

            var product = new Product
            {
                Name    = "Buty Halwin Meain XL",
                Barcode = "Buty Halwin Meain XL",
            };

            var product1 = new Product
            {
                Name    = "Spodnie Jeans Amba M",
                Barcode = "Spodnie Jeans Amba M"
            };

            var product2 = new Product
            {
                Name    = "Koszula Meadow L",
                Barcode = "Koszula Meadow L"
            };

            var product3 = new Product
            {
                Name    = "Czapka Xiaming",
                Barcode = "Czapka Xiaming"
            };

            ProductRepository.Add(product);
            ProductRepository.Add(product1);
            ProductRepository.Add(product2);
            ProductRepository.Add(product3);

            var productAttributes = new List <ProductAttribute>()
            {
                new ProductAttribute
                {
                    ProductId   = product.Id,
                    AttributeId = attribute.Id,
                    Value       = "Xinmex"
                },
                new ProductAttribute
                {
                    ProductId   = product.Id,
                    AttributeId = attribute1.Id,
                    Value       = "Obuwie skórzane"
                },
                new ProductAttribute
                {
                    ProductId   = product1.Id,
                    AttributeId = attribute.Id,
                    Value       = "Abibas"
                },
                new ProductAttribute
                {
                    ProductId   = product1.Id,
                    AttributeId = attribute1.Id,
                    Value       = "Spodnie"
                },
                new ProductAttribute
                {
                    ProductId   = product2.Id,
                    AttributeId = attribute.Id,
                    Value       = "Pomba"
                },
                new ProductAttribute
                {
                    ProductId   = product2.Id,
                    AttributeId = attribute1.Id,
                    Value       = "Koszula bawelniana"
                }
            };

            ProductAttributeRepository.AddRange(productAttributes);

            var productDetails = new List <ProductDetail>()
            {
                new ProductDetail
                {
                    LocationId = location.Id,
                    ProductId  = product.Id,
                    Count      = 300
                },
                new ProductDetail
                {
                    LocationId = location1.Id,
                    ProductId  = product.Id,
                    Count      = 150
                },
                new ProductDetail
                {
                    LocationId = location.Id,
                    ProductId  = product1.Id,
                    Count      = 200
                },
                new ProductDetail
                {
                    LocationId = location1.Id,
                    ProductId  = product1.Id,
                    Count      = 150
                },
                new ProductDetail
                {
                    LocationId = location.Id,
                    ProductId  = product2.Id,
                    Count      = 600
                },
                new ProductDetail
                {
                    LocationId = location1.Id,
                    ProductId  = product2.Id,
                    Count      = 350
                },
                new ProductDetail
                {
                    LocationId = location.Id,
                    ProductId  = product3.Id,
                    Count      = 400
                },
                new ProductDetail
                {
                    LocationId = location1.Id,
                    ProductId  = product3.Id,
                    Count      = 250
                }
            };

            ProductDetailsRepository.AddRange(productDetails);

            var goodsDispatchedNote = new GoodsDispatchedNote
            {
                DocumentId   = string.Format("PZ/{0:yyyyMMddhhmmss}", currentDate),
                Remarks      = "Testowy opis...",
                InvoiceId    = invoice1.Id,
                IssueDate    = currentDate,
                DispatchDate = currentDate
            };

            GoodsDispatchedNoteRepository.Add(goodsDispatchedNote);

            var goodsReceivedNote = new GoodsReceivedNote
            {
                DocumentId  = string.Format("WZ/{0:yyyyMMddhhmmss}", currentDate),
                Remarks     = "Testowy opis...",
                InvoiceId   = invoice.Id,
                IssueDate   = currentDate,
                ReceiveDate = currentDate
            };

            GoodsReceivedNoteRepository.Add(goodsReceivedNote);
        }
 public async Task DeleteGoodsReceivedNoteAsync(GoodsReceivedNote goodsReceivedNote)
 {
     _context.Delete(goodsReceivedNote);
     await _context.CommitAsync();
 }
 public async Task UpdateGoodsReceivedNoteAsync(GoodsReceivedNote goodsReceivedNote)
 {
     _context.Modify(goodsReceivedNote);
     await _context.CommitAsync();
 }
Beispiel #29
0
 public void GoToGoodsReceivedNoteDetails(GoodsReceivedNote model)
 {
     GoTo <Fragments.Details.GoodsReceivedNote>(model);
 }