Exemplo n.º 1
0
 private void SaveManifestReferenceNumber(xcuda_ASYCUDA da, ASYCUDA a)
 {
     if (da.xcuda_Identification.Manifest_reference_number != null)
     {
         a.Identification.Manifest_reference_number.Text.Add(da.xcuda_Identification.Manifest_reference_number);
     }
 }
Exemplo n.º 2
0
        private void SaveContainer(xcuda_ASYCUDA da, ASYCUDA a)
        {
            if (da.xcuda_Container.Count > 0)
            {
                a.Transport.Container_flagSpecified = true;
                a.Transport.Container_flag          = true;
                foreach (var cnt in da.xcuda_Container)
                {
                    ASYCUDAContainer ac = null;

                    a.Container = new ObservableCollection <ASYCUDAContainer>();


                    ac = new ASYCUDAContainer();
                    a.Container.Add(ac);

                    ac.Item_Number          = cnt.Item_Number;
                    ac.Container_identity   = cnt.Container_identity;
                    ac.Container_type       = cnt.Container_type;
                    ac.Empty_full_indicator = cnt.Empty_full_indicator;
                    if (ac.Gross_weight == null)
                    {
                        ac.Gross_weight = new ASYCUDAContainerGross_weight();
                    }
                    ac.Gross_weight.Text.Add(cnt.Gross_weight.ToString());
                    ac.Goods_description = cnt.Goods_description;
                    ac.Packages_number   = cnt.Packages_number;
                    ac.Packages_type     = cnt.Packages_type;
                    ac.Packages_weight   = cnt.Packages_weight.ToString();
                }
            }
        }
Exemplo n.º 3
0
        private void SavePreviousItem(xcuda_ASYCUDA da, ASYCUDA a)
        {
            if (da.xcuda_PreviousItem != null)
            {
                var lncounter = 0;
                foreach (var item in da.xcuda_PreviousItem.OrderBy(x => Convert.ToInt32(x.Current_item_number)))
                {
                    lncounter += 1;
                    var pi = new ASYCUDAPrev_decl();//ASYCUDAPreviousItem
                    pi.Prev_decl_office_code                 = item.Prev_reg_cuo;
                    pi.Prev_decl_reg_year                    = item.Prev_reg_dat;
                    pi.Prev_decl_reg_serial                  = item.Prev_reg_ser;
                    pi.Prev_decl_reg_number                  = item.Prev_reg_nbr;
                    pi.Prev_decl_item_number                 = item.Previous_item_number;
                    pi.Prev_decl_HS_code                     = item.Hs_code;
                    pi.Prev_decl_HS_prec                     = item.Commodity_code;
                    pi.Prev_decl_country_origin              = item.Goods_origin;
                    pi.Prev_decl_number_packages             = item.Packages_number;
                    pi.Prev_decl_weight                      = item.Net_weight.ToString();
                    pi.Prev_decl_supp_quantity               = item.Suplementary_Quantity.ToString();
                    pi.Prev_decl_ref_value                   = Math.Round(item.Current_value, 4).ToString();
                    pi.Prev_decl_current_item                = lncounter.ToString();//item.Current_item_number;
                    pi.Prev_decl_number_packages_written_off = item.Previous_Packages_number;
                    pi.Prev_decl_weight_written_off          = item.Prev_net_weight.ToString();
                    pi.Prev_decl_supp_quantity_written_off   = item.Preveious_suplementary_quantity.ToString();
                    pi.Prev_decl_ref_value_written_off       = Math.Round(item.Previous_value, 4).ToString();

                    a.Prev_decl.Add(pi);
                }
                if (a.Prev_decl.Any() == true)
                {
                    a.Prev_decl[0].Prev_decl_number_packages = a.Item[0].Packages.Number_of_packages;
                }
            }
        }
Exemplo n.º 4
0
        public void LoadFromDataBase(xcuda_ASYCUDA da, ASYCUDA a)
        {
            try
            {
                SetupProperties(a, da);
                SaveGeneralInformation(a, da);
                SaveTraders(a, da);
                SaveProperty(a, da);
                SaveDeclarant(da, a);
                SaveContainer(da, a);
                SaveIdentification(da, a);
                SaveItem(da, a);
                SavePreviousItem(da, a);
                SaveValuationItem(da, a);

                if (a.Valuation.Gs_Invoice.Amount_foreign_currency == null)
                {
                    a.Valuation.Gs_Invoice.Amount_foreign_currency = Math.Round(da.xcuda_Item.Where(i => i.xcuda_Valuation_item.xcuda_Item_Invoice != null).Sum(i => i.xcuda_Valuation_item.xcuda_Item_Invoice.Amount_foreign_currency), 2).ToString();
                }
            }
            catch (Exception Ex)
            {
                throw;
            }
        }
