Esempio n. 1
0
 static private Exception CreateBillStamperException(Bill bill, WSConecFM.Resultados stampResult) {
   var e = new Ordering.TradeOrderingException(Ordering.TradeOrderingException.Msg.CreateBillStamperException,
                                               bill.Order.Number, bill.Order.Customer.FullName,
                                               stampResult.code, stampResult.message);
   e.Publish();
   return e;
 }
Esempio n. 2
0
    static public XmlBill Parse(Bill bill) {
      XmlBill facturaXml = new XmlBill();

      facturaXml.bill = bill;

      return facturaXml;
    }
Esempio n. 3
0
 static public void CancelStamp(Bill bill) {
   var ws = new WSConecFM.Cancelado();
   var request = BillStamper.GetCancelStampRequest(bill);
   WSConecFM.Resultados stampResult = ws.Cancelar(request, bill.Stamp.UUID);
   if (!stampResult.status) {
     throw CancelBillStamperException(bill, stampResult);
   }
 }
Esempio n. 4
0
    static internal int WriteBill(Bill o) {
      DataOperation dataOperation = DataOperation.Parse("writeCRMBill", o.Id, (char) o.BillType,
                        o.Order.Id, o.Order.ExternalOrderId, o.IssuedBy.Id, o.IssuedTime, o.CertificateNumber,
                        o.SerialNumber, o.Number, o.ApprovalYear, o.ApprovalNumber, o.DigitalString,
                        o.DigitalSign, o.GetXmlString(), o.HasStamp ? o.Stamp.ToJson() : String.Empty,
                        o.CanceledBy.Id, o.CancelationTime, (char) o.Status);

      return DataWriter.Execute(dataOperation);
    }
Esempio n. 5
0
    static internal BillStamp Stamp(Bill bill) {
      var ws = new WSConecFM.Timbrado();
      var request = BillStamper.GetStampRequest(bill);

      WSConecFM.Resultados stampResult = ws.Timbrar(bill.GetXmlFileNameFull(), request);
      if (stampResult.status) {
        return new BillStamp(stampResult);
      } else {
        throw CreateBillStamperException(bill, stampResult);
      }
    }
Esempio n. 6
0
    static private WSConecFM.requestCancelarCFDI GetCancelStampRequest(Bill bill) {
      var request = new WSConecFM.requestCancelarCFDI();

      if (bill.NotOrderData == null) {
        request.emisorRFC = bill.Order.Supplier.FormattedTaxIDNumber;
      } else {
        request.emisorRFC = bill.IssuedBy.FormattedTaxIDNumber;
      }
      request.urlCancelado = BillStamper.WSConnectUrl;
      request.UserID = BillStamper.WSConnectUserID;
      request.UserPass = BillStamper.WSConnectUserPass;
      request.uuid = bill.Stamp.UUID;

      return request;
    }
Esempio n. 7
0
    static private WSConecFM.requestTimbrarCFDI GetStampRequest(Bill bill) {
      var request = new WSConecFM.requestTimbrarCFDI();

      if (bill.NotOrderData == null) {
        request.emisorRFC = bill.Order.Supplier.FormattedTaxIDNumber;
      } else {
        request.emisorRFC = bill.IssuedBy.FormattedTaxIDNumber;
      }
      request.generarCBB = true;
      request.generarPDF = false;
      request.generarTXT = false;
      request.urlTimbrado = BillStamper.WSConnectUrl;
      request.UserID = BillStamper.WSConnectUserID;
      request.UserPass = BillStamper.WSConnectUserPass;

      return request;
    }
Esempio n. 8
0
    protected override void OnLoadObjectData(DataRow row) {
      this.number = (string) row["SupplierOrderNumber"];
      this.customerOrderNumber = (string) row["CustomerOrderNumber"];
      this.dutyEntryTag = (string) row["OrderDutyEntryTag"];
      this.concept = (string) row["SupplyOrderConcept"];
      this.supplyChannel = SupplyChannel.Parse((int) row["SupplyChannelId"]);
      this.supplyPoint = Contact.Parse((int) row["SupplyPointId"]);
      this.supplier = Contact.Parse((int) row["SupplierId"]);
      this.supplierContact = Person.Parse((int) row["SupplierContactId"]);

      this.customerContact = Person.Parse((int) row["CustomerContactId"]);
      this.deliveryMode = DeliveryMode.Parse((int) row["DeliveryModeId"]);
      this.deliveryTo = Contact.Parse((int) row["DeliveryToId"]);
      this.deliveryPoint = Contact.Parse((int) row["DeliveryPointId"]);
      this.deliveryContact = Person.Parse((int) row["DeliveryContactId"]);

      this.authorizationId = (int) row["OrderAuthorizationId"];
      this.currency = Currency.Parse((int) row["SupplyOrderCurrencyId"]);
      this.orderingTime = (DateTime) row["OrderingTime"];
      this.closedBy = Person.Parse((int) row["ClosedById"]);
      this.closingTime = (DateTime) row["ClosingTime"];
      this.canceledBy = Person.Parse((int) row["CanceledById"]);
      this.cancelationTime = (DateTime) row["CancelationTime"];
      this.keywords = (string) row["SupplyOrderKeywords"];
      this.payment = CRTransaction.Parse((int) row["CRTransactionId"]);
      this.bill = Bill.Parse((int) row["BillId"]);
      this.externalOrderId = (int) row["ExternalOrderId"];
      this.parentSupplyOrderId = (int) row["ParentSupplyOrderId"];
      this.postedBy = Contact.Parse((int) row["PostedById"]);
      this.postingTime = (DateTime) row["PostingTime"];

      this.status = (OrderStatus) Convert.ToChar(row["SupplyOrderStatus"]);

      if (this.Status == OrderStatus.Opened) {
        this.customer = BaseObject.ParseFull<Contact>((int) row["CustomerId"]);
      } else {
        this.customer = Contact.Parse((int) row["CustomerId"]);
      }
    }
