Exemplo n.º 1
0
        public async Task <bool> CreateIncome(GeneralLedgerView glView)
        {
            try
            {
                //ChartOfAccts coa = await unitOfWork.generalLedgerRepository.GetChartofAccount("1000", "1200", "300", "");
                ChartOfAccount coa = await ChartOfAccounts.Query().GetEntity("1000", "1200", "300", "");

                //Udc udcLedgerType = await unitOfWork.generalLedgerRepository.GetUdc("GENERALLEDGERTYPE", "AA");
                Udc udcLedgerType = await UDC.Query().GetUdc("GENERALLEDGERTYPE", "AA");

                Udc udcDocType = await UDC.Query().GetUdc("DOCTYPE", "PV");

                //Udc udcDocType = await unitOfWork.generalLedgerRepository.GetUdc("DOCTYPE","PV");
                //AddressBook addressBook = await unitOfWork.addressBookRepository.GetAddressBookByAddressId(addressId);
                AddressBook addressBook = await AddressBook.Query().GetEntityById(glView.AddressId);



                glView.DocType      = udcDocType.KeyCode;
                glView.AccountId    = coa.AccountId;
                glView.LedgerType   = udcLedgerType.KeyCode;
                glView.CreatedDate  = DateTime.Now;
                glView.AddressId    = addressBook.AddressId;
                glView.FiscalPeriod = glView.GLDate.Month;
                glView.FiscalYear   = glView.GLDate.Year;
                glView.DebitAmount  = glView.Amount;
                glView.CreditAmount = 0;


                GeneralLedgerView glLookup = null;

                if (String.IsNullOrEmpty(glView.CheckNumber) == false)
                {
                    glLookup = await GeneralLedger.Query().GetLedgerViewByExpression(
                        e => e.AccountId == glView.AccountId &&
                        e.AddressId == glView.AddressId &&
                        e.Amount == glView.Amount &&
                        e.CheckNumber == glView.CheckNumber &&
                        e.DocType == glView.DocType &&
                        e.Gldate == glView.GLDate
                        );
                }
                if (glLookup == null)
                {
                    //create income

                    GeneralLedger.CreateGeneralLedgerByView(glView).Apply();
                    GeneralLedger.UpdateAccountBalances(glView);
                    GeneralLedgerView glViewLookup = await GeneralLedger.Query().GetViewByDocNumber(glView.DocNumber, glView.DocType);

                    return(glViewLookup != null);
                }
                else
                {
                    glView.DocNumber = glLookup.DocNumber;
                }
                return(true);
            }
            catch (Exception ex) { throw new Exception("CreateCash", ex); }
        }
Exemplo n.º 2
0
        public bool CreateSupplier(AddressBook addressBook, EmailEntity emailEntity, LocationAddress locationAddress)
        {
            try
            {
                AddressBook
                .CreateSupplierAddressBook(addressBook, emailEntity)
                .Apply();

                Task <AddressBook> addressBookLookupTask = Task.Run(async() => await AddressBook.Query().GetAddressBookbyEmail(emailEntity.Email));

                locationAddress.AddressId = addressBookLookupTask.Result.AddressId;

                LocationAddress

                .AddLocationAddress(locationAddress)
                .Apply();

                Email.CreateSupplierEmail(addressBook.AddressId, emailEntity).Apply();

                Supplier supplier = new Supplier {
                    AddressId = addressBook.AddressId, Identification = emailEntity.Email
                };

                Supplier
                .AddSupplier(supplier)
                .Apply();
                return(true);
            }
            catch (Exception ex) { throw new Exception("CreateSupplier", ex); }
        }