コード例 #1
0
 public CashSalesInvoiceController()
 {
     _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());
     _cashSalesInvoiceService       = new CashSalesInvoiceService(new CashSalesInvoiceRepository(), new CashSalesInvoiceValidator());
     _cashSalesInvoiceDetailService = new CashSalesInvoiceDetailService(new CashSalesInvoiceDetailRepository(), new CashSalesInvoiceDetailValidator());
     _cashSalesReturnService        = new CashSalesReturnService(new CashSalesReturnRepository(), new CashSalesReturnValidator());
     _quantityPricingService        = new QuantityPricingService(new QuantityPricingRepository(), new QuantityPricingValidator());
     _receivableService             = new ReceivableService(new ReceivableRepository(), new ReceivableValidator());
     _receiptVoucherService         = new ReceiptVoucherService(new ReceiptVoucherRepository(), new ReceiptVoucherValidator());
     _receiptVoucherDetailService   = new ReceiptVoucherDetailService(new ReceiptVoucherDetailRepository(), new ReceiptVoucherDetailValidator());
     _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());
 }
コード例 #2
0
        public CashSalesReturn VConfirmObject(CashSalesReturn cashSalesReturn, ICashSalesReturnDetailService _cashSalesReturnDetailService, ICashSalesReturnService _cashSalesReturnService,
                                              ICashSalesInvoiceService _cashSalesInvoiceService, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService)
        {
            VIsNotConfirmed(cashSalesReturn);
            if (!isValid(cashSalesReturn))
            {
                return(cashSalesReturn);
            }
            VIsValidCashSalesInvoice(cashSalesReturn, _cashSalesInvoiceService);
            if (!isValid(cashSalesReturn))
            {
                return(cashSalesReturn);
            }
            VHasCashSalesReturnDetails(cashSalesReturn, _cashSalesReturnDetailService);
            if (!isValid(cashSalesReturn))
            {
                return(cashSalesReturn);
            }
            VIsConfirmableCashSalesReturnDetails(cashSalesReturn, _cashSalesReturnDetailService, _cashSalesInvoiceDetailService);
            if (!isValid(cashSalesReturn))
            {
                return(cashSalesReturn);
            }


            return(cashSalesReturn);
        }
コード例 #3
0
 public bool ValidConfirmObject(CashSalesReturn cashSalesReturn, ICashSalesReturnDetailService _cashSalesReturnDetailService, ICashSalesReturnService _cashSalesReturnService,
                                ICashSalesInvoiceService _cashSalesInvoiceService, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService)
 {
     cashSalesReturn.Errors.Clear();
     VConfirmObject(cashSalesReturn, _cashSalesReturnDetailService, _cashSalesReturnService, _cashSalesInvoiceService, _cashSalesInvoiceDetailService);
     return(isValid(cashSalesReturn));
 }
コード例 #4
0
 public bool ValidCreateObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService,
                               ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, IItemService _itemService, IWarehouseItemService _warehouseItemService,
                               IQuantityPricingService _quantityPricingService)
 {
     VCreateObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, _cashSalesInvoiceDetailService, _itemService, _warehouseItemService, _quantityPricingService);
     return(isValid(cashSalesInvoiceDetail));
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 public bool ValidUpdateObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService,
                               ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, IItemService _itemService, IWarehouseItemService _warehouseItemService,
                               IQuantityPricingService _quantityPricingService)
 {
     cashSalesInvoiceDetail.Errors.Clear();
     VUpdateObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, _cashSalesInvoiceDetailService, _itemService, _warehouseItemService, _quantityPricingService);
     return(isValid(cashSalesInvoiceDetail));
 }
コード例 #7
0
        public CashSalesReturn VHasCashSalesInvoice(CashSalesReturn cashSalesReturn, ICashSalesInvoiceService _cashSalesInvoiceService)
        {
            CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesReturn.CashSalesInvoiceId);

            if (cashSalesInvoice == null)
            {
                cashSalesReturn.Errors.Add("CashSalesInvoiceId", "Tidak valid");
            }
            return(cashSalesReturn);
        }