Esempio n. 9
0
    static public void GenerateDailyBill(Contact supplier, DateTime fromDate, DateTime toDate) {
      if (fromDate.Month != toDate.Month || fromDate.Year != toDate.Year) {
        throw new TradeOrderingException(TradeOrderingException.Msg.InvalidPeriodForDailyBills, fromDate, toDate);
      }
      DateTime dailyBillDate = toDate.AddDays(3) > DateTime.Now ? toDate : DateTime.Now;   // 72 hrs to send to stamp;

      DataView view = BillingDS.GetBills(fromDate, toDate, "[BillType] IN ('G', 'L')");
      if (view.Count != 0) { // Global bills already generated
        Empiria.Messaging.Publisher.Publish("Global bills already generated for the selected period");
        return;
      }

      Bill bill = null;

      string filter = "( (BillId = -1 AND SupplyOrderStatus <> 'O') AND ClosingTime >= '" + fromDate.ToString("yyyy-MM-dd") + "' AND " +
                      "ClosingTime <= '" + toDate.ToString("yyyy-MM-dd HH:mm:ss") + "' AND " +
                      "CancelationTime > '" + toDate.ToString("yyyy-MM-dd HH:mm:ss") + "' ) OR " +
                      "( (BillId <> -1 AND SupplyOrderStatus <> 'O') AND ClosingTime >= '" + fromDate.ToString("yyyy-MM-dd") + "' AND " +
                      "ClosingTime <= '" + toDate.ToString("yyyy-MM-dd HH:mm:ss") + "' AND " +
                      "BillIssuedTime > '" + toDate.ToString("yyyy-MM-dd HH:mm:ss") + "' )";

      view = SupplyOrdersData.GetSupplierOrders(supplier, filter, "ExternalOrderId ASC");

      if (view.Count != 0) {
        bill = new Bill();
        bill.BillType = BillType.GlobalBill;
        bill.issuedBy = supplier;
        bill.supplyOrder = SupplyOrder.Empty;
        bill.issuedTime = dailyBillDate;   // 72 hrs to send to stamp
        bill.NotOrderData = BillNoOrderData.Parse(view);
        bill.Create();
      }
      filter = "(BillId = -1) AND ClosingTime < '" + fromDate.ToString("yyyy-MM-dd") + "' AND " +
               "CancelationTime >= '" + fromDate.ToString("yyyy-MM-dd") + "' AND " +
               "CancelationTime <= '" + toDate.ToString("yyyy-MM-dd HH:mm:ss") + "' AND SupplyOrderStatus IN ('L', 'X')";

      view = SupplyOrdersData.GetSupplierOrders(supplier, filter, "ExternalOrderId ASC");

      if (view.Count != 0) {
        bill = new Bill();
        bill.BillType = BillType.GlobalCreditNote;
        bill.issuedBy = supplier;
        bill.supplyOrder = SupplyOrder.Empty;
        bill.issuedTime = dailyBillDate;   // 72 hrs to send to stamp
        bill.NotOrderData = BillNoOrderData.Parse(view);
        bill.Create();
      }

      filter = "(BillId <> -1) AND ClosingTime < '" + fromDate.ToString("yyyy-MM-dd") + "' AND " +
               "BillIssuedTime >= '" + fromDate.ToString("yyyy-MM-dd") + "' AND " +
               "BillIssuedTime <= '" + toDate.ToString("yyyy-MM-dd HH:mm:ss") + "' AND SupplyOrderStatus IN ('D','C')";

      view = SupplyOrdersData.GetSupplierOrders(supplier, filter, "ExternalOrderId ASC");

      if (view.Count != 0) {
        bill = new Bill();
        bill.BillType = BillType.GlobalCreditNote;
        bill.issuedBy = supplier;
        bill.supplyOrder = SupplyOrder.Empty;
        bill.issuedTime = dailyBillDate;   // 72 hrs to send to stamp
        bill.NotOrderData = BillNoOrderData.Parse(view);
        bill.Create();
      }
    }
Esempio n. 10
0
    static public Bill Parse(SupplyOrder order) {
      Assertion.AssertObject(order, "order");

      if (order.Bill.IsEmptyInstance) {
        var bill = new Bill();
        bill.supplyOrder = order;
        bill.Create();
        order.Bill = bill;
        order.Save();
      }
      return order.Bill;
    }