Ejemplo n.º 1
0
        public LineCompleted(BILL_LineBillQuotation line)
        {
            base.BILL_BillQuotation = line.BILL_BillQuotation;
            base.BILL_Product = line.BILL_Product;
            base.BillQuotation_Id = line.BillQuotation_Id;
            base.DateLine = line.DateLine;
            base.LineBillQuotation_Id = line.LineBillQuotation_Id;
            base.Product_Id = line.Product_Id;
            base.Quantite = line.Quantite;

            if (line.BILL_Product != null)
            {
                var tva = line.BILL_Product.BILL_Vat;
                var unitPrice = line.BILL_Product.Price;

                AmountHT = unitPrice * Quantite;

                if (tva != null)
                    AmountTTC = Convert.ToDouble((AmountHT * tva.Rate) + AmountHT);
                else
                    AmountTTC = AmountHT;
            }
        }
Ejemplo n.º 2
0
 public LineExtended(BILL_LineBillQuotation line, bool included)
     : base(line)
 {
     Included = included;
 }
Ejemplo n.º 3
0
        public bool CreateBillQuotation(BillQuotationComplete billQuotationComplete)
        {
            var res = true;
            try
            {
                BILL_BillQuotation bill = new BILL_BillQuotation
                {
                    AmountDF = billQuotationComplete.AmountDF,
                    BILL_Transmitter = billQuotationComplete.BILL_Transmitter,
                    Company = billQuotationComplete.Company,
                    DateBillQuotation = billQuotationComplete.DateBillQuotation,
                    NBill = billQuotationComplete.NBill,
                    Vat = billQuotationComplete.Vat,
                    Company_Id = billQuotationComplete.Company_Id,
                    Transmitter_Id = billQuotationComplete.Transmitter_Id
                };

                //bill = billQuotationBLL.CreateBillQutotation(bill);

                var status = new BILL_BillQuotationStatus { BILL_BillQuotation = bill, BillQuotation_Id = bill.BillQuotation_Id, DateAdvancement = DateTime.Now, Status_Id = billQuotationComplete.BillStatus.Status_Id };
                bqsBLL.CreateBillQuotationStatus(status);

                billQuotationBLL.SetNumFacture();

                if (billQuotationComplete.lines == null) return res;

                var listLine = new List<BILL_LineBillQuotation>();
                foreach (var line in billQuotationComplete.lines)
                {
                    var l = new BILL_LineBillQuotation
                    {
                        BILL_BillQuotation = bill,
                        BILL_Product = line.BILL_Product,
                        BillQuotation_Id = bill.BillQuotation_Id,
                        DateLine = line.DateLine,
                        LineBillQuotation_Id = line.LineBillQuotation_Id,
                        Product_Id = line.Product_Id,
                        Quantite = line.Quantite
                    };

                    listLine.Add(l);
                }

                lineBLL.CreateLineBillQuotation(listLine);
            }
            catch (Exception)
            {
                res = false;
            }
            return res;
        }
Ejemplo n.º 4
0
        /******************************/
        /*    MODIFICATION FACTURE    */
        /******************************/
        public bool ModifyBillQuotation(BillQuotationComplete billQuotationComplete)
        {
            var res = true;
            try
            {
                /*** Modification de la facture/devis ***/
                BILL_BillQuotation bill = new BILL_BillQuotation
                {
                    BillQuotation_Id = billQuotationComplete.BillQuotation_Id,
                    AmountDF = billQuotationComplete.AmountDF,
                    BILL_Transmitter = billQuotationComplete.BILL_Transmitter,
                    Company = billQuotationComplete.Company,
                    DateBillQuotation = billQuotationComplete.DateBillQuotation,
                    NBill = billQuotationComplete.NBill,
                    Vat = billQuotationComplete.Vat,
                    Company_Id = billQuotationComplete.Company_Id,
                    Transmitter_Id = billQuotationComplete.Transmitter_Id
                };

                var billEdit = billQuotationBLL.EditBillQuotation(bill);

                /*** Modification du status ***/
                var status = new BILL_BillQuotationStatus { BillQuotation_Id = bill.BillQuotation_Id, DateAdvancement = DateTime.Now, Status_Id = billQuotationComplete.BillStatus.Status_Id };
                //bqsBLL.CreateBillQuotationStatus(status);

                /*** Modification des lignes de facture ***/
                var lineBDD = lineBLL.GetLineBillQuotation(billQuotationComplete.BillQuotation_Id);
                var lineModif = billQuotationComplete.BILL_LineBillQuotation;

                var listLineAModifie = new List<BILL_LineBillQuotation>();
                var listLineAAjoute = new List<BILL_LineBillQuotation>();
                /* TODO: METTRE A JOUR LES LIGNES FACTURES */
                foreach (var line in lineModif)
                {
                    if (line != null)
                    {
                        var l = new BILL_LineBillQuotation
                       {
                           BillQuotation_Id = bill.BillQuotation_Id,
                           DateLine = line.DateLine,
                           LineBillQuotation_Id = line.LineBillQuotation_Id,
                           Product_Id = line.Product_Id,
                           Quantite = line.Quantite
                       };

                        var lineExist = lineBDD.SingleOrDefault(x => x.LineBillQuotation_Id == line.LineBillQuotation_Id);
                        if (lineExist != null && lineExist.LineBillQuotation_Id != 0)
                        {
                            listLineAModifie.Add(l);
                            lineBDD.Remove(l);
                        }
                        else
                        {
                            listLineAAjoute.Add(l);
                            lineBDD.Remove(l);
                        }
                    }
                }

                lineBLL.CreateLineBillQuotation(listLineAAjoute);
                lineBLL.EditLineBillQuotation(listLineAModifie);
                lineBLL.DeleteLineBillQuotation(lineBDD);
            }
            catch (Exception)
            {
                res = false;
            }
            return res;
        }
Ejemplo n.º 5
0
        public List<LineExtended> GetAllLines(long billQuotation_id)
        {
            var listLineExtended = lineBLL.GetLineBillQuotation(billQuotation_id).Select(l => new LineExtended(l, true)).ToList();

            var listProductNotIncluded = productBLL.getListProductIncludedOrNot(billQuotation_id).Where(p => !p.included);
            foreach (var p in listProductNotIncluded)
            {
                var product = new ProductExtended(p, billQuotation_id);
                var line = new BILL_LineBillQuotation
                {
                    BILL_Product = productBLL.GetProductByID(product.Product_Id),
                    Quantite = 0,
                    BillQuotation_Id = billQuotation_id
                };
                listLineExtended.Add(new LineExtended(line, false));
            }

            return listLineExtended;
        }