editing yunus invoice

editing yunus invoice

Postby Silvio.Falconi » Tue Oct 19, 2021 9:52 am

As a friend asked me for a small program to place orders,
since I don't have much time to devote to family problems,
I'm trying to modify yunus.prg to make it viable in Italy,
I will probably have countless problems but i want to try if i can use yunus.prg for my friend

I added tax fields because here in Italy we can have a different VAT for each item.

1. I added the tax for each item (items.dbf)
2. I added the tax in the body of the invoice (invitems.dbf)

when I go to create an order it makes the wrong calculation ie as you can see in this figure

Image

the Net column should be 6 but 4.7595 that is rounded 4.76 where does the calculation of the Net column do?

for a sample :

Price 25.05

TAX %: 19%
Price without Tax: 25.05
Price with tax: 29.81 ( amount)
Tax import: 4.76

How i can to implement this on yunus ?



I modified on function EditInvoice( oRec )

I add this line before the xbrowse

Code: Select all  Expand view
bCalcRow := { || (TotalRow(oBrw),  oBrw:RefreshFooters(), oDlg:Update() )}



Code: Select all  Expand view

for each cCol in { "qty", "price", "discount","tax" }
      WITH OBJECT oBrw:oCol( cCol )
         :nEditType     := EDIT_GET
         :bEditValid    := { |o| o:VarGet() >= 0 }
        * :bOnChange     := { || oBrw:MakeTotals( { "amount", "net" } ), oBrw:RefreshFooters(), oDlg:Update() }
         :bOnChange     := bCalcRow

      END
   next


I add this function to cal the total of row

Code: Select all  Expand view
static function TotalRow(oBrw)
   local nPriceUnit := oBrw:aCols[ 5 ]:Value
   local nQuantity  := oBrw:aCols[ 3 ]:Value
   local ntax       := oBrw:aCols[ 7 ]:Value
   local ndescount  := oBrw:aCols[ 8 ]:Value
   local nTotalRow  := 0
   local nTotalTax  := 0

      nTotalRow  := nPriceUnit * nQuantity
      nTotalTax  := (nTotalRow*100)/ntax

        If ndescount >0
            nTotalRow :=  nTotalRow - ndescount
         Endif

     oBrw:aCols[6]:VarPut(nTotalRow)
     oBrw:aCols[9]:VarPut(nTotalTax)

return nil

 


But not run !!!











thanks
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7047
Joined: Thu Oct 18, 2012 7:17 pm

Re: editing yunus invoice

Postby Marc Venken » Tue Oct 19, 2021 11:04 am

Silvio,

In Yunus, the NET is calculated in the header part of the xbrowse. Did you change that also ? Position is now column 9 in your sample.

The calculation for tax =

// not so : nTotalTax := (nTotalRow*100)/ntax

NTotalTax:= (nTotalrow * nTax) / 100

Tip :

Consider using that header name in your functions for better reading and sure when you add a column, all formulas will go wrong. With the names you have no problems.

oBrw:NET:VarPut( value ) instead of oBrw:acols[9]:varput(value)
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1426
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: editing yunus invoice

Postby Marc Venken » Tue Oct 19, 2021 11:09 am

Ask your friend also if the discount will be a percentage or a value.

I think it will always be a percentage and than you have to rewrite your code accourdingly.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1426
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: editing yunus invoice

Postby Marc Venken » Tue Oct 19, 2021 11:22 am

Maybe this code can help you a little :
Code: Select all  Expand view

   aVelden :=  { ;
   { "refnummer"  , "Code"    ,nil,  90 }, ;
   { "aantal"     , "BES"     ,nil,  40 }, ;
   { "geleverd"   , "LEV"     ,nil,  40 }, ;
   { "backorder"  , "Back"    ,nil,  45 }, ;
   { "benaming"   , "Benaming",nil, 530 }, ;
   { "eenh_prijs" , "Prijs"   ,nil,  65 }, ;
   { "korting"    , "Kor"     ,nil,  40 }, ;
   { "totaal"     , "Totaal"  ,nil,  60  } }

    REDEFINE  XBROWSE  oLbxdet ;
      DATASOURCE "detail" ;
      COLUMNS aVelden;
      font oXbrwFont;
      ID 9000 ;
      OF  oFld:aDialogs[ 1 ];
      CELL LINES FOOTERS NOBORDER FASTEDIT

      oLbxdet:lAutoAppend:=.t.
.....

        WITH OBJECT :PRIJS
           :nEditType     := EDIT_GET
           :bOnChange     := { |oCol,uOldVal| Herberekening( oLbxdet, oCol:Value ) }
           :bKeyChar      := { |k| If( k == VK_RETURN, ( oLbxdet:GoRight(), 0 ), nil ) }
        ENDWITH

        WITH OBJECT :KOR
           :nEditType     := EDIT_GET
           :bOnChange     := { |oCol,uOldVal| Herberekening( oLbxdet, oCol:Value ) }
           :bKeyChar      := { |k| If( k == VK_RETURN, ( oLbxdet:GoRight(), 0 ), nil ) }

        ENDWITH

function Herberekening(oBrw,oCol)
  local nTotaal:=0
  nTotaal = (oBrw:BES:value * oBrw:prijs:value) - ;
            ((oBrw:BES:value*oBrw:prijs:value)*oBrw:kor:value/100)
  oBrw:totaal:varput(nTotaal)
  oBrw:BACK:varput(oBrw:BES:value - oBrw:LEV:value)
  oBrw:MakeTotals()
  oBrw:refresh()
return .t.

 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1426
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: editing yunus invoice

Postby Silvio.Falconi » Tue Oct 19, 2021 11:31 am

Marc Venken wrote:Silvio,

In Yunus, the NET is calculated in the header part of the xbrowse. Did you change that also ? Position is now column 9 in your sample.

The calculation for tax =

// not so : nTotalTax := (nTotalRow*100)/ntax

NTotalTax:= (nTotalrow * nTax) / 100

Tip :

Consider using that header name in your functions for better reading and sure when you add a column, all formulas will go wrong. With the names you have no problems.

oBrw:NET:VarPut( value ) instead of oBrw:acols[9]:varput(value)



you're right (nTotalRow*ntax)/100

oBrw:NET:VarPut( nTotalTax )Not run ok
oBrw:AMOUNT:VarPut( nTotalRow ) Not run ok
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7047
Joined: Thu Oct 18, 2012 7:17 pm


Re: editing yunus invoice

Postby Marc Venken » Tue Oct 19, 2021 12:32 pm

Silvio.Falconi wrote:
oBrw:NET:VarPut( nTotalTax )Not run ok
oBrw:AMOUNT:VarPut( nTotalRow ) Not run ok



The problem is that ndescount = undifined ?? and it failes at

if ndescount > 0

if you comment them out, you get no error, but i'm sure that the browse is setup correct. I never use the

ADD to oBrw at 6 HEADER "Amount" stuff
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1426
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: editing yunus invoice

Postby Silvio.Falconi » Tue Oct 19, 2021 12:46 pm

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7047
Joined: Thu Oct 18, 2012 7:17 pm

Re: editing yunus invoice

Postby Marc Venken » Tue Oct 19, 2021 1:30 pm

I wish use yunus.prg and adapt it for a italian invoice , it is too differentbfrom invoice of yunus.prg
you know we italians have a tax for each articles


Silvio,

Taxes are no problem. In Belgium there are also several taxes, and you simple put a tax code for each article and you make a tax function to process them when printing.

But I suppose that there is more stuff involved ? I get many invoices from Portugal, are they like the once in Italia ?
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1426
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Natter and 85 guests