Exemplo n.º 1
0
        protected virtual async Task ValidatePayrollUnitAsync(PayrollEntryDocumentUnit invoiceunit)
        {
            //Validating if Duplicate DocumentReference(PayrollInvoice#) exists
            if (PayrollEntryDocumentUnitRepository != null)
            {
                var invoices = (await PayrollEntryDocumentUnitRepository.GetAllListAsync(
                                    p => p.DocumentReference == invoiceunit.DocumentReference && p.OrganizationUnitId == invoiceunit.OrganizationUnitId &&
                                    p.TypeOfAccountingDocumentId == TypeOfAccountingDocument.Payroll));

                if (invoiceunit.Id == 0)
                {
                    if (invoices.Count > 0)
                    {
                        throw new UserFriendlyException(L("Duplicate PayrollInvoice#", invoiceunit.DocumentReference));
                    }
                }
                else
                {
                    if (invoices.FirstOrDefault(p => p.Id != invoiceunit.Id && p.DocumentReference == invoiceunit.DocumentReference) != null)
                    {
                        throw new UserFriendlyException(L("Duplicate PayrollInvoice#", invoiceunit.DocumentReference));
                    }
                }
            }
        }
Exemplo n.º 2
0
        public virtual async Task UpdateAsync(PayrollEntryDocumentUnit input)
        {
            await ValidatePayrollUnitAsync(input);

            await PayrollEntryDocumentUnitRepository.UpdateAsync(input);
        }
Exemplo n.º 3
0
        public virtual async Task <long> CreateAsync(PayrollEntryDocumentUnit input)
        {
            await ValidatePayrollUnitAsync(input);

            return(await PayrollEntryDocumentUnitRepository.InsertOrUpdateAndGetIdAsync(input));
        }