コード例 #8
0
 public CashSalesReturn VCreateObject(CashSalesReturn cashSalesReturn, ICashSalesInvoiceService _cashSalesInvoiceService, ICashBankService _cashBankService)
 {
     VHasReturnDate(cashSalesReturn);
     if (!isValid(cashSalesReturn))
     {
         return(cashSalesReturn);
     }
     VHasCashSalesInvoice(cashSalesReturn, _cashSalesInvoiceService);
     if (!isValid(cashSalesReturn))
     {
         return(cashSalesReturn);
     }
     VHasCashBank(cashSalesReturn, _cashBankService);
     return(cashSalesReturn);
 }
コード例 #9
0
 public CashSalesReturn VUpdateObject(CashSalesReturn cashSalesReturn, ICashSalesInvoiceService _cashSalesInvoiceService, ICashBankService _cashBankService)
 {
     VIsNotDeleted(cashSalesReturn);
     if (!isValid(cashSalesReturn))
     {
         return(cashSalesReturn);
     }
     VIsNotConfirmed(cashSalesReturn);
     if (!isValid(cashSalesReturn))
     {
         return(cashSalesReturn);
     }
     VCreateObject(cashSalesReturn, _cashSalesInvoiceService, _cashBankService);
     return(cashSalesReturn);
 }
コード例 #10
0
        public ReportController()
        {
            _itemService       = new ItemService(new ItemRepository(), new ItemValidator());
            _itemTypeService   = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator());
            _uoMService        = new UoMService(new UoMRepository(), new UoMValidator());
            _companyService    = new CompanyService(new CompanyRepository(), new CompanyValidator());
            _cashBankService   = new CashBankService(new CashBankRepository(), new CashBankValidator());
            _payableService    = new PayableService(new PayableRepository(), new PayableValidator());
            _receivableService = new ReceivableService(new ReceivableRepository(), new ReceivableValidator());

            _cashSalesInvoiceService            = new CashSalesInvoiceService(new CashSalesInvoiceRepository(), new CashSalesInvoiceValidator());
            _cashSalesInvoiceDetailService      = new CashSalesInvoiceDetailService(new CashSalesInvoiceDetailRepository(), new CashSalesInvoiceDetailValidator());
            _cashSalesReturnService             = new CashSalesReturnService(new CashSalesReturnRepository(), new CashSalesReturnValidator());
            _cashSalesReturnDetailService       = new CashSalesReturnDetailService(new CashSalesReturnDetailRepository(), new CashSalesReturnDetailValidator());
            _customPurchaseInvoiceService       = new CustomPurchaseInvoiceService(new CustomPurchaseInvoiceRepository(), new CustomPurchaseInvoiceValidator());
            _customPurchaseInvoiceDetailService = new CustomPurchaseInvoiceDetailService(new CustomPurchaseInvoiceDetailRepository(), new CustomPurchaseInvoiceDetailValidator());
        }
コード例 #11
0
 public CashSalesInvoice VConfirmObject(CashSalesInvoice cashSalesInvoice, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService,
                                        ICashSalesInvoiceService _cashSalesInvoiceService, IWarehouseItemService _warehouseItemService, IContactService _contactService,
                                        ICashBankService _cashBankService, IClosingService _closingService)
 {
     VHasCashSalesInvoiceDetails(cashSalesInvoice, _cashSalesInvoiceDetailService);
     if (!isValid(cashSalesInvoice))
     {
         return(cashSalesInvoice);
     }
     VIsConfirmableCashSalesInvoiceDetails(cashSalesInvoice, _cashSalesInvoiceDetailService, _cashSalesInvoiceService, _warehouseItemService);
     if (!isValid(cashSalesInvoice))
     {
         return(cashSalesInvoice);
     }
     VIsNotConfirmed(cashSalesInvoice);
     if (!isValid(cashSalesInvoice))
     {
         return(cashSalesInvoice);
     }
     VHasDueDate(cashSalesInvoice);
     if (!isValid(cashSalesInvoice))
     {
         return(cashSalesInvoice);
     }
     VIsValidDiscount(cashSalesInvoice);
     if (!isValid(cashSalesInvoice))
     {
         return(cashSalesInvoice);
     }
     VIsValidTax(cashSalesInvoice);
     if (!isValid(cashSalesInvoice))
     {
         return(cashSalesInvoice);
     }
     VHasConfirmationDate(cashSalesInvoice);
     //if (!isValid(cashSalesInvoice)) { return cashSalesInvoice; }
     //VHasCashBank(cashSalesInvoice, _cashBankService);
     //if (!isValid(cashSalesInvoice)) { return cashSalesInvoice; }
     //VIsCashBankTypeNotBank(cashSalesInvoice, _cashBankService);
     if (!isValid(cashSalesInvoice))
     {
         return(cashSalesInvoice);
     }
     VGeneralLedgerPostingHasNotBeenClosed(cashSalesInvoice, _closingService, 1);
     return(cashSalesInvoice);
 }