Exemplo n.º 5
0
 private void SaveIdentification(xcuda_ASYCUDA da, ASYCUDA a)
 {
     if (da.xcuda_Identification != null)
     {
         SaveOfficeSegment(da, a);
         SaveManifestReferenceNumber(da, a);
         SaveRegistration(da, a);
         SaveType(da, a);
     }
 }
Exemplo n.º 6
0
        private void SaveGeneralInformation(ASYCUDA a, xcuda_ASYCUDA da)
        {
            if (da.xcuda_General_information != null && da.xcuda_General_information.xcuda_Country != null)
            {
                var gi = new ASYCUDAGeneral_information();

                SaveCountry(gi, da.xcuda_General_information);
                gi.Value_details = da.xcuda_General_information.Value_details;
                gi.Comments_free_text.Text.Add(da.xcuda_General_information.Comments_free_text);
                a.General_information = gi;
            }
        }
Exemplo n.º 7
0
 private void SaveOfficeSegment(xcuda_ASYCUDA da, ASYCUDA a)
 {
     if (da.xcuda_Identification.xcuda_Office_segment != null)
     {
         if (da.xcuda_Identification.xcuda_Office_segment.Customs_clearance_office_code != null)
         {
             a.Identification.Office_segment.Customs_clearance_office_code.Text.Add(da.xcuda_Identification.xcuda_Office_segment.Customs_clearance_office_code);
         }
         if (da.xcuda_Identification.xcuda_Office_segment.Customs_Clearance_office_name != null)
         {
             a.Identification.Office_segment.Customs_Clearance_office_name.Text.Add(da.xcuda_Identification.xcuda_Office_segment.Customs_Clearance_office_name);
         }
     }
 }
Exemplo n.º 8
0
 private void SaveRegistration(xcuda_ASYCUDA da, ASYCUDA a)
 {
     if (da.xcuda_Identification.xcuda_Registration != null)
     {
         if (da.xcuda_Identification.xcuda_Registration.Date != null)
         {
             a.Identification.Registration.Date = da.xcuda_Identification.xcuda_Registration.Date;
         }
         if (da.xcuda_Identification.xcuda_Registration.Number != null)
         {
             a.Identification.Registration.Number = da.xcuda_Identification.xcuda_Registration.Number;
         }
     }
 }
Exemplo n.º 9
0
 private void SaveType(xcuda_ASYCUDA da, ASYCUDA a)
 {
     if (da.xcuda_Identification.xcuda_Type != null)
     {
         if (da.xcuda_Identification.xcuda_Type.Type_of_declaration != null)
         {
             a.Identification.Type.Type_of_declaration = da.xcuda_Identification.xcuda_Type.Type_of_declaration;
         }
         if (da.xcuda_Identification.xcuda_Type.Declaration_gen_procedure_code != null)
         {
             a.Identification.Type.Declaration_gen_procedure_code = da.xcuda_Identification.xcuda_Type.Declaration_gen_procedure_code;
         }
     }
 }
Exemplo n.º 10
0
        private void SaveItem(xcuda_ASYCUDA da, ASYCUDA a)
        {
            if (da.xcuda_Item != null)
            {
                var lnCounter = 0;
                foreach (var item in da.xcuda_Item.OrderBy(x => x.LineNumber))
                {
                    lnCounter      += 1;
                    item.LineNumber = lnCounter;
                    var ai = SetupItemProperties(da);

                    if (item.Licence_number != null)
                    {
                        ai.Licence_number.Text.Add(item.Licence_number);
                    }
                    if (item.Quantity_deducted_from_licence != null)
                    {
                        ai.Quantity_deducted_from_licence = item.Quantity_deducted_from_licence;
                    }
                    if (item.Free_text_1 != null)
                    {
                        ai.Free_text_1.Text.Add(item.Free_text_1);
                    }
                    if (item.Free_text_2 != null)
                    {
                        ai.Free_text_2.Text.Add(item.Free_text_2);
                    }



                    // SaveAttachedDocuments(item, ai);
                    if (item.xcuda_Tarification == null)
                    {
                        throw new Exception("Null Tarification, for item number: " + item.ItemNumber);
                    }
                    SaveTarification(item, ai);
                    SaveGoodsDescription(item, ai);
                    SavePreviousDoc(item, ai);

                    SaveValuationItem(item, ai);

                    a.Item.Add(ai);
                }
                if (a.Item.Count != 0)
                {
                    a.Item[0].Packages.Number_of_packages = "1";
                }
            }
        }
