/[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.42 by apronotti, Mon Mar 10 21:25:42 2003 UTC revision 1.43 by apronotti, Wed Mar 12 20:05:40 2003 UTC
# Line 132  Line 132 
132    </datasource>    </datasource>
133    
134    <!-- Origen de datos para obtener el total facturado a este cliente (para el calculo del balance de la cta cte) -->    <!-- Origen de datos para obtener el total facturado a este cliente (para el calculo del balance de la cta cte) -->
135    <datasource name="serviceInvoiceTotalDataSource" database="papo"  <!--   <datasource name="serviceInvoiceTotalDataSource" database="papo" -->
136      table="_entity_data, own_document, own_item, own_service_item, own_item_tax"  <!--     table="_entity_data, own_document, own_item, own_service_item, own_item_tax" -->
137      order_by="own_service_item.id">  <!--     order_by="own_service_item.id"> -->
138      <condition>  <!--     <condition> -->
139        <and>  <!--       <and> -->
140          <eq>  <!--         <eq> -->
141            <!-- Aqui se refiere al cliente  -->            <!-- Aqui se refiere al cliente  -->
142            <cfield name="_entity_data.id"/>  <!--           <cfield name="_entity_data.id"/> -->
143            <cfield name="own_document.recipient"/>  <!--           <cfield name="own_document.recipient"/> -->
144          </eq>  <!--         </eq> -->
145          <eq>  <!--         <eq> -->
146            <cfield name="own_document.id"/>  <!--           <cfield name="own_document.id"/> -->
147            <cfield name="own_item.own_document"/>  <!--           <cfield name="own_item.own_document"/> -->
148          </eq>  <!--         </eq> -->
149          <eq>  <!--         <eq> -->
150            <cfield name="own_item.id"/>  <!--           <cfield name="own_item.id"/> -->
151            <cfield name="own_service_item.own_item"/>  <!--           <cfield name="own_service_item.own_item"/> -->
152          </eq>  <!--         </eq> -->
153          <eq>  <!--         <eq> -->
154            <cfield name="own_item.id"/>  <!--           <cfield name="own_item.id"/> -->
155            <cfield name="own_item_tax.own_item"/>  <!--           <cfield name="own_item_tax.own_item"/> -->
156          </eq>  <!--         </eq> -->
157          <eq>  <!--         <eq> -->
158            <cfield name="own_document.own_document_type"/>  <!--           <cfield name="own_document.own_document_type"/> -->
159            <cconst value="1"/>  <!--      <cconst value="1"/>  -->
160          </eq>  <!--         </eq> -->
161       </and>  <!--      </and> -->
162      </condition>  <!--     </condition> -->
163    </datasource>  <!--   </datasource> -->
164    
165    <!-- Origen de datos que srive para calcular el total facturado -->    <!-- Origen de datos que srive para calcular el total facturado -->
166    
167    <datasource name="productInvoiceTotalDataSource" database="papo"    <datasource name="productInvoiceTotalDataSource" database="papo"
168                table="_entity_data, own_document, own_item, own_product_item, _price_data, own_item_tax"                table="_entity_data, own_document, own_item, own_product_item, own_item_tax"
169                order_by="own_product_item.id">                order_by="own_product_item.id">
170      <condition>      <condition>
171        <and>        <and>
# Line 183  Line 183 
183            <cfield name="own_product_item.own_item"/>            <cfield name="own_product_item.own_item"/>
184          </eq>          </eq>
185          <eq>          <eq>
           <cfield name="own_product_item.price"/>  
           <cfield name="_price_data.id"/>  
         </eq>  
         <eq>  
186            <cfield name="own_item.id"/>            <cfield name="own_item.id"/>
187            <cfield name="own_item_tax.own_item"/>            <cfield name="own_item_tax.own_item"/>
188          </eq>          </eq>
# Line 569  Line 565 
565        #print "cantidad: ",lQty        #print "cantidad: ",lQty
566        lBonus = hack.a2f(lRecord.getField("own_item.bonus"))        lBonus = hack.a2f(lRecord.getField("own_item.bonus"))
567        lDiscount = hack.a2f(lRecord.getField("own_item.discount"))        lDiscount = hack.a2f(lRecord.getField("own_item.discount"))
568        lResultSet = priceDataSource.createResultSet({"id":lRecord.getField("own_product_item.price")})        lUnitPrice = hack.a2f(lRecord.getField("own_product_item.unit_price"))
569        if (lResultSet.firstRecord()):        #lResultSet = priceDataSource.createResultSet({"id":lRecord.getField("own_product_item.price")})
570          lUnitPrice = hack.a2f(lResultSet.current.getField("unit_price"))        #if (lResultSet.firstRecord()):
571        else:        #lUnitPrice = hack.a2f(lResultSet.current.getField("unit_price"))
572          lUnitPrice = 0        #else:
573          #print "lUnitPrice = ",lUnitPrice        #  lUnitPrice = 0
574          #print "lUnitPrice = ",lUnitPrice
575                
576        lItemPrice = (lQty * lUnitPrice) - lBonus - lDiscount        lItemPrice = (lQty * lUnitPrice) - lBonus - lDiscount
577        lTNeto += lItemPrice        lTNeto += lItemPrice
# Line 626  Line 623 
623          import hack          import hack
624            
625          condProductInvoice = GConditions.GCondition()          condProductInvoice = GConditions.GCondition()
626          condServiceInvoice = GConditions.GCondition()          #condServiceInvoice = GConditions.GCondition()
627          condPay = GConditions.GCondition()          condPay = GConditions.GCondition()
628                    
629          balance = 0          balance = 0
# Line 638  Line 635 
635              eq = GConditions.GCeq(tmpAnd)              eq = GConditions.GCeq(tmpAnd)
636              GConditions.GCField(eq,"_entity_data._table")              GConditions.GCField(eq,"_entity_data._table")
637              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))
638              tmpAnd = GConditions.GCand(condServiceInvoice)              #tmpAnd = GConditions.GCand(condServiceInvoice)
639              gt = GConditions.GCgt(tmpAnd)              #gt = GConditions.GCgt(tmpAnd)
640              GConditions.GCField(gt,"own_document.date")              #GConditions.GCField(gt,"own_document.date")
641              GConditions.GCConst(gt,str(creditLimit1Block.timeStampEntry))              #GConditions.GCConst(gt,str(creditLimit1Block.timeStampEntry))
642              eq = GConditions.GCeq(tmpAnd)              #eq = GConditions.GCeq(tmpAnd)
643              GConditions.GCField(eq,"_entity_data._table")              #GConditions.GCField(eq,"_entity_data._table")
644              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))              #GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))
645              tmpAnd = GConditions.GCand(condPay)              tmpAnd = GConditions.GCand(condPay)
646              gt = GConditions.GCgt(tmpAnd)              gt = GConditions.GCgt(tmpAnd)
647              GConditions.GCField(gt,"own_document.date")              GConditions.GCField(gt,"own_document.date")
# Line 657  Line 654 
654              eq = GConditions.GCeq(condProductInvoice)              eq = GConditions.GCeq(condProductInvoice)
655              GConditions.GCField(eq,"_entity_data._table")              GConditions.GCField(eq,"_entity_data._table")
656              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))
657              eq = GConditions.GCeq(condServiceInvoice)              #eq = GConditions.GCeq(condServiceInvoice)
658              GConditions.GCField(eq,"_entity_data._table")              #GConditions.GCField(eq,"_entity_data._table")
659              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))              #GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))
660              eq = GConditions.GCeq(condPay)              eq = GConditions.GCeq(condPay)
661              GConditions.GCField(eq,"_entity_data._table")              GConditions.GCField(eq,"_entity_data._table")
662              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))              GConditions.GCConst(eq,str(ownDocumentBlock.clientRecipientBox.currentClientEntry))
# Line 675  Line 672 
672              currOwnDoc = productInvoiceResultSet.current.getField("own_document.id")              currOwnDoc = productInvoiceResultSet.current.getField("own_document.id")
673              while productInvoiceResultSet.current.getField("own_document.id") == currOwnDoc and more:              while productInvoiceResultSet.current.getField("own_document.id") == currOwnDoc and more:
674                  lQty = hack.a2f(productInvoiceResultSet.current.getField("own_product_item.qty"))                  lQty = hack.a2f(productInvoiceResultSet.current.getField("own_product_item.qty"))
675                  lUnitPrice = hack.a2f(productInvoiceResultSet.current.getField("_price_data.unit_price"))                  lUnitPrice = hack.a2f(productInvoiceResultSet.current.getField("own_product_item.unit_price"))
676                  lBonus = hack.a2f(productInvoiceResultSet.current.getField("own_item.bonus"))                  lBonus = hack.a2f(productInvoiceResultSet.current.getField("own_item.bonus"))
677                  lDiscount = hack.a2f(productInvoiceResultSet.current.getField("own_item.discount"))                  lDiscount = hack.a2f(productInvoiceResultSet.current.getField("own_item.discount"))
678                  item = lQty * lUnitPrice - lBonus - lDiscount                  item = lQty * lUnitPrice - lBonus - lDiscount
# Line 696  Line 693 
693                            
694          # Calculo del total facturado          # Calculo del total facturado
695          ## Factura de servicios          ## Factura de servicios
696          serviceInvoiceResultSet= serviceInvoiceTotalDataSource.createResultSet (condServiceInvoice)          #serviceInvoiceResultSet= serviceInvoiceTotalDataSource.createResultSet (condServiceInvoice)
697          more= serviceInvoiceResultSet.firstRecord ()          #more= serviceInvoiceResultSet.firstRecord ()
698    
699          # por todos los documentos post-checkpoint (si no hay, desde el principio)          # por todos los documentos post-checkpoint (si no hay, desde el principio)
700          # print "calc 4"          # print "calc 4"
701          while more:          #while more:
702              invoiceTotal = 0          #   invoiceTotal = 0
703              currentOwnDocument= serviceInvoiceResultSet.current.getField ("own_document.id")          #   currentOwnDocument= serviceInvoiceResultSet.current.getField ("own_document.id")
704            #
705              # por todos los items del documento          #   # por todos los items del documento
706              # print "calc 5: [%s] %d" % (currentOwnDocument, spentTotal)          #   # print "calc 5: [%s] %d" % (currentOwnDocument, spentTotal)
707              while serviceInvoiceResultSet.current.getField ("own_document.id")==currentOwnDocument and more:          #   while serviceInvoiceResultSet.current.getField ("own_document.id")==currentOwnDocument and more:
708                  item = hack.a2f(serviceInvoiceResultSet.current.getField ("own_service_item.amount"))          #       item = hack.a2f(serviceInvoiceResultSet.current.getField ("own_service_item.amount"))
709                  currentItem= serviceInvoiceResultSet.current.getField ("own_item.id")          #       currentItem= serviceInvoiceResultSet.current.getField ("own_item.id")
710                  itemTaxTotal = 0          #       itemTaxTotal = 0
711                  # por todos los impuestos del item          #       # por todos los impuestos del item
712                  # print "calc 6: [%s:%s] %d" % (currentOwnDocument, currentItem, invoiceTotal)          #       # print "calc 6: [%s:%s] %d" % (currentOwnDocument, currentItem, invoiceTotal)
713                  while serviceInvoiceResultSet.current.getField ("own_item.id")==currentItem and more:          #       while serviceInvoiceResultSet.current.getField ("own_item.id")==currentItem and more:
714                      # calculate the item price exactly as I do in the other trigger          #           # calculate the item price exactly as I do in the other trigger
715                      # not revised yet, but I think it was like this          #           # not revised yet, but I think it was like this
716                      itemTaxTotal += hack.a2f(serviceInvoiceResultSet.current.getField ("own_item_tax.amount"))          #           itemTaxTotal += hack.a2f(serviceInvoiceResultSet.current.getField ("own_item_tax.amount"))
717                      more= serviceInvoiceResultSet.nextRecord ()          #           more= serviceInvoiceResultSet.nextRecord ()
718                      # print "calc 7: %d:%d" % (item, itemTaxTotal)          #           # print "calc 7: %d:%d" % (item, itemTaxTotal)
719            #
720                  invoiceTotal+= item + itemTaxTotal          #       invoiceTotal+= item + itemTaxTotal
721                            #      
722              spentTotal+= invoiceTotal          #   spentTotal+= invoiceTotal
723    
724    
725          # Calculo del total cobrado          # Calculo del total cobrado
# Line 1047  Line 1044 
1044      ownItemBlock.prodCodeSEntry = str(prodResultBlock.prodCodeEntry)      ownItemBlock.prodCodeSEntry = str(prodResultBlock.prodCodeEntry)
1045      ownItemBlock.prodNameSEntry = str(prodResultBlock.prodNameEntry)      ownItemBlock.prodNameSEntry = str(prodResultBlock.prodNameEntry)
1046      ownItemBlock.priceEntry = str(prodResultBlock.prodPriceEntry)      ownItemBlock.priceEntry = str(prodResultBlock.prodPriceEntry)
1047        
1048      lItemPrice = hack.a2f(prodResultBlock.prodUnitPriceEntry)*hack.a2f(ownItemBlock.qtyEntry)      lItemPrice = hack.a2f(prodResultBlock.prodUnitPriceEntry)*hack.a2f(ownItemBlock.qtyEntry)
1049      ownItemBlock.taxAmountEntry = (hack.a2f(prodResultBlock.prodIVATaxEntry)/100) * lItemPrice      ownItemBlock.taxAmountEntry = (hack.a2f(prodResultBlock.prodIVATaxEntry)/100) * lItemPrice
1050      ownItemBlock.ivaEntry = hack.a2f(prodResultBlock.prodIVATaxEntry)      ownItemBlock.ivaEntry = hack.a2f(prodResultBlock.prodIVATaxEntry)
# Line 1084  Line 1081 
1081      </entry>      </entry>
1082    
1083          <label name="priceLbl" text="Precio" x="55" y="10"/>          <label name="priceLbl" text="Precio" x="55" y="10"/>
1084          <entry x="55" y="11" readonly="" name="unitPriceEntry" width="10" rows="10" style="label" typecast="number" displaymask="%0.2f"/>          <entry x="55" y="11" name="unitPriceEntry" field="own_product_item.unit_price" width="10" rows="10" typecast="number" displaymask="%0.2f">
1085              <trigger name="unitPriceEntryPreFocusout" type="PRE-FOCUSOUT" src="totalCalcTrigger" />
1086            </entry>
1087          <entry x="1" y="14" readonly="" field="own_product_item.price" name="priceEntry" width="10" rows="5" hidden=""/>          <entry x="1" y="14" readonly="" field="own_product_item.price" name="priceEntry" width="10" rows="5" hidden=""/>
1088          <entry x="1" y="14" readonly="" field="own_item_tax.tax" name="taxTypeEntry" width="10" rows="5" default="1" hidden="" typecast="number" displaymask="%0.2f"/>          <entry x="1" y="14" readonly="" field="own_item_tax.tax" name="taxTypeEntry" width="10" rows="5" default="1" hidden="" typecast="number" displaymask="%0.2f"/>
1089          <entry x="1" y="14" readonly="" field="own_item_tax.amount" name="taxAmountEntry" width="10" rows="5" hidden="" typecast="number" displaymask="%0.2f"/>          <entry x="1" y="14" readonly="" field="own_item_tax.amount" name="taxAmountEntry" width="10" rows="5" hidden="" typecast="number" displaymask="%0.2f"/>

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.43

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