/[papo]/papo/forms/productInvoice.gfd
ViewVC logotype

Diff of /papo/forms/productInvoice.gfd

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.53 by styxman, Thu Apr 17 16:54:57 2003 UTC revision 1.54 by apronotti, Wed Apr 23 21:14:44 2003 UTC
# Line 243  Line 243 
243    
244    <!-- Origen de datos que srive para calcular los impuestos del la factura -->    <!-- Origen de datos que srive para calcular los impuestos del la factura -->
245    
246    <datasource name="invTaxTotDataSource" database="papo"    <datasource name="ownDocumentTaxTotDataSource" database="papo"
247                table="own_document, own_document_tax">                table="own_document, own_document_tax">
248      <condition>      <condition>
249        <eq>        <eq>
# Line 253  Line 253 
253      </condition>      </condition>
254    </datasource>    </datasource>
255    
256      <!-- Origen de datos que srive para calcular el total facturado -->
257    
258      <datasource name="productCreditNoteTotalDataSource" database="papo"
259                  table="_entity_data, own_document, own_item, own_product_item, own_item_tax"
260                  order_by="own_product_item.id">
261        <condition>
262          <and>
263            <eq>
264              <!-- Aqui se refiere al cliente  -->
265              <cfield name="_entity_data.id"/>
266              <cfield name="own_document.recipient"/>
267            </eq>
268            <eq>
269              <cfield name="own_document.id"/>
270              <cfield name="own_item.own_document"/>
271            </eq>
272            <eq>
273              <cfield name="own_item.id"/>
274              <cfield name="own_product_item.own_item"/>
275            </eq>
276            <eq>
277              <cfield name="own_item.id"/>
278              <cfield name="own_item_tax.own_item"/>
279            </eq>
280            <or>
281              <eq>
282                <cfield name="own_document.own_document_type"/>
283                <cconst value="14"/> <!-- Nota de Crédito tipo A -->
284              </eq>
285              <eq>
286                <cfield name="own_document.own_document_type"/>
287                <cconst value="15"/> <!-- Nota de Crédito tipo B -->
288              </eq>
289              <eq>
290                <cfield name="own_document.own_document_type"/>
291                <cconst value="16"/> <!-- Nota de Crédito tipo C -->
292              </eq>
293            </or>
294         </and>
295        </condition>
296      </datasource>
297    
298    <!-- Origen de datos que srive para calcular el total adeudado -->    <!-- Origen de datos que srive para calcular el total adeudado -->
299    
300    <datasource name="paidTotalDataSource" database="papo" table="_entity_data, own_document, own_document_proceeding">    <datasource name="paidTotalDataSource" database="papo" table="_entity_data, own_document, own_document_proceeding">
# Line 269  Line 311 
311          </eq>          </eq>
312          <and>          <and>
313            <or>            <or>
 <!--             <eq> -->  
 <!--               <cfield name="own_document.own_document_type"/> -->  
 <!--               <cconst value="1"/>  -->  
 <!--             </eq> -->  
314              <eq>              <eq>
315                <cfield name="own_document.own_document_type"/>                <cfield name="own_document.own_document_type"/>
316                <cconst value="4"/>                <cconst value="4"/>
# Line 675  Line 713 
713          import hack          import hack
714    
715          condProductInvoice = GConditions.GCondition()          condProductInvoice = GConditions.GCondition()
716            condCreditNote = GConditions.GCondition()
717          #condServiceInvoice = GConditions.GCondition()          #condServiceInvoice = GConditions.GCondition()
718          condPay = GConditions.GCondition()          condPay = GConditions.GCondition()
719    
# Line 687  Line 726 
726              eq = GConditions.GCeq(tmpAnd)              eq = GConditions.GCeq(tmpAnd)
727              GConditions.GCField(eq,"_entity_data._table")              GConditions.GCField(eq,"_entity_data._table")
728              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))
             #tmpAnd = GConditions.GCand(condServiceInvoice)  
             #gt = GConditions.GCgt(tmpAnd)  
             #GConditions.GCField(gt,"own_document.date")  
             #GConditions.GCConst(gt,str(creditLimit1Block.timeStampEntry))  
             #eq = GConditions.GCeq(tmpAnd)  
             #GConditions.GCField(eq,"_entity_data._table")  
             #GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))  
