/// <summary> /// This method used for add credit Note item offer. -An /// </summary> /// <param name="itemOfferCreditNote"></param> /// <returns></returns> public int AddCreditNoteItemOffer(ItemOfferCreditNote itemOfferCreditNote) { try { _itemOfferCreditNoteContext.Add(itemOfferCreditNote); _itemOfferCreditNoteContext.SaveChanges(); return(itemOfferCreditNote.Id); } catch (Exception ex) { _errorLog.LogException(ex); throw; } }
public IHttpActionResult GetCreditNote(int SupplierId) { try { List <CreditNoteAC> listOfCreditNoteAc = new List <CreditNoteAC>(); List <CreditNoteDetail> listOfCreditNote = _iCreditNoteRepository.GetListOfCreditNoteDetailByBranchId(Convert.ToInt32(MerchantContext.UserDetails.BranchId), MerchantContext.Permission.IsAllowToAccessAllBranch); if (listOfCreditNote.Count > 0) { foreach (var creditNote in listOfCreditNote) { CreditNoteAC creditNoteAC = new CreditNoteAC(); creditNoteAC.Id = creditNote.Id; creditNoteAC.Amount = creditNote.Amount; creditNoteAC.RemaningAmount = creditNote.RemainigAmount; creditNoteAC.IsCollected = creditNote.IsCollected; creditNoteAC.CreditNoteNo = creditNote.CreditNoteNo; creditNoteAC.InitiationDate = creditNote.InitiationDate.ToString("dd-MM-yyyy hh:mm tt"); if (creditNote.TypeId == Convert.ToInt32(CreditNoteType.SupplierItemOfferNote)) { ItemOfferCreditNote itemOfferCreditNote = _iCreditNoteRepository.GetItemOfferCreditNoteByCreditId(creditNote.Id); if (itemOfferCreditNote != null) { creditNoteAC.SupplierId = itemOfferCreditNote.SupplierId; creditNoteAC.SupplierName = itemOfferCreditNote.SupplierProfile.NameEn; } } else if (creditNote.TypeId == Convert.ToInt32(CreditNoteType.SupplierDestructionNote)) { ItemDestructionCreditNote itemDestructionCreditNote = _iCreditNoteRepository.GetItemDestructionCreditNoteByCreditId(creditNote.Id); if (itemDestructionCreditNote != null) { creditNoteAC.SupplierId = itemDestructionCreditNote.Destruction.SupplierId; creditNoteAC.SupplierName = itemDestructionCreditNote.Destruction.SupplierProfile.NameEn; } } else if (creditNote.TypeId == Convert.ToInt32(CreditNoteType.SupplierReturnNote)) { SupplierReturnCreditNote supplierReturnCreditNotes = _iCreditNoteRepository.GetSupplierReturnCreditNoteByCreditNoteId(creditNote.Id); if (supplierReturnCreditNotes != null) { creditNoteAC.SupplierId = supplierReturnCreditNotes.SupplierReturnDetail.SupplierId; creditNoteAC.SupplierName = supplierReturnCreditNotes.SupplierReturnDetail.SupplierProfile.NameEn; } } if (creditNoteAC.SupplierId == SupplierId) { if (creditNoteAC.IsCollected) { if (creditNoteAC.RemaningAmount > 0) { creditNoteAC.ActualAmount = creditNoteAC.RemaningAmount; listOfCreditNoteAc.Add(creditNoteAC); } } else { creditNoteAC.ActualAmount = creditNoteAC.Amount; listOfCreditNoteAc.Add(creditNoteAC); } } } } return(Ok(listOfCreditNoteAc)); } catch (Exception ex) { _errorLog.LogException(ex); throw; } }