Exemplo n.º 11
0
 private void SaveValuationItem(xcuda_ASYCUDA da, ASYCUDA a)
 {
     if (da.xcuda_Valuation != null)//&& da.xcuda_Valuation.xcuda_Gs_Invoice.Amount_foreign_currency != 0
     {
         var v = new ASYCUDAValuation();
         if (da.xcuda_Valuation.Calculation_working_mode != null)
         {
             v.Calculation_working_mode = da.xcuda_Valuation.Calculation_working_mode;
         }
         SaveGSInvoice(v, da.xcuda_Valuation.xcuda_Gs_Invoice);
         SaveGSExternalFreight(v, da.xcuda_Valuation.xcuda_Gs_external_freight);
         SaveWeight(v, da.xcuda_Valuation.xcuda_Weight);
         a.Valuation = v;
     }
 }
Exemplo n.º 12
0
        private void SaveTraders(ASYCUDA a, xcuda_ASYCUDA da)
        {
            if (da.xcuda_Traders != null)
            {
                var t = new ASYCUDATraders();

                var c = new ASYCUDATradersConsignee();
                if (da.xcuda_Traders.xcuda_Consignee != null)
                {
                    t.Consignee = new ASYCUDATradersConsignee();
                    if (da.xcuda_Traders.xcuda_Consignee.Consignee_code != null)
                    {
                        t.Consignee.Consignee_code.Text.Add(da.xcuda_Traders.xcuda_Consignee.Consignee_code);
                    }
                    if (da.xcuda_Traders.xcuda_Consignee.Consignee_name != null)
                    {
                        t.Consignee.Consignee_name.Text.Add(da.xcuda_Traders.xcuda_Consignee.Consignee_name);
                    }
                }
                if (da.xcuda_Traders.xcuda_Exporter != null)
                {
                    if (da.xcuda_Traders.xcuda_Exporter.Exporter_code != null)
                    {
                        t.Exporter.Exporter_code.Text.Add(da.xcuda_Traders.xcuda_Exporter.Exporter_code);
                    }
                    if (da.xcuda_Traders.xcuda_Exporter.Exporter_name != null)
                    {
                        t.Exporter.Exporter_name.Text.Add(da.xcuda_Traders.xcuda_Exporter.Exporter_name);
                    }
                }

                if (da.xcuda_Traders.xcuda_Traders_Financial != null && da.xcuda_Traders.xcuda_Traders_Financial.Financial_code != null)
                {
                    if (da.xcuda_Traders.xcuda_Traders_Financial.Financial_code != null)
                    {
                        t.Financial.Financial_code.Text.Add(da.xcuda_Traders.xcuda_Traders_Financial.Financial_code);
                    }
                    if (da.xcuda_Traders.xcuda_Traders_Financial.Financial_name != null)
                    {
                        t.Financial.Financial_name.Text.Add(da.xcuda_Traders.xcuda_Traders_Financial.Financial_name);
                    }
                }
                a.Traders = t;
            }
        }
Exemplo n.º 13
0
        private void SaveProperty(ASYCUDA a, xcuda_ASYCUDA da)
        {
            if (da.xcuda_Property != null)
            {
                if (da.xcuda_Property.Date_of_declaration != null)
                {
                    a.Property.Date_of_declaration = da.xcuda_Property.Date_of_declaration;
                }
                // a.Property.Place_of_declaration. = da.xcuda_Property.Place_of_declaration;
                if (da.xcuda_Property.Sad_flow != null)
                {
                    a.Property.Sad_flow = da.xcuda_Property.Sad_flow;
                }
                if (da.xcuda_Property.Selected_page != null)
                {
                    a.Property.Selected_page = da.xcuda_Property.Selected_page;
                }

                if (da.xcuda_Property.xcuda_Forms != null)
                {
                    if (da.xcuda_Property.xcuda_Forms.Number_of_the_form != null)
                    {
                        a.Property.Forms.Number_of_the_form = da.xcuda_Property.xcuda_Forms.Number_of_the_form.ToString();
                    }
                    if (da.xcuda_Property.xcuda_Forms.Total_number_of_forms != null)
                    {
                        a.Property.Forms.Total_number_of_forms = da.xcuda_Property.xcuda_Forms.Total_number_of_forms.ToString();
                    }
                }
                if (da.xcuda_Property.xcuda_Nbers != null)
                {
                    if (da.xcuda_Property.xcuda_Nbers.Number_of_loading_lists != null)
                    {
                        a.Property.Nbers.Number_of_loading_lists = da.xcuda_Property.xcuda_Nbers.Number_of_loading_lists;
                    }
                    if (da.xcuda_Property.xcuda_Nbers.Total_number_of_items != null)
                    {
                        a.Property.Nbers.Total_number_of_items = da.xcuda_Property.xcuda_Nbers.Total_number_of_items;
                    }
                    // if(da.xcuda_Property.xcuda_Nbers.Total_number_of_packages != 0)
                    a.Property.Nbers.Total_number_of_packages = da.xcuda_Property.xcuda_Nbers.Total_number_of_packages.ToString();
                }
            }
        }
Exemplo n.º 14
0
 private void SaveDeclarant(xcuda_ASYCUDA da, ASYCUDA a)
 {
     if (da.xcuda_Declarant != null)
     {
         if (da.xcuda_Declarant.Declarant_code != null)
         {
             a.Declarant.Declarant_code = da.xcuda_Declarant.Declarant_code;
         }
         if (da.xcuda_Declarant.Declarant_name != null)
         {
             a.Declarant.Declarant_name = da.xcuda_Declarant.Declarant_name;
         }
         if (da.xcuda_Declarant.Declarant_representative != null)
         {
             a.Declarant.Declarant_representative.Text.Add(da.xcuda_Declarant.Declarant_representative);
         }
         if (da.xcuda_Declarant.Number != null)
         {
             a.Declarant.Reference.Number.Text.Add(da.xcuda_Declarant.Number);
         }
     }
 }
