public Barring SoftDeleteObject(Barring barring, IItemTypeService _itemTypeService, IWarehouseItemService _warehouseItemService, IPriceMutationService _priceMutationService) { if (_validator.ValidDeleteObject(barring, _itemTypeService, _warehouseItemService)) { IList <WarehouseItem> allwarehouseitems = _warehouseItemService.GetObjectsByItemId(barring.Id); foreach (var warehouseitem in allwarehouseitems) { IWarehouseItemValidator warehouseItemValidator = _warehouseItemService.GetValidator(); if (!warehouseItemValidator.ValidDeleteObject(warehouseitem)) { barring.Errors.Add("Generic", "Tidak bisa menghapus item yang berhubungan dengan warehouse"); return(barring); } } foreach (var warehouseitem in allwarehouseitems) { _warehouseItemService.SoftDeleteObject(warehouseitem); } _repository.SoftDeleteObject(barring); IList <PriceMutation> priceMutations = _priceMutationService.GetActiveObjectsByItemId(barring.Id); foreach (var priceMutation in priceMutations) { _priceMutationService.DeactivateObject(priceMutation, barring.DeletedAt); } } return(barring); }
public CustomPurchaseInvoice ConfirmObject(CustomPurchaseInvoice customPurchaseInvoice, DateTime ConfirmationDate, ICustomPurchaseInvoiceDetailService _customPurchaseInvoiceDetailService, IContactService _contactService, IPriceMutationService _priceMutationService, IPayableService _payableService, ICustomPurchaseInvoiceService _customPurchaseInvoiceService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { customPurchaseInvoice.ConfirmationDate = ConfirmationDate; if (_validator.ValidConfirmObject(customPurchaseInvoice, _customPurchaseInvoiceDetailService, _customPurchaseInvoiceService, _warehouseItemService, _contactService, _closingService)) { IList <CustomPurchaseInvoiceDetail> customPurchaseInvoiceDetails = _customPurchaseInvoiceDetailService.GetObjectsByCustomPurchaseInvoiceId(customPurchaseInvoice.Id); customPurchaseInvoice.Total = 0; customPurchaseInvoice.CoGS = 0; foreach (var customPurchaseInvoiceDetail in customPurchaseInvoiceDetails) { customPurchaseInvoiceDetail.Errors = new Dictionary <string, string>(); _customPurchaseInvoiceDetailService.ConfirmObject(customPurchaseInvoiceDetail, _customPurchaseInvoiceService, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService, _priceMutationService); customPurchaseInvoice.Total += customPurchaseInvoiceDetail.Amount; customPurchaseInvoice.CoGS += customPurchaseInvoiceDetail.CoGS; } // Tax dihitung setelah discount //customPurchaseInvoice.Total = (customPurchaseInvoice.Total * (100 - customPurchaseInvoice.Discount) / 100) * (100 - customPurchaseInvoice.Tax) / 100; customPurchaseInvoice.Total = CalculateTotalAmountAfterDiscountAndTax(customPurchaseInvoice); Payable payable = _payableService.CreateObject(customPurchaseInvoice.ContactId, Core.Constants.Constant.PayableSource.CustomPurchaseInvoice, customPurchaseInvoice.Id, customPurchaseInvoice.Code, customPurchaseInvoice.Total, (DateTime)customPurchaseInvoice.DueDate.GetValueOrDefault()); _generalLedgerJournalService.CreateConfirmationJournalForCustomPurchaseInvoice(customPurchaseInvoice, _accountService); customPurchaseInvoice = _repository.ConfirmObject(customPurchaseInvoice); } else { customPurchaseInvoice.ConfirmationDate = null; } return(customPurchaseInvoice); }
public CashSalesReturn ConfirmObject(CashSalesReturn cashSalesReturn, DateTime ConfirmationDate, decimal Allowance, ICashSalesReturnDetailService _cashSalesReturnDetailService, IContactService _contactService, ICashSalesInvoiceService _cashSalesInvoiceService, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, IPriceMutationService _priceMutationService, IPayableService _payableService, ICashSalesReturnService _cashSalesReturnService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService, IClosingService _closingService) { cashSalesReturn.ConfirmationDate = ConfirmationDate; cashSalesReturn.Allowance = Allowance; if (_validator.ValidConfirmObject(cashSalesReturn, _cashSalesReturnDetailService, _cashSalesReturnService, _cashSalesInvoiceService, _cashSalesInvoiceDetailService)) { IList <CashSalesReturnDetail> cashSalesReturnDetails = _cashSalesReturnDetailService.GetObjectsByCashSalesReturnId(cashSalesReturn.Id); foreach (var cashSalesReturnDetail in cashSalesReturnDetails) { cashSalesReturnDetail.Errors = new Dictionary <string, string>(); _cashSalesReturnDetailService.ConfirmObject(cashSalesReturnDetail, _cashSalesReturnService, _cashSalesInvoiceService, _cashSalesInvoiceDetailService, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService, _cashSalesReturnDetailService); } // DueDate untuk Payable dari mana ? Contact contact = _contactService.GetObjectByName(Core.Constants.Constant.BaseContact); Payable payable = _payableService.CreateObject(contact.Id, Core.Constants.Constant.PayableSource.CashSalesReturn, cashSalesReturn.Id, cashSalesReturn.Code, cashSalesReturn.Total, ConfirmationDate.Add(Core.Constants.Constant.PaymentDueDateTimeSpan)); cashSalesReturn = _repository.ConfirmObject(cashSalesReturn); } else { cashSalesReturn.ConfirmationDate = null; cashSalesReturn.Allowance = 0; } return(cashSalesReturn); }
public Item UpdateLegacyObject(Item item, IUoMService _uomService, IItemTypeService _itemTypeService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IBarringService _barringService, IContactService _contactService, IMachineService _machineService, IPriceMutationService _priceMutationService, IContactGroupService _contactGroupService) { Barring barring = _barringService.GetObjectById(item.Id); if (barring != null) { _barringService.UpdateObject(barring, _barringService, _uomService, this, _itemTypeService, _contactService, _machineService, _warehouseItemService, _warehouseService, _contactGroupService, _priceMutationService); return(barring); } if (_validator.ValidUpdateLegacyObject(item, _uomService, this, _itemTypeService)) { ContactGroup contactGroup = _contactGroupService.GetObjectByIsLegacy(true); Item olditem = _repository.GetObjectById(item.Id); // Note: olditem might be pointing to the same memory with item (share the same contents) PriceMutation oldpriceMutation = _priceMutationService.GetObjectById(item.PriceMutationId); if (olditem.SellingPrice != item.SellingPrice) { DateTime priceMutationTimeStamp = DateTime.Now; PriceMutation priceMutation = _priceMutationService.CreateObject(item, /*contactGroup,*/ priceMutationTimeStamp); item.PriceMutationId = priceMutation.Id; _priceMutationService.DeactivateObject(oldpriceMutation, priceMutationTimeStamp); } item = _repository.UpdateObject(item); } return(item); }
public CustomPurchaseInvoiceController() { _contactService = new ContactService(new ContactRepository(), new ContactValidator()); _itemService = new ItemService(new ItemRepository(), new ItemValidator()); _itemTypeService = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator()); _uoMService = new UoMService(new UoMRepository(), new UoMValidator()); _warehouseItemService = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator()); _warehouseService = new WarehouseService(new WarehouseRepository(), new WarehouseValidator()); _stockMutationService = new StockMutationService(new StockMutationRepository(), new StockMutationValidator()); _barringService = new BarringService(new BarringRepository(), new BarringValidator()); _priceMutationService = new PriceMutationService(new PriceMutationRepository(), new PriceMutationValidator()); _contactGroupService = new ContactGroupService(new ContactGroupRepository(), new ContactGroupValidator()); _purchaseOrderDetailService = new PurchaseOrderDetailService(new PurchaseOrderDetailRepository(), new PurchaseOrderDetailValidator()); _salesOrderDetailService = new SalesOrderDetailService(new SalesOrderDetailRepository(), new SalesOrderDetailValidator()); _stockAdjustmentDetailService = new StockAdjustmentDetailService(new StockAdjustmentDetailRepository(), new StockAdjustmentDetailValidator()); _cashBankService = new CashBankService(new CashBankRepository(), new CashBankValidator()); _cashMutationService = new CashMutationService(new CashMutationRepository(), new CashMutationValidator()); _customPurchaseInvoiceService = new CustomPurchaseInvoiceService(new CustomPurchaseInvoiceRepository(), new CustomPurchaseInvoiceValidator()); _customPurchaseInvoiceDetailService = new CustomPurchaseInvoiceDetailService(new CustomPurchaseInvoiceDetailRepository(), new CustomPurchaseInvoiceDetailValidator()); _cashSalesReturnService = new CashSalesReturnService(new CashSalesReturnRepository(), new CashSalesReturnValidator()); _quantityPricingService = new QuantityPricingService(new QuantityPricingRepository(), new QuantityPricingValidator()); _payableService = new PayableService(new PayableRepository(), new PayableValidator()); _paymentVoucherService = new PaymentVoucherService(new PaymentVoucherRepository(), new PaymentVoucherValidator()); _paymentVoucherDetailService = new PaymentVoucherDetailService(new PaymentVoucherDetailRepository(), new PaymentVoucherDetailValidator()); _receivableService = new ReceivableService(new ReceivableRepository(), new ReceivableValidator()); _accountService = new AccountService(new AccountRepository(), new AccountValidator()); _generalLedgerJournalService = new GeneralLedgerJournalService(new GeneralLedgerJournalRepository(), new GeneralLedgerJournalValidator()); _closingService = new ClosingService(new ClosingRepository(), new ClosingValidator()); _validCombService = new ValidCombService(new ValidCombRepository(), new ValidCombValidator()); }
public RetailSalesInvoice ConfirmObject(RetailSalesInvoice retailSalesInvoice, DateTime ConfirmationDate, int ContactId, IRetailSalesInvoiceDetailService _retailSalesInvoiceDetailService, IContactService _contactService, IPriceMutationService _priceMutationService, IReceivableService _receivableService, IRetailSalesInvoiceService _retailSalesInvoiceService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService, IClosingService _closingService) { retailSalesInvoice.ContactId = ContactId; retailSalesInvoice.ConfirmationDate = ConfirmationDate; if (_validator.ValidConfirmObject(retailSalesInvoice, _retailSalesInvoiceDetailService, _retailSalesInvoiceService, _warehouseItemService, _contactService)) { IList <RetailSalesInvoiceDetail> retailSalesInvoiceDetails = _retailSalesInvoiceDetailService.GetObjectsByRetailSalesInvoiceId(retailSalesInvoice.Id); retailSalesInvoice.Total = 0; retailSalesInvoice.CoGS = 0; foreach (var retailSalesInvoiceDetail in retailSalesInvoiceDetails) { retailSalesInvoiceDetail.Errors = new Dictionary <string, string>(); _retailSalesInvoiceDetailService.ConfirmObject(retailSalesInvoiceDetail, _retailSalesInvoiceService, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService); retailSalesInvoice.Total += retailSalesInvoiceDetail.Amount; retailSalesInvoice.CoGS += retailSalesInvoiceDetail.CoGS; } // Tax dihitung setelah Discount retailSalesInvoice.Total = (retailSalesInvoice.Total * ((100 - retailSalesInvoice.Discount) / 100) * ((100 + retailSalesInvoice.Tax) / 100)); Receivable receivable = _receivableService.CreateObject(retailSalesInvoice.ContactId, Core.Constants.Constant.ReceivableSource.RetailSalesInvoice, retailSalesInvoice.Id, retailSalesInvoice.Code, retailSalesInvoice.Total, (DateTime)retailSalesInvoice.DueDate.GetValueOrDefault()); retailSalesInvoice = _repository.ConfirmObject(retailSalesInvoice); } else { retailSalesInvoice.ConfirmationDate = null; //retailSalesInvoice.ContactId = 0; //null; } return(retailSalesInvoice); }
public MstBarringController() { _itemTypeService = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator()); _warehouseItemService = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator()); _itemService = new ItemService(new ItemRepository(), new ItemValidator()); _uomService = new UoMService(new UoMRepository(), new UoMValidator()); _warehouseService = new WarehouseService(new WarehouseRepository(), new WarehouseValidator()); _machineService = new MachineService(new MachineRepository(), new MachineValidator()); _barringService = new BarringService(new BarringRepository(), new BarringValidator()); _contactService = new ContactService(new ContactRepository(), new ContactValidator()); _contactGroupService = new ContactGroupService(new ContactGroupRepository(), new ContactGroupValidator()); _priceMutationService = new PriceMutationService(new PriceMutationRepository(), new PriceMutationValidator()); }
public Item CreateLegacyObject(Item item, IUoMService _uomService, IItemTypeService _itemTypeService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IPriceMutationService _priceMutationService, IContactGroupService _contactGroupService) { item.Errors = new Dictionary <String, String>(); if (_validator.ValidCreateLegacyObject(item, _uomService, this, _itemTypeService)) { ContactGroup contactGroup = _contactGroupService.GetObjectByIsLegacy(true); item = _repository.CreateObject(item); PriceMutation priceMutation = _priceMutationService.CreateObject(item, /*contactGroup,*/ item.CreatedAt); item.PriceMutationId = priceMutation.Id; _repository.UpdateObject(item); } return(item); }
public GroupItemPrice VHasDifferentPrice(GroupItemPrice groupItemPrice, IPriceMutationService _priceMutationService) { IList <PriceMutation> priceMutations = _priceMutationService.GetObjectsByIsActive(true, groupItemPrice.ItemId /*, groupItemPrice.ContactGroupId*/, 0); foreach (var priceMutation in priceMutations) { if (groupItemPrice.Price == priceMutation.Amount) { groupItemPrice.Errors.Add("Price", "Tidak boleh sama dengan current active price"); return(groupItemPrice); } } return(groupItemPrice); }
public Barring CreateObject(Barring barring, IBarringService _barringService, IUoMService _uomService, IItemService _itemService, IItemTypeService _itemTypeService, IContactService _contactService, IMachineService _machineService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IPriceMutationService _priceMutationService, IContactGroupService _contactGroupService) { barring.Errors = new Dictionary <String, String>(); if (_validator.ValidCreateObject(barring, _barringService, _uomService, _itemService, _itemTypeService, _contactService, _machineService)) { ContactGroup contactGroup = _contactGroupService.GetObjectByIsLegacy(true); barring = _repository.CreateObject(barring); PriceMutation priceMutation = _priceMutationService.CreateObject(barring, /*contactGroup,*/ barring.CreatedAt); barring.PriceMutationId = priceMutation.Id; barring = _repository.UpdateObject(barring); } return(barring); }
public CoreBuilder CreateObject(string BaseSku, string SkuNewCore, string SkuUsedCore, string Name, string Category, int UoMId, IUoMService _uomService, IItemService _itemService, IItemTypeService _itemTypeService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IPriceMutationService _priceMutationService, IContactGroupService _contactGroupService) { CoreBuilder coreBuilder = new CoreBuilder { BaseSku = BaseSku, SkuNewCore = SkuNewCore, SkuUsedCore = SkuUsedCore, Name = Name, Category = Category, UoMId = UoMId }; return(this.CreateObject(coreBuilder, _uomService, _itemService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService)); }
public MstItemController() { _itemService = new ItemService(new ItemRepository(), new ItemValidator()); _itemTypeService = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator()); _uoMService = new UoMService(new UoMRepository(), new UoMValidator()); _warehouseItemService = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator()); _warehouseService = new WarehouseService(new WarehouseRepository(), new WarehouseValidator()); _stockMutationService = new StockMutationService(new StockMutationRepository(), new StockMutationValidator()); _barringService = new BarringService(new BarringRepository(), new BarringValidator()); _contactService = new ContactService(new ContactRepository(), new ContactValidator()); _priceMutationService = new PriceMutationService(new PriceMutationRepository(), new PriceMutationValidator()); _contactGroupService = new ContactGroupService(new ContactGroupRepository(), new ContactGroupValidator()); _purchaseOrderDetailService = new PurchaseOrderDetailService(new PurchaseOrderDetailRepository(), new PurchaseOrderDetailValidator()); _stockAdjustmentDetailService = new StockAdjustmentDetailService(new StockAdjustmentDetailRepository(), new StockAdjustmentDetailValidator()); _salesOrderDetailService = new SalesOrderDetailService(new SalesOrderDetailRepository(), new SalesOrderDetailValidator()); _machineService = new MachineService(new MachineRepository(), new MachineValidator()); }
public Barring UpdateObject(Barring barring, IBarringService _barringService, IUoMService _uomService, IItemService _itemService, IItemTypeService _itemTypeService, IContactService _contactService, IMachineService _machineService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IContactGroupService _contactGroupService, IPriceMutationService _priceMutationService) { if (_validator.ValidUpdateObject(barring, _barringService, _uomService, _itemService, _itemTypeService, _contactService, _machineService)) { ContactGroup contactGroup = _contactGroupService.GetObjectByIsLegacy(true); Barring oldbarring = _repository.GetObjectById(barring.Id); PriceMutation oldpriceMutation = _priceMutationService.GetObjectById(barring.PriceMutationId); if (oldbarring.SellingPrice != barring.SellingPrice) { DateTime priceMutationTimeStamp = DateTime.Now; PriceMutation priceMutation = _priceMutationService.CreateObject(oldbarring, /*contactGroup,*/ priceMutationTimeStamp); barring.PriceMutationId = priceMutation.Id; _priceMutationService.DeactivateObject(oldpriceMutation, priceMutationTimeStamp); } _repository.UpdateObject(barring); } return(barring); }
public CashSalesInvoice ConfirmObject(CashSalesInvoice cashSalesInvoice, DateTime ConfirmationDate, decimal Discount, decimal Tax, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, IContactService _contactService, IPriceMutationService _priceMutationService, IReceivableService _receivableService, ICashSalesInvoiceService _cashSalesInvoiceService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService, ICashBankService _cashBankService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { cashSalesInvoice.ConfirmationDate = ConfirmationDate; if (_validator.ValidConfirmObject(cashSalesInvoice, _cashSalesInvoiceDetailService, _cashSalesInvoiceService, _warehouseItemService, _contactService, _cashBankService, _closingService)) { cashSalesInvoice.Discount = Discount; cashSalesInvoice.Tax = Tax; IList <CashSalesInvoiceDetail> cashSalesInvoiceDetails = _cashSalesInvoiceDetailService.GetObjectsByCashSalesInvoiceId(cashSalesInvoice.Id); cashSalesInvoice.Total = 0; cashSalesInvoice.CoGS = 0; foreach (var cashSalesInvoiceDetail in cashSalesInvoiceDetails) { cashSalesInvoiceDetail.Errors = new Dictionary <string, string>(); _cashSalesInvoiceDetailService.ConfirmObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService); cashSalesInvoice.Total += cashSalesInvoiceDetail.Amount; cashSalesInvoice.CoGS += cashSalesInvoiceDetail.CoGS; } // Tax dihitung setelah Discount cashSalesInvoice.Total = (cashSalesInvoice.Total * ((100 - cashSalesInvoice.Discount) / 100) * ((100 + cashSalesInvoice.Tax) / 100)); Contact contact = _contactService.GetObjectByName(Core.Constants.Constant.BaseContact); Receivable receivable = _receivableService.CreateObject(contact.Id, Core.Constants.Constant.ReceivableSource.CashSalesInvoice, cashSalesInvoice.Id, cashSalesInvoice.Code, cashSalesInvoice.Total, (DateTime)cashSalesInvoice.DueDate.GetValueOrDefault()); _generalLedgerJournalService.CreateConfirmationJournalForCashSalesInvoice(cashSalesInvoice, _accountService); cashSalesInvoice = _repository.ConfirmObject(cashSalesInvoice); } else { cashSalesInvoice.ConfirmationDate = null; } return(cashSalesInvoice); }
public MstCoreBuilderController() { _coreBuilderService = new CoreBuilderService(new CoreBuilderRepository(), new CoreBuilderValidator()); _itemTypeService = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator()); _rollerBuilderService = new RollerBuilderService(new RollerBuilderRepository(), new RollerBuilderValidator()); _coreIdentificationDetailService = new CoreIdentificationDetailService(new CoreIdentificationDetailRepository(), new CoreIdentificationDetailValidator()); _recoveryOrderDetailService = new RecoveryOrderDetailService(new RecoveryOrderDetailRepository(), new RecoveryOrderDetailValidator()); _recoveryAccessoryDetailService = new RecoveryAccessoryDetailService(new RecoveryAccessoryDetailRepository(), new RecoveryAccessoryDetailValidator()); _warehouseItemService = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator()); _stockMutationService = new StockMutationService(new StockMutationRepository(), new StockMutationValidator()); _itemService = new ItemService(new ItemRepository(), new ItemValidator()); _uomService = new UoMService(new UoMRepository(), new UoMValidator()); _warehouseService = new WarehouseService(new WarehouseRepository(), new WarehouseValidator()); _barringService = new BarringService(new BarringRepository(), new BarringValidator()); _contactService = new ContactService(new ContactRepository(), new ContactValidator()); _priceMutationService = new PriceMutationService(new PriceMutationRepository(), new PriceMutationValidator()); _contactGroupService = new ContactGroupService(new ContactGroupRepository(), new ContactGroupValidator()); _purchaseOrderDetailService = new PurchaseOrderDetailService(new PurchaseOrderDetailRepository(), new PurchaseOrderDetailValidator()); _stockAdjustmentDetailService = new StockAdjustmentDetailService(new StockAdjustmentDetailRepository(), new StockAdjustmentDetailValidator()); _salesOrderDetailService = new SalesOrderDetailService(new SalesOrderDetailRepository(), new SalesOrderDetailValidator()); _machineService = new MachineService(new MachineRepository(), new MachineValidator()); _rollerTypeService = new RollerTypeService(new RollerTypeRepository(), new RollerTypeValidator()); }
public RollerBuilder CreateObject(string BaseSku, string SkuRollerNewCore, string SkuRollerUsedCore, string Name, string Category, int CD, int RD, int RL, int WL, int TL, IMachineService _machineService, IUoMService _uomService, IItemService _itemService, IItemTypeService _itemTypeService, ICoreBuilderService _coreBuilderService, IRollerTypeService _rollerTypeService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IPriceMutationService _priceMutationService, IContactGroupService _contactGroupService) { RollerBuilder rollerBuilder = new RollerBuilder { BaseSku = BaseSku, SkuRollerNewCore = SkuRollerNewCore, SkuRollerUsedCore = SkuRollerUsedCore, Name = Name, Category = Category, CD = CD, RD = RD, RL = RL, WL = WL, TL = TL }; return(this.CreateObject(rollerBuilder, _machineService, _uomService, _itemService, _itemTypeService, _coreBuilderService, _rollerTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService)); }
public GroupItemPrice VUpdateObject(GroupItemPrice groupItemPrice, int oldGroupId, int oldItemId, IGroupItemPriceService _groupItemPriceService, IPriceMutationService _priceMutationService) { // TODO Bugfix: oldgroupItemPrice seems to have the same content with groupItemPrice causing new itemid/groupid looks the same with old id //GroupItemPrice oldgroupItemPrice = _groupItemPriceService.GetObjectById(groupItemPrice.Id); VSameGroupId(groupItemPrice, oldGroupId); if (!isValid(groupItemPrice)) { return(groupItemPrice); } VSameItemId(groupItemPrice, oldItemId); if (!isValid(groupItemPrice)) { return(groupItemPrice); } VHasDifferentPrice(groupItemPrice, _priceMutationService); if (!isValid(groupItemPrice)) { return(groupItemPrice); } VNonNegativePrice(groupItemPrice); return(groupItemPrice); }
public GroupItemPrice UpdateObject(GroupItemPrice groupItemPrice, int oldGroupId, int oldItemId, IItemService _itemService, IPriceMutationService _priceMutationService) { if (_validator.ValidUpdateObject(groupItemPrice, oldGroupId, oldItemId, this, _priceMutationService)) { Item item = _itemService.GetObjectById(groupItemPrice.ItemId); PriceMutation oldpriceMutation = _priceMutationService.GetObjectById(item.PriceMutationId); groupItemPrice.UpdatedAt = DateTime.Now; PriceMutation priceMutation = _priceMutationService.CreateObject(item.Id, /*groupItemPrice.ContactGroupId,*/ item.SellingPrice, (DateTime)groupItemPrice.UpdatedAt.GetValueOrDefault()); groupItemPrice.PriceMutationId = priceMutation.Id; groupItemPrice = _repository.UpdateObject(groupItemPrice); _priceMutationService.DeactivateObject(oldpriceMutation, groupItemPrice.UpdatedAt); } return(groupItemPrice); }
public GroupItemPrice CreateObject(GroupItemPrice groupItemPrice, IContactGroupService _contactGroupService, IItemService _itemService, IPriceMutationService _priceMutationService) { groupItemPrice.Errors = new Dictionary <String, String>(); if (_validator.ValidCreateObject(groupItemPrice, this, _contactGroupService, _itemService)) { Item item = _itemService.GetObjectById(groupItemPrice.ItemId); groupItemPrice.CreatedAt = DateTime.Now; PriceMutation priceMutation = _priceMutationService.CreateObject(item.Id, /*groupItemPrice.ContactGroupId,*/ item.SellingPrice, groupItemPrice.CreatedAt); groupItemPrice.PriceMutationId = priceMutation.Id; groupItemPrice = _repository.CreateObject(groupItemPrice); } return(groupItemPrice); }
public CustomPurchaseInvoiceDetail ConfirmObject(CustomPurchaseInvoiceDetail customPurchaseInvoiceDetail, ICustomPurchaseInvoiceService _customPurchaseInvoiceService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService, IPriceMutationService _priceMutationService) { if (_validator.ValidConfirmObject(customPurchaseInvoiceDetail, _customPurchaseInvoiceService, _warehouseItemService)) { CustomPurchaseInvoice customPurchaseInvoice = _customPurchaseInvoiceService.GetObjectById(customPurchaseInvoiceDetail.CustomPurchaseInvoiceId); WarehouseItem warehouseItem = _warehouseItemService.FindOrCreateObject(customPurchaseInvoice.WarehouseId, customPurchaseInvoiceDetail.ItemId); Item item = _itemService.GetObjectById(customPurchaseInvoiceDetail.ItemId); StockMutation stockMutation = new StockMutation() { ItemId = customPurchaseInvoiceDetail.ItemId, ItemCase = Core.Constants.Constant.ItemCase.Ready, Status = Core.Constants.Constant.MutationStatus.Addition, Quantity = customPurchaseInvoiceDetail.Quantity, SourceDocumentCode = customPurchaseInvoice.Code, SourceDocumentId = customPurchaseInvoice.Id, SourceDocumentType = Core.Constants.Constant.SourceDocumentType.CustomPurchaseInvoice, SourceDocumentDetailCode = customPurchaseInvoiceDetail.Code, SourceDocumentDetailId = customPurchaseInvoiceDetail.Id, SourceDocumentDetailType = Core.Constants.Constant.SourceDocumentDetailType.CustomPurchaseInvoiceDetail, WarehouseId = customPurchaseInvoice.WarehouseId, WarehouseItemId = warehouseItem.Id }; decimal hiPrice = GetHighestPrice(/*customPurchaseInvoice.Id,*/ customPurchaseInvoiceDetail.ItemId); decimal newPrice = hiPrice * (100 + item.Margin) / 100; if (newPrice > item.SellingPrice) { item.SellingPrice = newPrice; PriceMutation priceMutation = _priceMutationService.CreateObject(item.Id, item.SellingPrice, DateTime.Now); item.PriceMutationId = priceMutation.Id; } decimal itemPrice = customPurchaseInvoiceDetail.Amount / customPurchaseInvoiceDetail.Quantity; item.AvgPrice = _itemService.CalculateAndUpdateAvgPrice(item, customPurchaseInvoiceDetail.Quantity, itemPrice); stockMutation = _stockMutationService.CreateObject(stockMutation, _warehouseService, _warehouseItemService, _itemService, _barringService); stockMutation.CreatedAt = (DateTime)customPurchaseInvoice.ConfirmationDate.GetValueOrDefault(); _stockMutationService.UpdateObject(stockMutation, _warehouseService, _warehouseItemService, _itemService, _barringService); _stockMutationService.StockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService); customPurchaseInvoiceDetail.CoGS = customPurchaseInvoiceDetail.Quantity * item.AvgPrice; customPurchaseInvoiceDetail = _repository.ConfirmObject(customPurchaseInvoiceDetail); } return(customPurchaseInvoiceDetail); }
public Item SoftDeleteLegacyObject(Item item, IStockMutationService _stockMutationService, IItemTypeService _itemTypeService, IWarehouseItemService _warehouseItemService, IBarringService _barringService, IPurchaseOrderDetailService _purchaseOrderDetailService, IStockAdjustmentDetailService _stockAdjustmentDetailService, ISalesOrderDetailService _salesOrderDetailService, IPriceMutationService _priceMutationService) { Barring barring = _barringService.GetObjectById(item.Id); if (barring != null) { _barringService.SoftDeleteObject(barring, _itemTypeService, _warehouseItemService, _priceMutationService); return(barring); } if (_validator.ValidDeleteLegacyObject(item, _stockMutationService, _itemTypeService, _warehouseItemService, _purchaseOrderDetailService, _stockAdjustmentDetailService, _salesOrderDetailService)) { IList <WarehouseItem> allwarehouseitems = _warehouseItemService.GetObjectsByItemId(item.Id); foreach (var warehouseitem in allwarehouseitems) { IWarehouseItemValidator warehouseItemValidator = _warehouseItemService.GetValidator(); if (!warehouseItemValidator.ValidDeleteObject(warehouseitem)) { item.Errors.Add("Generic", "Tidak bisa menghapus item yang berhubungan dengan warehouse"); return(item); } } foreach (var warehouseitem in allwarehouseitems) { _warehouseItemService.SoftDeleteObject(warehouseitem); } _repository.SoftDeleteObject(item); IList <PriceMutation> priceMutations = _priceMutationService.GetActiveObjectsByItemId(item.Id); foreach (var priceMutation in priceMutations) { _priceMutationService.DeactivateObject(priceMutation, item.DeletedAt); } } return(item); }
void before_each() { var db = new OffsetPrintingSuppliesEntities(); using (db) { db.DeleteAllTables(); itemService = new ItemService(new ItemRepository(), new ItemValidator()); contactService = new ContactService(new ContactRepository(), new ContactValidator()); poService = new PurchaseOrderService(new PurchaseOrderRepository(), new PurchaseOrderValidator()); poDetailService = new PurchaseOrderDetailService(new PurchaseOrderDetailRepository(), new PurchaseOrderDetailValidator()); _stockMutationService = new StockMutationService(new StockMutationRepository(), new StockMutationValidator()); _itemTypeService = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator()); _uomService = new UoMService(new UoMRepository(), new UoMValidator()); _warehouseItemService = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator()); _warehouseService = new WarehouseService(new WarehouseRepository(), new WarehouseValidator()); _barringService = new BarringService(new BarringRepository(), new BarringValidator()); _itemService = new ItemService(new ItemRepository(), new ItemValidator()); _stockAdjustmentService = new StockAdjustmentService(new StockAdjustmentRepository(), new StockAdjustmentValidator()); _stockAdjustmentDetailService = new StockAdjustmentDetailService(new StockAdjustmentDetailRepository(), new StockAdjustmentDetailValidator()); _accountService = new AccountService(new AccountRepository(), new AccountValidator()); _closingService = new ClosingService(new ClosingRepository(), new ClosingValidator()); _generalLedgerJournalService = new GeneralLedgerJournalService(new GeneralLedgerJournalRepository(), new GeneralLedgerJournalValidator()); _priceMutationService = new PriceMutationService(new PriceMutationRepository(), new PriceMutationValidator()); _contactGroupService = new ContactGroupService(new ContactGroupRepository(), new ContactGroupValidator()); if (!_accountService.GetLegacyObjects().Any()) { Asset = _accountService.CreateLegacyObject(new Account() { Name = "Asset", Code = Constant.AccountCode.Asset, LegacyCode = Constant.AccountLegacyCode.Asset, Level = 1, Group = Constant.AccountGroup.Asset, IsLegacy = true }, _accountService); CashBank = _accountService.CreateLegacyObject(new Account() { Name = "CashBank", Code = Constant.AccountCode.CashBank, LegacyCode = Constant.AccountLegacyCode.CashBank, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true }, _accountService); AccountReceivable = _accountService.CreateLegacyObject(new Account() { Name = "Account Receivable", IsLeaf = true, Code = Constant.AccountCode.AccountReceivable, LegacyCode = Constant.AccountLegacyCode.AccountReceivable, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true }, _accountService); GBCHReceivable = _accountService.CreateLegacyObject(new Account() { Name = "GBCH Receivable", IsLeaf = true, Code = Constant.AccountCode.GBCHReceivable, LegacyCode = Constant.AccountLegacyCode.GBCHReceivable, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true }, _accountService); Inventory = _accountService.CreateLegacyObject(new Account() { Name = "Inventory", IsLeaf = true, Code = Constant.AccountCode.Inventory, LegacyCode = Constant.AccountLegacyCode.Inventory, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true }, _accountService); Expense = _accountService.CreateLegacyObject(new Account() { Name = "Expense", Code = Constant.AccountCode.Expense, LegacyCode = Constant.AccountLegacyCode.Expense, Level = 1, Group = Constant.AccountGroup.Expense, IsLegacy = true }, _accountService); CashBankAdjustmentExpense = _accountService.CreateLegacyObject(new Account() { Name = "CashBank Adjustment Expense", IsLeaf = true, Code = Constant.AccountCode.CashBankAdjustmentExpense, LegacyCode = Constant.AccountLegacyCode.CashBankAdjustmentExpense, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); COGS = _accountService.CreateLegacyObject(new Account() { Name = "Cost Of Goods Sold", IsLeaf = true, Code = Constant.AccountCode.COGS, LegacyCode = Constant.AccountLegacyCode.COGS, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); Discount = _accountService.CreateLegacyObject(new Account() { Name = "Discount", IsLeaf = true, Code = Constant.AccountCode.Discount, LegacyCode = Constant.AccountLegacyCode.Discount, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); SalesAllowance = _accountService.CreateLegacyObject(new Account() { Name = "Sales Allowance", IsLeaf = true, Code = Constant.AccountCode.SalesAllowance, LegacyCode = Constant.AccountLegacyCode.SalesAllowance, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); StockAdjustmentExpense = _accountService.CreateLegacyObject(new Account() { Name = "Stock Adjustment Expense", IsLeaf = true, Code = Constant.AccountCode.StockAdjustmentExpense, LegacyCode = Constant.AccountLegacyCode.StockAdjustmentExpense, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); Liability = _accountService.CreateLegacyObject(new Account() { Name = "Liability", Code = Constant.AccountCode.Liability, LegacyCode = Constant.AccountLegacyCode.Liability, Level = 1, Group = Constant.AccountGroup.Liability, IsLegacy = true }, _accountService); AccountPayable = _accountService.CreateLegacyObject(new Account() { Name = "Account Payable", IsLeaf = true, Code = Constant.AccountCode.AccountPayable, LegacyCode = Constant.AccountLegacyCode.AccountPayable, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true }, _accountService); GBCHPayable = _accountService.CreateLegacyObject(new Account() { Name = "GBCH Payable", IsLeaf = true, Code = Constant.AccountCode.GBCHPayable, LegacyCode = Constant.AccountLegacyCode.GBCHPayable, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true }, _accountService); GoodsPendingClearance = _accountService.CreateLegacyObject(new Account() { Name = "Goods Pending Clearance", IsLeaf = true, Code = Constant.AccountCode.GoodsPendingClearance, LegacyCode = Constant.AccountLegacyCode.GoodsPendingClearance, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true }, _accountService); Equity = _accountService.CreateLegacyObject(new Account() { Name = "Equity", Code = Constant.AccountCode.Equity, LegacyCode = Constant.AccountLegacyCode.Equity, Level = 1, Group = Constant.AccountGroup.Equity, IsLegacy = true }, _accountService); OwnersEquity = _accountService.CreateLegacyObject(new Account() { Name = "Owners Equity", Code = Constant.AccountCode.OwnersEquity, LegacyCode = Constant.AccountLegacyCode.OwnersEquity, Level = 2, Group = Constant.AccountGroup.Equity, ParentId = Equity.Id, IsLegacy = true }, _accountService); EquityAdjustment = _accountService.CreateLegacyObject(new Account() { Name = "Equity Adjustment", IsLeaf = true, Code = Constant.AccountCode.EquityAdjustment, LegacyCode = Constant.AccountLegacyCode.EquityAdjustment, Level = 3, Group = Constant.AccountGroup.Equity, ParentId = OwnersEquity.Id, IsLegacy = true }, _accountService); Revenue = _accountService.CreateLegacyObject(new Account() { Name = "Revenue", IsLeaf = true, Code = Constant.AccountCode.Revenue, LegacyCode = Constant.AccountLegacyCode.Revenue, Level = 1, Group = Constant.AccountGroup.Revenue, IsLegacy = true }, _accountService); } baseGroup = _contactGroupService.CreateObject(Core.Constants.Constant.GroupType.Base, "Base Group", true); Pcs = new UoM() { Name = "Pcs" }; _uomService.CreateObject(Pcs); contact = new Contact() { Name = "President of Indonesia", Address = "Istana Negara Jl. Veteran No. 16 Jakarta Pusat", ContactNo = "021 3863777", PIC = "Mr. President", PICContactNo = "021 3863777", Email = "*****@*****.**" }; contact = contactService.CreateObject(contact, _contactGroupService); type = _itemTypeService.CreateObject("Item", "Item"); warehouse = new Warehouse() { Name = "Sentral Solusi Data", Description = "Kali Besar Jakarta", Code = "LCL" }; warehouse = _warehouseService.CreateObject(warehouse, _warehouseItemService, itemService); item1 = new Item() { ItemTypeId = _itemTypeService.GetObjectByName("Item").Id, Name = "Batik Tulis", Category = "Item", Sku = "bt123", UoMId = Pcs.Id }; itemService.CreateObject(item1, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService); item2 = new Item() { ItemTypeId = _itemTypeService.GetObjectByName("Item").Id, Name = "Buku Gambar", Category = "Item", Sku = "bg123", UoMId = Pcs.Id }; itemService.CreateObject(item2, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService); StockAdjustment sa = new StockAdjustment() { AdjustmentDate = DateTime.Today, WarehouseId = warehouse.Id, Description = "item adjustment" }; _stockAdjustmentService.CreateObject(sa, _warehouseService); StockAdjustmentDetail sadItem1 = new StockAdjustmentDetail() { ItemId = item1.Id, Quantity = 1000, StockAdjustmentId = sa.Id }; _stockAdjustmentDetailService.CreateObject(sadItem1, _stockAdjustmentService, _itemService, _warehouseItemService); StockAdjustmentDetail sadItem2 = new StockAdjustmentDetail() { ItemId = item2.Id, Quantity = 1000, StockAdjustmentId = sa.Id }; _stockAdjustmentDetailService.CreateObject(sadItem2, _stockAdjustmentService, _itemService, _warehouseItemService); _stockAdjustmentService.ConfirmObject(sa, DateTime.Today, _stockAdjustmentDetailService, _stockMutationService, _itemService, _barringService, _warehouseItemService, _generalLedgerJournalService, _accountService, _closingService); } }
public PurchaseBuilder() { _accountService = new AccountService(new AccountRepository(), new AccountValidator()); _barringService = new BarringService(new BarringRepository(), new BarringValidator()); _barringOrderService = new BarringOrderService(new BarringOrderRepository(), new BarringOrderValidator()); _barringOrderDetailService = new BarringOrderDetailService(new BarringOrderDetailRepository(), new BarringOrderDetailValidator()); _cashBankAdjustmentService = new CashBankAdjustmentService(new CashBankAdjustmentRepository(), new CashBankAdjustmentValidator()); _cashBankMutationService = new CashBankMutationService(new CashBankMutationRepository(), new CashBankMutationValidator()); _cashBankService = new CashBankService(new CashBankRepository(), new CashBankValidator()); _cashMutationService = new CashMutationService(new CashMutationRepository(), new CashMutationValidator()); _closingService = new ClosingService(new ClosingRepository(), new ClosingValidator()); _coreBuilderService = new CoreBuilderService(new CoreBuilderRepository(), new CoreBuilderValidator()); _coreIdentificationDetailService = new CoreIdentificationDetailService(new CoreIdentificationDetailRepository(), new CoreIdentificationDetailValidator()); _coreIdentificationService = new CoreIdentificationService(new CoreIdentificationRepository(), new CoreIdentificationValidator()); _contactService = new ContactService(new ContactRepository(), new ContactValidator()); _deliveryOrderService = new DeliveryOrderService(new DeliveryOrderRepository(), new DeliveryOrderValidator()); _deliveryOrderDetailService = new DeliveryOrderDetailService(new DeliveryOrderDetailRepository(), new DeliveryOrderDetailValidator()); _generalLedgerJournalService = new GeneralLedgerJournalService(new GeneralLedgerJournalRepository(), new GeneralLedgerJournalValidator()); _itemService = new ItemService(new ItemRepository(), new ItemValidator()); _itemTypeService = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator()); _machineService = new MachineService(new MachineRepository(), new MachineValidator()); _payableService = new PayableService(new PayableRepository(), new PayableValidator()); _paymentVoucherDetailService = new PaymentVoucherDetailService(new PaymentVoucherDetailRepository(), new PaymentVoucherDetailValidator()); _paymentVoucherService = new PaymentVoucherService(new PaymentVoucherRepository(), new PaymentVoucherValidator()); _purchaseInvoiceDetailService = new PurchaseInvoiceDetailService(new PurchaseInvoiceDetailRepository(), new PurchaseInvoiceDetailValidator()); _purchaseInvoiceService = new PurchaseInvoiceService(new PurchaseInvoiceRepository(), new PurchaseInvoiceValidator()); _purchaseOrderService = new PurchaseOrderService(new PurchaseOrderRepository(), new PurchaseOrderValidator()); _purchaseOrderDetailService = new PurchaseOrderDetailService(new PurchaseOrderDetailRepository(), new PurchaseOrderDetailValidator()); _purchaseReceivalService = new PurchaseReceivalService(new PurchaseReceivalRepository(), new PurchaseReceivalValidator()); _purchaseReceivalDetailService = new PurchaseReceivalDetailService(new PurchaseReceivalDetailRepository(), new PurchaseReceivalDetailValidator()); _receivableService = new ReceivableService(new ReceivableRepository(), new ReceivableValidator()); _receiptVoucherDetailService = new ReceiptVoucherDetailService(new ReceiptVoucherDetailRepository(), new ReceiptVoucherDetailValidator()); _receiptVoucherService = new ReceiptVoucherService(new ReceiptVoucherRepository(), new ReceiptVoucherValidator()); _recoveryOrderDetailService = new RecoveryOrderDetailService(new RecoveryOrderDetailRepository(), new RecoveryOrderDetailValidator()); _recoveryOrderService = new RecoveryOrderService(new RecoveryOrderRepository(), new RecoveryOrderValidator()); _recoveryAccessoryDetailService = new RecoveryAccessoryDetailService(new RecoveryAccessoryDetailRepository(), new RecoveryAccessoryDetailValidator()); _rollerBuilderService = new RollerBuilderService(new RollerBuilderRepository(), new RollerBuilderValidator()); _rollerTypeService = new RollerTypeService(new RollerTypeRepository(), new RollerTypeValidator()); _rollerWarehouseMutationDetailService = new RollerWarehouseMutationDetailService(new RollerWarehouseMutationDetailRepository(), new RollerWarehouseMutationDetailValidator()); _rollerWarehouseMutationService = new RollerWarehouseMutationService(new RollerWarehouseMutationRepository(), new RollerWarehouseMutationValidator()); _salesInvoiceDetailService = new SalesInvoiceDetailService(new SalesInvoiceDetailRepository(), new SalesInvoiceDetailValidator()); _salesInvoiceService = new SalesInvoiceService(new SalesInvoiceRepository(), new SalesInvoiceValidator()); _salesOrderService = new SalesOrderService(new SalesOrderRepository(), new SalesOrderValidator()); _salesOrderDetailService = new SalesOrderDetailService(new SalesOrderDetailRepository(), new SalesOrderDetailValidator()); _stockAdjustmentDetailService = new StockAdjustmentDetailService(new StockAdjustmentDetailRepository(), new StockAdjustmentDetailValidator()); _stockAdjustmentService = new StockAdjustmentService(new StockAdjustmentRepository(), new StockAdjustmentValidator()); _stockMutationService = new StockMutationService(new StockMutationRepository(), new StockMutationValidator()); _uomService = new UoMService(new UoMRepository(), new UoMValidator()); _validCombService = new ValidCombService(new ValidCombRepository(), new ValidCombValidator()); _warehouseItemService = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator()); _warehouseService = new WarehouseService(new WarehouseRepository(), new WarehouseValidator()); _warehouseMutationOrderService = new WarehouseMutationOrderService(new WarehouseMutationOrderRepository(), new WarehouseMutationOrderValidator()); _warehouseMutationOrderDetailService = new WarehouseMutationOrderDetailService(new WarehouseMutationOrderDetailRepository(), new WarehouseMutationOrderDetailValidator()); _priceMutationService = new PriceMutationService(new PriceMutationRepository(), new PriceMutationValidator()); _contactGroupService = new ContactGroupService(new ContactGroupRepository(), new ContactGroupValidator()); typeAccessory = _itemTypeService.CreateObject("Accessory", "Accessory"); typeBar = _itemTypeService.CreateObject("Bar", "Bar"); typeBarring = _itemTypeService.CreateObject("Barring", "Barring", true); typeBearing = _itemTypeService.CreateObject("Bearing", "Bearing"); typeBlanket = _itemTypeService.CreateObject("Blanket", "Blanket"); typeChemical = _itemTypeService.CreateObject("Chemical", "Chemical"); typeCompound = _itemTypeService.CreateObject("Compound", "Compound"); typeConsumable = _itemTypeService.CreateObject("Consumable", "Consumable"); typeCore = _itemTypeService.CreateObject("Core", "Core", true); typeGlue = _itemTypeService.CreateObject("Glue", "Glue"); typeUnderpacking = _itemTypeService.CreateObject("Underpacking", "Underpacking"); typeRoller = _itemTypeService.CreateObject("Roller", "Roller", true); typeDamp = _rollerTypeService.CreateObject("Damp", "Damp"); typeFoundDT = _rollerTypeService.CreateObject("Found DT", "Found DT"); typeInkFormX = _rollerTypeService.CreateObject("Ink Form X", "Ink Form X"); typeInkDistD = _rollerTypeService.CreateObject("Ink Dist D", "Ink Dist D"); typeInkDistM = _rollerTypeService.CreateObject("Ink Dist M", "Ink Dist M"); typeInkDistE = _rollerTypeService.CreateObject("Ink Dist E", "Ink Dist E"); typeInkDuctB = _rollerTypeService.CreateObject("Ink Duct B", "Ink Duct B"); typeInkDistH = _rollerTypeService.CreateObject("Ink Dist H", "Ink Dist H"); typeInkFormW = _rollerTypeService.CreateObject("Ink Form W", "Ink Form W"); typeInkDistHQ = _rollerTypeService.CreateObject("Ink Dist HQ", "Ink Dist HQ"); typeDampFormDQ = _rollerTypeService.CreateObject("Damp Form DQ", "Damp Form DQ"); typeInkFormY = _rollerTypeService.CreateObject("Ink Form Y", "Ink Form Y"); baseGroup = _contactGroupService.CreateObject(Core.Constants.Constant.GroupType.Base, "Base Group", true); if (!_accountService.GetLegacyObjects().Any()) { Asset = _accountService.CreateLegacyObject(new Account() { Name = "Asset", Code = Constant.AccountCode.Asset, LegacyCode = Constant.AccountLegacyCode.Asset, Level = 1, Group = Constant.AccountGroup.Asset, IsLegacy = true }, _accountService); CashBank = _accountService.CreateLegacyObject(new Account() { Name = "CashBank", Code = Constant.AccountCode.CashBank, LegacyCode = Constant.AccountLegacyCode.CashBank, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true }, _accountService); AccountReceivable = _accountService.CreateLegacyObject(new Account() { Name = "Account Receivable", IsLeaf = true, Code = Constant.AccountCode.AccountReceivable, LegacyCode = Constant.AccountLegacyCode.AccountReceivable, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true }, _accountService); GBCHReceivable = _accountService.CreateLegacyObject(new Account() { Name = "GBCH Receivable", IsLeaf = true, Code = Constant.AccountCode.GBCHReceivable, LegacyCode = Constant.AccountLegacyCode.GBCHReceivable, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true }, _accountService); Inventory = _accountService.CreateLegacyObject(new Account() { Name = "Inventory", IsLeaf = true, Code = Constant.AccountCode.Inventory, LegacyCode = Constant.AccountLegacyCode.Inventory, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true }, _accountService); Expense = _accountService.CreateLegacyObject(new Account() { Name = "Expense", Code = Constant.AccountCode.Expense, LegacyCode = Constant.AccountLegacyCode.Expense, Level = 1, Group = Constant.AccountGroup.Expense, IsLegacy = true }, _accountService); CashBankAdjustmentExpense = _accountService.CreateLegacyObject(new Account() { Name = "CashBank Adjustment Expense", IsLeaf = true, Code = Constant.AccountCode.CashBankAdjustmentExpense, LegacyCode = Constant.AccountLegacyCode.CashBankAdjustmentExpense, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); COGS = _accountService.CreateLegacyObject(new Account() { Name = "Cost Of Goods Sold", IsLeaf = true, Code = Constant.AccountCode.COGS, LegacyCode = Constant.AccountLegacyCode.COGS, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); Discount = _accountService.CreateLegacyObject(new Account() { Name = "Discount", IsLeaf = true, Code = Constant.AccountCode.Discount, LegacyCode = Constant.AccountLegacyCode.Discount, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); SalesAllowance = _accountService.CreateLegacyObject(new Account() { Name = "Sales Allowance", IsLeaf = true, Code = Constant.AccountCode.SalesAllowance, LegacyCode = Constant.AccountLegacyCode.SalesAllowance, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); StockAdjustmentExpense = _accountService.CreateLegacyObject(new Account() { Name = "Stock Adjustment Expense", IsLeaf = true, Code = Constant.AccountCode.StockAdjustmentExpense, LegacyCode = Constant.AccountLegacyCode.StockAdjustmentExpense, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); Liability = _accountService.CreateLegacyObject(new Account() { Name = "Liability", Code = Constant.AccountCode.Liability, LegacyCode = Constant.AccountLegacyCode.Liability, Level = 1, Group = Constant.AccountGroup.Liability, IsLegacy = true }, _accountService); AccountPayable = _accountService.CreateLegacyObject(new Account() { Name = "Account Payable", IsLeaf = true, Code = Constant.AccountCode.AccountPayable, LegacyCode = Constant.AccountLegacyCode.AccountPayable, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true }, _accountService); GBCHPayable = _accountService.CreateLegacyObject(new Account() { Name = "GBCH Payable", IsLeaf = true, Code = Constant.AccountCode.GBCHPayable, LegacyCode = Constant.AccountLegacyCode.GBCHPayable, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true }, _accountService); GoodsPendingClearance = _accountService.CreateLegacyObject(new Account() { Name = "Goods Pending Clearance", IsLeaf = true, Code = Constant.AccountCode.GoodsPendingClearance, LegacyCode = Constant.AccountLegacyCode.GoodsPendingClearance, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true }, _accountService); Equity = _accountService.CreateLegacyObject(new Account() { Name = "Equity", Code = Constant.AccountCode.Equity, LegacyCode = Constant.AccountLegacyCode.Equity, Level = 1, Group = Constant.AccountGroup.Equity, IsLegacy = true }, _accountService); OwnersEquity = _accountService.CreateLegacyObject(new Account() { Name = "Owners Equity", Code = Constant.AccountCode.OwnersEquity, LegacyCode = Constant.AccountLegacyCode.OwnersEquity, Level = 2, Group = Constant.AccountGroup.Equity, ParentId = Equity.Id, IsLegacy = true }, _accountService); EquityAdjustment = _accountService.CreateLegacyObject(new Account() { Name = "Equity Adjustment", IsLeaf = true, Code = Constant.AccountCode.EquityAdjustment, LegacyCode = Constant.AccountLegacyCode.EquityAdjustment, Level = 3, Group = Constant.AccountGroup.Equity, ParentId = OwnersEquity.Id, IsLegacy = true }, _accountService); Revenue = _accountService.CreateLegacyObject(new Account() { Name = "Revenue", IsLeaf = true, Code = Constant.AccountCode.Revenue, LegacyCode = Constant.AccountLegacyCode.Revenue, Level = 1, Group = Constant.AccountGroup.Revenue, IsLegacy = true }, _accountService); } }
public bool ValidDeactivateObject(PriceMutation priceMutation, IPriceMutationService _priceMutationService) { priceMutation.Errors.Clear(); VUpdateObject(priceMutation, _priceMutationService); return(isValid(priceMutation)); }
public bool ValidCreateObject(PriceMutation priceMutation, IPriceMutationService _priceMutationService) { VCreateObject(priceMutation, _priceMutationService); return(isValid(priceMutation)); }
public CustomPurchaseInvoice UnconfirmObject(CustomPurchaseInvoice customPurchaseInvoice, ICustomPurchaseInvoiceDetailService _customPurchaseInvoiceDetailService, IPayableService _payableService, IPaymentVoucherDetailService _paymentVoucherDetailService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService, IPriceMutationService _priceMutationService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { if (_validator.ValidUnconfirmObject(customPurchaseInvoice, _customPurchaseInvoiceDetailService, _payableService, _paymentVoucherDetailService, _closingService)) { IList <CustomPurchaseInvoiceDetail> customPurchaseInvoiceDetails = _customPurchaseInvoiceDetailService.GetObjectsByCustomPurchaseInvoiceId(customPurchaseInvoice.Id); foreach (var customPurchaseInvoiceDetail in customPurchaseInvoiceDetails) { customPurchaseInvoiceDetail.Errors = new Dictionary <string, string>(); _customPurchaseInvoiceDetailService.UnconfirmObject(customPurchaseInvoiceDetail, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService, _priceMutationService); } Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.CustomPurchaseInvoice, customPurchaseInvoice.Id); _payableService.SoftDeleteObject(payable); customPurchaseInvoice.Total = 0; customPurchaseInvoice.CoGS = 0; _generalLedgerJournalService.CreateUnconfirmationJournalForCustomPurchaseInvoice(customPurchaseInvoice, _accountService); customPurchaseInvoice = _repository.UnconfirmObject(customPurchaseInvoice); } return(customPurchaseInvoice); }
public PriceMutation VCreateObject(PriceMutation priceMutation, IPriceMutationService _priceMutationService) { return(priceMutation); }
public bool ValidUpdateObject(GroupItemPrice groupItemPrice, int oldGroupId, int oldItemId, IGroupItemPriceService _groupItemPriceService, IPriceMutationService _priceMutationService) { groupItemPrice.Errors.Clear(); VUpdateObject(groupItemPrice, oldGroupId, oldItemId, _groupItemPriceService, _priceMutationService); return(isValid(groupItemPrice)); }
public PriceMutation VUpdateObject(PriceMutation priceMutation, IPriceMutationService _priceMutationService) { VCreateObject(priceMutation, _priceMutationService); return(priceMutation); }
public CustomPurchaseInvoiceDetail UnconfirmObject(CustomPurchaseInvoiceDetail customPurchaseInvoiceDetail, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService, IPriceMutationService _priceMutationService) { if (_validator.ValidUnconfirmObject(customPurchaseInvoiceDetail)) { Item item = _itemService.GetObjectById(customPurchaseInvoiceDetail.ItemId); //CustomPurchaseInvoiceDetail hiCustomPurchaseInvoiceDetail = GetAll().Where(x => x.ItemId == item.Id).OrderByDescending(x => x.Price).FirstOrDefault(); decimal hiPrice = GetHighestPrice(/*customPurchaseInvoiceDetail.CustomPurchaseInvoiceId,*/ customPurchaseInvoiceDetail.ItemId); decimal newPrice = hiPrice * (100 + item.Margin) / 100; if (newPrice > item.SellingPrice) { item.SellingPrice = newPrice; PriceMutation priceMutation = _priceMutationService.CreateObject(item.Id, item.SellingPrice, DateTime.Now); item.PriceMutationId = priceMutation.Id; } decimal itemPrice = customPurchaseInvoiceDetail.Amount / customPurchaseInvoiceDetail.Quantity; item.AvgPrice = _itemService.CalculateAndUpdateAvgPrice(item, customPurchaseInvoiceDetail.Quantity * (-1), itemPrice); IList <StockMutation> stockMutations = _stockMutationService.GetObjectsBySourceDocumentDetailForItem(customPurchaseInvoiceDetail.ItemId, Core.Constants.Constant.SourceDocumentDetailType.CustomPurchaseInvoiceDetail, customPurchaseInvoiceDetail.Id); foreach (var stockMutation in stockMutations) { stockMutation.Errors = new Dictionary <string, string>(); _stockMutationService.ReverseStockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService); _stockMutationService.SoftDeleteObject(stockMutation, _warehouseService, _warehouseItemService, _itemService, _barringService); } customPurchaseInvoiceDetail.CoGS = 0; customPurchaseInvoiceDetail = _repository.UnconfirmObject(customPurchaseInvoiceDetail); } return(customPurchaseInvoiceDetail); }