- Code: Select all
Function CreatePayment(ByVal purchaseInvoice As PurchaseInvoice)
...
Dim paymentBatch = JiwaFactory.CreateBusinessLogic(Of JiwaCRBatchTX.CreditorBatchTrans)(Nothing)
paymentBatch.CreateNew()
paymentBatch.Setup()
paymentBatch.RecID = NewJiwaID(20)
paymentBatch.BatchType = JiwaCRBatchTX.CreditorBatchTrans.CreditorBatchTypes.Creditor_Payment
paymentBatch.BatchDate = Date.Today
paymentBatch.Description = "Payment for Receipt/Invoice #" & purchaseInvoice.InvoiceNo
paymentBatch.Save()
paymentBatch.Read(paymentBatch.RecID) ' reload
Dim creditorID = purchaseInvoice.Creditor.CreditorID
Dim receiptDate As Date = Date.Parse(purchaseInvoice.InvoiceDate)
For Each pil As JiwaPurchaseInvoices.Line In purchaseInvoice.Lines
Dim payment As JiwaCRBatchTX.CRBatchTranLine = New JiwaCRBatchTX.CRBatchTranLine() With {.Manager = paymentBatch.Manager}
payment.Setup()
payment.RecID = NewJiwaID(20)
payment.RemitNo = purchaseInvoice.InvoiceNo
payment.Creditor.ReadRecord(creditorID)
payment.ReceiptDate = receiptDate
payment.CurrencyRateUsed = pil.CurrencyRateUsed
paymentBatch.TransLines.Add(payment)
payment.HomeTransAmount = pil.LineTotal
Dim dispersal As JiwaCRBatchTX.CRBatchDispersal = payment.Dispersals(1)
dispersal.OtherLedger.ReadRecord(paymentMethod.RecID)
dispersal.Remark = purchaseOrder.OrderNo
If purchaseOrder.BackToBackSalesOrder IsNot Nothing AndAlso Not String.IsNullOrWhiteSpace(purchaseOrder.BackToBackSalesOrder.InvoiceNo) Then
Dim so = purchaseOrder.BackToBackSalesOrder
dispersal.LineReference = String.Format("{0} ({1} - {2})", so.InvoiceNo, so.DebtorAccountNo, so.DebtorName)
End If
Next
paymentBatch.Save()
Is there a handy example on how to do the next bit, which is to allocate the payment (to the supplied invoice)?


