public override void SaveJournal(TTrans trans, decimal totalHPP) { string desc = string.Format("Penjualan paket jasa kepada {0}", trans.TransBy); string newVoucher = Helper.CommonHelper.GetVoucherNo(false); //save header of journal TJournal journal = SaveJournalHeader(newVoucher, trans, desc); MAccountRef accountRef = null; if (trans.TransPaymentMethod == EnumPaymentMethod.Tunai.ToString()) { //save cash SaveJournalDet(journal, newVoucher, Helper.AccountHelper.GetCashAccount(), EnumJournalStatus.D, trans.TransGrandTotal.Value, trans, desc); } else { accountRef = AccountRefRepository.GetByRefTableId(EnumReferenceTable.Customer, trans.TransBy); //save piutang SaveJournalDet(journal, newVoucher, accountRef.AccountId, EnumJournalStatus.D, trans.TransGrandTotal.Value, trans, desc); } //save penjualan SaveJournalDet(journal, newVoucher, Helper.AccountHelper.GetSalesAccount(), EnumJournalStatus.K, trans.TransGrandTotal.Value, trans, desc); //save ikhtiar LR SaveJournalDet(journal, newVoucher, Helper.AccountHelper.GetIkhtiarLRAccount(), EnumJournalStatus.D, totalHPP, trans, desc); //save persediaan accountRef = AccountRefRepository.GetByRefTableId(EnumReferenceTable.Warehouse, trans.WarehouseId.Id); SaveJournalDet(journal, newVoucher, accountRef.AccountId, EnumJournalStatus.K, totalHPP, trans, desc); JournalRepository.Save(journal); //save journal ref SaveJournalRef(trans, journal); }
public ActionResult Insert(MWarehouse viewModel, FormCollection formCollection) { RefAddress address = new RefAddress(); address.AddressLine1 = formCollection["AddressLine1"]; address.AddressLine2 = formCollection["AddressLine2"]; address.AddressLine3 = formCollection["AddressLine3"]; address.AddressPhone = formCollection["AddressPhone"]; address.AddressCity = formCollection["AddressCity"]; address.SetAssignedIdTo(Guid.NewGuid().ToString()); _refAddressRepository.Save(address); MWarehouse mWarehouseToInsert = new MWarehouse(); TransferFormValuesTo(mWarehouseToInsert, viewModel); mWarehouseToInsert.EmployeeId = _mEmployeeRepository.Get(formCollection["EmployeeId"]); mWarehouseToInsert.CostCenterId = _mCostCenterRepository.Get(formCollection["CostCenterId"]); mWarehouseToInsert.SetAssignedIdTo(viewModel.Id); mWarehouseToInsert.CreatedDate = DateTime.Now; mWarehouseToInsert.CreatedBy = User.Identity.Name; mWarehouseToInsert.DataStatus = EnumDataStatus.New.ToString(); mWarehouseToInsert.AddressId = address; _mWarehouseRepository.Save(mWarehouseToInsert); //save account persediaan barang MAccountRef accountRef = new MAccountRef(); accountRef.SetAssignedIdTo(Guid.NewGuid().ToString()); accountRef.ReferenceId = mWarehouseToInsert.Id; accountRef.ReferenceTable = EnumReferenceTable.Warehouse.ToString(); accountRef.ReferenceType = EnumReferenceTable.Warehouse.ToString(); accountRef.AccountId = _mAccountRepository.Get(formCollection["AccountId"]); _mAccountRefRepository.Save(accountRef); //save account pemakaian barang accountRef = new MAccountRef(); accountRef.SetAssignedIdTo(Guid.NewGuid().ToString()); accountRef.ReferenceId = mWarehouseToInsert.Id; accountRef.ReferenceTable = EnumReferenceTable.WarehouseUsing.ToString(); accountRef.ReferenceType = EnumReferenceTable.WarehouseUsing.ToString(); accountRef.AccountId = _mAccountRepository.Get(formCollection["UsingAccountId"]); _mAccountRefRepository.Save(accountRef); try { _mWarehouseRepository.DbContext.CommitChanges(); } catch (Exception e) { _mWarehouseRepository.DbContext.RollbackTransaction(); //throw e.GetBaseException(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }
public ActionResult Update(MWarehouse viewModel, FormCollection formCollection) { MWarehouse mWarehouseToUpdate = _mWarehouseRepository.Get(viewModel.Id); TransferFormValuesTo(mWarehouseToUpdate, viewModel); mWarehouseToUpdate.EmployeeId = _mEmployeeRepository.Get(formCollection["EmployeeId"]); mWarehouseToUpdate.CostCenterId = _mCostCenterRepository.Get(formCollection["CostCenterId"]); mWarehouseToUpdate.ModifiedDate = DateTime.Now; mWarehouseToUpdate.ModifiedBy = User.Identity.Name; mWarehouseToUpdate.DataStatus = EnumDataStatus.Updated.ToString(); mWarehouseToUpdate.AddressId.AddressLine1 = formCollection["AddressLine1"]; mWarehouseToUpdate.AddressId.AddressLine1 = formCollection["AddressLine1"]; mWarehouseToUpdate.AddressId.AddressLine2 = formCollection["AddressLine2"]; mWarehouseToUpdate.AddressId.AddressLine3 = formCollection["AddressLine3"]; mWarehouseToUpdate.AddressId.AddressPhone = formCollection["AddressPhone"]; mWarehouseToUpdate.AddressId.AddressCity = formCollection["AddressCity"]; _mWarehouseRepository.Update(mWarehouseToUpdate); bool isSave = false; MAccountRef accountRef = GetAccountRef(mWarehouseToUpdate.Id); if (accountRef == null) { accountRef = new MAccountRef(); accountRef.SetAssignedIdTo(Guid.NewGuid().ToString()); isSave = true; } accountRef.ReferenceId = mWarehouseToUpdate.Id; accountRef.ReferenceTable = EnumReferenceTable.Warehouse.ToString(); accountRef.ReferenceType = EnumReferenceTable.Warehouse.ToString(); accountRef.AccountId = _mAccountRepository.Get(formCollection["AccountId"]); if (isSave) { _mAccountRefRepository.Save(accountRef); } else { _mAccountRefRepository.Update(accountRef); } try { _mWarehouseRepository.DbContext.CommitChanges(); } catch (Exception e) { _mWarehouseRepository.DbContext.RollbackTransaction(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }
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); }
public ActionResult Update(MSupplier viewModel, FormCollection formCollection) { UpdateNumericData(viewModel, formCollection); MSupplier mSupplierToUpdate = _mSupplierRepository.Get(viewModel.Id); TransferFormValuesTo(mSupplierToUpdate, viewModel); mSupplierToUpdate.ModifiedDate = DateTime.Now; mSupplierToUpdate.ModifiedBy = User.Identity.Name; mSupplierToUpdate.DataStatus = EnumDataStatus.Updated.ToString(); RefAddress address = mSupplierToUpdate.AddressId; TransferFormValuesTo(address, formCollection); address.ModifiedDate = DateTime.Now; address.ModifiedBy = User.Identity.Name; address.DataStatus = EnumDataStatus.Updated.ToString(); _mSupplierRepository.Update(mSupplierToUpdate); bool isSave = false; MAccountRef accountRef = GetAccountRef(mSupplierToUpdate.Id); if (accountRef == null) { accountRef = new MAccountRef(); accountRef.SetAssignedIdTo(Guid.NewGuid().ToString()); isSave = true; } accountRef.ReferenceId = mSupplierToUpdate.Id; accountRef.ReferenceTable = EnumReferenceTable.Supplier.ToString(); accountRef.ReferenceType = EnumReferenceTable.Supplier.ToString(); accountRef.AccountId = _mAccountRepository.Get(formCollection["AccountId"]); if (isSave) { _mAccountRefRepository.Save(accountRef); } else { _mAccountRefRepository.Update(accountRef); } try { _mSupplierRepository.DbContext.CommitChanges(); } catch (Exception e) { _mSupplierRepository.DbContext.RollbackTransaction(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }
public ActionResult Update(MJobType viewModel, FormCollection formCollection) { try { _mJobTypeRepository.DbContext.BeginTransaction(); MJobType mJobTypeToUpdate = _mJobTypeRepository.Get(viewModel.Id); TransferFormValuesTo(mJobTypeToUpdate, viewModel); mJobTypeToUpdate.ModifiedDate = DateTime.Now; mJobTypeToUpdate.ModifiedBy = User.Identity.Name; mJobTypeToUpdate.DataStatus = EnumDataStatus.Updated.ToString(); _mJobTypeRepository.Update(mJobTypeToUpdate); bool isSave = false; MAccountRef accountRef = GetAccountRef(mJobTypeToUpdate.Id); if (accountRef == null) { accountRef = new MAccountRef(); accountRef.SetAssignedIdTo(Guid.NewGuid().ToString()); accountRef.CreatedDate = DateTime.Now; accountRef.CreatedBy = User.Identity.Name; accountRef.DataStatus = EnumDataStatus.New.ToString(); isSave = true; } else { accountRef.ModifiedDate = DateTime.Now; accountRef.ModifiedBy = User.Identity.Name; accountRef.DataStatus = EnumDataStatus.Updated.ToString(); } accountRef.ReferenceId = mJobTypeToUpdate.Id; accountRef.ReferenceTable = EnumReferenceTable.JobType.ToString(); accountRef.ReferenceType = EnumReferenceTable.JobType.ToString(); accountRef.AccountId = _mAccountRepository.Get(formCollection["AccountId"]); if (isSave) { _mAccountRefRepository.Save(accountRef); } else { _mAccountRefRepository.Update(accountRef); } _mJobTypeRepository.DbContext.CommitChanges(); } catch (Exception e) { _mJobTypeRepository.DbContext.RollbackTransaction(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }
public ActionResult Insert(MSupplier viewModel, FormCollection formCollection) { try { _mSupplierRepository.DbContext.BeginTransaction(); UpdateNumericData(viewModel, formCollection); RefAddress address = new RefAddress(); TransferFormValuesTo(address, formCollection); address.SetAssignedIdTo(Guid.NewGuid().ToString()); address.CreatedDate = DateTime.Now; address.CreatedBy = User.Identity.Name; address.DataStatus = EnumDataStatus.New.ToString(); _refAddressRepository.Save(address); MSupplier mSupplierToInsert = new MSupplier(); TransferFormValuesTo(mSupplierToInsert, viewModel); mSupplierToInsert.SetAssignedIdTo(viewModel.Id); mSupplierToInsert.CreatedDate = DateTime.Now; mSupplierToInsert.CreatedBy = User.Identity.Name; mSupplierToInsert.DataStatus = EnumDataStatus.New.ToString(); mSupplierToInsert.AddressId = address; _mSupplierRepository.Save(mSupplierToInsert); MAccountRef accountRef = new MAccountRef(); accountRef.SetAssignedIdTo(Guid.NewGuid().ToString()); accountRef.ReferenceId = mSupplierToInsert.Id; accountRef.ReferenceTable = EnumReferenceTable.Supplier.ToString(); accountRef.ReferenceType = EnumReferenceTable.Supplier.ToString(); accountRef.AccountId = _mAccountRepository.Get(formCollection["AccountId"]); accountRef.CreatedDate = DateTime.Now; accountRef.CreatedBy = User.Identity.Name; accountRef.DataStatus = EnumDataStatus.New.ToString(); _mAccountRefRepository.Save(accountRef); _mSupplierRepository.DbContext.CommitChanges(); } catch (Exception e) { _mSupplierRepository.DbContext.RollbackTransaction(); //throw e.GetBaseException(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }
public override void SaveJournal(TTrans trans, decimal totalHPP) { string desc = string.Format("Penerimaan Stok dari {0}", trans.TransBy); string newVoucher = Helper.CommonHelper.GetVoucherNo(false); //delete journal first DeleteJournal(EnumReferenceTable.Transaction, trans.TransStatus, trans.Id); //save header of journal TJournal journal = SaveJournalHeader(trans.WarehouseId.CostCenterId, newVoucher, trans.TransBy, trans.TransDate, trans.TransFactur, desc); MAccountRef accountRef = null; ////save persediaan //accountRef = AccountRefRepository.GetByRefTableId(EnumReferenceTable.Warehouse, trans.WarehouseId.Id); //SaveJournalDet(journal, newVoucher, accountRef.AccountId, EnumJournalStatus.D, totalHPP, trans.TransFactur, desc); ////save ikhtiar LR //SaveJournalDet(journal, newVoucher, Helper.AccountHelper.GetHppAccount(), EnumJournalStatus.K, totalHPP, trans.TransFactur, desc); JournalRepository.Save(journal); //save journal ref SaveJournalRef(journal, trans.Id, trans.TransStatus, trans.TransDesc); }
public override void SaveJournal(TTrans trans, decimal totalHPP) { string desc = string.Format("Pembelian dari {0}", trans.TransBy); string newVoucher = Helper.CommonHelper.GetVoucherNo(false); //delete journal first DeleteJournal(EnumReferenceTable.Transaction, trans.TransStatus, trans.Id); //save header of journal TJournal journal = SaveJournalHeader(trans.WarehouseId.CostCenterId, newVoucher, trans.TransBy, trans.TransDate, trans.TransFactur, desc); MAccountRef accountRef = null; //save pembelian SaveJournalDet(journal, newVoucher, Helper.AccountHelper.GetPurchaseAccount(), EnumJournalStatus.D, totalHPP, trans.TransFactur, desc); if (trans.TransPaymentMethod == EnumPaymentMethod.Tunai.ToString()) { //save cash SaveJournalDet(journal, newVoucher, Helper.AccountHelper.GetCashAccount(), EnumJournalStatus.K, totalHPP, trans.TransFactur, desc); } else { accountRef = AccountRefRepository.GetByRefTableId(EnumReferenceTable.Supplier, trans.TransBy); //save hutang SaveJournalDet(journal, newVoucher, accountRef.AccountId, EnumJournalStatus.K, totalHPP, trans.TransFactur, desc); } ////save persediaan //accountRef = AccountRefRepository.GetByRefTableId(EnumReferenceTable.Warehouse, trans.WarehouseId.Id); //SaveJournalDet(journal, newVoucher, accountRef.AccountId, EnumJournalStatus.D, totalHPP, trans, desc); ////save ikhtiar LR //SaveJournalDet(journal, newVoucher, Helper.AccountHelper.GetIkhtiarLRAccount(), EnumJournalStatus.K, totalHPP, trans, desc); JournalRepository.Save(journal); //save journal ref SaveJournalRef(journal, trans.Id, trans.TransStatus, trans.TransDesc); }
public ActionResult Insert(MJobType viewModel, FormCollection formCollection) { try { _mJobTypeRepository.DbContext.BeginTransaction(); MJobType mJobTypeToInsert = new MJobType(); TransferFormValuesTo(mJobTypeToInsert, viewModel); mJobTypeToInsert.SetAssignedIdTo(viewModel.Id); mJobTypeToInsert.CreatedDate = DateTime.Now; mJobTypeToInsert.CreatedBy = User.Identity.Name; mJobTypeToInsert.DataStatus = EnumDataStatus.New.ToString(); _mJobTypeRepository.Save(mJobTypeToInsert); MAccountRef accountRef = new MAccountRef(); accountRef.SetAssignedIdTo(Guid.NewGuid().ToString()); accountRef.ReferenceId = mJobTypeToInsert.Id; accountRef.ReferenceTable = EnumReferenceTable.JobType.ToString(); accountRef.ReferenceType = EnumReferenceTable.JobType.ToString(); accountRef.AccountId = _mAccountRepository.Get(formCollection["AccountId"]); accountRef.CreatedDate = DateTime.Now; accountRef.CreatedBy = User.Identity.Name; accountRef.DataStatus = EnumDataStatus.New.ToString(); _mAccountRefRepository.Save(accountRef); _mJobTypeRepository.DbContext.CommitChanges(); } catch (Exception e) { _mJobTypeRepository.DbContext.RollbackTransaction(); //throw e.GetBaseException(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }