The 1C:Enterprise developers forum

#1
People who like this: 0 Yes / 0 No
Just came
Rating: 1
Joined: Oct 16, 2024
Company:

I want to retrieve the values for the Bank Account and Virtual Account parameters in the Sales Invoice Document print template. Each Customer (Catalog Counterparty) has one Bank Account and one Virtual Account (from the Catalog Bank Accounts). Currently, the Bank Account is being pulled directly from the Bank Account attribute in the Sales Invoice Document, which may cause discrepancies if the customer's Bank Account differs. How can I ensure the correct data is retrieved for each customer?

Notes: The Bank Account value is retrieved from the last picture I provided

Download pic 6.jpg (124.23 KB)
Download pic 7.jpg (118.65 KB)
Download pic 8.jpg (182.2 KB)
Download pic 9.jpg (53.15 KB)
 
#2
People who like this: 0 Yes / 0 No
Administrator
Rating: 27
Joined: Oct 3, 2019
Company:

Hello Ahmad,

you should change the line in the query:

Code
SalesInvoice.BankAccount AS BankAccount,


to the line:

Code
BankAccounts.Ref AS BankAccount,


Leaving this piece of code:

Code
FROM
Document.SalesInvoice AS SalesInvoice
LEFT JOIN Catalog.BankAccounts AS BankAccounts
ON SalesInvoice.BankAccount = BankAccounts.Ref




But there is no point in checking the client's bank account, since it is also recorded in the document from the "Bank Accounts" Catalog.

Well, maybe only if the client changed his bank account, then probably yes, it is necessary to check...

 
#3
People who like this: 0 Yes / 0 No
Just came
Rating: 1
Joined: Oct 16, 2024
Company:

Then how do i get the data?

CounterpartyInfoArea.Parameters.AccountBank = BankAccount.Bank; //error
CounterpartyInfoArea.Parameters.VirtualAccount = BankAccount.VirtualAccount; //error

Download pic 11.jpg (235.61 KB)
 
#4
People who like this: 0 Yes / 0 No
Just came
Rating: 1
Joined: Oct 16, 2024
Company:

The user wants the printed Bank Account value in the Sales Invoice document to come from the Bank Account in the Counterparty catalog (customer). Current BankAccount attribute on Sales Invoice Document refer to Catalog Company not Counterparty. However, there is NO Bank Account and Virtual Account attribute of Catalog Counterparty within the Sales Invoice Document. How should I solve this?

 
#5
People who like this: 0 Yes / 0 No
Administrator
Rating: 27
Joined: Oct 3, 2019
Company:

Dear Ahmad,

please see my last post again. I gave you an example of how to change the query text so that the query returns bank account data not from the document, but from the Catalog.

 
#6
People who like this: 0 Yes / 0 No
Just came
Rating: 1
Joined: Oct 16, 2024
Company:

Then how do i get the data?

CounterpartyInfoArea.Parameters.AccountBank = BankAccount.Bank; //error
CounterpartyInfoArea.Parameters.VirtualAccount = BankAccount.VirtualAccount; //error


I've try your code but still confuse, how should i do to fill the parameters template value. AccountBank Should be this second picture, first picture is my SalesInvoice templates.

Download pic 12.jpg (183.66 KB)
 
#7
People who like this: 0 Yes / 0 No
Administrator
Rating: 27
Joined: Oct 3, 2019
Company:

Hello Ahmad,

I guess I didn't quite understand your question... :(

Unfortunately, I don't have the configuration you are working with at hand, but based on the screenshots you provided, I see that the "VirtualAccount" attribute is already selected from the client's bank account, not from the document data.

Please look at my screenshot, I highlighted this code in red.

The program first gets the client's bank account (BankAccountRef), and then selects "VirtualAccount" from it.

Download 1.png (157.51 KB)
 
#8
People who like this: 0 Yes / 0 No
Just came
Rating: 1
Joined: Oct 16, 2024
Company:

