示例#1
0
        protected virtual async Task ValidateJournalUnitAsync(PettyCashEntryDocumentUnit pettyCashUnit)
        {
            //Validating if Duplicate DocumentReference(INVOICE#) exists
            if (_pettyCashEntryDocumentUnitRepository != null)
            {
                var pcUnits = (await _pettyCashEntryDocumentUnitRepository.GetAllListAsync(
                                   p => p.DocumentReference == pettyCashUnit.DocumentReference && p.OrganizationUnitId == pettyCashUnit.OrganizationUnitId &&
                                   p.TypeOfAccountingDocumentId == TypeOfAccountingDocument.PettyCash));

                if (pettyCashUnit.Id == 0)
                {
                    if (pcUnits.Count > 0)
                    {
                        throw new UserFriendlyException(L("Duplicate PettyCash#", pettyCashUnit.DocumentReference));
                    }
                }
                else
                {
                    if (pcUnits.FirstOrDefault(p => p.Id != pettyCashUnit.Id && p.DocumentReference == pettyCashUnit.DocumentReference) != null)
                    {
                        throw new UserFriendlyException(L("Duplicate PettyCash#", pettyCashUnit.DocumentReference));
                    }
                }
            }
        }
示例#2
0
        public virtual async Task UpdateAsync(PettyCashEntryDocumentUnit input)
        {
            await ValidateJournalUnitAsync(input);

            await _pettyCashEntryDocumentUnitRepository.UpdateAsync(input);
        }
示例#3
0
        public virtual async Task <long> CreateAsync(PettyCashEntryDocumentUnit input)
        {
            await ValidateJournalUnitAsync(input);

            return(await _pettyCashEntryDocumentUnitRepository.InsertAndGetIdAsync(input));
        }