729              tmpAnd = GConditions.GCand(condPay)              tmpAnd = GConditions.GCand(condPay)
730              gt = GConditions.GCgt(tmpAnd)              gt = GConditions.GCgt(tmpAnd)
731              GConditions.GCField(gt,"own_document.date")              GConditions.GCField(gt,"own_document.date")
# Line 706  Line 738 
738              eq = GConditions.GCeq(condProductInvoice)              eq = GConditions.GCeq(condProductInvoice)
739              GConditions.GCField(eq,"_entity_data._table")              GConditions.GCField(eq,"_entity_data._table")
740              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))
741              #eq = GConditions.GCeq(condServiceInvoice)              eq = GConditions.GCeq(condCreditNote)
742              #GConditions.GCField(eq,"_entity_data._table")              GConditions.GCField(eq,"_entity_data._table")
743              #GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))
744              eq = GConditions.GCeq(condPay)              eq = GConditions.GCeq(condPay)
745              GConditions.GCField(eq,"_entity_data._table")              GConditions.GCField(eq,"_entity_data._table")
746              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))
# Line 736  Line 768 
768                      more = productInvoiceResultSet.nextRecord()                      more = productInvoiceResultSet.nextRecord()
769                  invoiceTotal += item + itemTaxTotal                  invoiceTotal += item + itemTaxTotal
770              # Calcula los impuestos del documento en si              # Calcula los impuestos del documento en si
771              odt_rs = invTaxTotDataSource.createResultSet({"own_document.id":currOwnDoc})              odt_rs = ownDocumentTaxTotDataSource.createResultSet({"own_document.id":currOwnDoc})
772              odt_more = odt_rs.firstRecord()              odt_more = odt_rs.firstRecord()
773              while odt_more:              while odt_more:
774                  invoiceTotal += hack.a2f(odt_rs.current.getField("own_document_tax.amount"))                  invoiceTotal += hack.a2f(odt_rs.current.getField("own_document_tax.amount"))
775                  odt_more = odt_rs.nextRecord()                  odt_more = odt_rs.nextRecord()
776              spentTotal += invoiceTotal              spentTotal += invoiceTotal
777    
778          # Calculo del total facturado          # Calculo del total acreditado
779          ## Factura de servicios          productCreditNoteResultSet = productCreditNoteTotalDataSource.createResultSet(condCreditNote)
780          #serviceInvoiceResultSet= serviceInvoiceTotalDataSource.createResultSet (condServiceInvoice)          more = productCreditNoteResultSet.firstRecord()
781          #more= serviceInvoiceResultSet.firstRecord ()          creditTotal = 0
   
         # por todos los documentos post-checkpoint (si no hay, desde el principio)  
         # print "calc 4"  
         #while more:  
         #   invoiceTotal = 0  
         #   currentOwnDocument= serviceInvoiceResultSet.current.getField ("own_document.id")  
         #  
         #   # por todos los items del documento  
         #   # print "calc 5: [%s] %d" % (currentOwnDocument, spentTotal)  
         #   while serviceInvoiceResultSet.current.getField ("own_document.id")==currentOwnDocument and more:  
         #       item = hack.a2f(serviceInvoiceResultSet.current.getField ("own_service_item.amount"))  
         #       currentItem= serviceInvoiceResultSet.current.getField ("own_item.id")  
         #       itemTaxTotal = 0  
         #       # por todos los impuestos del item  
         #       # print "calc 6: [%s:%s] %d" % (currentOwnDocument, currentItem, invoiceTotal)  
         #       while serviceInvoiceResultSet.current.getField ("own_item.id")==currentItem and more:  
         #           # calculate the item price exactly as I do in the other trigger  
         #           # not revised yet, but I think it was like this  
         #           itemTaxTotal += hack.a2f(serviceInvoiceResultSet.current.getField ("own_item_tax.amount"))  
         #           more= serviceInvoiceResultSet.nextRecord ()  
         #           # print "calc 7: %d:%d" % (item, itemTaxTotal)  
         #  
         #       invoiceTotal+= item + itemTaxTotal  
         #  
         #   spentTotal+= invoiceTotal  
782    
783            while more:
784                creditNoteTotal = 0
785                currOwnDoc = productCreditNoteResultSet.current.getField("own_document.id")
786                while productCreditNoteResultSet.current.getField("own_document.id") == currOwnDoc and more:
787                    lQty = hack.a2f(productCreditNoteResultSet.current.getField("own_product_item.qty"))
788                    lUnitPrice = hack.a2f(productCreditNoteResultSet.current.getField("own_product_item.unit_price"))
789                    lBonus = hack.a2f(productCreditNoteResultSet.current.getField("own_item.bonus"))
790                    lDiscount = hack.a2f(productCreditNoteResultSet.current.getField("own_item.discount"))
791                    item = lQty * lUnitPrice - lBonus - lDiscount
792                    #print "qty %d * unit_price %d - bonus %d - discount %d = %d " % (lQty, lUnitPrice, lBonus, lDiscount, lQty * lUnitPrice - lBonus - lDiscount)
793                    itemTaxTotal = 0
794                    currItem = productCreditNoteResultSet.current.getField("own_item.id")
795                    while productCreditNoteResultSet.current.getField("own_item.id") == currItem and more:
796                        itemTaxTotal += hack.a2f(productCreditNoteResultSet.current.getField("own_item_tax.amount"))
797                        more = productCreditNoteResultSet.nextRecord()
798                    creditNoteTotal += item + itemTaxTotal
799                # Calcula los impuestos del documento en si
800                odt_rs = ownDocumentTaxTotDataSource.createResultSet({"own_document.id":currOwnDoc})
801                odt_more = odt_rs.firstRecord()
802                while odt_more:
803                    creditNoteTotal += hack.a2f(odt_rs.current.getField("own_document_tax.amount"))
804                    odt_more = odt_rs.nextRecord()
805                creditTotal += creditNoteTotal
806    
807          # Calculo del total cobrado          # Calculo del total cobrado
808          paidResultSet = paidTotalDataSource.createResultSet(condPay)          paidResultSet = paidTotalDataSource.createResultSet(condPay)
# Line 788  Line 818 
818          #print "invoiceTotal ", invoiceTotal          #print "invoiceTotal ", invoiceTotal
819          #print "balance ", balance          #print "balance ", balance
820          #print "payTotal ", payTotal          #print "payTotal ", payTotal
821            #print "creditTotal ", creditTotal
822          # Calculo del total adeudado          # Calculo del total adeudado
823          deudaTotal = spentTotal - balance - payTotal          deudaTotal = spentTotal - payTotal - creditTotal - balance
824          ownDocumentBlock.clientRecipientBox.deudaEntry = deudaTotal          ownDocumentBlock.clientRecipientBox.deudaEntry = deudaTotal
825    
826          # ******** FALTA GRABAR EL BALANCE **************          # ******** FALTA GRABAR EL BALANCE **************

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.54

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26