I'm sorry for my previous question. When i get the value of BankAccount it's refer to Company as an Owner. But I want to get the bank account and virtual account data from catalog bank account that Counterparty as an Owner. I tried to create new attribute on the extension named "AccountBank" can you please check it out. But when i want to go to print template on application mode Pop Up Error like last picture.

Code
 Query.Text = 
   "SELECT ALLOWED
   |   SalesInvoice.Ref AS Ref,
   |   SalesInvoice.Number AS Number,
   |   SalesInvoice.Date AS Date,
   |   SalesInvoice.Company AS Company,
   |   SalesInvoice.CompanyVATNumber AS CompanyVATNumber,
   |   SalesInvoice.Counterparty AS Counterparty,
   |   SalesInvoice.Contract AS Contract,
   |   SalesInvoice.ShippingAddress AS ShippingAddress,
   |   SalesInvoice.ContactPerson AS ContactPerson,
   |   SalesInvoice.AmountIncludesVAT AS AmountIncludesVAT,
   |   SalesInvoice.DocumentCurrency AS DocumentCurrency,
   |   CAST(SalesInvoice.Comment AS STRING(1024)) AS Comment,
   |   SalesInvoice.Order AS Order,
   |   SalesInvoice.SalesOrderPosition AS SalesOrderPosition,
   |   SalesInvoice.VATTaxation = VALUE(Enum.VATTaxationTypes.ReverseChargeVAT) AS ReverseCharge,
   |   SalesInvoice.StructuralUnit AS StructuralUnit,
   |   SalesInvoice.DeliveryOption AS DeliveryOption,
   |   SalesInvoice.ProvideEPD AS ProvideEPD,
   |   SalesInvoice.DeliveryStartDate AS DeliveryStartDate,
   |   SalesInvoice.DeliveryEndDate AS DeliveryEndDate,
   |   SalesInvoice.DeliveryDatePeriod AS DeliveryDatePeriod,
   |   SalesInvoice.DeliveryDatePosition AS DeliveryDatePosition,
   |   SalesInvoice.IsRegisterDeliveryDate AS IsRegisterDeliveryDate,
   |   CASE
   |      WHEN SalesInvoice.OperationKind = VALUE(Enum.OperationTypesSalesInvoice.ZeroInvoice)
   |         THEN TRUE
   |      ELSE FALSE
   |   END AS ZeroInvoice,
   |   SalesInvoice.AccountBank AS AccountBank
   |INTO SalesInvoices
   |FROM
   |   Document.SalesInvoice AS SalesInvoice
   |WHERE
   |   SalesInvoice.Ref IN(&ObjectsArray)
   |;
   |
   |////////////////////////////////////////////////////////////////////////////////
   |SELECT ALLOWED
   |   SalesInvoice.Ref AS Ref,
   |   SalesInvoice.Number AS DocumentNumber,
   |   SalesInvoice.Date AS DocumentDate,
   |   SalesInvoice.Company AS Company,
   |   SalesInvoice.CompanyVATNumber AS CompanyVATNumber,
   |   SalesInvoice.Counterparty AS Counterparty,
   |   SalesInvoice.Contract AS Contract,
   |   SalesInvoice.ShippingAddress AS ShippingAddress,
   |   CASE
   |      WHEN SalesInvoice.ContactPerson <> VALUE(Catalog.ContactPersons.EmptyRef)
   |         THEN SalesInvoice.ContactPerson
   |      WHEN CounterpartyContracts.ContactPerson <> VALUE(Catalog.ContactPersons.EmptyRef)
   |         THEN CounterpartyContracts.ContactPerson
   |      ELSE Counterparties.ContactPerson
   |   END AS CounterpartyContactPerson,
   |   SalesInvoice.AmountIncludesVAT AS AmountIncludesVAT,
   |   SalesInvoice.DocumentCurrency AS DocumentCurrency,
   |   ISNULL(SalesOrder.Number, """") AS SalesOrderNumber,
   |   ISNULL(SalesOrder.Date, DATETIME(1, 1, 1)) AS SalesOrderDate,
   |   SalesInvoice.Comment AS Comment,
   |   SalesInvoice.ReverseCharge AS ReverseCharge,
   |   SUM(ISNULL(SalesInvoicePrepayment.AmountDocCur, 0)) AS Paid,
   |   SalesInvoice.StructuralUnit AS StructuralUnit,
   |   SalesInvoice.DeliveryOption AS DeliveryOption,
   |   SalesInvoice.ProvideEPD AS ProvideEPD,
   |   SalesInvoice.IsRegisterDeliveryDate AS IsRegisterDeliveryDate,
   |   SalesInvoice.DeliveryDatePosition AS DeliveryDatePosition,
   |   SalesInvoice.DeliveryDatePeriod AS DeliveryDatePeriod,
   |   SalesInvoice.DeliveryStartDate AS DeliveryStartDate,
   |   SalesInvoice.DeliveryEndDate AS DeliveryEndDate,
   |   SalesInvoice.ZeroInvoice AS ZeroInvoice,
   |   SalesInvoice.AccountBank AS AccountBank
   |INTO Header
   |FROM
   |   SalesInvoices AS SalesInvoice
   |      LEFT JOIN Catalog.Counterparties AS Counterparties
   |      ON SalesInvoice.Counterparty = Counterparties.Ref
   |      LEFT JOIN Catalog.BankAccounts AS BankAccounts
   |      ON SalesInvoice.AccountBank   = BankAccounts.Ref
   |      LEFT JOIN Catalog.CounterpartyContracts AS CounterpartyContracts
   |      ON SalesInvoice.Contract = CounterpartyContracts.Ref
   |      LEFT JOIN Document.SalesOrder AS SalesOrder
   |      ON SalesInvoice.Order = SalesOrder.Ref
   |         AND (SalesInvoice.SalesOrderPosition = VALUE(Enum.AttributeStationing.InHeader))
   |      LEFT JOIN Document.SalesInvoice.Prepayment AS SalesInvoicePrepayment
   |      ON SalesInvoice.Ref = SalesInvoicePrepayment.Ref
   |
   |GROUP BY
   |   SalesInvoice.Number,
   |   SalesInvoice.Date,
   |   SalesInvoice.Counterparty,
   |   SalesInvoice.Company,
   |   SalesInvoice.CompanyVATNumber,
   |   SalesInvoice.Ref,
   |   SalesInvoice.Comment,
   |   ISNULL(SalesOrder.Date, DATETIME(1, 1, 1)),
   |   ISNULL(SalesOrder.Number, """"),
   |   SalesInvoice.DocumentCurrency,
   |   SalesInvoice.AmountIncludesVAT,
   |   SalesInvoice.ShippingAddress,
   |   CASE
   |      WHEN SalesInvoice.ContactPerson <> VALUE(Catalog.ContactPersons.EmptyRef)
   |         THEN SalesInvoice.ContactPerson
   |      WHEN CounterpartyContracts.ContactPerson <> VALUE(Catalog.ContactPersons.EmptyRef)
   |         THEN CounterpartyContracts.ContactPerson
   |      ELSE Counterparties.ContactPerson
   |   END,
   |   SalesInvoice.ReverseCharge,
   |   SalesInvoice.Contract,
   |   SalesInvoice.StructuralUnit,
   |   SalesInvoice.DeliveryOption,
   |   SalesInvoice.ProvideEPD,
   |   SalesInvoice.IsRegisterDeliveryDate,
   |   SalesInvoice.DeliveryDatePosition,
   |   SalesInvoice.DeliveryDatePeriod,
   |   SalesInvoice.DeliveryStartDate,
   |   SalesInvoice.DeliveryEndDate,
   |   SalesInvoice.ZeroInvoice,
   |   SalesInvoice.AccountBank
   |; 

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.