Skip to Content
0
Former Member
Jun 03, 2008 at 12:00 PM

Error whilst posting a payment against an invoice ..

74 Views

I'm trying to post a payment against an invoice but i'm getting an error saying

"Error -10: Base Document Card and Target Document Card do not match"

The code is shown below


 // Post a payment against this invoice  ..

            Payments oPay = (Payments)B1Connections.diCompany.GetBusinessObject(BoObjectTypes.oIncomingPayments);
            oPay.CardCode = form.DataSources.DBDataSources.Item("@MyFileName").GetValue("U_BPCode", 0);
            oPay.CardName = ((EditText)form.Items.Item("CardName").Specific).Value;
            oPay.Reference1 = ((EditText)form.Items.Item("DocEntry").Specific).Value;
            string workFld = ((EditText)form.Items.Item("U_Balance").Specific).Value;

            oPay.CashSum = Convert.ToDouble(workFld);
            oPay.CashAccount = "161010";
            oPay.DocType = BoRcptTypes.rCustomer;

            oPay.Invoices.DocEntry = invoice.DocNum;
            oPay.Invoices.DocLine = 0; 
            oPay.Invoices.InvoiceType = BoRcptInvTypes.it_Receipt;
            oPay.Invoices.DiscountPercent = 0;
            oPay.Invoices.SumApplied = invoice.BaseAmount;
            oPay.Invoices.Add();

            int rtnCode = oPay.Add();

           Utility.handleAnError(rtnCode);

I've checked the obvious that the invoice.DocNum does relate to the business partner in oPay.CardCode ..

Anyone any ideas ? The invoice is a service invoice and I don't have any Sales Order or anything for it ..

TIA