コード例 #12
0
 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);
 }
コード例 #13
0
 public CashSalesReturnDetail ConfirmObject(CashSalesReturnDetail cashSalesReturnDetail, ICashSalesReturnService _cashSalesReturnService,
                                            ICashSalesInvoiceService _cashSalesInvoiceService, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService,
                                            IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService,
                                            IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService, ICashSalesReturnDetailService _cashSalesReturnDetailService)
 {
     if (_validator.ValidConfirmObject(cashSalesReturnDetail, _cashSalesInvoiceDetailService, _cashSalesReturnDetailService))
     {
         CashSalesReturn        cashSalesReturn        = _cashSalesReturnService.GetObjectById(cashSalesReturnDetail.CashSalesReturnId);
         CashSalesInvoiceDetail cashSalesInvoiceDetail = _cashSalesInvoiceDetailService.GetObjectById(cashSalesReturnDetail.CashSalesInvoiceDetailId);
         CashSalesInvoice       cashSalesInvoice       = _cashSalesInvoiceService.GetObjectById(cashSalesReturn.CashSalesInvoiceId);
         WarehouseItem          warehouseItem          = _warehouseItemService.FindOrCreateObject(cashSalesInvoice.WarehouseId, cashSalesInvoiceDetail.ItemId);
         Item          item          = _itemService.GetObjectById(cashSalesInvoiceDetail.ItemId);
         StockMutation stockMutation = new StockMutation()
         {
             ItemId                   = cashSalesInvoiceDetail.ItemId,
             ItemCase                 = Core.Constants.Constant.ItemCase.Ready,
             Status                   = Core.Constants.Constant.MutationStatus.Addition,
             Quantity                 = cashSalesReturnDetail.Quantity,
             SourceDocumentCode       = cashSalesReturn.Code,
             SourceDocumentId         = cashSalesReturn.Id,
             SourceDocumentType       = Core.Constants.Constant.SourceDocumentType.CashSalesReturn,
             SourceDocumentDetailCode = cashSalesReturnDetail.Code,
             SourceDocumentDetailId   = cashSalesReturnDetail.Id,
             SourceDocumentDetailType = Core.Constants.Constant.SourceDocumentDetailType.CashSalesReturnDetail,
             WarehouseId              = cashSalesInvoice.WarehouseId,
             WarehouseItemId          = warehouseItem.Id
         };
         stockMutation           = _stockMutationService.CreateObject(stockMutation, _warehouseService, _warehouseItemService, _itemService, _barringService);
         stockMutation.CreatedAt = (DateTime)cashSalesReturn.ConfirmationDate.GetValueOrDefault();
         _stockMutationService.UpdateObject(stockMutation, _warehouseService, _warehouseItemService, _itemService, _barringService);
         _stockMutationService.StockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
         item.AvgPrice         = _itemService.CalculateAndUpdateAvgPrice(item, cashSalesReturnDetail.Quantity, (cashSalesInvoiceDetail.CoGS / cashSalesInvoiceDetail.Quantity));
         cashSalesReturnDetail = _repository.ConfirmObject(cashSalesReturnDetail);
     }
     return(cashSalesReturnDetail);
 }
