Small Invoice with tdatabase

Small Invoice with tdatabase

Postby Silvio.Falconi » Sun Aug 11, 2019 7:20 pm

Some have a sample How create an Invoice with tdatabase add/mod/del

using 2 archives one for the header and one for the body of the invoice linked by the invoice number

and preferably using an array for the invoice body

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: 7053
Joined: Thu Oct 18, 2012 7:17 pm

Re: Small Invoice with tdatabase

Postby joseluisysturiz » Mon Aug 12, 2019 1:38 am

Saludos, tengo sistema de facturacion pero con MYSQL. la diferencia es mas el uso de los campos, trabaja con 2 tablas, tabla MASTER para datos de cabecera y totales de la factura y tabla DETALLES donde estan los items facturados relacionados con el numero de la factura en el master...la parte de carga de los items a faturarse los manejo en un array cuando se crea y cuando se modifica la factura...te sirve asi.? gracias... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: Small Invoice with tdatabase

Postby nageswaragunupudi » Mon Aug 12, 2019 2:04 am

Mr. Silivio

Please wait
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Small Invoice with tdatabase

Postby Silvio.Falconi » Mon Aug 12, 2019 10:30 am

joseluisysturiz wrote:Saludos, tengo sistema de facturacion pero con MYSQL. la diferencia es mas el uso de los campos, trabaja con 2 tablas, tabla MASTER para datos de cabecera y totales de la factura y tabla DETALLES donde estan los items facturados relacionados con el numero de la factura en el master...la parte de carga de los items a faturarse los manejo en un array cuando se crea y cuando se modifica la factura...te sirve asi.? gracias... :shock:


I know very well how an invoice was made exclusively: for the detail I used ordscope to set the invoice body. both with listbox and xbrowse

Now using the tdatabase class and then in share mode the problem is the network because all users on the network could use both the archive for the invoice header (reserva.dbf) and the details (resitems.dbf)

So a solution could be to block the record used in Reserva.dbf and since resitems is used in connection with reserva.dbf the other users cannot open it.

moreover in my specific case as I have already explained above I have to use a proper array as the example yunus.prg does

therefore in the insertion of the record I must add a line at the beginning
with the selected element and the price calculate according to a price table

when I go to save I have to take back the deleted records
and for now I have adopted a solution that is not very correct
1. block the reserva.dbf record
2. load the detail from resitems.dbf into an array aItems field-> invNUm == nInvoice
3. work with the xbrowse
4. except the record in reserva.dbf
5 except for the details on resitems.dbf first deleting all the records with the number nInvoice and then inserting all the content in aItems
5 unlock the record in reserva.dbf
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: 7053
Joined: Thu Oct 18, 2012 7:17 pm

Re: Small Invoice with tdatabase

Postby Silvio.Falconi » Mon Aug 12, 2019 11:26 am

[quote="nageswaragunupudi"]Mr. Silivio

Please wait[/quotethanks I'mwaiting fof your help sample
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: 7053
Joined: Thu Oct 18, 2012 7:17 pm

Re: Small Invoice with tdatabase

Postby joseluisysturiz » Mon Aug 12, 2019 1:27 pm

Silvio, creo deberias ser mas especifico en tu consulta y en lo que quieres ayuda, ya que tu requerimiento original solo dice que necesitas un pequeno ejemplo de factura con TDatabase, lamentablement yo trabajo con MYSQL y alli todo ese control sobre los archivos maestro y detalles...es mas facil...para eso es MYSQL para hacernos la vida mas facil y segura en relacion al manejo de datos, gracias... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: Small Invoice with tdatabase

Postby Silvio.Falconi » Mon Aug 12, 2019 7:11 pm

ok i try to be more specific, I explain you

I'm using the tdatabase class with two file reserva.dbf and resItems.dbf

I have a window where I have a series of btnbmp controls

the buttons can be free green or busy red the procedure check the file reserva.dbf if found the reservatiion, if yes load the reservation and change the button as red ( occupated)

when the user presses a btnbmp must open a menupopup where the user can change if it is red or can insert a reservation if it is green.

if it is a new entry, create the record object type

oPrenotazione:=oreservations:record(.t.)

or if a modify

oPrenotazione:=oreservations:record()

If is a modify I load the aItems array from resitems archive with

aItems := ( oPartres:cAlias )->( FW_DbfToArray( cItemFlds, { || AllTrim( FIELD->INVNUM ) = alltrim(nInvoice) }) )


When the reservation dialog opens, the number, type and dates of check_in and check-out, the user can select the customer holding the invoice
as you can see here



as I explained before I use an "aItems" array to create the body of the invoice

the procedure as the first line must include the information and the price of the item rented in this case the umbrella number 2 from 5 to 9 August ie for 4 days
therefore the first line must contain the reference to the umbrella with the aforementioned dates and the price that the procedure must assign according to a specific table

the user can insert the products you see listed in the figure, the procedure inserts them in the xbrowse (body of Invoice)


now I have to proceed with the save operation on reserva.dbf and resitems.dbf

for reserva.dbf there are no problemsthere may be some edit fields but in general use to save oPrenotazione :save ()


for the body ( resitems.dbf) I didn't understand how to proceed
if it is a new entry I go to the content of the "aItems" array in the resitems archive
if instead it is a change how do I save the detail?


in the exclusive version I decided to delete all records with the same invoice number and re-enter everything from the "aItems" array and then make the archive pack

but with the database class I open all the archives in share mode and I don't have to do the same operation that is I can't delete the records and then pack them

then I delete the records with the same invoice number and then replace the records with the arraytodbf function also making a recall of the deleted files

this procedure can run ok but there is an error as you can see here

Image

the records you see in red are deleted, then the function

Code: Select all  Expand view
oPartRes:ArrayToDBF( aItems, cItemFlds,nil , .t., .t. )


is not recalling deleted records and still saves the "aItems" array




I show you more specifically the rescue procedure


//check line number
AEval( aItems, { |a,i| a[ 2 ] := i } )

// delete all those with the same invoice number
oPartRes:Gotop()
Do While .not. oPartRes:eof()
IF alltrim(oPartRes:InvNum) == alltrim(nInvoice)
// Msginfo( oPartRes:InvNum ,nInvoice)
oPartRes:delete()
Endif
oPartRes:skip()
EndDo
oPartRes:Gotop()


// except by calling the deleted and filtering by num invoice
SET DELETED ON
oPartRes:setorder(0)
oPartRes:Exec( < ||
SET FILTER TO AllTrim( FIELD->INVNUM ) = alltrim(nInvoice)
return nil
> )
oPartRes:gotop()
oPartRes:ArrayToDBF( aItems, cItemFlds,nil , .t., .t. )
oPartRes:SetFilter( "" )
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: 7053
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 90 guests