Exemplo n.º 15
0
        private void SetupProperties(ASYCUDA a, xcuda_ASYCUDA da)
        {
            ExportTemplate Exp;

            Exp = db.ExportTemplate.AsEnumerable().Where(x => da.xcuda_ASYCUDA_ExtendedProperties.Document_Type != null && x.Description == da.xcuda_ASYCUDA_ExtendedProperties.Document_Type.DisplayName).FirstOrDefault();

            //if (Exp == null && da.xcuda_ASYCUDA_ExtendedProperties.AsycudaDocumentSet != null && da.xcuda_ASYCUDA_ExtendedProperties.AsycudaDocumentSet.ExportTemplate != null)
            //{
            //    Exp = da.xcuda_ASYCUDA_ExtendedProperties.AsycudaDocumentSet.ExportTemplate;
            //}

            if (Exp == null)
            {
                Exp = db.ExportTemplate.FirstOrDefault();
            }
            a.Financial = new ASYCUDAFinancial();

            if (Exp.Deffered_payment_reference != null)
            {
                a.Financial.Deffered_payment_reference.Text.Add(Exp.Deffered_payment_reference);
            }

            a.Export_release = new ASYCUDAExport_release();
            a.Identification.Office_segment.Customs_clearance_office_code.Text.Add(Exp.Customs_clearance_office_code);

            a.General_information = new ASYCUDAGeneral_information();
            //a.Property = new ASYCUDAProperty();
            //a.Property.Forms = new ASYCUDAPropertyForms();
            a.Transport.Single_waybill_flag = true;
            a.Transport.Container_flag      = false;
            a.Container = null;
            a.Property.Forms.Number_of_the_form       = "1";
            a.Property.Nbers.Number_of_loading_lists  = "1";
            a.Property.Nbers.Total_number_of_packages = "1";
            a.Property.Forms.Total_number_of_forms    = "1";
            a.Property.Selected_page = "1";
            a.Traders = new ASYCUDATraders();
            if (Exp.Exporter_code != null)
            {
                a.Traders.Exporter.Exporter_code.Text.Add(Exp.Exporter_code);
            }
            if (Exp.Exporter_name != null)
            {
                a.Traders.Exporter.Exporter_name.Text.Add(Exp.Exporter_name);
            }
            if (Exp.Financial_code != null)
            {
                a.Traders.Financial.Financial_code.Text.Add(Exp.Financial_code);
            }
            if (Exp.Consignee_code != null)
            {
                a.Traders.Consignee.Consignee_code.Text.Add(Exp.Consignee_code);
            }
            if (Exp.Consignee_name != null)
            {
                a.Traders.Consignee.Consignee_name.Text.Add(Exp.Consignee_name);
            }
            a.Transit = new ASYCUDATransit();

            if (Exp.Country_first_destination != null)
            {
                a.General_information.Country.Country_first_destination.Text.Add(Exp.Country_first_destination);
            }

            if (Exp.Trading_country != null)
            {
                a.General_information.Country.Trading_country.Text.Add(Exp.Trading_country);
            }

            if (Exp.Export_country_code != null)
            {
                a.General_information.Country.Export.Export_country_code = Exp.Export_country_code;
            }

            if (Exp.Destination_country_code != null)
            {
                a.General_information.Country.Destination.Destination_country_code.Text.Add(Exp.Destination_country_code);
            }

            if (Exp.TransportName != null)
            {
                a.Transport.Means_of_transport.Departure_arrival_information.Identity.Text.Add(Exp.TransportName);
            }

            if (Exp.TransportNationality != null)
            {
                a.Transport.Means_of_transport.Departure_arrival_information.Nationality.Text.Add(Exp.TransportNationality);
            }

            if (Exp.Location_of_goods != null)
            {
                a.Transport.Location_of_goods.Text.Add(Exp.Location_of_goods);
            }

            if (Exp.Border_information_Mode != null)
            {
                a.Transport.Means_of_transport.Border_information.Mode.Text.Add(Exp.Border_information_Mode);
            }

            if (Exp.Delivery_terms_Code != null)
            {
                a.Transport.Delivery_terms.Code.Text.Add(Exp.Delivery_terms_Code);
            }

            a.Warehouse = new ASYCUDAWarehouse();
            if (Exp.Warehouse_Delay != null)
            {
                a.Warehouse.Delay = Exp.Warehouse_Delay;
            }

            if (Exp.Warehouse_Identification != null)
            {
                a.Warehouse.Identification.Text.Add(Exp.Warehouse_Identification);
            }



            a.Valuation = new ASYCUDAValuation();

            if (Exp.Gs_Invoice_Currency_code != null)
            {
                a.Valuation.Gs_Invoice.Currency_code.Text.Add(Exp.Gs_Invoice_Currency_code);
            }


            a.Valuation.Gs_Invoice.Amount_foreign_currency = Math.Round(da.xcuda_Item.Where(i => i.xcuda_Valuation_item.xcuda_Item_Invoice != null).Sum(i => i.xcuda_Valuation_item.xcuda_Item_Invoice.Amount_foreign_currency), 2).ToString();
            a.Supplier_documents.Add(new ASYCUDASupplier_documents()
            {
                Invoice_supplier_city = new ASYCUDASupplier_documentsInvoice_supplier_city()
                {
                    @null = new object()
                },

                Invoice_supplier_country = new ASYCUDASupplier_documentsInvoice_supplier_country()
                {
                    @null = new object()
                },

                Invoice_supplier_fax = new ASYCUDASupplier_documentsInvoice_supplier_fax()
                {
                    @null = new object()
                },

                Invoice_supplier_name = new ASYCUDASupplier_documentsInvoice_supplier_name()
                {
                    @null = new object()
                },
                Invoice_supplier_street = new ASYCUDASupplier_documentsInvoice_supplier_street()
                {
                    @null = new object()
                },
                Invoice_supplier_telephone = new ASYCUDASupplier_documentsInvoice_supplier_telephone()
                {
                    @null = new object()
                },

                Invoice_supplier_zip_code = new ASYCUDASupplier_documentsInvoice_supplier_zip_code()
                {
                    @null = new object()
                },
            });
        }
Exemplo n.º 16
0
        public void LoadFromDataBase(int ASYCUDA_Id, ASYCUDA a)
        {
            var doc = db.xcuda_ASYCUDA.FirstOrDefault(x => x.ASYCUDA_Id == ASYCUDA_Id);

            LoadFromDataBase(doc, a);
        }