+ it('apply the cash receipt to the invoice', function (done) {
+ var sql = mqlToSql("SELECT applyCashReceiptLineBalance(" +
+ " <? value('crid') ?>, aropen_id, aropen_amount," +
+ " aropen_curr_id) AS result" +
+ " FROM aropen" +
+ " JOIN invchead ON aropen_doctype = 'I'" +
+ " AND aropen_docnumber=invchead_invcnumber" +
+ " WHERE invchead_id=<? value('invchead') ?>;",
+ { crid: cashrcpt.cashrcpt_id,
+ invchead: invchead.invchead_id });
+ datasource.query(sql, creds, function (err, res) {
+ assert.equal(res.rowCount, 1);
+ assert(res.rows[0].result > 0, 'expect an application');
+ // applyCashReceiptLineBalance subtracts discounts so we can't just
+ // assert.closeTo(res.rows[0].result, cohead.amount, closeEnough);
+ done();
+ });
+ });
+