示例#1
0
        protected virtual async Task ValidateJournalUnitAsync(ApHeaderTransactions invoiceunit)
        {
            //Validating if Duplicate DocumentReference(INVOICE#) exists
            if (ApHeaderTransactionsUnitRepository != null)
            {
                var invoices = (await ApHeaderTransactionsUnitRepository.GetAllListAsync(
                                    p => p.DocumentReference == invoiceunit.DocumentReference && p.OrganizationUnitId == invoiceunit.OrganizationUnitId &&
                                    p.TypeOfAccountingDocumentId == TypeOfAccountingDocument.AccountsPayable));

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

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

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