Esempio n. 1
0
        private MAccountRef GetAccountRef(string supId)
        {
            MAccountRef accountRef = _mAccountRefRepository.GetByRefTableId(EnumReferenceTable.Supplier, supId);

            if (accountRef != null)
            {
                return(accountRef);
            }
            return(null);
        }
        private MAccountRef GetAccountRef(string warehouseId)
        {
            MAccountRef accountRef = _mAccountRefRepository.GetByRefTableId(EnumReferenceTable.Warehouse, warehouseId);

            if (accountRef != null)
            {
                return(accountRef);
            }
            return(null);
        }
        private MAccountRef GetAccountRef(string jobTypeId)
        {
            MAccountRef accountRef = _mAccountRefRepository.GetByRefTableId(EnumReferenceTable.JobType, jobTypeId);

            if (accountRef != null)
            {
                return(accountRef);
            }
            return(null);
        }
Esempio n. 4
0
        private void SaveJournal(TPayment payment, string transBy, string cashAccountId, string costCenterId, string desc)
        {
            TJournal journal = new TJournal();

            journal.JournalType      = EnumJournalType.GeneralLedger.ToString();
            journal.JournalVoucherNo = Helper.CommonHelper.GetVoucherNo();
            journal.JournalDate      = payment.PaymentDate;
            journal.JournalDesc      = payment.PaymentDesc;
            journal.JournalPic2      = payment.PaymentPic;
            journal.JournalPic       = transBy;

            journal.SetAssignedIdTo(Guid.NewGuid().ToString());
            journal.CostCenterId = _mCostCenterRepository.Get(costCenterId);
            journal.CreatedDate  = DateTime.Now;
            journal.CreatedBy    = User.Identity.Name;
            journal.DataStatus   = Enums.EnumDataStatus.New.ToString();
            journal.JournalDets.Clear();

            MAccount    accountCash = _mAccountRepository.Get(cashAccountId);
            MAccountRef accountRef;

            if (payment.PaymentType == EnumPaymentType.Hutang.ToString())
            {
                //search supplier hutang account
                accountRef = _mAccountRefRepository.GetByRefTableId(EnumReferenceTable.Supplier, transBy);
                //save debet
                SaveJournalDet(journal, EnumJournalStatus.D, accountRef.AccountId, payment.PaymentTotal, desc);
                //save kredit
                SaveJournalDet(journal, EnumJournalStatus.K, accountCash, payment.PaymentTotal, desc);
            }
            else if (payment.PaymentType == EnumPaymentType.Piutang.ToString())
            {
                //search Customer piutang account
                accountRef = _mAccountRefRepository.GetByRefTableId(EnumReferenceTable.Customer, transBy);
                //save debet
                SaveJournalDet(journal, EnumJournalStatus.D, accountCash, payment.PaymentTotal, desc);
                //save kredit
                SaveJournalDet(journal, EnumJournalStatus.K, accountRef.AccountId, payment.PaymentTotal, desc);
            }

            _tJournalRepository.Save(journal);
        }
        private void SaveJournalClosing(string closingId, DateTime?dateFrom, DateTime?dateTo)
        {
            IList <MWarehouse> listWarehouse = _mWarehouseRepository.GetAll();
            MAccountRef        accountRef;

            foreach (MWarehouse warehouse in listWarehouse)
            {
                string   newVoucher = Helper.CommonHelper.GetVoucherNo(false);
                TJournal journal    = new TJournal();
                journal.SetAssignedIdTo(Guid.NewGuid().ToString());
                journal.CostCenterId      = warehouse.CostCenterId;
                journal.JournalType       = EnumJournalType.GeneralLedger.ToString();
                journal.JournalVoucherNo  = newVoucher;
                journal.JournalPic        = User.Identity.Name;
                journal.JournalDate       = dateTo;
                journal.JournalEvidenceNo = closingId;
                //j.JournalAmmount = ammount;
                journal.JournalDesc = "Hitung HPP";

                journal.DataStatus  = EnumDataStatus.New.ToString();
                journal.CreatedBy   = User.Identity.Name;
                journal.CreatedDate = DateTime.Now;
                journal.JournalDets.Clear();

                //save persediaan awal
                decimal?totalStockAwal = _tStockRepository.GetTotalStockBeforeDate(warehouse.Id, dateFrom.Value.AddDays(-1));
                accountRef = _mAccountRefRepository.GetByRefTableId(EnumReferenceTable.Warehouse, warehouse.Id);
                SaveJournalDet(journal, newVoucher, accountRef.AccountId, EnumJournalStatus.D, totalStockAwal, "Saldo Awal Periode");

                //save ikhtiar LR
                SaveJournalDet(journal, newVoucher, Helper.AccountHelper.GetHppAccount(), EnumJournalStatus.K, totalStockAwal, "Saldo Awal Periode");

                //save persediaan akhir
                decimal?totalLastStock = _tStockRepository.GetTotalStockBeforeDate(warehouse.Id, dateTo.Value);
                SaveJournalDet(journal, newVoucher, accountRef.AccountId, EnumJournalStatus.K, totalLastStock, "Saldo Akhir Periode");

                //save ikhtiar LR
                SaveJournalDet(journal, newVoucher, Helper.AccountHelper.GetHppAccount(), EnumJournalStatus.D, totalLastStock, "Saldo Akhir Periode");

                _tJournalRepository.Save(journal);
            }
        }