コード例 #14
0
        public CashSalesInvoice VIsConfirmableCashSalesInvoiceDetails(CashSalesInvoice cashSalesInvoice, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService,
                                                                      ICashSalesInvoiceService _cashSalesInvoiceService, IWarehouseItemService _warehouseItemService)
        {
            IList <CashSalesInvoiceDetail> cashSalesInvoiceDetails = _cashSalesInvoiceDetailService.GetObjectsByCashSalesInvoiceId(cashSalesInvoice.Id);

            if (!cashSalesInvoiceDetails.Any())
            {
                cashSalesInvoice.Errors.Add("Generic", "CashSalesInvoiceDetails Tidak ada");
            }
            else
            {
                ICashSalesInvoiceDetailValidator validator = _cashSalesInvoiceDetailService.GetValidator();
                foreach (var cashSalesInvoiceDetail in cashSalesInvoiceDetails)
                {
                    cashSalesInvoiceDetail.Errors = new Dictionary <string, string>();
                    if (!validator.ValidConfirmObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, _warehouseItemService))
                    {
                        cashSalesInvoice.Errors.Add("Generic", "CashSalesInvoiceDetails harus confirmable semua");
                        return(cashSalesInvoice);
                    }
                }
            }
            return(cashSalesInvoice);
        }
コード例 #15
0
 public bool ValidDeleteObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService)
 {
     cashSalesInvoiceDetail.Errors.Clear();
     VDeleteObject(cashSalesInvoiceDetail, _cashSalesInvoiceService);
     return(isValid(cashSalesInvoiceDetail));
 }
コード例 #16
0
ファイル: CashSalesBuilder.cs プロジェクト: ANR2ME/CashSales
        public CashSalesBuilder()
        {
            _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());
            _quantityPricingService          = new QuantityPricingService(new QuantityPricingRepository(), new QuantityPricingValidator());
            _contactGroupService             = new ContactGroupService(new ContactGroupRepository(), new ContactGroupValidator());
            _retailSalesInvoiceService       = new RetailSalesInvoiceService(new RetailSalesInvoiceRepository(), new RetailSalesInvoiceValidator());
            _retailSalesInvoiceDetailService = new RetailSalesInvoiceDetailService(new RetailSalesInvoiceDetailRepository(), new RetailSalesInvoiceDetailValidator());
            _cashSalesInvoiceService         = new CashSalesInvoiceService(new CashSalesInvoiceRepository(), new CashSalesInvoiceValidator());
            _cashSalesInvoiceDetailService   = new CashSalesInvoiceDetailService(new CashSalesInvoiceDetailRepository(), new CashSalesInvoiceDetailValidator());
            _cashSalesReturnService          = new CashSalesReturnService(new CashSalesReturnRepository(), new CashSalesReturnValidator());
            _cashSalesReturnDetailService    = new CashSalesReturnDetailService(new CashSalesReturnDetailRepository(), new CashSalesReturnDetailValidator());

            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);
            group2      = _contactGroupService.CreateObject("Pedagang", "Group Pedagang", false);
            baseContact = _contactService.CreateObject(Core.Constants.Constant.BaseContact, "BaseAddr", "BaseNo", "BasePIC", "BasePICNo", "BaseEmail", _contactGroupService);

            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);
            }
        }
コード例 #17
0
        public CashSalesReturn VIsValidCashSalesInvoice(CashSalesReturn cashSalesReturn, ICashSalesInvoiceService _cashSalesInvoiceService)
        {
            CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesReturn.CashSalesInvoiceId);

            if (cashSalesInvoice == null)
            {
                cashSalesReturn.Errors.Add("Generic", "CashSalesInvoice Tidak valid");
            }
            else if (!(cashSalesInvoice.IsConfirmed && cashSalesInvoice.IsPaid))
            {
                cashSalesReturn.Errors.Add("Generic", "CashSalesInvoice Harus sudah terkonfirmasi dan terbayar");
            }
            return(cashSalesReturn);
        }
コード例 #18
0
 public bool ValidUpdateObject(CashSalesReturn cashSalesReturn, ICashSalesInvoiceService _cashSalesInvoiceService, ICashBankService _cashBankService)
 {
     cashSalesReturn.Errors.Clear();
     VUpdateObject(cashSalesReturn, _cashSalesInvoiceService, _cashBankService);
     return(isValid(cashSalesReturn));
 }
コード例 #19
0
 public bool ValidCreateObject(CashSalesReturn cashSalesReturn, ICashSalesInvoiceService _cashSalesInvoiceService, ICashBankService _cashBankService)
 {
     VCreateObject(cashSalesReturn, _cashSalesInvoiceService, _cashBankService);
     return(isValid(cashSalesReturn));
 }
コード例 #20
0
        public CashSalesInvoiceDetail VIsParentNotConfirmed(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService)
        {
            CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);

            if (cashSalesInvoice != null)
            {
                if (cashSalesInvoice.IsConfirmed)
                {
                    cashSalesInvoiceDetail.Errors.Add("Generic", "CashSalesInvoice tidak boleh terkonfirmasi");
                }
            }
            else
            {
                cashSalesInvoiceDetail.Errors.Add("Generic", "CashSalesInvoice tidak ada");
            }
            return(cashSalesInvoiceDetail);
        }
コード例 #21
0
 public CashSalesInvoiceDetail VConfirmObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService, IWarehouseItemService _warehouseItemService)
 {
     VIsValidQuantityOrdered(cashSalesInvoiceDetail, _cashSalesInvoiceService, _warehouseItemService);
     return(cashSalesInvoiceDetail);
 }
コード例 #22
0
 public CashSalesInvoiceDetail VCreateObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService,
                                             ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, IItemService _itemService, IWarehouseItemService _warehouseItemService,
                                             IQuantityPricingService _quantityPricingService)
 {
     VIsParentNotConfirmed(cashSalesInvoiceDetail, _cashSalesInvoiceService);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VHasCashSalesInvoice(cashSalesInvoiceDetail, _cashSalesInvoiceService);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VIsValidQuantity(cashSalesInvoiceDetail, _cashSalesInvoiceService, _warehouseItemService);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VIsValidDiscount(cashSalesInvoiceDetail);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VIsValidAssignedPrice(cashSalesInvoiceDetail);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VHasItem(cashSalesInvoiceDetail, _itemService);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VUniqueItem(cashSalesInvoiceDetail, _cashSalesInvoiceDetailService, _itemService);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VConfirmObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, _warehouseItemService);
     //if (!isValid(cashSalesInvoiceDetail)) { return cashSalesInvoiceDetail; }
     //VHasQuantityPricing(cashSalesInvoiceDetail, _itemService, _quantityPricingService);
     return(cashSalesInvoiceDetail);
 }
コード例 #23
0
 public CashSalesInvoiceDetail VUpdateObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService,
                                             ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, IItemService _itemService, IWarehouseItemService _warehouseItemService,
                                             IQuantityPricingService _quantityPricingService)
 {
     //VIsParentNotConfirmed(cashSalesInvoiceDetail, _cashSalesInvoiceService);
     //if (!isValid(cashSalesInvoiceDetail)) { return cashSalesInvoiceDetail; }
     return(VCreateObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, _cashSalesInvoiceDetailService, _itemService, _warehouseItemService, _quantityPricingService));
 }
コード例 #24
0
        public CashSalesInvoiceDetail VIsValidQuantity(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService, IWarehouseItemService _warehouseItemService)
        {
            CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);
            WarehouseItem    warehouseItem    = _warehouseItemService.FindOrCreateObject(cashSalesInvoice.WarehouseId, cashSalesInvoiceDetail.ItemId);

            if (cashSalesInvoiceDetail.Quantity <= 0 || cashSalesInvoiceDetail.Quantity > warehouseItem.Quantity)
            {
                cashSalesInvoiceDetail.Errors.Add("Quantity", "Quantity harus lebih besar dari 0 dan lebih kecil atau sama dengan WarehouseItem Quantity");
                return(cashSalesInvoiceDetail);
            }
            return(cashSalesInvoiceDetail);
        }
コード例 #25
0
        /*public CashSalesInvoiceDetail VHasQuantityPricing(CashSalesInvoiceDetail cashSalesInvoiceDetail, IItemService _itemService, IQuantityPricingService _quantityPricingService)
         * {
         *  Item item = _itemService.GetObjectById(cashSalesInvoiceDetail.ItemId);
         *  IList<QuantityPricing> quantityPricings = _quantityPricingService.GetObjectsByItemTypeId(item.ItemTypeId);
         *  if (quantityPricings.Any())
         *  {
         *      cashSalesInvoiceDetail.Errors.Add("Generic", "Tidak ada QuantityPricing terasosiasi");
         *  }
         *  return cashSalesInvoiceDetail;
         * }*/

        public CashSalesInvoiceDetail VIsValidQuantityOrdered(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService, IWarehouseItemService _warehouseItemService)
        {
            CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);
            WarehouseItem    warehouseItem    = _warehouseItemService.FindOrCreateObject(cashSalesInvoice.WarehouseId, cashSalesInvoiceDetail.ItemId);

            if (warehouseItem.Quantity - cashSalesInvoiceDetail.Quantity < 0)
            {
                cashSalesInvoiceDetail.Errors.Add("Generic", "Quantity harus lebih kecil atau sama dengan WarehouseItem Quantity");
                return(cashSalesInvoiceDetail);
            }
            return(cashSalesInvoiceDetail);
        }
