Topic: Minus values on refunds

I just couldn't work out the way to display refund (Cr.) invoice values in minus. I got some OK (Thanks to Derek's sample) but some not as highlighted on the image below. As a result calcs return incorrect values.


https://s27.postimg.org/qndrs2hdv/zzzzz_Temp33.png


Please see the attached sample project.
------------------------

Post's attachments

Attachment icon Minus Totals Cr.zip 16.02 kb, 320 downloads since 2017-05-21 

Adam
God... please help me become the person my dog thinks I am.

Re: Minus values on refunds

Sorted calc fields.. but cannot get Discount and Deliv Cost values displayed as minus (-) values.


tried following but no luck

frmSalesInv.edSalesInvDelivCost.Value := - (frmSalesInv.edSalesInvDelivCost.Value);
frmSalesInv.edSalesInvDiscount.value := - (frmSalesInv.edSalesInvDiscount.value);
Adam
God... please help me become the person my dog thinks I am.

Re: Minus values on refunds

Check this out and see if it's ok for you.

Post's attachments

Attachment icon Minus Totals Cr2.zip 594.04 kb, 348 downloads since 2017-05-22 

Re: Minus values on refunds

Hi EHW,


Great stuff as usual.................
Thank you very much.............
Truly appreciated....................

Adam
God... please help me become the person my dog thinks I am.

Re: Minus values on refunds

Hi EHW,


Looks like I have overlooked some items.

Adding sale or refund inv works fine.
However, converting (changing) sele inv to refund inv and refund inv to sale inv using DB/CR combo is not.


1. Entered sale  then changed DC/CR combo to refund. Discount and Deliv Cost fields values is not converted to minus:
https://s15.postimg.org/yyhjhd097/zzzzz_Temp34.png



1. Entered refund then changed DC/CR combo to sale. Discount and Deliv Cost fields values is not converted to positive numbers:
https://s24.postimg.org/m5lhj19id/zzzzz_Temp35.png


I have tried to move your code under DBCR combo on change with else but didn't work:

procedure frmSalesInv_cbSaleInvDBCR_OnChange (Sender: string); // SALE or REFUND
begin
  If (frmSalesInv.cbSaleInvDBCR.dbItemID = 2) and (frmSalesInv.edSalesInvDelivCost.Value > 0) then
      begin
      frmSalesInv.edSalesInvDelivCost.Value := 0 - frmSalesInv.edSalesInvDelivCost.Value;
      CalculateTotal;
      end else
      begin
      frmSalesInv.cbSaleInvDBCR.dbItemID := 1;
      frmSalesInv.edSalesInvDelivCost.Value;
      CalculateTotal;
      end;

  If (frmSalesInv.cbSaleInvDBCR.dbItemID = 2) and (frmSalesInv.edSalesInvDiscount.Value > 0) then
      begin
      frmSalesInv.edSalesInvDiscount.Value := 0 - frmSalesInv.edSalesInvDiscount.value;
      CalculateTotal;
      end else
      frmSalesInv.cbSaleInvDBCR.dbItemID := 1;
      frmSalesInv.edSalesInvDiscount.Value;
      CalculateTotal;
end;
Adam
God... please help me become the person my dog thinks I am.

6 (edited by ehwagner 2017-05-23 16:10:17)

Re: Minus values on refunds

Just place the following in your DB/CR combo. That should take care of that situation.

procedure frmSalesInv_cbSaleInvDBCR_OnChange (Sender: string); // SALE or REFUND
begin
  If frmSalesInv.cbSaleInvDBCR.dbItemID = 1 then
    Begin
     If frmSalesInv.edSalesInvDelivCost.Value < 0 then
      frmSalesInv.edSalesInvDelivCost.Value := 0 - frmSalesInv.edSalesInvDelivCost.Value;
     If frmSalesInv.edSalesInvDiscount.Value < 0 then
      frmSalesInv.edSalesInvDiscount.Value := 0 - frmSalesInv.edSalesInvDiscount.value;
    End;
  If frmSalesInv.cbSaleInvDBCR.dbItemID = 2 then
    Begin
     If frmSalesInv.edSalesInvDelivCost.Value > 0 then
      frmSalesInv.edSalesInvDelivCost.Value := 0 - frmSalesInv.edSalesInvDelivCost.Value;
     If frmSalesInv.edSalesInvDiscount.Value > 0 then
      frmSalesInv.edSalesInvDiscount.Value := 0 - frmSalesInv.edSalesInvDiscount.value;
    End;;
  CalculateTotal;
end;

Re: Minus values on refunds

Thank you very much for the solution and quick reply..............................................


Looks like my logic is still rotten in these matters.

Adam
God... please help me become the person my dog thinks I am.