コード例 #26
0
 public CashSalesInvoiceDetail SoftDeleteObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService)
 {
     if (_validator.ValidDeleteObject(cashSalesInvoiceDetail, _cashSalesInvoiceService))
     {
         CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);
         _repository.SoftDeleteObject(cashSalesInvoiceDetail);
         cashSalesInvoice.Total = CalculateTotal(cashSalesInvoice.Id);
         cashSalesInvoice.CoGS  = CalculateCoGS(cashSalesInvoice.Id);
         _cashSalesInvoiceService.GetRepository().Update(cashSalesInvoice);
     }
     ;
     return(cashSalesInvoiceDetail);
 }
コード例 #27
0
 public CashSalesInvoiceDetail VDeleteObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService)
 {
     VIsParentNotConfirmed(cashSalesInvoiceDetail, _cashSalesInvoiceService);
     return(cashSalesInvoiceDetail);
 }
コード例 #28
0
 public bool ValidConfirmObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService, IWarehouseItemService _warehouseItemService)
 {
     cashSalesInvoiceDetail.Errors.Clear();
     VConfirmObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, _warehouseItemService);
     return(isValid(cashSalesInvoiceDetail));
 }
コード例 #29
0
        public CashSalesInvoiceDetail UpdateObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService,
                                                   IItemService _itemService, IWarehouseItemService _warehouseItemService,
                                                   IQuantityPricingService _quantityPricingService)
        {
            if (_validator.ValidUpdateObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, this, _itemService, _warehouseItemService, _quantityPricingService))
            {
                Item            item            = _itemService.GetObjectById(cashSalesInvoiceDetail.ItemId);
                QuantityPricing quantityPricing = _quantityPricingService.GetObjectByItemTypeIdAndQuantity(item.ItemTypeId, cashSalesInvoiceDetail.Quantity);
                decimal         price           = item.SellingPrice;
                decimal         discount        = cashSalesInvoiceDetail.Discount;
                if (cashSalesInvoiceDetail.IsManualPriceAssignment)
                {
                    price = cashSalesInvoiceDetail.AssignedPrice;
                }
                else
                {
                    cashSalesInvoiceDetail.AssignedPrice = 0;
                }
                if (quantityPricing != null)
                {
                    if (cashSalesInvoiceDetail.Discount <= 0)
                    {
                        discount = quantityPricing.Discount;
                    }
                    ;
                }
                cashSalesInvoiceDetail.Amount = (price * (100 - discount) / 100) * cashSalesInvoiceDetail.Quantity;
                cashSalesInvoiceDetail.CoGS   = cashSalesInvoiceDetail.Quantity * item.AvgPrice;

                CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);
                cashSalesInvoiceDetail.PriceMutationId = item.PriceMutationId;
                cashSalesInvoiceDetail = _repository.UpdateObject(cashSalesInvoiceDetail);
                cashSalesInvoice.Total = CalculateTotal(cashSalesInvoice.Id);
                cashSalesInvoice.CoGS  = CalculateCoGS(cashSalesInvoice.Id);
                _cashSalesInvoiceService.GetRepository().Update(cashSalesInvoice);
            }
            return(cashSalesInvoiceDetail);
        }
コード例 #30
0
        public CashSalesInvoiceDetail VHasCashSalesInvoice(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService)
        {
            CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);

            if (cashSalesInvoice == null)
            {
                cashSalesInvoiceDetail.Errors.Add("CashSalesInvoiceId", "Tidak valid");
            }
            return(cashSalesInvoiceDetail);
        }